Controling the state of a pin?
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
24 Aug 2013 00:25 #38009
by Todd Zuercher
Controling the state of a pin? was created by Todd Zuercher
I want to use custom M codes to control the state of some pins. I also need to be able to indicate what the state of that pin is in a pyvcp pannel. My problem is that if I connect the pins to signals to twiddle the led in the pyvcp, then I can not control the state of the pin with setp in the custom M code. I am sure there has to be a way arround this, I just don't know what it is.
Please Log in or Create an account to join the conversation.
24 Aug 2013 00:29 #38010
by BigJohnT
Replied by BigJohnT on topic Controling the state of a pin?
Read this:
linuxcnc.org/docs/html/hal/basic_hal.html
Only one "thing" can be in control of a pin. Many "readers" can view the "signal".
The lines your trying to use would help.
JT
linuxcnc.org/docs/html/hal/basic_hal.html
Only one "thing" can be in control of a pin. Many "readers" can view the "signal".
The lines your trying to use would help.
JT
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
24 Aug 2013 01:19 #38012
by Todd Zuercher
Replied by Todd Zuercher on topic Controling the state of a pin?
I have the pin (lut5.0.in-2) that I want to control with setp, in custom M codesand
I also want to twidle it with pyvcp buttons, no problem just use halui commands to the custom M codes.
My problem, is I want to have some indication on the pyvcp of what the state of the lut5.0.in-2 1
pin is. How do I do that without breaking the M codes?
I haven't actually tried anything yet. I am still working at typing up all the configuration files.
Maybe I can just add another setp line in the M code to directly effect the pyvcp pin for the LED.
M113
#!/bin/bash
# file to Enables the Z Spindle
halcmd setp lut5.0.in-2 1
exit 0
M115
#!/bin/bash
# file to Disables the Z Spindle
halcmd setp lut5.0.in-2 0
exit 0
I also want to twidle it with pyvcp buttons, no problem just use halui commands to the custom M codes.
My problem, is I want to have some indication on the pyvcp of what the state of the lut5.0.in-2 1
pin is. How do I do that without breaking the M codes?
I haven't actually tried anything yet. I am still working at typing up all the configuration files.
Maybe I can just add another setp line in the M code to directly effect the pyvcp pin for the LED.
Please Log in or Create an account to join the conversation.
24 Aug 2013 01:56 - 24 Aug 2013 01:57 #38015
by BigJohnT
Replied by BigJohnT on topic Controling the state of a pin?
Instead of setp the pin sets the signal name. Both the led and the in pin for lut5 can be connected to the same signal.
JT
net lut5in0signal lut5.0.in-0 pyvcp.my-led
M113
...
sets lut5in0signal 1
JT
Last edit: 24 Aug 2013 01:57 by BigJohnT.
The following user(s) said Thank You: Todd Zuercher
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
24 Aug 2013 04:23 #38017
by Todd Zuercher
Replied by Todd Zuercher on topic Controling the state of a pin?
I completely missed that there was a "sets" command in hal. That makes my life much simpler.
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
24 Aug 2013 09:57 #38023
by Todd Zuercher
Replied by Todd Zuercher on topic Controling the state of a pin?
I don't think "sets" is mentioned in most of the manuals. (it is in linuxcnc.org/docs/html/man/man1/halcmd.1.html)
Now that I have it working I can better explain what I was trying to do.
We have some routers with two spindles on W and Z axis. Some times both are used together to mill 2 things at a time. Other times they are used separately to do to separate tasks on a single piece. Such as one milling a key hole slot with a t-slot bit, and the other using an end mill to cut out the piece.
So I created 4 M codes M113 and M123 to enable Z and W and M115 and M125 to disable each. So to run both spindles I would first command M113 and M123 then S18000 M3. If I need to run just the W spindle I would command M115 and M123 before the M3.
I used the lut5 to control the inputs for the spindle at speed signals. So that if one of the drives is disabled then LinuxCNC only waits for the signal from the enabled drive, and if both are enabled then the signal must come from both drives.
Then I used two and2 gates to connect each spindle enable signal and the spindle on so that only the drive(s) that are enabled start when the M3 is commanded.
Finally, I set up some pyvcp LEDs to indicate what spindle(s) are enabled so you know what it going to start when you press the start button, and a couple of buttons to manually set them.
I had been mulling this over in my head on and off for the last 6 months. It feels really good to finally have it set up and work as planned. If anyone wants me to share the config, I'll zip it up and post it. It is kind of involved with lots of little osubs and the M1xx codes to work with the pvcp. (I think there are 44 halui commands in there)
Now that I have it working I can better explain what I was trying to do.
We have some routers with two spindles on W and Z axis. Some times both are used together to mill 2 things at a time. Other times they are used separately to do to separate tasks on a single piece. Such as one milling a key hole slot with a t-slot bit, and the other using an end mill to cut out the piece.
So I created 4 M codes M113 and M123 to enable Z and W and M115 and M125 to disable each. So to run both spindles I would first command M113 and M123 then S18000 M3. If I need to run just the W spindle I would command M115 and M123 before the M3.
I used the lut5 to control the inputs for the spindle at speed signals. So that if one of the drives is disabled then LinuxCNC only waits for the signal from the enabled drive, and if both are enabled then the signal must come from both drives.
Then I used two and2 gates to connect each spindle enable signal and the spindle on so that only the drive(s) that are enabled start when the M3 is commanded.
Finally, I set up some pyvcp LEDs to indicate what spindle(s) are enabled so you know what it going to start when you press the start button, and a couple of buttons to manually set them.
I had been mulling this over in my head on and off for the last 6 months. It feels really good to finally have it set up and work as planned. If anyone wants me to share the config, I'll zip it up and post it. It is kind of involved with lots of little osubs and the M1xx codes to work with the pvcp. (I think there are 44 halui commands in there)
Please Log in or Create an account to join the conversation.
24 Aug 2013 14:45 #38025
by cncbasher
Replied by cncbasher on topic Controling the state of a pin?
hell your brain must be fried by now Todd .. glad you figured it out
post your configs etc , this sounds interesting to try out !
post your configs etc , this sounds interesting to try out !
Please Log in or Create an account to join the conversation.
25 Aug 2013 03:04 #38040
by BigJohnT
It is missing from the Basic Hal Tutorial manual. I know the chap that wrote that part and will give him a proper flogging so he won't leave out important stuff like that in the future.
JT
Replied by BigJohnT on topic Controling the state of a pin?
I don't think "sets" is mentioned in most of the manuals. (it is in linuxcnc.org/docs/html/man/man1/halcmd.1.html)
It is missing from the Basic Hal Tutorial manual. I know the chap that wrote that part and will give him a proper flogging so he won't leave out important stuff like that in the future.
JT
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
25 Aug 2013 10:09 #38046
by Todd Zuercher
Replied by Todd Zuercher on topic Controling the state of a pin?
You asked for it so here it is
Please Log in or Create an account to join the conversation.
Time to create page: 0.084 seconds