ok, I've added this in the PLC script but it always turns the btn1000micron button green, regardless of the increment that I know is working correctly because it jogs the amount that it should.
So it looks like the line "increment, rc = mc.mcJogGetInc(inst, mc.X_AXIS)" always returns 1.
Can you see what I'm doing wrong? In a previous example you set up the function in the screen script and called that from the PLC. Maybe you can't access the increment from the PLC script directly?
Also, I'm not sure about that line in the error checking that says "return" I think that needs to go.
-------------------------------------------------------
-- Handle the radio button action of the Jog increment buttons
-------------------------------------------------------
local increment
local rc
increment, rc = mc.mcJogGetInc(inst, mc.X_AXIS)
if (rc ~= mc.MERROR_NOERROR) then
mc.mcCntlSetLastError(inst, "JogGetInc failed")
return; --?
end
if (increment == 1) then
scr.SetProperty("btn1000micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
?? this line always executed
scr.SetProperty("btn100micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
scr.SetProperty("btn10micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
scr.SetProperty("btn1micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
elseif (increment == 0.1) then
scr.SetProperty("btn1000micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
scr.SetProperty("btn100micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
scr.SetProperty("btn10micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
scr.SetProperty("btn1micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
elseif (increment == 0.01) then
scr.SetProperty("btn1000micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
scr.SetProperty("btn100micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
scr.SetProperty("btn10micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
scr.SetProperty("btn1micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
elseif (increment == 0.001) then
scr.SetProperty("btn1000micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
scr.SetProperty("btn100micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
scr.SetProperty("btn10micron", "Bg Color", "");--"ControlName", "PropertyName", "Value"
scr.SetProperty("btn1micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
end