NEWS
LinuxCNC 2.5.2 Release
LinuxCNC 2.5.2 Update Released (changelog).
 
LinuxCNC 2.5.1 Release

LinuxCNC 2.5.1 Update Released (changelog). If the Package Manager does not prompt you to upgrade see this page.

 
LinuxCNC 2.5.0 Release
New major release (changelog). See the instructions to update your system from EMC 2.4 to LinuxCNC 2.5.
 
Home Forum Using LinuxCNC G Code G-Code to turn machine OFF

Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: G-Code to turn machine OFF

G-Code to turn machine OFF 05 Jan 2012 14:54 #16361

Hi all, my first post in this great forum!

Been using EMC2 for a couple of years but never actually needed this feature before. But I'm tinkering with a very small router now that has motor heating issues and it's so quiet (cutting with a laser diode) that I no longer hear the cutting process complete.

I would love to be able to turn the power to the machine off automatically upon completion of the program but neither M2 nor M30 seem to accomplish what the F2 (Toggle machine power) button in EMC2 interface does.
I have Pin 17 in the parallel interface defined as "Amplifier Enable" and it works just fine with the F2 button but I need to be near the machine to press it, obviously.

is there a G-code already for doing something like that automatically? Or should I define a user M-code for that? I'd have to admit I never did custom codes before and some pointers would be greatly appreciated.

Thanks!
The administrator has disabled public write access.

Re:G-Code to turn machine OFF 05 Jan 2012 15:58 #16364

  • andypugh
  • andypugh's Avatar
  • OFFLINE
  • Moderator
  • Posts: 4092
  • Thank you received: 139
  • Karma: 129
ElectroNick wrote:
[quoteis there a G-code already for doing something like that automatically? ![/quote]

No.

However, I think that you could easily do it with a custom M-code.

You will need HALUI=halui in the [HAL] section of the INI file.
Then create an executable file called (for example) M101 as described here
www.linuxcnc.org/docview/html/gcode_main.html#sec:M100-to-M199
That needs to contain a command to set the machine state as described here
www.linuxcnc.org/docview/html/gui_halui.html#r1_2_10

so, try this:
#!/bin/sh
halcmd setp halui.machine.off true
exit 0
The administrator has disabled public write access.

Re:G-Code to turn machine OFF 05 Jan 2012 20:28 #16370

Thank you andypugh, that sounds easy enough to do. I was just wondering if similar command could be added to the part of EMC2 code that responds to a regular "program end" code like M2 or M30. Is standard G and/or M-code processing accessible in a similar way in EMC?

Also, speaking of custom M codes: does anyone think that there may be codes to stay away from, i.e. ones that are already frequently used by various G-code converters and such? I've looked into some 3D printing G-Code and there's a whole lot of M commands that are from within the user-defined range 101-199 but are used pretty regularly.

Thanks!
The administrator has disabled public write access.

Re:G-Code to turn machine OFF 06 Jan 2012 02:40 #16374

  • andypugh
  • andypugh's Avatar
  • OFFLINE
  • Moderator
  • Posts: 4092
  • Thank you received: 139
  • Karma: 129
ElectroNick wrote:
Thank you andypugh, that sounds easy enough to do. I was just wondering if similar command could be added to the part of EMC2 code that responds to a regular "program end" code like M2 or M30. !

Possibly.
linuxcnc.org/docview/devel/html/remap/structure.html
it's a fair bit less trivial, though.
The administrator has disabled public write access.

Re:G-Code to turn machine OFF 06 Jan 2012 09:58 #16381

andypugh wrote:
Possibly.
linuxcnc.org/docview/devel/html/remap/structure.html
it's a fair bit less trivial, though.
You were not kidding about this being less trivial! :S
Also, after reading this, it looks like remapping is not supported for the modal group 4 codes, which all program stops belong to. And, digging even deeper into Axis internals would be a foolish move. I guess I'll just add a user-defined M-code.

As a side question though: why would you NOT want to turn the amps OFF when you've stopped the program for good? Sounds like what I'm looking for should have been a default behavior? After all, it does turn spindle and coolant off without additional M9 or M5 upon encountering an M2 or M30. Why not also throw amps into OFF? What am I missing?
The administrator has disabled public write access.

Re:G-Code to turn machine OFF 06 Jan 2012 10:01 #16383

  • andypugh
  • andypugh's Avatar
  • OFFLINE
  • Moderator
  • Posts: 4092
  • Thank you received: 139
  • Karma: 129
ElectroNick wrote:
As a side question though: why would you NOT want to turn the amps OFF when you've stopped the program for good?
On many systems doing that will drop the head onto the table, or the knee onto the floor.
You also tend to lose home positions etc.

Bear in mind that at program-end most machines get reloaded and run the next part.
The administrator has disabled public write access.

Re:G-Code to turn machine OFF 06 Jan 2012 10:23 #16384

andypugh wrote:
On many systems doing that will drop the head onto the table, or the knee onto the floor.
You also tend to lose home positions etc.

Bear in mind that at program-end most machines get reloaded and run the next part.
I see, it does make sense. Anyway, thanks for the tip on the custom M code. To add one at the end of the program is not a big deal, I'll just go that route.
Thanks!
The administrator has disabled public write access.
  • Page:
  • 1
Time to create page: 1.328 seconds
Powered by Kunena Forum
© 2013 LinuxCNC.org
Joomla! is Free Software released under the GNU General Public License.