Hello Guest it is April 18, 2024, 12:32:23 AM

Author Topic: Condition testing in Gcode  (Read 2346 times)

0 Members and 1 Guest are viewing this topic.

Condition testing in Gcode
« on: April 12, 2016, 03:32:15 AM »
Hi Guys,

I need your help again. I'm really not all that good with gcode, nor with Mach3 beyond the basic stuff, so I hope somebody has an easy solution to the problem I have.

I have made the coordinate table for the battery spot welding machine. Basically you put a bunch of the batteries on the table and fasten them, and run the gcode, most often the simple X-Y array, so the batteries are welded into a pack. No problems there, quite a simple task even for me. The welder's head has two electrodes and is driven down and up again by the pneumatic cylinder. I've hooked the switch to the relays on the BOB and use the coolant command to start the cycle, and a dwell command to give it time to do it's thing. Most of the time, everything work flawlessly, but sometimes the electrodes stick to the battery contacts, and the problem has to be resolved before the next move, if not, the electrodes will bend rather than unstick, the position is lost etc...

So I have added the switch at the head top position and need to test if it's on before the next move is made. Simple enough, except I don't know how to do it;)

I hope the above is clear enough, and that somebody can help me with this. Is there any command in Gcode I can use for this, or any setting in MACH3 which wouold do this?

Thanks in advance

Miso

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Condition testing in Gcode
« Reply #1 on: April 12, 2016, 03:56:56 AM »
You could make a custom M Code and add it into the code before each next move.
Something like this may work

If IsActive(Input1) Then
message "moving to next"
Else
MsgBox " Electrode stuck, release then press OK"
End If
 
To make a custom macro go to Operator menu then Edit VB scripts, the editor will open, paste the above code to it then save as m101.m1s to the macro folder of the profile you are using.
If you then insert m101 into the relevant places in your G  code it will either, depending on Input 1 state, continue with a message showing in the ticker window or it will stop and a message box will pop up and it will wait until you press Ok before it will continue.
Hood
Re: Condition testing in Gcode
« Reply #2 on: April 12, 2016, 09:55:16 AM »
Thanks Hood,

I'll try to do that, much appreciated.

Miso
(No subject)
« Reply #3 on: April 12, 2016, 11:52:54 AM »
Ive only been playing with the Mach3 software/controller (dont have machine yet) so sorry if this is off base. Couldnt you also do this with pure software, add an IF condition and if Z not equal bla M0 instead of M1 ?

Mach seams pretty cool if you can script like that with a VBS MsgBox and it will cause the machine to sit till further instruction.

.

_
~ What was once an Opinion, became a Fact, to be later proven Wrong ~
Re: Condition testing in Gcode
« Reply #4 on: April 14, 2016, 06:13:26 PM »
Works perfectly, took only a couple of minutes, Hood thanks a ton;)

Also thanks for other suggestions, but I'm quite happy with this one, so will probably stick to it...

Miso