Mesa 7i96 - getting limit switch status in python

More
11 Jul 2020 22:59 #174338 by cody
I've fumbled around the LinuxCNC python interface guide for a while trying to find how I can read the status of the limit switches. For example, I want a 1 if a limit switch is pressed and a 0 if it is not pressed.

I ran the s.din command and was able to read the other inputs to my machine (prox switches and other sensors) just not limit switches. I press the limit switch and see the LED light up on the Mesa board, and the limit switches work to home the robot, I just can't figure out how to read whether they are pressed or not.

Does anybody know if this is possible to do?

Thanks in advance!

Cody

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

More
12 Jul 2020 03:41 #174351 by phillc54
You could try reading the hal pins like joint.0.pos-lim-sw-in joint.0.neg-lim-sw-in etc.
The following user(s) said Thank You: cody

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

More
12 Jul 2020 14:10 #174387 by cody
Thanks for pointing me in the right direction! I got it figured out. I've added the python code below to make this work if anybody else is interested

import hal
import time

while 1:
    h = hal.component("passthrough")
    limitX = hal.get_value("joint.0.home-sw-in")
    print(limitX)

    time.sleep(0.1)

    h.exit()

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

More
12 Jul 2020 18:37 #174413 by cmorley
linuxcnc.org/docs/2.8/html/gui/GStat.html

specifically
hard-limits-tripped

(returns bool, Python List) - Sent when any hard limit is tripped. bool indicates if any limit is tripped, the list shows all available joint’s current limit values.
The following user(s) said Thank You: phillc54, nkp

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

Moderators: PCWjmelson
Time to create page: 0.118 seconds
Powered by Kunena Forum