Hal Standalone. some trouble..

More
7 years 1 month ago #145098 by cmorley
push notification?

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

More
7 years 1 month ago #145121 by dab77

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 .

no, i need to change a parameter, not a pin, so i cannot link a signal to a parameter..

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 or Create an account to join the conversation.

More
7 years 1 month ago #145122 by dab77

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

really, i couldn't find those functions anywhere!
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 or Create an account to join the conversation.

More
7 years 1 month ago - 7 years 1 month ago #145129 by dab77
the problem is this:
Code:
>>> import hal >>> hal.set_p("stepgen.0.maxaccel", "22") Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: Cannot call before creating component >>>
I don't know how to refer to hal components.

I have also tried what is suggested in that page, while running linuxcnc, but without success:
Code:
>>> os.system("halcmd show comp") Loaded HAL Components: ID Type Name PID State 82 User halcmd4120 4120 ready 76 User axisui 4108 ready 74 User inihal 4104 ready 65 RT match8 ready 62 RT wcomp ready 57 RT comp ready 54 RT or2 ready 49 User hal_manualtoolchange 4088 ready 43 RT scale ready 40 RT near ready 37 RT lowpass ready 34 RT limit2 ready 31 RT sim_spindle ready 26 RT hypot ready 23 RT ddt ready 20 RT __servo-thread ready 19 RT motmod ready 16 RT trivkins ready 10 User halui 4065 ready 4 User iocontrol 4063 ready 0 >>> value = hal.get_value("iocontrol.0.emc-enable-in") Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: Can't set value: pin / param iocontrol.0.emc-enable-in not found >>>
..and obviously the pin was there:
Code:
.... 4 bit OUT FALSE iocontrol.0.coolant-flood 4 bit OUT FALSE iocontrol.0.coolant-mist 4 bit IN TRUE iocontrol.0.emc-enable-in <== estop-loop 4 bit OUT TRUE iocontrol.0.lube 4 bit IN FALSE iocontrol.0.lube_level ....

I've forgot to say that I have Linuxcnc 2.9.0 on..
Last edit: 7 years 1 month ago by dab77.

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

More
7 years 1 month ago #145143 by cmorley
You need to make a dummy component first.
Code:
import hal hal.component("dummy") hal.set_p("stepgen.0.maxaccel", "22")

The dummy component makes the module create a shared memory path to HAL.

Chris
The following user(s) said Thank You: dab77

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

More
7 years 1 month ago #145172 by dab77
Thanks, that made hal.set_p() work.

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

Time to create page: 0.412 seconds
Powered by Kunena Forum