Hello Guest it is March 28, 2024, 06:53:28 PM

Author Topic: Switch to Another Work Offset When the G-Code is Loaded in Mach3  (Read 5048 times)

0 Members and 1 Guest are viewing this topic.

Offline kvid

*
  •  25 25
    • View Profile
Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #10 on: November 29, 2017, 11:25:43 AM »
Wow, that is so simple. It is a brilliant solution.

Would you mind sharing the code?

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #11 on: November 29, 2017, 11:39:11 AM »
Zero the axis first, then run this code.


Code: [Select]

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)
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #12 on: November 29, 2017, 11:56:37 AM »
saved for later ^

Offline Tweakie.CNC

*
  • *
  •  9,196 9,196
  • Super Kitty
    • View Profile
Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #13 on: November 30, 2017, 03:53:09 AM »
Quote
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.

PEACE

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #14 on: November 30, 2017, 06:28:26 AM »
Why would M30 change the offset?
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline Tweakie.CNC

*
  • *
  •  9,196 9,196
  • Super Kitty
    • View Profile
Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #15 on: November 30, 2017, 09:21:52 AM »
Quote
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.

PEACE