Mesa 7i96 - getting limit switch status in python

More
6 years 3 months ago #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 to join the conversation.

More
6 years 3 months ago #174351 by phillc54
You could try reading the hal pins like joint.0.pos-lim-sw-in joint.0.neg-lim-sw-in etc.

Please Log in to join the conversation.

More
6 years 3 months ago #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

Code:
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 to join the conversation.

More
6 years 3 months ago #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.

Please Log in to join the conversation.

Time to create page: 0.095 seconds
Powered by Kunena Forum