Python interface states of the home switches?

More
16 Mar 2018 15:50 #107432 by bladekel
Hello to all,

I'm creating a new GUI and I need to get the state of a home switch to light on the hal_led.
I can get the state of estop like;
self.led_estop.set_active(not self.s.estop)

Is there any way to get the home switches states like estop ?

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

More
16 Mar 2018 16:36 - 16 Mar 2018 16:44 #107437 by Todd Zuercher
Not sure about the state of home inputs the same way as you are looking at e-stop. But it is trivial to get the state of a hal pin and since your home switches are or are connected to hal pins there you go.
linuxcnc.org/docs/html/hal/halmodule.htm..._pins_and_parameters
Last edit: 16 Mar 2018 16:44 by Todd Zuercher.

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

More
16 Mar 2018 17:28 #107440 by cmorley
No at the moment there is no way to directly read a HAL pin with python.
You can make a python component that you can connect to a HAL signal with:
linuxcnc.org/docs/2.7/html/hal/halmodule.html
then you can read the signal.

I do have code to add this capability - hopefully it will be added to master.

Chris M

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

More
16 Mar 2018 17:44 #107441 by Todd Zuercher
I guess I don't understand. How is it am I making, monitoring and controlling hal pins with the python file for my Gladevcp then?

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

More
16 Mar 2018 21:16 #107447 by cmorley
I assume you are making a python component with it's own pins and connecting those pins to other pins you are interested in, so as to read or write.

That's different from just reading a pin directly (like using halmeter) without connecting to it.

Chris M

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

More
16 Mar 2018 21:31 #107449 by cmorley
An example of the new way would be:
import hal

actual_spindle_rpm = hal.get_value('motion.spindle-speed-in') * 60

Chris M

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

More
17 Mar 2018 05:30 #107457 by bladekel

An example of the new way would be:
import hal

actual_spindle_rpm = hal.get_value('motion.spindle-speed-in') * 60

Chris M


Hi Chris.
I get "AttributeError: 'module' object has no attribute 'get_value'" error by this method....

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

More
17 Mar 2018 12:23 #107465 by cmorley
Sorry i wasn't clear - I haven't pushed the code to master yet.
If you are using 2.7.x then this will never work.
If you are using master I could cherry pick the code and push to master in a day or so.

Chris M

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

More
17 Mar 2018 13:25 #107466 by bladekel

Sorry i wasn't clear - I haven't pushed the code to master yet.
If you are using 2.7.x then this will never work.
If you are using master I could cherry pick the code and push to master in a day or so.

Chris M

Unfortunately I'm using 2.7.x ....

Then what must I do ?
Please help me :cheer:

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

More
17 Mar 2018 18:42 #107473 by cmorley
Then the practical thing to do is to (as Todd mentioned) create HAL pins for your screen and connect them to the signals/pins you are interested in.

Chris M

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

Time to create page: 0.114 seconds
Powered by Kunena Forum