Hello Guest it is June 21, 2021, 01:27:58 PM

Author Topic: EMCO PCMill100 or VMC100 Toolchange Macro M6  (Read 415 times)

0 Members and 1 Guest are viewing this topic.

Offline SimonRafferty

  •  43 43
  • Movie SFX Design Engineer
    • View Profile
EMCO PCMill100 or VMC100 Toolchange Macro M6
« on: May 07, 2020, 04:21:06 AM »
The PCMill100, VMC and several other EMCO mills use the spindle to drive the toolchange turret.
After you Home Z, if you continue raizing Z, the tool disengages and after 90mm (on mine, check on yours!) the spindle engages with a bevel gear and then can turn the turret.

Originally, the machines use a hybrid Analog / Pulse+Direction drive for the spindle.  I couldn't get it to do either and suspect it needed the original PC to send it someting via RS485 to activate as well as setting the input pins.

With this example, you can drive it just using a simple VFD driving the original spindle motor.

There's a video of it operating here:

The turret has an index sensor, detecting magents set into the rear.  There is one for each tool, the rising edge of the sensor pulse coresponds to the tool being correctly located.  There is an extra magnet between tool 10 & 1.  This is used to determine the position of tool 1, just using a timer.

Initially the turret is turned and the max time between index pulses measured.  If a pulse comes along, with less than 75% of the max time - that must be the extra magnet - so the next pulse indicates tool 1.

Then it just counts up the number of pulses  / tools until the right one is reached.

There's not much on line about converting these machines.  Ping me a message if you need more info on my approach.  I'm using CSMIO/IP-M with Mach 4.

Code: [Select]
local inst = mc.mcGetInstance()
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)

package.path = path .. "\\Modules\\?.lua;" .. path .. "\\Profiles\\" ..  profile .. "\\Modules\\?.lua;"

function m6()
------ Toolchange Macro for EMCO PCMill 100 ------
--                                              --
-- Simon Rafferty May 2020                      --
--                                              --
-- This will allow you to control the spindle   --
-- with a simple VFD, rather than the hybrid    --
-- servo spindle (which I failed to reverse     --
-- Engineer).                                   --
-- Don't run the turret too fast or Mach4's     --
-- Macro pump will miss the indexing pulses     --
-- That said, it will execute a toolchange      --
-- reasonably quickly                           --
--                                              --
-- Run from a program or MDI using "T?? M06"    --

local SelectedTool = 0
local CurrentTool = 0
local CurrentTime = 0
local MaxTime = 0
local TurretHome = false
local ToolCounter = 0
local TimeInterval = 0
local rc = 0 --Return Code

-- mc.ISIG_INPUT0  used to read turret index sensor - Change this to the input you've used

SelectedTool,rc = mc.mcToolGetSelected(inst)
CurrentTool,rc = mc.mcToolGetCurrent(inst)

if(SelectedTool ==   CurrentTool) then
rc = mc.mcCntlSetLastError(inst, "Next tool = Current tool")


if((SelectedTool<11) and (SelectedTool>0)) then
------ Tool number valid ------
rc = mc.mcCntlSetLastError(inst, "Changing Tool")

-- Move Z to Home
--rc = mc.mcAxisHome(inst, 2)
rc = mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z0.0\n")

-- Start the spindle turning slowly to aid the gears meshing nicely
--rc = mc.mcCntlGcodeExecuteWait(inst, "M03 S20\n")
-- Move Z +93 - the position above Z home switch where the gears are fully meshed
rc = mc.mcCntlGcodeExecuteWait(inst, "G01 G90 G53 Z90 F400\n")

--Increase the speed of the spindle a bit, to speed up the process.  Don't go too fast or Mach will miss the index pulse
rc = mc.mcCntlGcodeExecuteWait(inst, "M03 S50\n")

--We need to measure the time interval between each index pulse
--The turret has an extra magnet between tool 10 and 1
--First rotate the turret and determine the longest interval between pulses.
--If the time interval is less than the max, it must be the extra magnet passing - so we are just beyond tool 10

rc = mc.mcCntlSetLastError(inst, "Homing Tool Turret")

while( TurretHome==false )
--Measure the time between each pulse of Input 0

CurrentTime = mc.mcCntlGetPoundVar(inst, 3001)
--rc = mc.mcSignalWait(inst,hTurretIndex,mc.WAIT_MODE_HIGH,10.0) --Wait for the index to go high
rc = mc.mcSignalWait(inst,mc.ISIG_INPUT0,mc.WAIT_MODE_HIGH,50.0) --Wait for the index to go high
if(rc==0) then
rc = mc.mcSignalWait(inst,mc.ISIG_INPUT0,mc.WAIT_MODE_LOW,50.0) --Wait for the index to go low
if(rc~=0) then
print("ERRROR2 RC=", mcErrorCheck[rc])

TimeInterval = mc.mcCntlGetPoundVar(inst, 3001)-CurrentTime --How long did we wait

--Update the longest interval between index marks
if(TimeInterval>MaxTime) then
MaxTime = TimeInterval

--If the interval is less than 75% of the max, this is probably the home index
if(TimeInterval<(MaxTime*0.75)) then
--This indicates the home pulse
TurretHome = true  --This will terminate the loop
rc = mc.mcCntlGcodeExecuteWait(inst, "M05\n") --Stop Turret

print("ERRROR1 RC=", mcErrorCheck[rc])

--rc = mc.mcCntlSetLastError(inst, "Turret Homed")
--At this point the turret is homed and the next tool is #1

rc = mc.mcCntlGcodeExecuteWait(inst, "M03 S50\n")  --Slow down turret a bit
ToolCounter = 0  --Set to zero as next index pulse will indicate tool 1

while (SelectedTool~=ToolCounter) --keep the turret turning until we reach the required tool
--Just wait while the turret rotates & Count the number of tools passing
if(ToolCounter==(SelectedTool-1)) then
rc = mc.mcCntlGcodeExecuteWait(inst, "M03 S20\n")  --Slow down turret

rc = mc.mcSignalWait(inst,mc.ISIG_INPUT0,mc.WAIT_MODE_HIGH,50.0) --Wait for the index to go high

if(rc==0) then
--At this point, the index input has gone HIGH so increment the tool count
ToolCounter = ToolCounter + 1
print(string.format("Found Tool No: %.0f", ToolCounter))
if(ToolCounter==SelectedTool) then
rc = mc.mcCntlGcodeExecuteWait(inst, "M05\n")  --Stop turret

--Wait until turret index goeS low before continuing

rc = mc.mcSignalWait(inst,mc.ISIG_INPUT0,mc.WAIT_MODE_LOW,50.0) --Wait for the index to go low
if(rc~=0) then
print("ERRROR4 RC=", mcErrorCheck[rc])
print("ERRROR3 RC=", mcErrorCheck[rc])

--When we get to here, the required tool has been found and the turret is in position.
--The turret location does not have to be that precise as the drive disconnects before the
--tool is in the socket.  It will self align if not too far off.
--Return Z to the home position
--rc = mc.mcAxisHome(inst, 2)
rc = mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z0.0\n")

--Lastly change the active tool number in Mach4
rc = mc.mcToolSetCurrent(inst, SelectedTool)
rc = mc.mcCntlSetLastError(inst,string.format("Selected Tool: %.0f", SelectedTool))
rc = mc.mcAxisHome(inst, 2)
rc = mc.mcCntlEStop(inst)   
rc = mc.mcCntlSetLastError(inst, "ERROR: Tool number out of range!")
do return end

if (mc.mcInEditor() == 1) then
--If you get a 'not found' error here, change the path below to where load_modules.mcs lives
--If, like me, you don't have a copy, you can download it here:

dofile (path .. "\\Profiles\\" .. profile .. "\\Macros\\load_modules.mcs")