Hello Guest it is March 29, 2024, 04:14:35 AM

Author Topic: G-Code Macro help needed!  (Read 5210 times)

0 Members and 1 Guest are viewing this topic.

G-Code Macro help needed!
« on: June 26, 2012, 02:06:38 PM »
I've built a machine that mills two parts behind an enclosure (running mach3 with ajax hardware). The operator loads the parts through the enclosure. As the machine is milling on the first part the operator is putting in the second part. When the machine is finished with the first part it automatically unclamps and moves on to the second part while the operator removes the first part and puts in a new one. The clamping/unclamping is performed by a plc that sends a "clamped" signal to tell the cnc that the part is clamped, and when the part is done the cnc sends a signal to the plc to unclamp that part. To do this I've made 4 macro's M300,M301,M302, and M303. M300 is placed about 4th line in G-code. It makes sure the first part is clamped before moving on. This is the macro M300

RightClampDone= not GetOEMLED(1000)
While(RightClampDone)
sleep100
Wend

Then at the end of the first part program I have macro M301 which unclamps the first part.

SetUserLED(1002,1)
code "G4 P1"
While Ismoving
Wend
SetUserLED(1002,0)


OK here's the problems. If I load a part without hitting cycle start the plc clamps the part and sends the "clamped" signal to the cnc. The cnc starts up automatically and begins milling without me hitting cycle start. When is finishes the part it automatically unclamps like it's supposed to and moves on to the second part. I'm not sure why the machine starts up automatically....makes it dangerous!!

If I hit cycle start first the machine moves into position and waits until receiving the signal from plc to begin, but now when it gets to the end it does not unclamp the part.

I'm confused. It seems like sometimes it skips right over the unclamp macro. Also if the second part is not present the machine will wait until it's present before beginning to run the part, but now you have to hit the cycle start for it to proceed with the G-Code. Am I going about this all wrong?  Help!

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: G-Code Macro help needed!
« Reply #1 on: June 26, 2012, 02:20:21 PM »
RightClampDone= not GetOEMLED(1000)
While(RightClampDone)
sleep100
Wend

The above macro never updates the condition variable it may be better to try something like this :-

While Not (GetOEMLED(1000))
sleep100
Wend

I am still not sure why the machine starts though.
Without engineers the world stops

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: G-Code Macro help needed!
« Reply #2 on: June 26, 2012, 07:30:35 PM »
The Macro Itself Cannot control the gcode side of MAch3 by HOLDING until the macro is satisfied (;-) The Gcode will run right around the macro code "AT TIMES" and proceed. and it can be vise versa.

Never trust life or limb to a MACH3 CB macro . Sooner or later it will get you.

NOW for the good PART Ajax/Mach3  does a LOT of things Differently than a standard Mach3 setup your best bet would be to contact AJAX for help they are the only ones that know the quirks behind their plugin control.

(;-) TP





Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: G-Code Macro help needed!
« Reply #3 on: June 27, 2012, 02:17:44 AM »
OK I am not really following HOW you signal the PLC ? Normally one would use the inputs and outputs to do this BUT I don't see where you are using anything of that nature.

HOW are you signalling the PLC  or receiving signals from the PLC?

What you are doing should not be that hard I just did a CNC cold saw setup with 3 clamps and it cycles fine.

(;-) TP
Re: G-Code Macro help needed!
« Reply #4 on: June 27, 2012, 04:41:22 PM »
Thanks for the replies. Graham's code fixed 90% of my problems, but it still automatically starts when you put a part in....which is acutally ok because that is what I was shooting for. As far as safety goes, this machine makes one part and is fully guarded making it impossible to injure yourself. The part is slide in through a cutout in a lexan shield with safety interlocks. I'm still not completely happy with it, because I'd like to know why it is behaving like it is, but it's functional. I've sent a message to Ajax, but they're on vacation. I'm wondering if the input is somehow tied into something else causing it to "cycle start" when the input goes high....just a theory.

BR549 The plc sends an output to an input on the ajax board (I should have specified this before).

Offline RICH

*
  • *
  •  7,427 7,427
    • View Profile
Re: G-Code Macro help needed!
« Reply #5 on: December 19, 2012, 04:45:36 PM »
darly01,
Just start a new topic under G code cam Discussions. I will delete what you have posted here.
RICH