Python pendant logic problems
- heffamonster
- Offline
- New Member
-
Less
More
- Posts: 6
- Thank you received: 0
17 Sep 2025 03:01 #335105
by heffamonster
Python pendant logic problems was created by heffamonster
Greetings ,
You guys are awesome BTW
I am working on a python logic script to control some switches, a button, and a couple encoders connected to the p1 connector of the Mesa 7i96s IO with 5vdc going to power the encoders. They are just simple switches wired one side to P1 input, the other side to ground. I have been working with ChatGPT to develop this script but it can only go so far. It really has trouble with the little details. (id; .get() set()) I don't totally understand it either and need some help. I have included my hal filses and the python script. Any and all help is greatly appreciated.
You guys are awesome BTW
I am working on a python logic script to control some switches, a button, and a couple encoders connected to the p1 connector of the Mesa 7i96s IO with 5vdc going to power the encoders. They are just simple switches wired one side to P1 input, the other side to ground. I have been working with ChatGPT to develop this script but it can only go so far. It really has trouble with the little details. (id; .get() set()) I don't totally understand it either and need some help. I have included my hal filses and the python script. Any and all help is greatly appreciated.
Attachments:
Please Log in or Create an account to join the conversation.
- heffamonster
- Offline
- New Member
-
Less
More
- Posts: 6
- Thank you received: 0
17 Sep 2025 03:03 #335106
by heffamonster
Replied by heffamonster on topic Python pendant logic problems
Sorry i uploaded them twoce
Please Log in or Create an account to join the conversation.
- unknown
- Offline
- Platinum Member
-
Less
More
- Posts: 581
- Thank you received: 194
17 Sep 2025 05:14 #335114
by unknown
Replied by unknown on topic Python pendant logic problems
All the Hal files are useful, with what you supplied there is no telling how your mesa card was setup.
More time wasted with using AI. You don't requires script to assemble the logic for a simple pendant with buttons and an mpg, it can all be done via Hal.
A mesa card does require a seperate Hal component to be loaded for an encoder, if you are using the on board encoder and don't require it for any spindle speed or position feedback. The encoder Hal component is usually used with the parallel port, when no encoder is available, ie with with a mesa card, tho you could set one by using mesa input pins as would you would do via a parallel port.
To tell the truth I did write a Hal component that takes the count from a encoder on the mesa card and some other pin inputs for scale and such, but this was just a way to simplify the Hal file for myself, it is not really required, all the connections can be made using seperate Hal components.
If you do want to use a script, the best way to get the values of the input pins and the encoder counts is to simply create the pins needed.
I would honestly browse the forum, I'm sure a topic came up recently regarding a configuration for a pendant.
Forget AI for Linuxcnc, I have seen some very upset people when it is pointed out the code produced is more or less useless.
One reason for the concept of Hal in Linuxcnc is so that a non programmer can just join this bit to this and this bit to that without having to indulge in programming.
Now my thoughts usually don't run in an ordered manner, what you best might is to describe by words, schematics, drawing on the back of an envelope, blackboard or for us more of a Luddite bent maybe a drawing on a cavewall. Once we know how you want to connect this bit to that bit answers will come.
But yeah read the docs, have a browse of some of the supplied components and see what best fits what you need to do.
What follows is the ranting old man, can be ignored. Or hysterically laughed at.
It does seem quite ironic that AI isn't a great help with a project such as Linuxcnc. CNC controlling the machines and AI replacing the use of the human mind.
Once humanity achieves Actual Intelligence may Artificial Intelligence maybe of some use.
More time wasted with using AI. You don't requires script to assemble the logic for a simple pendant with buttons and an mpg, it can all be done via Hal.
A mesa card does require a seperate Hal component to be loaded for an encoder, if you are using the on board encoder and don't require it for any spindle speed or position feedback. The encoder Hal component is usually used with the parallel port, when no encoder is available, ie with with a mesa card, tho you could set one by using mesa input pins as would you would do via a parallel port.
To tell the truth I did write a Hal component that takes the count from a encoder on the mesa card and some other pin inputs for scale and such, but this was just a way to simplify the Hal file for myself, it is not really required, all the connections can be made using seperate Hal components.
If you do want to use a script, the best way to get the values of the input pins and the encoder counts is to simply create the pins needed.
I would honestly browse the forum, I'm sure a topic came up recently regarding a configuration for a pendant.
Forget AI for Linuxcnc, I have seen some very upset people when it is pointed out the code produced is more or less useless.
One reason for the concept of Hal in Linuxcnc is so that a non programmer can just join this bit to this and this bit to that without having to indulge in programming.
Now my thoughts usually don't run in an ordered manner, what you best might is to describe by words, schematics, drawing on the back of an envelope, blackboard or for us more of a Luddite bent maybe a drawing on a cavewall. Once we know how you want to connect this bit to that bit answers will come.
But yeah read the docs, have a browse of some of the supplied components and see what best fits what you need to do.
What follows is the ranting old man, can be ignored. Or hysterically laughed at.

It does seem quite ironic that AI isn't a great help with a project such as Linuxcnc. CNC controlling the machines and AI replacing the use of the human mind.
Once humanity achieves Actual Intelligence may Artificial Intelligence maybe of some use.
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
Less
More
- Posts: 23550
- Thank you received: 5017
17 Sep 2025 18:56 #335139
by andypugh
Replied by andypugh on topic Python pendant logic problems
Can you describe what you want to happen? I have a feeling that the AI might be over-complicatiing things. But without knowing your requirements it is hard to tell.
Does the MPG connect to a Mesa counter, or only to GPIO?
Does the MPG connect to a Mesa counter, or only to GPIO?
Please Log in or Create an account to join the conversation.
- heffamonster
- Offline
- New Member
-
Less
More
- Posts: 6
- Thank you received: 0
17 Sep 2025 23:04 #335144
by heffamonster
Replied by heffamonster on topic Python pendant logic problems
I don't have an MPG. It's all done with switches. 1. empty 26. PE
2. empty 25. empty
3. momentary switch 24. empty
4. mode switch 23. empty
5. DT (encoder) 22. encoder power 5vdc
6. SW (encoder) 21. X,Y,Z; Z-Y: unused GND
7. CLK (encoder) 20. momentary GND
8. Z (X,Y,Z switch) 19. encoder GND
9. X (X,Y,Z switch) 18. D-pad GND
10. Y-Z switch 17. down
11. unused 16. up
12. empty 15. right
13. empty 14.left
Its all connected to a parallel port breakout board, connected to the P1 of the Mesa 7i96s. I don't NEED a python script. If i can handle the logic through hal, that would be the best way for me. I don't even need the logic. I just want to get them functioning and then i can add features later. I have a spindle encoder so i would need to load at least one more. The diagram doesn't reflect and additional encoder connected to 1,2,12. At the end of the day, Ai does complicate otherwise basic tasks. Thank you for the responses. If you need anymore information, just let me know.
2. empty 25. empty
3. momentary switch 24. empty
4. mode switch 23. empty
5. DT (encoder) 22. encoder power 5vdc
6. SW (encoder) 21. X,Y,Z; Z-Y: unused GND
7. CLK (encoder) 20. momentary GND
8. Z (X,Y,Z switch) 19. encoder GND
9. X (X,Y,Z switch) 18. D-pad GND
10. Y-Z switch 17. down
11. unused 16. up
12. empty 15. right
13. empty 14.left
Its all connected to a parallel port breakout board, connected to the P1 of the Mesa 7i96s. I don't NEED a python script. If i can handle the logic through hal, that would be the best way for me. I don't even need the logic. I just want to get them functioning and then i can add features later. I have a spindle encoder so i would need to load at least one more. The diagram doesn't reflect and additional encoder connected to 1,2,12. At the end of the day, Ai does complicate otherwise basic tasks. Thank you for the responses. If you need anymore information, just let me know.
Please Log in or Create an account to join the conversation.
- heffamonster
- Offline
- New Member
-
Less
More
- Posts: 6
- Thank you received: 0
18 Sep 2025 00:13 #335146
by heffamonster
Replied by heffamonster on topic Python pendant logic problems
Would something like this work? net pendant-encoder-a pendant.encoder-a [HMOT](CARD0).0.gpio.034.in
net pendant-encoder-b pendant.encoder-b [HMOT](CARD0).0.gpio.035.in
net pendant-encoder-btn pendant.encoder-btn [HMOT](CARD0).0.gpio.036.in
net pendant-jog-a pendant.jog-a [HMOT](CARD0).0.gpio.037.in
net pendant-jog-b pendant.jog-b [HMOT](CARD0).0.gpio.038.in
net pendant-jog-btn pendant.jog-btn [HMOT](CARD0).0.gpio.039.in
net pendant-momentary pendant.momentary-btn [HMOT](CARD0).0.gpio.040.in
net pendant-mode-sw pendant.mode-sw [HMOT](CARD0).0.gpio.041.in
net pendant-axis-x pendant.axis-x-sel [HMOT](CARD0).0.gpio.042.in
net pendant-axis-y pendant.axis-y-sel [HMOT](CARD0).0.gpio.043.in
net pendant-axis-z pendant.axis-z-sel [HMOT](CARD0).0.gpio.044.in
net pendant-z-y-sel pendant.z-y-sel [HMOT](CARD0).0.gpio.045.in
net pendant-dpad-up pendant.dpad-up [HMOT](CARD0).0.gpio.046.in
net pendant-dpad-down pendant.dpad-down [HMOT](CARD0).0.gpio.047.in
net pendant-dpad-left pendant.dpad-left [HMOT](CARD0).0.gpio.048.in
net pendant-dpad-right pendant.dpad-right [HMOT](CARD0).0.gpio.049.in
net pendant-coolant-hw pendant.coolant-hw [HMOT](CARD0).0.gpio.050.in
I know im missing something.
net pendant-encoder-b pendant.encoder-b [HMOT](CARD0).0.gpio.035.in
net pendant-encoder-btn pendant.encoder-btn [HMOT](CARD0).0.gpio.036.in
net pendant-jog-a pendant.jog-a [HMOT](CARD0).0.gpio.037.in
net pendant-jog-b pendant.jog-b [HMOT](CARD0).0.gpio.038.in
net pendant-jog-btn pendant.jog-btn [HMOT](CARD0).0.gpio.039.in
net pendant-momentary pendant.momentary-btn [HMOT](CARD0).0.gpio.040.in
net pendant-mode-sw pendant.mode-sw [HMOT](CARD0).0.gpio.041.in
net pendant-axis-x pendant.axis-x-sel [HMOT](CARD0).0.gpio.042.in
net pendant-axis-y pendant.axis-y-sel [HMOT](CARD0).0.gpio.043.in
net pendant-axis-z pendant.axis-z-sel [HMOT](CARD0).0.gpio.044.in
net pendant-z-y-sel pendant.z-y-sel [HMOT](CARD0).0.gpio.045.in
net pendant-dpad-up pendant.dpad-up [HMOT](CARD0).0.gpio.046.in
net pendant-dpad-down pendant.dpad-down [HMOT](CARD0).0.gpio.047.in
net pendant-dpad-left pendant.dpad-left [HMOT](CARD0).0.gpio.048.in
net pendant-dpad-right pendant.dpad-right [HMOT](CARD0).0.gpio.049.in
net pendant-coolant-hw pendant.coolant-hw [HMOT](CARD0).0.gpio.050.in
I know im missing something.
Please Log in or Create an account to join the conversation.
Time to create page: 0.213 seconds