G-Code to turn machine OFF

More
28 Jun 2019 02:25 #138078 by MasterSpoon
Thank you for the prompt replies, making progress

I created a M130 code with
#! /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
#! /bin/bash
halcmd setp halui.estop.activate 1
exit 0
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 ?

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

More
28 Jun 2019 02:29 #138079 by cmorley
I would try something like:
#! /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.

More
28 Jun 2019 02:54 #138080 by MasterSpoon

I would try something like:
#! /bin/bash
halcmd setp halui.machine.off 0
halcmd setp halui.machine.off 1
exit 0

halui expects the pin to toggle.

Chris M


Booya, we have a winner !

Okay so tried that code, didn't work but it led me to the answer

M130
#! /bin/bash
halcmd setp halui.estop.activate 1
exit 0
M129
#! /bin/bash
halcmd setp halui.estop.activate 0
exit 0
M300
o<m300> sub
m129
M9
M5
G4 P5
m130
m30
o<m300> endsub

M129 effectively resets the Pin, but M129 then M130 straight after appears to try too quickly before the M129 has reset the pin and it doesn't work

M300 resets the pin, turns off coolant & spindle, waits 5 seconds for them to spin down then hits the E-Stop

I'm now one step closer to having it all set exactly how I want, thank you for the help

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

More
28 Jun 2019 10:14 #138105 by andypugh
I am surprised that the G-code subroutine continues to execute through e-stop.

Try doing it all in the bash script, but re-set the pins afterwards.
#! /bin/bash
halcmd setp halui.flood.off 1
halcmd setp halui.spindle.stop 1
sleep 5
halcmd setp halui.estop.activate 1

halcmd getp halui.machine.is-on
while [ $? = 1]
do
    sleep 1
    halcmd getp halui.machine.is-on
done
halcmd setp halui.estop.activate 0
halcmd setp halui.flood.off 0
halcmd setp halui.spindle.stop 0
exit 0

I don't have bash here so can't test this, but the idea is to turn off spindle and coolant, wait 5 secs, toggle e-stop then poll the machine status until e-stop has activated.
Then all the halui pins are toggled back to zero for the next time round.

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

More
28 Jun 2019 10:30 #138108 by pl7i92
Replied by pl7i92 on topic G-Code to turn machine OFF
5-7 seconds of untrou states that is a real whear behavior even on e-stop

E-stop is e-stop
then user shoudt take action non Mcode state changes after this

Why at all shoudt the G-code trigger e-stop
this is mashine and safty issue non g-code related

im with you at M9 M5 M30

the Mashine off as on large printings 24+ hr is here a Realy that shuts the complete power down

g-code mashine issues behavior is real wheard

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

More
28 Jun 2019 13:03 #138115 by MasterSpoon

Try doing it all in the bash script, but re-set the pins afterwards.


I gave your code a try as it seemed a bit more elegant then my solution but for some reason the sleep command doesn't work in the bash script.

If I even try just
#! /bin/bash
sleep 5
halcmd setp halui.estop.activate 1
exit 0
then the code still runs but it seems to ignore the sleep command and just toggles it off straight away as if sleep wasn't there.

I also tried sleep 5s but no dice either.

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

More
28 Jun 2019 13:09 #138116 by andypugh
Try "5s"
Maybe it defaults to nS or something?

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

More
28 Jun 2019 17:39 #138127 by pl7i92
Replied by pl7i92 on topic G-Code to turn machine OFF
get a
sleep --help

and somtimes the wrong bash sleep versions
sleep --version

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

More
29 Jun 2019 00:17 #138143 by MasterSpoon
Ok I feel like an idiot now...
I have a G-code folder that I use to transfer G-code from my main computer to the milling computer, I have then been doing my custom M code files in the linuxcnc/nc_files folder
Forgot that it checks the default folder first, which was the G-code folder and I had a duplicate in there so when I was editing the one in the nc_files folder it wasn't doing anything as it was reading the one from my G-code folder first.

Sleep works fine now that I have solved the operator error.

I was still having trouble with andypugh's script not working, it seemed to work once then when I ran it a second time it wouldn't turn the machine off. I used a simplified and probably not quite as graceful script but doing
#! /bin/bash
halcmd setp halui.mist.off 1
halcmd setp halui.spindle.stop 1
sleep 5
halcmd setp halui.estop.activate 1
sleep 1
halcmd setp halui.estop.activate 0
halcmd setp halui.mist.off 0
halcmd setp halui.spindle.stop 0
exit 0

seems to do exactly what I want so I will leave it at that for now.

Thanks again for the help

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

More
30 Jun 2019 13:52 #138237 by andypugh
Replied by andypugh on topic G-Code to turn machine OFF
Your version of the script has the potential problem that if the machine takes more than 1 second to respond to the e-stop then it might never see it as the signal then resets regardless of machine state.

I also really do think that machine-off would be better than e-stop.
machine-off should shut down all the amps and stop all motion.

e-stop should be reserved for emergency stops, and probably ought to lock-out a machine re-start unless a hardware button is pressed. (though I confess that nether of my machines have this for the sofware e-stop, only for the hardware stop)

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

Time to create page: 0.105 seconds
Powered by Kunena Forum