Hello Guest it is December 06, 2019, 05:35:39 PM

Author Topic: Work offset not remembered  (Read 221 times)

0 Members and 1 Guest are viewing this topic.

Offline geast

*
  •  46 46
    • View Profile
Work offset not remembered
« on: July 04, 2019, 02:36:00 AM »
Hello.
I notice that when i work to a work offset, like G56, or whatever except G54, and shut down normally the Mach3, when i startup again the work offset is always G54. In general config everything is checked as persist. Is there a way to accomplish that the last working work offset will be remembered, and when i startup the mach3 it will be in G57 for example and that i don't have to switch to this work offset every time i startup?
Any help will be appreciated.
Re: Work offset not remembered
« Reply #1 on: July 04, 2019, 08:48:57 AM »
Hi,
when you shut Mach3  down all G54,G55, G56 etc should be saved so you can use them in the next Mach session.

Have you noticed the string of Gcodes at the top right of the screen. These are the initialization codes that run when Mach
is started up. Note the G54 in the string....that's why Mach always starts with the G54 work offsets. I'm not sure whether you can
change it. There is however the possibility to add others by using the 'Initialisation String' field of Config/General Config....
Thus you could overwrite the current G54 with a G55 say.

Craig
My wife left with my best friend...
     and I miss him!

Offline geast

*
  •  46 46
    • View Profile
Re: Work offset not remembered
« Reply #2 on: July 04, 2019, 08:53:23 AM »
Thank you for the reply.
Yes i have noticed this string and i was also wondering from where it comes from, so i can change it.
Any way, yes if i would always use for example the G55 , this would be a solution, but i want to use whatever work offset i was working before i shut down my machine.
Re: Work offset not remembered
« Reply #3 on: July 04, 2019, 08:57:44 AM »
Hi,
I'm not sure how you would go about that in Mach3.

I changed to Mach4 about three years ago. I could make a pretty fair stab at how to go about coding that sort behavior
in Mach4 but really I can't be bothered with coding in VB with Mach3....its just to buggy.

Craig
My wife left with my best friend...
     and I miss him!

Offline ger21

*
  • *
  •  6,289 6,289
    • View Profile
    • The CNC Woodworker
Re: Work offset not remembered
« Reply #4 on: July 04, 2019, 10:10:45 AM »
Try removing the G54 from the initialization string, and enabling "Persistent Offsets".

Well, I tried it, and it doesn't work.

Your best bet is to have the offset in your g-code, but you probably need to be in the offset before the g-code is loaded?
« Last Edit: July 04, 2019, 10:14:33 AM by ger21 »
Gerry

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

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

Offline TPS

*
  •  1,415 1,415
    • View Profile
Re: Work offset not remembered
« Reply #5 on: July 04, 2019, 01:32:30 PM »
ok with a Little trick

create a button on your Screen witch has the "Name" shutdown Mach or something like this.

this is the code for the button:
Code: [Select]
Sub Main()
'save the actual workoffset
Open "C:\Mach3\ActOffset.txt" For Output As #1 ' Open to write file.
'get the actual offset
wo = GetOEMDro(46)+53
Write #1, wo
Close #1

'shut down Mach3
SendKeys "%+{F4}"
End Sub

create a macro in C:\Mach3\macros\your Profile Name    for example M889.M1S

this would be the code for the macro:
Code: [Select]
Sub Main()
'read last workoffset
Open "C:\Mach3\ActOffset.txt" for Input As #2 ' Open to read file.
Line Input #2, FileData ' Read a line of data.
Close #2
' make sure that we only restore the WO once
If FileData <> "999" Then
Code "G"&FileData
End if

'clear the WO data
Open "C:\Mach3\ActOffset.txt" For Output As #1 ' Open to write file.
Write #1, 999
Close #1

End Sub

then add the M889 to your initialization string

now after restart and pressing the reset button the last workoffset should be restored
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline geast

*
  •  46 46
    • View Profile
Re: Work offset not remembered
« Reply #6 on: July 04, 2019, 04:09:31 PM »
Thanks a lot for the answer.
It would be perfect if all this could be done in the background without the use of a button. By the time of shutdown the work offsets are saved and also there is a popup window asking you if you want to save them. It would be great if in this function the last work offset would be saved by your "button routine", somehow.
Anyway i will try this its a good approach anyway.
Re: Work offset not remembered
« Reply #7 on: July 04, 2019, 10:18:40 PM »
Hi,
Mach4 has an 'unload script' which runs when the machine shuts down. It would be a simple matter to include some code  record the current  work coordinate
set in the .ini file. When Mach4 is restarted the screenload script runs but immediately thereafter the PLC script runs. The firs run through
of the PLC script is the ideal place to put the code to read the .ini file and repopulate the work coordinate offset from the previous session.

Mach4 has a structure which allows this sort of flexibility and is a major reason that more and more users are migrating to it.

Craig
My wife left with my best friend...
     and I miss him!

Offline ger21

*
  • *
  •  6,289 6,289
    • View Profile
    • The CNC Woodworker
Re: Work offset not remembered
« Reply #8 on: July 04, 2019, 11:53:14 PM »
Quote
It would be perfect if all this could be done in the background without the use of a button.

I think the main issue here is that all development of Mach3 stopped about 6 years ago.
It seems like "Persistent Offsets" should do what you want. Either it's a bug, or it does something else that I'm not aware of.
Gerry

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

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

Offline TPS

*
  •  1,415 1,415
    • View Profile
Re: Work offset not remembered
« Reply #9 on: July 05, 2019, 02:15:47 AM »
you can put the following code into macropump, then the Offset will be saved every 60 seconds.

just make sure OEMDRO(1300) is not used

Code: [Select]
Const LastMsDRO = 1300 'DRO for data
Dim LastMs As Long

LastMs = GetUserDRO(LastMsDRO)
If LastMs > 6000 Then
LastMs = 0
'save the actual workoffset
Open "C:\Mach3\ActOffset.txt" For Output As #1 ' Open to write file.
'get the actual offset
wo = GetOEMDro(46)+53
Write #1, wo
Close #1
End If
LastMs = LastMs + 10
'save data
SetUserDRO(LastMsDRO,LastMs)
anything is possible, just try it.
if you find some mistakes, in my bad bavarian english,they are yours.