- Posts: 4
- Thank you received: 0
G-Code to turn machine OFF
- ElectroNick
- Offline
- New Member
-
Less
More
14 years 9 months ago #16384
by ElectroNick
Replied by ElectroNick on topic Re:G-Code to turn machine OFF
andypugh wrote:
Thanks!
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.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.
Thanks!
Please Log in or Create an account to join the conversation.
- MasterSpoon
- Offline
- New Member
-
Less
More
- Posts: 10
- Thank you received: 0
7 years 4 months ago #138069
by MasterSpoon
Replied by MasterSpoon on topic Re:G-Code to turn machine OFF
Figured rather than starting a new topic would ask in this one as it's the top search result however most of the links are dead.
I am trying to do similar to what the OP was wanting to do, have a desktop machine that I'm planning to have running while I'm not near it and might not be back to check on it for hours at a time so want it to power down the stepper motors once it's finished. Have just finished installing relays for the cooling and spindle so turning them off in G-code is easy.
Running a Gecko G540 stepper controller, have it setup using a charge pump (Pin 16) to enable the stepper drivers. If it has charge pump signal the steppers are powered regardless of if the Machine Power (F2) is on or off. Without charge pump the controller sends an E-stop.
hal file entry for charge pump if it makes any difference is
loadrt charge_pump
net estop-out charge-pump.enable iocontrol.0.user-enable-out
net charge-pump <= charge-pump.out
Ideally I would want to be able to pop an M300 at the end of my Gcode file if I'm not hanging around and have it power off the steppers once it's done. I have been able to get part of what I want done, just stuck on the final piece of the puzzle.
So far with reading the Wiki and also following this topic
forum.linuxcnc.org/38-general-linuxcnc-q.../31909-custom-m-code
I have created a sub routine to power off the coolant, spindle, wait 5 seconds but don't know how to send an E-Stop or turn off the charge pump to power down the steppers
o<m300> sub
M9
M5
G4 P5
m30
o<m300> endsub
If turning off the coolant, spindle, wait 5 seconds then power down is to hard, it will also work by just sending an E-stop or turning off the charge pump as their relays are controlled through the G540 so a E-stop will turn them off also. I'm not sure if the subroutine was the right way or if I should have been creating an executable ?
I am trying to do similar to what the OP was wanting to do, have a desktop machine that I'm planning to have running while I'm not near it and might not be back to check on it for hours at a time so want it to power down the stepper motors once it's finished. Have just finished installing relays for the cooling and spindle so turning them off in G-code is easy.
Running a Gecko G540 stepper controller, have it setup using a charge pump (Pin 16) to enable the stepper drivers. If it has charge pump signal the steppers are powered regardless of if the Machine Power (F2) is on or off. Without charge pump the controller sends an E-stop.
hal file entry for charge pump if it makes any difference is
loadrt charge_pump
net estop-out charge-pump.enable iocontrol.0.user-enable-out
net charge-pump <= charge-pump.out
Ideally I would want to be able to pop an M300 at the end of my Gcode file if I'm not hanging around and have it power off the steppers once it's done. I have been able to get part of what I want done, just stuck on the final piece of the puzzle.
So far with reading the Wiki and also following this topic
forum.linuxcnc.org/38-general-linuxcnc-q.../31909-custom-m-code
I have created a sub routine to power off the coolant, spindle, wait 5 seconds but don't know how to send an E-Stop or turn off the charge pump to power down the steppers
o<m300> sub
M9
M5
G4 P5
m30
o<m300> endsub
If turning off the coolant, spindle, wait 5 seconds then power down is to hard, it will also work by just sending an E-stop or turning off the charge pump as their relays are controlled through the G540 so a E-stop will turn them off also. I'm not sure if the subroutine was the right way or if I should have been creating an executable ?
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
-
Less
More
- Posts: 19899
- Thank you received: 4655
7 years 4 months ago - 7 years 4 months ago #138070
by andypugh
Replied by andypugh on topic Re:G-Code to turn machine OFF
The M100-M199 codes can be any executable file.
Without any testing my first guess would be
This is very similar to the M101 and M102 examples here:
linuxcnc.org/docs/2.7/html/gcode/m-code.html#mcode:m100-m199
Without any testing my first guess would be
Code:
#! /bin/bash
halcmd setp halui.machine.off 1
exit 0
This is very similar to the M101 and M102 examples here:
linuxcnc.org/docs/2.7/html/gcode/m-code.html#mcode:m100-m199
Last edit: 7 years 4 months ago by andypugh.
Please Log in or Create an account to join the conversation.
- bevins
- Offline
- Platinum Member
-
Less
More
- Posts: 1947
- Thank you received: 338
7 years 4 months ago #138071
by bevins
Replied by bevins on topic Re:G-Code to turn machine OFF
So why don't you simply have a relay follow machine-is-on , and supply charge pump signal to g540 with the relay.
That's how I use my g540
That's how I use my g540
Please Log in or Create an account to join the conversation.
- MasterSpoon
- Offline
- New Member
-
Less
More
- Posts: 10
- Thank you received: 0
7 years 4 months ago #138078
by MasterSpoon
Replied by MasterSpoon on topic Re:G-Code to turn machine OFF
Thank you for the prompt replies, making progress
I created a M130 code with
It works the first time but then doesn't work again until you close and reopen LinuxCNC, Even when it's working however it only toggles machine power (F2) where I'm trying to toggle E-stop (F1)
I found this
wiki.linuxcnc.org/cgi-bin/wiki.pl?Halui
estop:
halui.estop.activate bit //pin for setting Estop (emc internal) On
halui.estop.reset bit //pin for resetting Estop (emc internal) Off
halui.estop.is-reset bit //pin for displaying Estop state (emc internal) On/Off?
using
It does exactly what I want however not consistently. I can load LinuxCNC, F1 - Estop, F2 - toggle machine power, F5 - MDI, M130 and does exactly what it should
If I then F1 - Estop, F2 - toggle machine power, M130 a second time the M130 does nothing.
So it works but it only appears to work the first time for each session but won't work a second time. Am I missing something obvious here ?
I created a M130 code with
Code:
#! /bin/bash
halcmd setp halui.machine.off 1
exit 0
It works the first time but then doesn't work again until you close and reopen LinuxCNC, Even when it's working however it only toggles machine power (F2) where I'm trying to toggle E-stop (F1)
I found this
wiki.linuxcnc.org/cgi-bin/wiki.pl?Halui
estop:
halui.estop.activate bit //pin for setting Estop (emc internal) On
halui.estop.reset bit //pin for resetting Estop (emc internal) Off
halui.estop.is-reset bit //pin for displaying Estop state (emc internal) On/Off?
using
Code:
#! /bin/bash
halcmd setp halui.estop.activate 1
exit 0
If I then F1 - Estop, F2 - toggle machine power, M130 a second time the M130 does nothing.
So it works but it only appears to work the first time for each session but won't work a second time. Am I missing something obvious here ?
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
-
Less
More
- Posts: 7368
- Thank you received: 2181
7 years 4 months ago #138079
by cmorley
Replied by cmorley on topic Re:G-Code to turn machine OFF
I would try something like:
halui expects the pin to toggle.
Chris M
Code:
#! /bin/bash
halcmd setp halui.machine.off 0
halcmd setp halui.machine.off 1
exit 0
halui expects the pin to toggle.
Chris M
Please Log in or Create an account to join the conversation.
Time to create page: 0.189 seconds