when they experiment, they simply find that it doesn't work how they might reasonably expect.
Agreed, but I tend to accept Mach4 for what it is, powerful yet amazingly good value, and use the flexible scripting to make it work as I would wish. It can be a challenge but to me that is part of the fun.
Allan
Agreed, it's a lot of fun playing when it makes sense. I don't mind going the extra mile to figure out how to make it do what I want. It's just frustrating when it's actually a bug that's been causing so much grief! such is life.
Anyway, here's my solution to the RadioButton type of interface that seems to work ok now.
This function is written in the SreenScript and called in the PLC loop.
Each increment button uses a Left Down Action of Jog Node Step and a Left Up Action of Jog Inc. 3 for example. There's also a Left Up script as follows...
--Set JogIncX variable using mcJogSetInc() and test it using a call
--from the PLC script to set the radio button colours
--For some reason this has no effect on the actual jog amount which is
--set from the UpAction event for this button
local inst = mc.mcGetInstance()
local rc
rc = mc.mcJogSetInc(inst, mc.X_AXIS, 0.01)
....We now know that this shouldn't have been necessary, the GUI should have done that for us.
----------------------------------------------------------------------------
-- Handle the radio button action of the Jog increment buttons - My code!
----------------------------------------------------------------------------
function UpdateJogRadioButtons()
--currentInc = 0 -- my global var to track the current increment is defined above
--currentMode = -1 -- my global var to track current mode is defined above
local increment
local rc
--See if we're in continous or incremental jog mode first
local cont = mc.mcSignalGetHandle(inst, mc.OSIG_JOG_CONT);
local jogcont = mc.mcSignalGetState(cont)
if (jogcont ~= currentMode) then --so it's not done every loop
--mc.mcCntlSetLastError(inst, "jogcont=" .. tostring(jogcont)); --debug only
if (jogcont==1) then --continuous
scr.SetProperty("btnContinuousMode", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
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", "");--"ControlName", "PropertyName", "Value"
end
currentMode = jogcont --so we don't update every time
end
if (jogcont==0) then --incremental
scr.SetProperty("btnContinuousMode", "Bg Color", "");--"ControlName", "PropertyName", "Value"
--NB:-The following gets the value set by the buttons, it has no effect on the actual jog amount!
increment, rc = mc.mcJogGetInc(inst, mc.X_AXIS) --You can see the value JogIncX in the Debug_RegFile
if (increment ~= currentInc) then --so we don't unnecessarily update anything
if (increment == 1) then
scr.SetProperty("btn1000micron", "Bg Color", "Green");--"ControlName", "PropertyName", "Value"
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
currentInc = increment --remember what the new increment is
end
end
end
So this is pretty simple now really. I've tested the Continuous mode signal that's used elsewhere to decide whether to blank out the incremental buttons.
It's a fantastic piece of software, but I'm famous for breaking things and finding bugs that have lain dormant for years. I'm dogged an won't just give up because it doesn't make sense.
Anyway, hopefully others will be able to do this easily now all this has been thoroughly aired.
Many thanks to all who've contributed, it's been an enormous help. I'm now going to tackle the MDI box to make that less dangerous.