Hello Guest it is July 18, 2025, 12:05:34 PM

Author Topic: G54 to G55 Script in PLC not working  (Read 8372 times)

0 Members and 1 Guest are viewing this topic.

G54 to G55 Script in PLC not working
« on: August 08, 2024, 09:12:45 PM »
Hey, Im pretty stuck at this point. The way my machine is supposed to function is I have 2 "Work Zones" a Left and Right, When machine is running in the Left, I can clamp my part on the right side. Press Right "Cycle start" and the right part is in Queue. This is done by "Right Cycle start" setting a Register. I have everything working well, Gcode rewind etc. BUT I cannot figure out a way to Automate the G54 to G55 swap back and forth. I have tried from PLC script with mc.mcCntlGcodeExecute and ExecuteWait and MDIexecute. Nothing seems to take. I also have used mc.mcCntlCycleStop before trying to execute the offset change. I really want to do it Outside of the Gcode file, because then I can run 2 right parts in row/ 4 left parts in a row, the gcode stays the same. IF anyone has some advice about changing fixture offsets "automated" that would be very helpful.

Thanks
Re: G54 to G55 Script in PLC not working
« Reply #1 on: August 12, 2024, 04:13:20 PM »
Anyone got anything?
Re: G54 to G55 Script in PLC not working
« Reply #2 on: August 14, 2024, 08:52:09 AM »
You haven't really explained how you want to do this.  What do you mean by you want to automate the work offset change?
You can press the buttons on the offset tab.  There are 6 buttons on that screen to change from G54-G59.
If these buttons won't suffice, give us more detail on what you want to accomplish. 

It sounds like you're machining either the right or left side of the same part?  You're clamping either the right side or left side.
So G54 machines one side with the opposite side of the part clamped and then G55 is the same but in reverse?
You have the same exact code you use to run either setup, the only thing that changes is the work offset?
If that is the case, use the buttons I have mentioned above.
« Last Edit: August 14, 2024, 08:56:57 AM by Cbyrdtopper »
Chad Byrd
Re: G54 to G55 Script in PLC not working
« Reply #3 on: August 14, 2024, 04:31:25 PM »
Hey, So The machine has 2 "work zones" right(G54) and left(G55). While the machine is running in "Right Zone" The operator can clamp the work piece in "Left Zone" and press the "left" cycle start. This changes a register value (RegLeftPartQueued) to 1. Once the Gcode file is finished on the "Right Zone" and that RegLeftPartQueued is 1. The PLC script is supposed to change the Fixture offset to left zone (G55) and rewind the G code and cycle start is done automatically since the RegLeftPartQueue was 1. The machine automatically comes over and starts the left(G55 side), no operator input to change fixture offset.

While the machine is Running in the left zone (G55) the operator can clamp the part into the right fixture and press the "right" cycle start button queuing the part. then it works the same way just changing the new offset to G54 when it comes to right side.

I have all the Registers, Left and Right cycle starts working with the PLC script. But changing the offset from the PLC script does not work. As posted in first post I tried all the mc.mc*********x commands i could think of that seemed like they should work. We dont want the operator to have to manual press the G54/G55 buttons that exist. If you have a left and right cycle start button it should be able to make an automatic fixture change.  The problem with doing it from Left/Right cycle start buttons is that their actually a Queueing button. You cant change to G55 while G54 is still running.
Re: G54 to G55 Script in PLC not working
« Reply #4 on: August 14, 2024, 05:12:10 PM »
Run the logic through a macro and just run the macro at the beginning of your program.  If the program is exactly the same, you're just changing the work offset, this should work.

Here is a sample using the state of the coolant output so I could test it.  Just change your logic to use the registers you have set up.

--Change Work Offset Based on Value
function m109()
local inst = mc.mcGetInstance()
local Coolant = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON)
local CoolState = mc.mcSignalGetState(Coolant)
if CoolState == 1 then
    mc.mcCntlGcodeExecuteWait(inst, "G55")
else
    mc.mcCntlGcodeExecuteWait(inst, "G56")
end

end--m109()

if (mc.mcInEditor() == 1) then
   m109()
end


Just put this at the beginning of your code.  Name it whatever you want I guess.  I just had m109 as the next mcode to test with.

Do your cycle start buttons actually cycle start the G Code?
If they hit the wrong cycle start button, will it crash into a clamp?  Just curious. 
« Last Edit: August 14, 2024, 05:14:08 PM by Cbyrdtopper »
Chad Byrd