Machsupport Forum

Mach Discussion => Mach4 General Discussion => Mach4 Toolbox => Topic started by: SimonRafferty on May 07, 2020, 04:21:06 AM

Title: EMCO PCMill100 or VMC100 Toolchange Macro M6
Post by: SimonRafferty 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:
https://www.youtube.com/watch?v=WpjGpXOVs3M

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")

else   



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 )
do
--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])
end

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

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

--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
end

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

--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
do
--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
end


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
else

--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])
end
end
else
print("ERRROR3 RC=", mcErrorCheck[rc])
end
end

--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)
else
rc = mc.mcCntlEStop(inst)   
rc = mc.mcCntlSetLastError(inst, "ERROR: Tool number out of range!")
do return end
end
end
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:
--https://www.machsupport.com/forum/index.php?action=dlattach;topic=34318.0;attach=45828

dofile (path .. "\\Profiles\\" .. profile .. "\\Macros\\load_modules.mcs")
m6()
end
Title: Re: EMCO PCMill100 or VMC100 Toolchange Macro M6
Post by: bierma32 on November 27, 2021, 03:20:48 AM
Hello Simon,
nice work.
Will this macro run also in the automatic mode of a Programm ?

I've got a Emco Concept Mill 155  and will try next year to retrofit this machine also to mach4 by control with csmio IP/S .
I will install Delta Servo B2 drives and Motors.

Can send some Pictures of  your switch cabinet.
Did you use some of original installation in the cabinet ?

Thx
Title: Re: EMCO PCMill100 or VMC100 Toolchange Macro M6
Post by: SimonRafferty on November 27, 2021, 11:06:56 AM
Not the tidiest machine cabinet in the world (at the moment anyway).

The ATC works fine inside a program, automatically.  Don't adjust the feed rate while the ATC is running though as it uses timing to determine the gap between the sensor positions.  If you change the speed (or the feed is too high), it messes up the timing.
Title: Re: EMCO PCMill100 or VMC100 Toolchange Macro M6
Post by: SimonRafferty on November 27, 2021, 11:07:42 AM
the other side
Title: Re: EMCO PCMill100 or VMC100 Toolchange Macro M6
Post by: bierma32 on November 27, 2021, 11:40:49 AM
Hello Simon,

Thank you for your fast reply.
So you use the original Berger Lahr Drivers and Motors, how is smooth ness of the motors ?
After I see you pictures I will try to make also a test installation and connection with original Berger Lahr motor and drives.
OK, I must modify the macro , Z Positions on my machine are different  to see how it works
Thx.
Title: Re: EMCO PCMill100 or VMC100 Toolchange Macro M6
Post by: SimonRafferty on November 27, 2021, 11:44:40 AM
The motors in the machine are a funny 5 pole design - and it's almost impossible to find different drivers for them.  Most people seem to replace the motors.
I figured the motors were perfectly good - so it made more sense to re-use the existing drives & motors.

They are not the smoothest or quietest, compared to modern drivers - but they work just fine.  They give 0,01mm resolution which is sufficient.