Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: kvid on November 28, 2017, 06:58:57 PM
-
When I open Mach3 it is in G54 WCS (Work Coordinate System) by default. I have fixtures on G55, G56, G57... Let's say I have a specfic program that is on G55. When I load the program Mach3 is still on G54 until I start the program. Before I run the program I have to zero the Z axis but because Mach3 is on G54 I always have to switch manually to G55 before I can zero the Z axis.
Is there any way for Mach3 to recognize which WCS the program is using when I load it so I can zero the Z axis in that WCS before the program starts?
-
There is always more than one way but my approach would be to add additional instructions to my Touch Probe routine.
After a Gcode has been loaded DRO(46) contains the Current Fixture Number and DRO(47) to DRO(52) the part offsets.
If your Touch Probe script reads the appropriate DRO it can take the appropriate action.
-
If you just want a quick fix for now until you decide to cancel it, just put a "G55" in your startup routine in general settings. Delete it when you want to stop doing this.
-
GetOEMDRO(46) returs number of the fixture that is currently active. I am not sure how is that helpful.
I could put WCS of the fixture manually at the beginning of each G-Code or modify the postprocessor to do it at line 0 and then I could edit my Auto Tool Zero script that it would first read line 0 of the currently loaded G-Code and switch to the WCS that is written in that line.
Is there a way to read lines of the currently loaded G-Code?
-
If you just want a quick fix for now until you decide to cancel it, just put a "G55" in your startup routine in general settings. Delete it when you want to stop doing this.
I have fixtures on G55. G56, G57... so that wouldn't achieve what I want.
-
GetOEMDRO(46) returs number of the fixture that is currently active. I am not sure how is that helpful.
Modify your Auto Tool script to read DRO(46).
Once you have loaded your Gcode file DRO(46) will contain your Fixture number as defined in the Gcode file.
You can also read your current Tool Offsets from the other DRO’s
How you deal with that information within your Auto Tool script will depend on what you wish to achieve.
-
Once you have loaded your Gcode file DRO(46) will contain your Fixture number as defined in the Gcode file.
When I load G-Code DRO(46) contains G54 until I click Cycle Start and then Mach3 sets it to whatever work offset is in that G-Code. I run Auto Tool Zero script before I click Cycle Start.
-
The program should provide for program comments and "safety" coding so that the machine state is correct to run the program.
(Sample Program G01EX2:)
( PROGRAM USES G55 Work Offset) COMMENT
(Workpiece Size: X4, Y3, Z1)
(Tool: Tool #3, 3/8" Slot Drill)
(Tool Start Position: X0, Y0, Z1)
N10 G90 G80 G40 G55 G20 G17 G50 G94 G64 (safety block)
RICH
-
That is exactly how I am dealing with it now Rich.
1. I load a G-Code
2. I go to Offsets and activate whatever work offset is in the code's comment,
3. I zero the tool with Auto Tool Zero macro
4. I press Cycle start.
I am trying to eliminate the second step.
-
I have my auto zero routine zero all of the offsets, so it doesn't matter which one is current.
-
Wow, that is so simple. It is a brilliant solution.
Would you mind sharing the code?
-
Zero the axis first, then run this code.
CurrentOffset = GetOEMDRO(46) ' Get Current Coordinate system 1 = G54, 2 = G55, ....
If CurrentOffset = 1 Then
ZOffset=GetVar(5223)
ElseIf CurrentOffset = 2 Then
ZOffset=GetVar(5243)
ElseIf CurrentOffset = 3 Then
ZOffset=GetVar(5263)
ElseIf CurrentOffset = 4 Then
ZOffset=GetVar(5283)
ElseIf CurrentOffset = 5 Then
ZOffset=GetVar(5303)
ElseIf CurrentOffset = 6 Then
ZOffset=GetVar(5323)
End If
For X = 5223 To 5323 Step 20
SetVar(X, ZOffset)
Next X
Sleep(250)
-
saved for later ^
-
When I load G-Code DRO(46) contains G54 until I click Cycle Start and then Mach3 sets it to whatever work offset is in that G-Code. I run Auto Tool Zero script before I click Cycle Start.
It probably depends on which version of Mach3 you are running, however...
If your Gcode finishes with an M30 then the Offset and DRO(46) will be reset to G54 after the Gcode has been loaded (as you have discovered). Deleting the M30 from the Gcode will allow the DRO(46) to display the correct Gcode Offset for that particular file.
-
Why would M30 change the offset?
-
Why would M30 change the offset?
Probably a question for Brian.
Try it and see...
As the Gcode loads and is read DRO(46) changes to the current offset then when the M30 is detected it reverts back to G54 - it will change to the current offset as soon as the Gcode is run (as discovered by Kvid).
But, as said, I am not certain this applies to all versions of Mach3.