Limit3 question.

More
10 Jan 2012 23:26 #16552 by dab77
Replied by dab77 on topic Re:Limit3 question.
got this error:
...
tgvcp.hal:45: value 'tgvcp.max_acc_out' invalid for float
tgvcp.hal:45: setp failed
Shutting down and cleaning up EMC2...

tried to do this:
# Prova modifica accelerazioni:
setp stepgen.0.maxaccel tgvcp.max_acc_out #this is line 45.
setp stepgen.1.maxaccel tgvcp.max_acc_out
setp stepgen.2.maxaccel tgvcp.max_acc_out
setp stepgen.3.maxaccel tgvcp.max_acc_out

tgvcp.max_acc_out is a out_pin created into python, with the value token from the spinbutton.

Please Log in or Create an account to join the conversation.

More
11 Jan 2012 00:02 #16554 by andypugh
Replied by andypugh on topic Re:Limit3 question.
dab77 wrote:

setp stepgen.0.maxaccel tgvcp.max_acc_out


You can't do that. setp takes a pin or a parameter and a number.

You can _type_ setp at the command line, but it isn't a way to link a gui control to a parameter. And you can't net a parameter.

without re-writing stepgen you can't change the acceleration on the fly.

I say it again, do it in CAM.

Please Log in or Create an account to join the conversation.

More
11 Jan 2012 00:12 - 11 Jan 2012 00:13 #16555 by dab77
Replied by dab77 on topic Re:Limit3 question.
andypugh wrote:

dab77 wrote:

setp stepgen.0.maxaccel tgvcp.max_acc_out


You can't do that. setp takes a pin or a parameter and a number.

You can _type_ setp at the command line, but it isn't a way to link a gui control to a parameter. And you can't net a parameter.

without re-writing stepgen you can't change the acceleration on the fly.

I say it again, do it in CAM.

no, i'm sorry, but in CAM is not the way it should be and it would be a real pita..

I think there should be a way!
as you say, i proved i can setp by typing into the command line, so how can i do that from my python file?

p.s. i've tried the limit3 way, but the acceleration doesn't change.
Last edit: 11 Jan 2012 00:13 by dab77.

Please Log in or Create an account to join the conversation.

More
11 Jan 2012 07:01 #16565 by ArcEye
Replied by ArcEye on topic Re:Limit3 question.
Andy Pugh wrote:

Stepgen-maxaccel is a parameter, it can't be netted. (you can only net pins)

I didn't say anything about connecting it with net

Andy Pugh wrote:

You can't do that. setp takes a pin or a parameter and a number.
You can _type_ setp at the command line, but it isn't a way to link a gui control to a parameter.

You can use setp. One way might be.

Write a handler for the slider or spinbox you set the new max accel with.

From that handler fork halcmd setp stepgen.0.maxaccel [value]

See the Forum discussion under Glade > Label regards writing python event handlers for glade widgets

Another way would be to write a user M code script which does the same thing and call it from your g code at the point
where you want to limit accel to a given value, no pretty gui sliders but can be written in 2 minutes.

regards

Please Log in or Create an account to join the conversation.

More
11 Jan 2012 14:23 #16596 by dab77
Replied by dab77 on topic Re:Limit3 question.
ArcEye wrote:

...
You can use setp. One way might be.

Write a handler for the slider or spinbox you set the new max accel with.

From that handler fork halcmd setp stepgen.0.maxaccel [value]

See the Forum discussion under Glade > Label regards writing python event handlers for glade widgets

Another way would be to write a user M code script which does the same thing and call it from your g code at the point
where you want to limit accel to a given value, no pretty gui sliders but can be written in 2 minutes.

regards

Both methods are very interesting for me!
yesterday i was trying to setup handlers, but the only way i know howis to create an hal_out_pin inside the python script. But then as you know i can't net that pin with a param.
can you explain what you mean for 'fork'?
how can i write that into python?

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.
Thanks, Davide.

Please Log in or Create an account to join the conversation.

More
11 Jan 2012 18:24 #16605 by ArcEye
Replied by ArcEye on topic Re:Limit3 question.
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

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

Please Log in or Create an account to join the conversation.

More
11 Jan 2012 19:04 #16607 by dab77
Replied by dab77 on topic Re:Limit3 question.
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.

Please Log in or Create an account to join the conversation.

More
12 Jan 2012 07:42 #16635 by ArcEye
Replied by ArcEye on topic Re:Limit3 question.

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

Please Log in or Create an account to join the conversation.

More
12 Jan 2012 11:18 #16643 by dab77
Replied by dab77 on topic Re:Limit3 question.
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.

Please Log in or Create an account to join the conversation.

More
12 Jan 2012 12:00 #16647 by dab77
Replied by dab77 on topic Re:Limit3 question.
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?

Please Log in or Create an account to join the conversation.

Time to create page: 0.244 seconds
Powered by Kunena Forum