Hello Guest it is May 07, 2021, 01:26:39 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Cedre01

Pages: 1
1
Mach4 General Discussion / Re: EMCO 6P CNC retrofit - M6 Issue
« 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

2
Mach4 General Discussion / 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.

Pages: 1