Control I/O from G-code?
05 Jun 2017 19:06 - 06 Jun 2017 19:38 #94115
by Cpk_Rbt
Control I/O from G-code? was created by Cpk_Rbt
I want to control some outputs while running g-code. One example is my spindle, it's connected to an output on the drive of the Y axis of my CNC, how can I turn it on and off when the appropriate spindle commands are executed in a g-code program?
It's a primitive setup right now (until I get communication going to the drive for the spindle) it is one speed, so just a toggle on/off.
I have uses for other outputs (connected to drives) also, like opening and closing clamps, starting air cooling, etc. that would ideally be controlled via g-code as well.
I do have HAL pins for the outputs, I can do a setp <output_pin> [1 | 0] and turn them on and off. Is there a way to achieve the same in running g-code?
It's a primitive setup right now (until I get communication going to the drive for the spindle) it is one speed, so just a toggle on/off.
I have uses for other outputs (connected to drives) also, like opening and closing clamps, starting air cooling, etc. that would ideally be controlled via g-code as well.
I do have HAL pins for the outputs, I can do a setp <output_pin> [1 | 0] and turn them on and off. Is there a way to achieve the same in running g-code?
Last edit: 06 Jun 2017 19:38 by Cpk_Rbt. Reason: resolved
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
05 Jun 2017 19:29 #94118
by Todd Zuercher
Replied by Todd Zuercher on topic Control I/O from G-code?
If you have hal pins that actually control those extra io pins on your drives. controlling them is as simple as connecting them in hal.
If there is a pin called "output_pin" that starts and stops your spindle, I simply connect that pin to the pin "motion.spindle-on" by adding this line to your hal file.Then an M3 Sn (where n=something other than zero) will turn on the spindle, and an M5 or any of the many other things that turn off the spindle will.
If you have another pin that you want to turn on and off via G-code you can use M62-M65 to control the pins motion.digital-out-NN
linuxcnc.org/docs/html/gcode/m-code.html#mcode:m62-m65
And connecting those pins to what ever pins you need to control.
If there is a pin called "output_pin" that starts and stops your spindle, I simply connect that pin to the pin "motion.spindle-on" by adding this line to your hal file.
net spindel-on <= motion.spindle-on => output_pin
If you have another pin that you want to turn on and off via G-code you can use M62-M65 to control the pins motion.digital-out-NN
linuxcnc.org/docs/html/gcode/m-code.html#mcode:m62-m65
And connecting those pins to what ever pins you need to control.
The following user(s) said Thank You: Cpk_Rbt
Please Log in or Create an account to join the conversation.
06 Jun 2017 14:50 #94173
by Cpk_Rbt
Replied by Cpk_Rbt on topic Control I/O from G-code?
Very thorough, thank you Todd!
Please Log in or Create an account to join the conversation.
Time to create page: 0.072 seconds