Hello Guest it is April 28, 2024, 06:10:03 PM

Author Topic: remember coordinates when Mach4 shuts down  (Read 491 times)

0 Members and 1 Guest are viewing this topic.

remember coordinates when Mach4 shuts down
« on: April 06, 2022, 12:16:38 PM »
Hi

I'm new to Mach4 and have a quick question

Is it possible for Mach4 to remember and record the last machine coordinates on shutting down?

Once restarted it could then input the last recorded X,Y and Z positions.

Is it possible to write code for this to happen?

Cheers

Frank
Re: remember coordinates when Mach4 shuts down
« Reply #1 on: April 07, 2022, 06:39:07 PM »
Hi,
this post should be on the Mach4 General Discussion Board, no doubt Tweakie will shift it there in due course.

Quote
Is it possible for Mach4 to remember and record the last machine coordinates on shutting down?

Yes it can. Couple of different ways.

One idea is to put some Lua code into the Screen Unload script, this script runs at shut-down. You can record machine coordinattes, or any other values in the .ini file usig:

Code: [Select]
LUA Syntax:
int mcProfileWriteInt(
number mInst,
string section,
string key,
number val)

Description:
Write a long value to the profile's INI file.

and similar APIs.

At start-up you can read those values back into Mach from the .ini file using:

Code: [Select]
LUA Syntax:
retval, rc = mc.mcProfileGetInt(
number mInst,
string section,
string key,
number defval)

Description:
Read a long value from the profile's INI file.


Another alternative is to establish some  instance registers using the Register plugin, and make those registers persistent. Then at shut-down (Screen Unload script)
you would update the registers with the current machine coordinates. After start-up the registers would be repopulated with the values that had been recorded at the
previous shut-down.

The question is what are you going to do with them?. You cannot program the machine coordinates of Mach at will, not with Mach3 nor with Mach4.
If you quote this:

Code: [Select]
LUA Syntax:
rc = mc.mcAxisSetMachinePos(
number mInst,
number axis,
number val)

Description:

I will tell you....try it! It DOES NOT set the machine coordinates.

The ONLY way you can set the machine coordinates is by use of referencing, also called homing, and intelligent use of HomeOffset parameter.

You are trying to do as many have tried before, and failed, myself included. There is only one way to set machine coorinates and that is by Homing at the start
of each and every session. If you have good home switches you could get to well under 0.01mm repeatability....I do. I can shut down Mach,
come back the next day, re-power, Home, and then go to the WorkZero established by the G54 of the last session within next to nothing.

Craig

'I enjoy sex at 73.....I live at 71 so its not too far to walk.'