Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Mauri on March 29, 2017, 03:41:23 PM

Title: Mach4 loses Machine Coordinates every time you start the Mach4 system?
Post by: Mauri on March 29, 2017, 03:41:23 PM
Hi,
Sequence of events.
Mach4 and Controller are started.
Mill is homed.
DRO's are Zeroed.
Mill is move at the Center of X/Y of Table.
This shows Machine Coordinated Table position exactly correct.
When are shut down Mach4 and Controller are restarted.
Now the Current Position DROs shows the machine position values, but the Machine Coordinated DROs are now Zero requiring to rehome the machine every time?

This code is in the Load Screen Script.
What does it do?
It does not appear to store anything in the machine.ini file or the registry at least the one under Diagnostics.
Should the Machine Coordinates be saved each time Mach4 closes down and then be recalled with the code below at startup showing the Machine Coordinates current position?
Please advise.
Regards,
Mauri.
---------------------------------------------------------------
-- Remember Position function.
---------------------------------------------------------------
function RememberPosition()
    local pos = mc.mcAxisGetMachinePos(inst, 0) -- Get current X (0) Machine Coordinates
    mc.mcProfileWriteString(inst, "RememberPos", "X", string.format (pos)) --Create a register and write the machine coordinates to it
    local pos = mc.mcAxisGetMachinePos(inst, 1) -- Get current Y (1) Machine Coordinates
    mc.mcProfileWriteString(inst, "RememberPos", "Y", string.format (pos)) --Create a register and write the machine coordinates to it
    local pos = mc.mcAxisGetMachinePos(inst, 2) -- Get current Z (2) Machine Coordinates
    mc.mcProfileWriteString(inst, "RememberPos", "Z", string.format (pos)) --Create a register and write the machine coordinates to it
end

---------------------------------------------------------------
-- Return to Position function.
---------------------------------------------------------------
function ReturnToPosition()
    local xval = mc.mcProfileGetString(inst, "RememberPos", "X", "NotFound") -- Get the register Value
    local yval = mc.mcProfileGetString(inst, "RememberPos", "Y", "NotFound") -- Get the register Value
    local zval = mc.mcProfileGetString(inst, "RememberPos", "Z", "NotFound") -- Get the register Value
   
    if(xval == "NotFound")then -- check to see if the register is found
        wx.wxMessageBox('Register xval does not exist.\nYou must remember a postion before you can return to it.'); -- If the register does not exist tell us in a message box
    elseif (yval == "NotFound")then -- check to see if the register is found
        wx.wxMessageBox('Register yval does not exist.\nYou must remember a postion before you can return to it.'); -- If the register does not exist tell us in a message box
    elseif (zval == "NotFound")then -- check to see if the register is found
        wx.wxMessageBox('Register zval does not exist.\nYou must remember a postion before you can return to it.'); -- If the register does not exist tell us in a message box
    else
        mc.mcCntlMdiExecute(inst, "G00 G53 Z0.0000 \n G00 G53 X" .. xval .. "\n G00 G53 Y" .. yval .. "\n G00 G53 Z" .. zval)
    end
end
Title: Re: Mach4 loses Machine Coordinates every time you start the Mach4 system?
Post by: DazTheGas on March 29, 2017, 03:56:03 PM
This might help http://www.machsupport.com/forum/index.php/topic,34141.0.html

DazTheGas
Title: Re: Mach4 loses Machine Coordinates every time you start the Mach4 system?
Post by: Mauri on March 29, 2017, 06:27:58 PM
Daz,
Thanks for your reply, I have read that topic.
If your Machine Location for example is:
X = +175
Y = +75
And your Current Position is:
X = 0
Y = 0
You then Exit Mach4 and say yes.
Then reload Mach4
The Machine location is:
X = 0
Y = 0
And your Current Position is:
X = -175
Y = -75
Now you do not want to move the Mill Table as this is where you want to do the next cut on the same part with a different same cutter (but this is the next day).
We would do this process over 5 days (with some cuts taking 16 hours) and we switch off after each days process.
Now the machine location is not correct to the Mill Table location.
If you ZERO your current Position then all is positions on the DRO's become ZERO.

Do those functions in the Startup Script need to be activated with some button or script?
The Button names to activate the Functions seem to be different "Position Remember" and "Position Return" and seem to do nothing?

I can write my own script to save the Machine Coordinates to the machine.ini file at shutdown and then read them at startup and rewrite the Current Position and Machine Coordinates Position if there is no other way.

We can home the Mill and it will go to the same place within .001 of a mm on the DRO's, we also have reasonably accurate ball screws, but do not want to Home and reset our job every time we want to do another cutting process the following day.

I still have now answer on what the Function actually do and how they are activated.

Regards,
Mauri.
Title: Re: Mach4 loses Machine Coordinates every time you start the Mach4 system?
Post by: Mauri on March 29, 2017, 10:02:07 PM
Hi,
I have scripted some Lua to make changes to the DRO's simulating "first start up" change for the "Machine Coordinates" X/Y/Z with the saved values of the saved Mach4 last Mill Table position as well as trying to Zero the DRO's "Current Position" X/Y/Z, however the values change and then revert back?
Any idea.
Regards,
Mauri.