Hello i havent posted for a while had different problem with controllers and function. this is where i am at i have a cnc control built around the Ethernet Smooth Stepper and the MB2. i added a pokeys board to make up extra inputs i needed. i tried to use it for mpg that didnt work so i put my mpg back to the ESS and continued to use the pokeys 56e for some simple inputs two rotary switches and three push buttons. also 9 led's. none of this worked i tried to update the firmware on the pokeys. i tried capacitors and resistors like the manual said. nothing worked i kept getting false triggering that is a problem when one of your switches is cycle start. so my next solution for not enough inputs. i realize i can use two inputs to make three if i do it like this first switch input one on. 2nd switch input 2 on. 3rd switch input one and two on at the same time however on switch three use two diodes so they cant back feed.
the same thing can be done with more my second rotary has 4 positions i use 3 inputs and two diodes. and three push buttons just to cover everything. electrically they work good i can see the led's on the MB2 light up exactly as they should. so here is my problems i just guessed at the diodes can anybody help me with what size diode to use for a 24v system set up like this. probably about switch timing but i dont know. 2nd lua script is something i am working on (side note some of the manuals and examples for lua look very different to do the same thing, confusing) so this is what i set up for the 3 push buttons in screen load script.
---------------------------------------------------------------
-- Signal Library
---------------------------------------------------------------
SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
machEnabled = state;
ButtonEnable()
end,
[mc.ISIG_INPUT1] = function (state)
if (state == 1) then
Cycle()
end
end,
[mc.ISIG_INPUT2] = function (state)
if (state == 1) then
Cycle()
end
end,
---------------------------------------------------------------
-- Cycle Start, Feed Hold, Cycle Stop function
---------------------------------------------------------------
function Cycle()
--function CycleStop()
local hsig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT1)
local Input1, rc = mc.mcSignalGetState(hsig)
local hsig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT2)
local Input2, rc = mc.mcSignalGetState(hsig)
--Cycle Stop
if Input1 == 1 and Input2 == 1 then
mc.mcCntlCycleStop(inst);
mc.mcSpindleSetDirection(inst, 0);
mc.mcCntlSetLastError(inst, "Cycle Stopped");
end
if Input1 == 0 and Input2 == 1 then
mc.mcCntlFeedHold(0)
end
if Input1 == 1 and Input2 == 0 then
--function CycleStart()
local rc;
local tab, rc = scr.GetProperty("MainTabs", "Current Tab")
local tabG_Mdione, rc = scr.GetProperty("nbGCodeMDI1", "Current Tab")
local tabG_Mditwo, rc = scr.GetProperty("nbGCodeMDI2", "Current Tab")
--See if we have to do an MDI command and if so, which one
if ((tonumber(tab) == 0 and tonumber(tabG_Mdione) == 1) or (tonumber(tab) == 2 and tonumber(tabG_Mditwo) == 1 )) then
local state = mc.mcCntlGetState(inst);
if (state == mc.MC_STATE_MRUN_MACROH) then
mc.mcCntlCycleStart(inst);
mc.mcCntlSetLastError(inst, "Do Cycle Start");
else
if (tonumber(tab) == 0) then
scr.ExecMdi('mdi1');
mc.mcCntlSetLastError(inst, "Do MDI 1");
else
scr.ExecMdi('mdi2');
mc.mcCntlSetLastError(inst, "Do MDI 2");
end
end
elseif tonumber(tab) > 2 then --No G Code or MDI panel is displayed so Do Nothing
mc.mcCntlSetLastError(inst, "Nothing to Start");
else --Do CycleStart
mc.mcCntlSetLastError(inst, "Do Cycle Start");
mc.mcCntlCycleStart(inst);
end
end
end
this works well and doesnt false start except when you press the third switch which is stop you can get a quick cycle start first then stop in the history i dont know if this is a problem or will be and it could be related to the diodes or i need to add a capacitor of .01 across my switches. i tried adjusting filtering but that didnt seem to help. i think the solution is in lua but i dont know enough lua. my next piece of code is for mpg jog X Y Z and A axis.
[mc.ISIG_INPUT4] = function (state)
if (state == 1) then
Mpg()
end
end,
[mc.ISIG_INPUT5] = function (state)
if (state == 1) then
Mpg()
end
end,
[mc.ISIG_INPUT6] = function (state)
if (state == 1) then
Mpg()
end
---------------------------------------------------------------
--Mpg Axis Increment
---------------------------------------------------------------
function Mpg()
local hsig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT4)
local Rotary1, rc = mc.mcSignalGetState(hsig)
local hsig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT5)
local Rotary2, rc = mc.mcSignalGetState(hsig)
local hsig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT6)
local Rotary3, rc = mc.mcSignalGetState(hsig)
--Mpg X
if Rotary1 == 1 and Rotary2 == 0 and Rotary3 == 0 then --Mpg X
mc.mcMpgSetAxis(inst,0,0)
mc.mcCntlSetLastError(inst,"X Selected")
elseif Rotary1 == 0 and Rotary2 == 1 and Rotary3 == 0 then --Mpg Y
mc.mcMpgSetAxis(inst,0,1)
mc.mcCntlSetLastError(inst,"Y Selected")
elseif Rotary1 == 0 and Rotary2 == 0 and Rotary3 == 1 then --Mpg Z
mc.mcMpgSetAxis(inst,0,2)
mc.mcCntlSetLastError(inst,"Z Selected")
elseif Rotary1 == 0 and Rotary2 == 1 and Rotary3 == 1 then --Mpg A
mc.mcMpgSetAxis(inst,0,3)
mc.mcCntlSetLastError(inst,"A Selected")
elseif Rotary1 == 0 and Rotary2 == 0 and Rotary3 == 0 then --Mpg off
mc.mcMpgSetAxis(inst,0,-1)
mc.mcCntlSetLastError(inst,"No Axis Selected")
end
end
i haven gotten to coding the last switch which is a rotary for increment x1 x10 x100. the mpg jog code works somewhat it will turn on X then Y then Z then A then go back as long as i dont go to fast. however it doesnt like to shut off mc.mcCntlSetLastError(inst,"No Axis Selected") i have only checked it with set last error so far my thought if it doesnt pass there how is it going to work. so i turn the switch to x then y then z then a then back fast slow ridiculous speed and is doesnt confuse to bad however it doenst like to shut off the last block of code i have done two ways as you see it and like this
else
mc.mcMpgSetAxis(inst,0,-1)
mc.mcCntlSetLastError(inst,"No Axis Selected")
end
end
this was better in that i got "No Axis Selected" from the outer switches y z a if i moved quickly but when i was on X and turned it to off it stayed X axis selected or should i say it didnt change to no axis selected as X was just the last axis selected and the others could be slugish. i thought about using the PMC for ladder logic and for speed might solve my problem however after looking it over unless somebody helps me set up the first rung for one input on and two inputs off jogs mpg i havent the foggiest idea of how to do it. also there is probably a better way with screen load script or maybe i should be using plc and dont know it. if i /we can find a way to make this work i can have my full blown control with inputs for probe and spindle A B I encoder. and i am sure others can benefit from this solution. thank you
mark