Hello Guest it is April 17, 2021, 08:01:20 AM

Author Topic: EMCO 6P CNC retrofit - M6 Issue  (Read 298 times)

0 Members and 1 Guest are viewing this topic.

EMCO 6P CNC retrofit - M6 Issue
« on: June 09, 2020, 03:58:17 PM »
Hi everyone,

Just arrived to the Mach community.

About to finish a complete rewamping of a very old emco 6P cnc including mach4 and pokeys57cnc.

I need help to write the M6 code for my ATC 8 station turret. A combination of 4 sensor give a feedback of which position is currently active and used to stop the motor to rotate the turret.

Thanks in advance for help.
Cedric.
Re: EMCO 6P CNC retrofit - M6 Issue
« Reply #1 on: June 11, 2020, 01:32:06 AM »
one advice i want give you ,very very important
you MUST think and give solution while M6 running ,if m6 stop in middle
because in mach if you press stop while m function run or its stop from any other reason ,its not stop at all the function
its only stop the movement
so for example if you stop before you release the tool  ,the machine not move any more ,but the tool will fall
SO you must give attention in any output activate to be sure what is the machine status bfore do something
thks

Offline Graham Waterworth

*
  • *
  •  2,305 2,305
  • Yorkshire Dales, England
    • View Profile
Re: EMCO 6P CNC retrofit - M6 Issue
« Reply #2 on: June 11, 2020, 08:31:27 PM »
This is a Mach3 M6Start.m1s file for an Emco that I did some time back, you should be able to replace the relevant calls with Mach4 ones and I am sure we can help if you get stuck.

Code: [Select]
' Emco 8 station turret index
' Version 1.0.2
' (c) G. Waterworth 11/12/2007

Sub Main()
If IsLoading() then
  ' do nowt
Else
  OldTurretPos=(GetOEMDRO(824))   'current tool position
  NextTool=GetSelectedTool()      'tool to be indexed
 
  If OldTurretPos<>NextTool Then
    ' new tool required
    If NextTool<1 Or NextTool>8 Then 'valid tool check
      Message("Next Tool out of range")
      Exit Sub
    End If

    ActivateSignal(OUTPUT4)   'rotate Turret

    '=== Index Tool ===
    Select Case NextTool
Case 1
count=1
Case 2
count=3
Case 3
count=2
Case 4
count=6
Case 5
count=4
Case 6
count=12
Case 7
count=8
Case 8
  count=9
    End Select

    thistool=OldTurretPos

    While thistool<>count
      sensors=0
      While sensors=0
        if IsActive(OEMTRIG1) then sensors=sensors+1
        if IsActive(OEMTRIG2) then sensors=sensors+2
        if IsActive(OEMTRIG3) then sensors=sensors+4
        if IsActive(OEMTRIG4) then sensors=sensors+8
      Wend
      thistool=sensors
    Wend

    Code"G04 P50"
    While Ismoving()
    Wend
 
    DeActivateSignal(OUTPUT4) 'stop turret rotation
    SetCurrentTool(thistool)
  End If
End If
End Sub           

'The actual timings are:-
'
'opto 1 2 3 4
'pin 10 11 12 13
'value 1 2 4 8
'Tool 1 on off off off
'Tool 2 on on off off
'Tool 3 off on off off
'Tool 4 off on on off
'Tool 5 off off on off
'Tool 6 off off on on
'Tool 7 off off off   on
'Tool 8 on off off on
Without engineers the world stops
Re: EMCO 6P CNC retrofit - M6 Issue
« Reply #3 on: June 20, 2020, 09:59:59 AM »
Many thanks HGraham for your help and bringing in your code.
With it, i was able to build a new LUA code for my machine, and IT WORKS !! :D

Code: [Select]
---Emco 8 station turret index
---Version 2.0 Mach4

local inst = mc.mcGetInstance()

SigLib = {
[mc.ISIG_INPUT0] = function (state)
m6()
end,
[mc.ISIG_INPUT1] = function (state)
m6()
end,
[mc.ISIG_INPUT2] = function (state)
m6()
end,
[mc.ISIG_INPUT3] = function (state)
m6()
end,
}

function m6()

---Basic values---

local CurrentTool = mc.mcToolGetCurrent(inst)   ---current tool position---
local NextTool = mc.mcToolGetSelected(inst)      ---tool to be indexed---

---Starting backward rotation---
 
if (CurrentTool == NextTool) then
mc.mcCntlSetLastError(inst, "ERROR: next tool = current tool!")
do return end
elseif (NextTool < 1 or NextTool > 8) then
    mc.mcCntlSetLastError(inst, "ERROR: Tool number out of range!")
do return end
else
mc.mcCntlSetLastError(inst, "ERROR: Tool OK Running")
end
---index---

local count = 0

if (NextTool == 1) then count = 4
elseif (NextTool == 2) then count = 6
elseif (NextTool == 3) then count = 2
elseif (NextTool == 4) then count = 3
elseif (NextTool == 5) then count = 1
elseif (NextTool == 6) then count = 9
elseif (NextTool == 7) then count = 8
elseif (NextTool == 8) then count = 12
else
mc.mcCntlEStop (inst)
    mc.mcCntlSetLastError(inst, "ERROR: Index!")
do return end
end

mc.mcCntlSetLastError (inst, string.format("comptage: %.0f", count)) --for debugging--

--Activate Turret Backward---

local  turretbwd = mc.OSIG_OUTPUT0
local hsig = mc.mcSignalGetHandle(inst, turretbwd)
mc.mcSignalSetState (hsig, 1)

---Position realtime control---

repeat

local sensors = 0

local in0 = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT0)
local OEMTRIG1 = mc.mcSignalGetState(in0)
        if (OEMTRIG1 == 1) then sensors = sensors+1
end
local in1 = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT1)
local OEMTRIG2 = mc.mcSignalGetState(in1)
        if (OEMTRIG2 == 1) then sensors = sensors+2
end
local in2 = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT2)
local OEMTRIG3 = mc.mcSignalGetState(in2)
        if (OEMTRIG3 == 1) then sensors = sensors+4
end
local in3 = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT3)
local OEMTRIG4 = mc.mcSignalGetState(in3)
        if (OEMTRIG4 == 1) then sensors = sensors+8
end
until sensors == count

---Stop indexing---

wx.wxMilliSleep(200)
mc.mcSignalSetState (hsig, 0)


--- Ratcheting Back ---

local  turretfwd = mc.OSIG_OUTPUT1
local hsig = mc.mcSignalGetHandle(inst, turretfwd)
mc.mcSignalSetState (hsig, 1)
wx.wxMilliSleep(400)
mc.mcSignalSetState (hsig, 0)

--- Set New Tool ---

mc.mcToolSetCurrent (inst, NextTool)
mc.mcCntlSetLastError (inst, string.format("Tool Change OK : Tool %0.f in place", NextTool))

end

Offline Graham Waterworth

*
  • *
  •  2,305 2,305
  • Yorkshire Dales, England
    • View Profile
Re: EMCO 6P CNC retrofit - M6 Issue
« Reply #4 on: June 20, 2020, 07:16:08 PM »
Great stuff,  :D
Without engineers the world stops