build 3841, pmdx411, gecko g540, lathe
I just finished installing a stepper to use my lathe spindle as an indexer and it works great. I would like to be able to home this. I have a single slot timing signal on the slot for rpm when using the spindle normally but thought I should be able to use it to home when the stepper is in use. The following code actually stops at the same place each time but the pmdx411 sometimes throws off an error message 'can't transition from MDI RUNNIG to STOP'. When I don't get that message the C axis dro gets set to zero but the machine position doesn't get set to zero and the led doesn't turn green.
First, is my approach logical/correct?
Second, can you spot any errors in the calls or signals
Third, is there another approach that doesn't include adding more sensors or wiring?
local function myhome()
local inst=mc.mcGetInstance()
local rc,sState
local hSig,rc=mc.mcSignalGetHandle(inst,mc.ISIG_INDEX)
if rc==mc.MERROR_SIGNAL_NOT_FOUND then
wx.wxMessageBox('wrong Signal')
end
sState=mc.mcSignalGetState(hSig)
mc.mcCntlMdiExecute(inst,'g1 h366 f5000')
while mc.mcSignalGetState(hSig)==1 do
wx.wxMilliSleep(25)
end
mc.mcCntlCycleStop(inst)
wx.wxMilliSleep(500)
mc.mcAxisSetPos(inst,mc.C_AXIS,0.0)
mc.mcAxisSetMachinePos(inst,mc.C_AXIS,0.0)
hSig,rc=mc.mcSignalGetHandle(inst,mc.ISIG_MOTOR3_HOME)
mc.mcSignalSetState(hSig,1)
end
myhome()
TIA
RT