Hello Guest it is May 14, 2021, 02:35:44 AM

Author Topic: The Reason why Mach4 loses Machine Coordinates at start the Mach4 system  (Read 1719 times)

0 Members and 1 Guest are viewing this topic.

Offline Mauri

  •  327 327
    • View Profile
"Smurph" Put me on the right direction with "Mach4 loses Machine Coordinates at start the Mach4 system" and said that the Plugin art startup has ZERO values on the Machine Coordinates.
But hang on I thought I was using the Simulator to try my Lua DRO changes.
So I looked at the Sim Configuration settings and there it was (All ZERO).
The reason that Mach4 Current Positions and Machine Coordinates are not restored at the restart of Mach4 is the Simulator Configuration Settings for Machine Coordinates are set to ZERO.
This Sim is trying to say it is using an encoder startup.

Let’s say we have “Homed” our Mill and have moved the Table and Head to the Current Positions on the DRO’s.
X = -175
Y = -75
Z = -80

Now if you look at the "Machine Coordinates" they will show all ZERO.
Now let’s ZERO the DRO’s on the "Current Position" and you will see that the "Machine Coordinates" now show:
X = 175
Y = 75
Z = -80

Now close down Mach4 and restart.
On Machine Coordinates you get:
X = 0
Y = 0
Z = 0

This is because of the Sim Configuration all having ZERO it is trying to simulate an encoder system.
Sim Configuration under Configure/Plugin
Motor 0 encoder startup value:  0.0000
Motor 1 encoder startup value:  0.0000
Motor 2 encoder startup value:  0.0000
At Mach Start-up uses the values (or the same if you have a Plugin startup) and sets the "Machine Coordinate" DRO’s to ZERO and recalculates the Current Positions DRO’s to compensate.

To show that this theory is correct I did the following:
You Multiple the X= 175 x Motor0 Counts Per Unit (800.6886)
You Multiple the X= 75 x Motor1 Counts Per Unit (800.2562)
You Multiple the X= -80 x Motor2 Counts Per Unit (800.0000)
You use the calculated numbers that are required in the Sim Configuration.
Motor 0 encoder startup value:  140120.5000
Motor 1 encoder startup value:  60019.2200
Motor 2 encoder startup value:  -64000.0000

Close Mach4 and Re-start you will get in the Machine Coordinates the following:
X = 175
Y =75
Z = -80

So this solves the Simulator issue, however the same problem exits with the other Plug in’s if you are using Stepper Motors on your machine.
They may also be set all to ZERO so that causes the problem with "Machine Coordinates" at Mach4 Start-up, mine must be set at ZERO.
Now we need some fix by the Plugin manufactures as not all users have encoded motors.


Offline DazTheGas

  •  753 753
  • DazTheGas
    • View Profile
I dont think mach4 loses them, more like when starting up it doesnt know where it is until homed.

Something you can try though is create a button and as a test put

Code: [Select]
local inst = mc.mcGetInstance()
mc.mcMotorSetHomePos(inst, 0, 175 * mc.mcProfileGetDouble(inst, 'Motor0','CountsPerUnit',0)) --X

jog x to 175 and shut down mach4 and restart, press button you should find your machine coords now at 175, however I cannot tell you how this will look on your system with say softlimits or offsets but worth atry.

Theres always time for a choccy biccy

Offline Mauri

  •  327 327
    • View Profile
You may have something that will work.
I will test it on the machine and controller later.
Seems to work without the controller on.
That code does enable me to restore the Machine Coordinates with a button after startup and makes them the same as when I closed down Mach4.
The HiCON vendor said they will try to fix this issue in the next release of their Plugin.

Offline Mauri

  •  327 327
    • View Profile
The theory was good but it did not work in practice.
The Button program works a treat in Simulation or with the Controller OFF.
My Button is run prior to shutdown, this stores the Machine Coordinates in the Registry in both the #variable 5021/5022/5023 and the HiCON Encoder0/1/2.
At restart of Mach4 you also run the button does read of data does its calculation and if the controller of OFF it works and all setting are correct.
When you try for real with the Controller on it does not, the Controller changes the Machine Coordinates back to ZERO.
So the only way it will be fixed is when HiCON change the Plugin to pickup the values at startup.
I presume that all Controller manufacturers will have the same issue if user have Stepper Motors with out encoders.
So when this is fixed it will not only restore the Machine Coordinates in Mach4 but also enable Soft Limits to operate correctly without having to rehome the machine.