NEWS
2.6 Live+Install image

Announcing a new Live+Install DVD image for installing LinuxCNC 2.6 on Debian Wheezy. Instructions here.

 
LinuxCNC 2.6.2 Released

Bug fix see the change log.

 
LinuxCNC 2.6.1 Released

Bug fix see the change log.

 

Welcome, Guest
Username: Password: Remember me

TOPIC: Limit3 question.

Re:Limit3 question. 11 Jan 2012 11:04 #16607

  • dab77
  • dab77's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 199
  • Karma: 6
ArcEye wrote:
Hi
In the future it will be very usefull for me to use a personalized M-code, but for now it should be enough to know that i can change it.
Put the below into a file named M111 in the directory pointed to in your .ini file by [DISPLAY] PROGRAM_PREFIX =
and make it executable (chmod 755)

Then you can use M111 Pn Qnnn in the MDI or in your code, where P is the stepgen number and Q is the integer value to set the stepgen maxaccel to.
#!/bin/bash

if [ ! $# -ge 2 ]; then
  echo "Usage: M111 Pn Qn - where arg1 is stepgen number & arg2 is maxaccel value "
  exit 1
fi

float=$1
float2=$2
stepgen=${float/.*}
maxaccel=${float2/.*}

halcmd setp stepgen.$stepgen.maxaccel $maxaccel

exit 0
Is it so simple?!?
i'm going to study some to understand what '[ ! $# -ge 2 ]' stands for... i wish to find some docs on this..
can you explain what you mean for 'fork'?

fork and spawn and all their variants are the ways that you start a child process through a shell in C.
I don't know anything about python, but there must be similar ways to do this in that language.

You'll need to do some reading, it can get complicated if you need to capture output or set up notification handlers to check the exit code etc, but at its simplest you just launch the process into the wild blue yonder and hope it all goes OK!

One for a rainy day perhaps?

regards
during these days i'm studying a lot of python 'cause i'm working for Opera theater and it gives a looot of free time!
but i don't understand what you suggest to do. Can you just explain the logic of the process?
do you mean to call the param setting from the python script directly? ..sorry it's my poor english fault..

now thank you very much for the m-code hint.
in the thruth i'm using JA3 branch, and inside this branch i shouldn't change stepgen.N.acceleration, but the Traj Planner acceleration (at least i think..), but i don't know which is the pin.
The administrator has disabled public write access.

Re:Limit3 question. 11 Jan 2012 23:42 #16635

  • ArcEye
  • ArcEye's Avatar
  • NOW ONLINE
  • Moderator
  • Posts: 2761
  • Thank you received: 441
  • Karma: 163
Is it so simple?!?
i'm going to study some to understand what '[ ! $# -ge 2 ]' stands for... i wish to find some docs on this..

You need to look up bash programming in google

Means 'if commandline args not greater or equal to 2' basically (checks both P and Q args used)
i don't understand what you suggest to do. Can you just explain the logic of the process?

It is a big and often complex process, you need to look up on google
For instance
www.yolinux.com/TUTORIALS/ForkExecProcesses.html

Basically system, spawn, spawnl, fork, exec, execv and all the other similar functions, start a child process, doing something different to or complementary to the the main program.

The differences are in whether the process is independent of the spawning program and continues after it closes, whether it is in an OS dependent shell or a new thread, if you capture and use its output, whether you handle its exit and use the code to determine future actions, etc etc etc.

Python will have a function which just executes a command through the OS's default shell (bash or sh), its just a question of finding it and figuring out the best way to use it.

Then your python program can get the value from your pyvcp slider or whatever and set the parameter directly with a system call.

Not something I can explain much more, you need to do a lot of reading until it becomes clear to you.

regards
The administrator has disabled public write access.

Re:Limit3 question. 12 Jan 2012 03:18 #16643

  • dab77
  • dab77's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 199
  • Karma: 6
ArcEye wrote:
Is it so simple?!?
i'm going to study some to understand what '[ ! $# -ge 2 ]' stands for... i wish to find some docs on this..

You need to look up bash programming in google

Means 'if commandline args not greater or equal to 2' basically (checks both P and Q args used)
Thanks, i got this.
i don't understand what you suggest to do. Can you just explain the logic of the process?

It is a big and often complex process, you need to look up on google
For instance
www.yolinux.com/TUTORIALS/ForkExecProcesses.html

Basically system, spawn, spawnl, fork, exec, execv and all the other similar functions, start a child process, doing something different to or complementary to the the main program.

The differences are in whether the process is independent of the spawning program and continues after it closes, whether it is in an OS dependent shell or a new thread, if you capture and use its output, whether you handle its exit and use the code to determine future actions, etc etc etc.

Python will have a function which just executes a command through the OS's default shell (bash or sh), its just a question of finding it and figuring out the best way to use it.

Then your python program can get the value from your pyvcp slider or whatever and set the parameter directly with a system call.

Not something I can explain much more, you need to do a lot of reading until it becomes clear to you.

regards
Good explanation. Now i understood what's the logic. It seems feasible..after some studying..

ArcEye, thank you very much for your suggestions and explanations.
it's much appreciated. I'm going to work on it.

Ciao, Davide.
The administrator has disabled public write access.

Re:Limit3 question. 12 Jan 2012 04:00 #16647

  • dab77
  • dab77's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 199
  • Karma: 6
Hi, I've tried to do simply this:
-run Emc2 RIP
-open Hal config windows to see results..
-open a terminal and type:
dab@dab-tetra:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> x = 2400
>>> os.system("halcmd setp stepgen.0.maxaccel %d"%x)
0
>>> x = 2500
>>> os.system("halcmd setp stepgen.0.maxaccel %d"%x)
0
>>>
dab@dab-tetra:~$
I can see the hal_param changing inside the window, so do you think it can be enough?
The administrator has disabled public write access.

Re:Limit3 question. 12 Jan 2012 04:56 #16652

  • ArcEye
  • ArcEye's Avatar
  • NOW ONLINE
  • Moderator
  • Posts: 2761
  • Thank you received: 441
  • Karma: 163
I can see the hal_param changing inside the window, so do you think it can be enough?
If it does the job, it is enough. You just have to figure out your GUI interface and write the code to update the
maxaccel values.

As I pointed to previously, look at this thread
www.linuxcnc.org/index.php/english/compo...=48&id=16439&limit=6
for ideas on how to write a glade gui and then have a python event handler execute some code when the state of a pin changes.

good luck
The administrator has disabled public write access.

Re:Limit3 question. 12 Jan 2012 05:51 #16658

  • dab77
  • dab77's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 199
  • Karma: 6
Yes, thanks. now i don't have problems on how to manage callbacks.
I had only on setting param from python.

Thanks again.
The administrator has disabled public write access.
Time to create page: 0.810 seconds
Powered by Kunena Forum
© 2014 LinuxCNC.org
Joomla! is Free Software released under the GNU General Public License.