Hello Guest it is April 18, 2024, 11:37:21 PM

Author Topic: Mach 4 macro for setting current fixture offset to zero?  (Read 3442 times)

0 Members and 1 Guest are viewing this topic.

Mach 4 macro for setting current fixture offset to zero?
« on: April 30, 2018, 10:45:13 AM »
I'm making a macro for probing the work piece. I put a probe block on the work piece or table top, and lowers the spindle until getting contact with the block. When contact I want to set the current fixture offset to zero. However I cannot find a way to read out which is the current active offset, and write to this same offsets Z-position.

This could be the same functionality that is in the Zero z button on mach4 mill screen, but I don't fin what is behind that button. Any Ideas on which pound variables to write to or other ways to solve it?
Re: Mach 4 macro for setting current fixture offset to zero?
« Reply #1 on: April 30, 2018, 02:21:05 PM »
Current work offsets can be read from the VARS #4014.   You can test this yourself, set your #Range to include #4014 from the registers and changed the Work Offset from the Offsets tab.  You can watch it change.

Read the #VARS in lua with the following command.

local CurrentOffset = mc.mcCntlGetPoundVar(inst, 4014)

Here is a link to the Mach4 Toolbox discussion on #VARS List.  The first post has a list and the 4th post has an updated list.

http://www.machsupport.com/forum/index.php/topic,27396.0.html
« Last Edit: April 30, 2018, 02:22:40 PM by Cbyrdtopper »
Chad Byrd
Re: Mach 4 macro for setting current fixture offset to zero?
« Reply #2 on: April 30, 2018, 03:55:54 PM »
Thanks. That helps me read which fixture offset is active. However, I still need to write to the Z entry in the fixture table to write the new Z position. Any input on that would be great.
Re: Mach 4 macro for setting current fixture offset to zero?
« Reply #3 on: April 30, 2018, 04:10:05 PM »
Hey Jorgenbli,
I can't find the VAR to change the Z Position.  There are registers to get the current Z and Machine Coordinate Z.  When I try to write to them they don't change/update anything.  

There is a command to change the Z Axis DRO position.    This does update the VARS relating to Current Z Position.

mc.mcAxisSetPos(inst, 2, 5.5) --(inst, Axis#, New Position)

Or make it update to a variable.

local NewZPos = 5.5
mc.mcAxisSetPos(inst, 2, NewZPos)
Chad Byrd
Re: Mach 4 macro for setting current fixture offset to zero?
« Reply #4 on: May 01, 2018, 06:43:20 AM »
Hmm,
But there must be some way to update the z-position of the various fixture offsets, or at least current fixture offset, similarly to what happens when you hit the Zero Z button. How can I find out the code behind this button?
Re: Mach 4 macro for setting current fixture offset to zero?
« Reply #5 on: May 01, 2018, 08:10:33 AM »
You can look in the screen editor.  But the Zero Buttons don't have code, it is a drop down option on these particular buttons. 
Chad Byrd
Re: Mach 4 macro for setting current fixture offset to zero?
« Reply #6 on: May 01, 2018, 02:33:55 PM »
Are some of the mach4 developers reading on this forum, or should I contact them elsewhere? There needs to be a way to solve this to make a proper fixture zero script. Or are there other ways to solve this?
Re: Mach 4 macro for setting current fixture offset to zero?
« Reply #7 on: May 01, 2018, 02:48:36 PM »
I'm curious,
If you are probing, why would you want to know what fixture offset is on.  Wouldn't that be something you initiate before you start your probing cycle?  Or are you going to probe mulitple fixtures at once?

The code I gave you , mc.mcAxisSetPos(inst, 2, 5.5) --(inst, Axis#, New Position)   changes the position of the current fixture offset and you can change the Z Position to 0 with this code and it will update the Work Offset.  You can watch it update in the

Diagnostics Tab.


To answer your most recent question; some of the developers do read through the forum, and you can start a ticket with Artsoft.  If you choose to go that route, be sure to come back here and post a solution to your problem that way everyone can learn

from your post.
Chad Byrd
Re: Mach 4 macro for setting current fixture offset to zero?
« Reply #8 on: May 01, 2018, 07:10:59 PM »
No need to go that route.. :-) I'm sorry I didn't read your first answer properly - you actually gave the solution to my problem. No I'dont really need to know which offset is active, I just needed to update the active offset - and your code certainly works like a charm for that! Thank you so much for your help Cbyrdtopper.
Re: Mach 4 macro for setting current fixture offset to zero?
« Reply #9 on: May 01, 2018, 07:15:07 PM »
No problem.  Glad you got it working!
Chad Byrd