Hello Guest it is May 22, 2024, 01:09:54 AM

Author Topic: mcAxisGetMachinePos is unreliable. How do I reliably get machine coordinates?  (Read 242 times)

0 Members and 1 Guest are viewing this topic.

In my tool changer script I need to make sure that the bottom of the spindle is above the top of the tool holders before moving to load a tool. I don't want to raise to machine coords z=0 (Z axis highest position) each time I change tools since it is 3.5" above the top of the tool holders, and this up and down movement wastes a lot of time. Most of the time this is not an issue since I will move to a safe height after dropping off a tool but there are a few situations where I manually unload the spindle and I want to ensure it's at a safe height. So I added some code to check, if it's below safe height, it should raise to a safe height.

so I use the following line to get the current position in machine coordinates:
Code: [Select]
local currentZ = mc.mcAxisGetMachinePos(inst, mc.Z_AXIS)
but about 75% of the time this call returns 0, while the dro (set to machine coords) displays a non zero number, and the dro is always correct. I can't read the DRO because most of the time it will be displaying work coords.

So is there a reliable way to read machine coordinates?

Offline Bill_O

*
  •  565 565
    • View Profile
I think all your tool change should be in machine coordinates.
I always put a g53 before movements in an atc.
Then just tell it where to go.
When the tool change is done I put a g54

GOOMBA

*
I agree with Bill, everything inside the TC should be in machine cords :)
I would just personally command the Z height to the correct height rather than doing a conditional.

Also at the beginning of your macro, do a machine state PUSH, then at the end do a machine state POP.
You have to activate the POP before you apply any TLO's or offsets of any nature.
Essentially it saves the state of the modals and tables and when you POP is puts them all back.
This way you don't have to worry about changing any modals or anything else within the macro, it'll all be set back to the way it was.
After the pop you can THEN change tool numbers, offsets etc.

To answer your original question, you could try checking the value of the pound var that holds the machine cord position for that axis.
The API.h is attached. You can find the var in there.