Mesa 7i96 - getting limit switch status in python
- cody
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
11 Jul 2020 22:59 #174338
by cody
Mesa 7i96 - getting limit switch status in python was created 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
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.
- phillc54
- Offline
- Platinum Member
Less
More
- Posts: 5698
- Thank you received: 2082
12 Jul 2020 03:41 #174351
by phillc54
Replied by phillc54 on topic Mesa 7i96 - getting limit switch status in python
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.
- cody
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
12 Jul 2020 14:10 #174387
by cody
Replied by cody on topic Mesa 7i96 - getting limit switch status in python
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.
- cmorley
- Away
- Moderator
Less
More
- Posts: 7764
- Thank you received: 2055
12 Jul 2020 18:37 #174413
by cmorley
Replied by cmorley on topic Mesa 7i96 - getting limit switch status in python
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.
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: PCW, jmelson
Time to create page: 0.063 seconds