Hello Guest it is November 07, 2024, 06:08:07 AM

Author Topic: Mach4 Lathe  (Read 2952 times)

0 Members and 1 Guest are viewing this topic.

Mach4 Lathe
« on: March 08, 2021, 12:27:14 PM »
I have a lathe on mach4 control uses a Pokeys 57e and a cnc4pc m16 .The Lathe has a Tool changer is there a way to make the tool change counter read tool 0 offset 0 after I home the turret  ? If so how do I do this ? Thank you all .
Re: Mach4 Lathe
« Reply #1 on: March 08, 2021, 01:05:48 PM »
At the end of your homing script add:
rc = mc.mcToolSetCurrent(inst,0)
This will set the current tool to tool zero but it will not set the offset.  There is an api call to get the current offset but not one to set it :(

In theory you should be able to set the register for that which is supposed to be #2032 and the tool #2029 according to some docs that spell out the pound variables.  However the following code always shows zero for each entry and when you display the variables through the diagnostics menu those values don't change so I don't know what are the real registers currently.  build 4612.

local inst=mc.mcGetInstance()
local val
local rc = mc.mcToolSetCurrent(inst,2)   
val,rc=mc.mcCntlGetPoundVar(inst,2029)
val,rc=mc.mcCntlGetPoundVar(inst,2032)
rc = mc.mcToolSetCurrent(inst,0)
val,rc=mc.mcCntlGetPoundVar(inst,2029)
val,rc=mc.mcCntlGetPoundVar(inst,2032)

HTH

RT
Re: Mach4 Lathe
« Reply #2 on: March 08, 2021, 01:48:13 PM »
Found another doc with enum list, code should be:

local inst=mc.mcGetInstance()
rc=mc.mcCntlSetPoundVar(inst, mc.SV_CUR_TOOL_NUMBER,0)
rc=mc.mcCntlSetPoundVar(inst, mc.SV_CUR_LENGTH_INDEX,0)
Re: Mach4 Lathe
« Reply #3 on: March 09, 2021, 12:53:18 PM »
Where is the homing script located ? Thank you for your help .
Re: Mach4 Lathe
« Reply #4 on: March 12, 2021, 02:45:02 PM »
It's in the screen load script: RefAllHome()  which is called when you hit the Ref All Button.  If your not familiar with screen editing Brianna has a video in the section above.
Re: Mach4 Lathe
« Reply #5 on: March 16, 2021, 07:15:27 AM »
---------------------------------------------------------------
-- Ref All Home() function.
---------------------------------------------------------------
function RefAllHome()
    mc.mcAxisDerefAll(inst)  --Just to turn off all ref leds
    mc.mcAxisHomeAll(inst)
    coroutine.yield() --yield coroutine so we can do the following after motion stops
    ----See ref all home button and plc script for coroutine.create and coroutine.resume
   
   local hReg, rc = mc.mcRegGetHandle(inst, "iRegs0/CurrentSlot")
      rc = mc.mcRegSetValue(hReg, 0)
      mc.mcToolSetCurrent(inst, 0)
      wx.wxMilliSleep(2000)
    wx.wxMessageBox('Referencing is complete')
end





So I would insert it just before the End comment ?

GOOMBA

*
Re: Mach4 Lathe
« Reply #6 on: March 22, 2021, 01:46:50 PM »
---------------------------------------------------------------
-- Ref All Home() function.
---------------------------------------------------------------
function RefAllHome()
    mc.mcAxisDerefAll(inst)  --Just to turn off all ref leds
    mc.mcAxisHomeAll(inst)
    coroutine.yield() --yield coroutine so we can do the following after motion stops
    ----See ref all home button and plc script for coroutine.create and coroutine.resume
   
   local hReg, rc = mc.mcRegGetHandle(inst, "iRegs0/CurrentSlot")
      rc = mc.mcRegSetValue(hReg, 0)
      rc = mc.mcToolSetCurrent(inst, 0)
      rc=mc.mcCntlSetPoundVar(inst, mc.SV_CUR_LENGTH_INDEX,0)
      wx.wxMilliSleep(2000)
    wx.wxMessageBox('Referencing is complete')
end
That should work.
I think RH has the right way to do this as you can't call G43 H0 to set the offset.
Pound vars are nice :)
Let me know if that works Gabe.
Re: Mach4 Lathe
« Reply #7 on: April 12, 2021, 11:36:54 AM »
Your suggestions worked . Thank you guys .