- Posts: 52
- Thank you received: 0
Hal Standalone. some trouble..
Working with python, I finally managed how to write it.
First I had to change from python3 to python2, because it seems to me that hal module cannot be imported in python3 (if I'm wrong please, tell me)
Than I choose Gtk, which is more natural in LinuxMint, and should be also cross-platform.
Till now I could create a hal file in-place based on the number of motors choosed (at the moment from 1 to 8, because using stepgen) and the buttons and scales in the gui also are created according to that number.
I've set all the stepgen in position mode, and it works ok, also the position feedback going back to the gui is perfectly shown.
The first big problem I cannot resolve, is deceleration in case the 'GO' button is released in the middle of a movement.
If I set stepgen.x.enable 0, the stepgen stops instantly. So I've tried to set stepgen.x.maxvel to 0, but that doesn't stop the current movement.
So here's my question:
Do you know how does it work in Axis when in jog-mode you have decelerations when stop jogging? are the stepgen temporarly set in velocity mode?
thanks, Davide.
Please Log in to join the conversation.
JT
Please Log in to join the conversation.
Yes I did.
this is the GO release code:
But I just discovered that if instead of '0', i set stepgen.x.maxvel to 1 it works as expected, meaning that it decelerates as soon as I release th GO button, but unfortunately it goes at 1-speed, doesn't stop.
In the meantime I also want to ask: instead of calling "os.system("command")", is there a way to directly change a Hal Parameter in python? I've looked in the code, but didn't find anything about that..
Please Log in to join the conversation.
dab77 wrote: (...)
In the meantime I also want to ask: instead of calling "os.system("command")", is there a way to directly change a Hal Parameter in python? I've looked in the code, but didn't find anything about that..
Well, there are few ways how to solve this, you can create HAL Python Userspace component which will create the HAL pins which you will be changing in your Python written program. And then you connect these pins inside the HAL layer to actual pins you need to change. That is described here: linuxcnc.org/docs/html/hal/halmodule.html .
Or you can create Python wrappers around the C hallib functions. That is probably quite a bit of work, but you can find the inspiration here: github.com/machinekit/machinekit-hal/tre...al/cython/machinekit
Or you can create direct connector to the HAL shared memory space and change values here. This is the most hard-core option and I would not recommend this.
Please Log in to join the conversation.
Well, there are few ways how to solve this, you can create HAL Python Userspace component which will create the HAL pins which you will be changing in your Python written program. And then you connect these pins inside the HAL layer to actual pins you need to change. That is described here: linuxcnc.org/docs/html/hal/halmodule.html .
You don't have to connect pins. There are some functions to do direct commands - depends on the version of linuxcnc.
in 2.7 fairly limited:
linuxcnc.org/docs/2.7/html/hal/halmodule...l#_helpful_functions
in 2.8 + a fair bit better (get_value is very useful):
linuxcnc.org/docs/2.8/html/hal/halmodule...l#_helpful_functions
Chris
Please Log in to join the conversation.
cmorley wrote: You don't have to connect pins. There are some functions to do direct commands - depends on the version of linuxcnc.
in 2.7 fairly limited:
(...)
Interesting, I didn't know about it. I presume there is no chance for some push notification pattern without major HAL rework, right?
(I am not Python developer, so I don't know what you are calling it in parseltongue.)
Please Log in to join the conversation.
Please Log in to join the conversation.
no, i need to change a parameter, not a pin, so i cannot link a signal to a parameter..Tower wrote:
dab77 wrote: (...)
In the meantime I also want to ask: instead of calling "os.system("command")", is there a way to directly change a Hal Parameter in python? I've looked in the code, but didn't find anything about that..
Well, there are few ways how to solve this, you can create HAL Python Userspace component which will create the HAL pins which you will be changing in your Python written program. And then you connect these pins inside the HAL layer to actual pins you need to change. That is described here: linuxcnc.org/docs/html/hal/halmodule.html .
Or you can create Python wrappers around the C hallib functions. That is probably quite a bit of work, but you can find the inspiration here: github.com/machinekit/machinekit-hal/tre...al/cython/machinekit
Or you can create direct connector to the HAL shared memory space and change values here. This is the most hard-core option and I would not recommend this.
Please Log in to join the conversation.
really, i couldn't find those functions anywhere!cmorley wrote:
Well, there are few ways how to solve this, you can create HAL Python Userspace component which will create the HAL pins which you will be changing in your Python written program. And then you connect these pins inside the HAL layer to actual pins you need to change. That is described here: linuxcnc.org/docs/html/hal/halmodule.html .
You don't have to connect pins. There are some functions to do direct commands - depends on the version of linuxcnc.
in 2.7 fairly limited:
linuxcnc.org/docs/2.7/html/hal/halmodule...l#_helpful_functions
in 2.8 + a fair bit better (get_value is very useful):
linuxcnc.org/docs/2.8/html/hal/halmodule...l#_helpful_functions
Chris
thank you.
i think what i need is hal.set_p() wishing it can change parameters too.
than i still don't understand if i can toggle the stepgen command mode between velocity and position, to solve the deceleration problem.
Please Log in to join the conversation.
I have also tried what is suggested in that page, while running linuxcnc, but without success:
I've forgot to say that I have Linuxcnc 2.9.0 on..
Please Log in to join the conversation.
