Hello Guest it is December 14, 2019, 01:49:38 PM

Author Topic: Mach4 loses Machine Coordinates every time you start the Mach4 system?  (Read 1126 times)

0 Members and 1 Guest are viewing this topic.

Offline Mauri

*
  •  306 306
    • View Profile
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

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Theres always time for a choccy biccy

Offline Mauri

*
  •  306 306
    • View Profile
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.

Offline Mauri

*
  •  306 306
    • View Profile
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.