flip state of parallel port pin using gcodes??

More
28 Feb 2014 07:33 #44247 by cnccircuits
i apologize for for my noobishness here but i was wondering how i could configure LinuxCNC to control one of the parallel port outputs via a gcode command?

i have a vacuum system for picking up parts and would like to programmatically instruct LinuxCNC to energize/deenergize a solenoid valve at specific steps in the program.

Thanks!!

Please Log in or Create an account to join the conversation.

More
28 Feb 2014 08:51 - 28 Feb 2014 08:52 #44248 by PCW
Last edit: 28 Feb 2014 08:52 by PCW.

Please Log in or Create an account to join the conversation.

More
28 Feb 2014 19:46 #44258 by andypugh

i was wondering how i could configure LinuxCNC to control one of the parallel port outputs via a gcode command?


There are at least two ways to do this.

1) Use the G-code digital outputs. There is a set of HAL pins called motion.digital-out-00 to motion.digital-out-03 (you can have more if required)
www.linuxcnc.org/docs/html/man/man9/motion.9.html
The state of these HAL pins is directly controlled by the M63-M65 G-codes as linked by PCW.
To make the HAL pin toggle a parallel port pin you need to make a connection in HAL, probably in your custom hal file.
net digout1 motion.digital-out-00 => parport.0.pin-01-out

2) Use a custom G-code. You can call any sort of executable file with a G-code, if the executable file is called M100 (for example), then M100 in your G-code will run that file.
If you open a terminal window when LinuxCNC is running and type
halcmd setp parport.0.pin-01-out 1
you will see that the state of the parport pin changes. (use 0 to change it back)
You can embed that command in a file. Create a file called "M100" containing the following text in the directory pointed to by the entry in your Linuxcnc config INI file.
#! /bin/bash
halcmd setp parport.0.pin-01-out 1
exit 0
Then set that file to be executable (chmod or use the GUI, your choice).
Now M100 in the G-code will run that script and set the pin.

3) Re-purpose mist coolant or similar.
If your system isn't using coolant, then just put his in your custom HAL.
net vacuum iocontrol.0.coolant-mist => parport.0.pin-01-out
Then you can control the vacuum with M7 for on and M9 for off.
The drawback with this approach is that timing control isn't as exact as option 1.

Please Log in or Create an account to join the conversation.

More
01 Mar 2014 16:43 #44287 by Rick G
For a little more information on custom g codes take a look here...
linuxcnc.org/docs/html/gcode/m-code.html#sec:M100-to-M199
and as Andy stated

Then you can control the vacuum with M7 for on and M9 for off.

This is a easy approach I have used and gives the advantage of having a built in button in the Axis Manual control mode to toggle the device on and off.

Rick G

Please Log in or Create an account to join the conversation.

Time to create page: 0.125 seconds
Powered by Kunena Forum