Hello Guest it is March 28, 2024, 06:05:41 PM

Author Topic: Shift Z-axis workshift with scale on knee  (Read 697 times)

0 Members and 1 Guest are viewing this topic.

Shift Z-axis workshift with scale on knee
« on: November 01, 2021, 03:46:54 PM »
Hello,

I have a three axis knee mill retrofitted with Mach4.  The Z-axis is on the quill and has only 5" of travel.

What I would like to do is use the scale that is on the knee (already interfaced to the DSPMC) to update the work shift when it is moved that way as the table is moved up and down the work offsets are still relevent.

The scale is interfaced to scale 6 of the DSPMC, what would be the most robust way to have it update the workshift when moved?

Offline thosj

*
  •  532 532
    • View Profile
Re: Shift Z-axis workshift with scale on knee
« Reply #1 on: November 01, 2021, 05:28:10 PM »
I can't visualize what you're trying to do. Do you intend to move the knee to compensate for tool length difference or something else? I can't think of any other reason to move the knee and change the Z work offset.

You could make a screen button with code to read the knee scale position and put the number in the Z work offset, but I'm having trouble seeing why you'd do that. If you're really trying to use the knee to offset TOOL length, you really need to manually move the knee the difference between, say, tool 1 and tool 2, and leave the work offset the same.

I have a knee mill also, but I've CNC'd the knee and use it, along with code and post processor changes, to compensate for tool length.

If your goal is something else, let us know and someone will have a tip or two!!

Tom
--
Tom
Re: Shift Z-axis workshift with scale on knee
« Reply #2 on: November 01, 2021, 06:22:24 PM »
With the Z-axis on the quill and only having 5" of travel I am limited to similar length tools, the difference in a facemill and drill can easily take up the entire travel of the Z-axis.  When I move the knee up or down to accommodate for the difference in tool lengths the calibration for the tool setter (mounted on the table) is no longer viable.

What I would like to do is to update the work offsets (using head shift or ext workoffset will shift all work offsets) automatically and in realtime as the table is moved up or down.  I suppose a script that reads encoder 6 (the knee scale), converts the position in pulses to either inch or metric and updates the ext work offset or another register of some sort.

This way as the table gets moved the work offset is updated automatically
Re: Shift Z-axis workshift with scale on knee
« Reply #3 on: November 06, 2021, 02:03:52 PM »
So I have the knee scale configured for the "C" axis (motor 5) Aux position.  I've created a DRO on the screen to display the C Aux position and it's reading properly.

What I need now and I am having an issue finding the right API calls is a script to do the following.

When C axis Aux position changes
     (read C aux position and write new position to Z head shift)

On screen load
     (read Z head shift and write position to C aux position)

Is Z head shift retained upon Mach4 restarts?  If not I would need to do this;

When C axis Aux position changes
     (read C aux position and write new position to Z head shift and also write to reg file)

On screen load
     (read reg file and write position to C aux position and also to Z head shift)

Can someone help me write this script?  Or at least get me close reading the aux position change and API calls to read/write aux position, head shift and reg file.

Offline Bill_O

*
  •  563 563
    • View Profile
Re: Shift Z-axis workshift with scale on knee
« Reply #4 on: November 08, 2021, 09:05:23 AM »
Most of the API calls are in the Mach4CoreAPI.
It is in the C:\Mach4 Hobby\ Docs folder.

This might also help.
https://www.machsupport.com/forum/index.php?topic=45397.0
Re: Shift Z-axis workshift with scale on knee
« Reply #5 on: November 08, 2021, 09:48:13 PM »
Thanks Bill,  I was able to get it working although I wasn't able to use the "Aux Position" function of Mach4 V2.  Instead I set up a dummy axis and used the API calls that are documented.

Unfortunately, with the release of V2 and all the updates it brings there doesn't seem to be much in the way of documentation, the Core API help file included in the installation seems to be from 2017, long before V2.

This is the code I added to the PLC script;
---------------------------------------------------------------
-- Check for Table move and update Table Position
---------------------------------------------------------------
local Cpos = mc.mcAxisGetMachinePos(inst, 5)
local ZheadShift = mc.mcCntlGetPoundVar(inst, mc.SV_HEAD_SHIFT_Z)
local TablePosReg = mc.mcRegGetHandle(inst, 'iRegs0/TablePosition')
local homedC=mc.mcAxisIsHomed(inst,mc.C_AXIS)

if  (homedC ~= 0) and (Cpos ~= ZheadShift) then
    mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Z, Cpos)
    mc.mcRegSetValue(TablePosReg, Cpos)
end
---------------------------------------------------------------
-- End of Check for Table move and update Table Position
---------------------------------------------------------------


And this code to the refAllHome() function in the screen load script;
---------------------------------------------------------------
-- Load Previous Table Position
---------------------------------------------------------------
local TablePosReg = mc.mcRegGetHandle(inst, 'iRegs0/TablePosition')
local TablePos = mc.mcRegGetValue(TablePosReg)
mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Z, TablePos)
mc.mcAxisSetHomeOffset(inst, 5, TablePos)
---------------------------------------------------------------
-- End of Load Previous Table Position
---------------------------------------------------------------