Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: donb9261 on March 02, 2015, 02:37:23 PM
-
In my experience (26 years+) working with Fanuc and Siemens operators prefer the more tactile feel of rotary selector switches for feed, rapid, and spindle overrides. Most of the time these are binary. Simple enough. The logic to do this in Lua seems straight forward. But, once I have taken the binary and converted it to BCD how do I tell Mach4 the new value. I am creating an operator pendant with these 3 selector switches and need the code to make them function.
In Mach3 there were Brains and DRO's. Now I am a little confused. Looking through the LuaCalls.txt file I see: rc, percent = mc.mcCntlGetFRO(number mInst). Which I assume will gather the current value??? But, how do I PUT the value???
Am I missing something?
I would appreciate anyone offering some help.
-
Nevermind. I found the way via this thread...
http://www.machsupport.com/forum/index.php/topic,27762.0.html
Next question.....
How do I limit the value from exceeding 250 or 0?
-
How do I limit the value from exceeding 250 or 0?
------------------------------------------------------------------
local MyValue = 0;
MyValue = (where ever you getting the value from);
if MyValue < 0 then
MyValue = 0;
end
if MyValue > 250 then
MyValue = 250;
end
Scott
-
Hello Scott and thank you. This is working.
May I burden you with some additional questions?
-
I have read where there is a screen load script????
Where is this file located. I have searched the settings and the directory and have found nothing that screams here I am...
Is it the MachPlc.mcs file?
If so, is this where I would insert the code to run Brian's Sig file like this:
SigLib = {
--Enable
[mc.OSIG_MACHINE_ENABLED] = function (state)
machEnabled = state;
end,
--HeadUp
[mc.ISIG_INPUT1] = function (on_off)--mc.ISIG_INPUT1
if( on_off==1 ) then
-- On
else
-- Off
end
end,
--HeadDn
[mc.ISIG_INPUT2] = function (state)--mc.ISIG_INPUT2
if( state == 1 ) then
-- On
else
-- Off Call A function here if you wanted
end
end,
[mc.ISIG_INPUT3] = function (state)--mc.ISIG_INPUT3 --Used as an enable button
if( state == 1 ) then
local inst= mc.mcGetInstance();
local reg = mc.mcSignalGetHandle(inst, mc.OSIG_MACHINE_ENABLED)
state = mc.mcSignalGetState(reg);
if(state == 1)then
state = 0
else
state = 1
end
mc.mcCntlEnable(inst, state);
end
end,
[mc.ISIG_INPUT4] = function (state)--mc.ISIG_INPUT2 button to do feed hold
if( state == 1 ) then
local inst= mc.mcGetInstance();
mc.mcCntlFeedHold(inst)
end
end,
[mc.ISIG_INPUT5] = function (state)--mc.ISIG_INPUT2
if( state == 1 ) then
CycleStart() --Run my cycle start function
end
end
}
-
Second, how do I determine what the Lua call is to say take a button input on Sig Input 1 and have it then choose a tab like the MDI tab?
I am trying to build a pendant and want buttons that can call these tabs without using keyboard or mouse functions.
Cycle Start nad FH are easy as they are listed in that handy file you posted. Thanks for that. Huge help. But, I cannot see how I can call the screen items from external sources nor what the syntax should or could be...
-
screen designer, click on main root, then events.
see mach 4 tool box for examples and mcLua doc.
Scott