Hello Guest it is March 28, 2024, 11:43:15 AM

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

0 Members and 1 Guest are viewing this topic.

Offline kvid

*
  •  25 25
    • View Profile
Switch to Another Work Offset When the G-Code is Loaded in Mach3
« 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?

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 #1 on: November 29, 2017, 02:24:22 AM »
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.
PEACE
Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #2 on: November 29, 2017, 05:51:26 AM »
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.

Offline kvid

*
  •  25 25
    • View Profile
Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #3 on: November 29, 2017, 05:55:28 AM »
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?

Offline kvid

*
  •  25 25
    • View Profile
Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #4 on: November 29, 2017, 05:58:52 AM »
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.

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 #5 on: November 29, 2017, 06:53:29 AM »
Quote
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.
PEACE

Offline kvid

*
  •  25 25
    • View Profile
Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #6 on: November 29, 2017, 08:00:02 AM »
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.

Offline RICH

*
  • *
  •  7,427 7,427
    • View Profile
Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #7 on: November 29, 2017, 08:09:57 AM »
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
« Last Edit: November 29, 2017, 08:13:15 AM by RICH »

Offline kvid

*
  •  25 25
    • View Profile
Re: Switch to Another Work Offset When the G-Code is Loaded in Mach3
« Reply #8 on: November 29, 2017, 09:10:40 AM »
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.

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 #9 on: November 29, 2017, 10:57:35 AM »
I have my auto zero routine zero all of the offsets, so it doesn't matter which one is current.
Gerry

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

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