Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: tatum_ra on September 13, 2022, 04:39:26 AM
-
Hello guys,
trying to retrofit an old Mikron-Wf3 mill with CSMIO-A.
Now I have a strange behaviour. All the outputs that use a pmc -editor script or a signal library script,
during mach4 loading, they cycle on-off a couple of times.
After the loading of mach 4 is completed they work as expected.
For example a have an external switch to turn on the coolant pump
and I have put the code bellow in the SigLib
[mc.ISIG_INPUT9] = function (S20ActivateCoolantPump)
local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON);
local sigState = mc.mcSignalGetState(sigh);
if(S20ActivateCoolantPump == 1) then
mc.mcSignalSetState(sigh, 1);
mc.mcCntlSetLastError(inst, "Flood coolant is ON")
else
mc.mcSignalSetState(sigh, 0);
mc.mcCntlSetLastError(inst, "Flood coolant is OFF")
end
end,
If anyone has any suggestions or I am doing sth wrong please comment.
Thank you in advance for your input.
-
In a screen script, just don't set signal states until the system is loaded.
if scr.IsLoaded() then
... signal setting code here ...
end
In a PMC object, you can wait on the machine to be enabled the first time or somethin go f the like.
Steve
-
Thanks for the reply Steve. Much appreciated.
I have tried the following
SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
machEnabled = state;
ButtonEnable()
end,
[mc.ISIG_INPUT9] = function (S20ActivateCoolantPump)
local inst = mc.mcGetInstance();
local hsig = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON);
if(S20ActivateCoolantPump == 1) and (scr.IsLoaded()) then
mc.mcSignalSetState(hsig, 1);
mc.mcCntlSetLastError(inst, "Flood coolant is ON")
else
mc.mcSignalSetState(hsig, 0);
mc.mcCntlSetLastError(inst, "Flood coolant is OFF")
end
end,
}
Unfortunately, I have the same behavior as I said before.
During screen loading the output cycles on-off-0n-off
what makes things worse is if I use sth like
[mc.ISIG_INPUT12] = function (S32ServoAmplifierON) --S32 Servo Amplifier ON
if (S32ServoAmplifierON == 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
then mach4 hangs and you must disconnect the ethernet connection to the controller and only then mach4 can restart.
What is really strange is, if mach 4 has finished loading, and you add the above code after loading, everything works as it should, until you restart and then during screen loading mach 4 hangs again.
Thank you all for your input.
Tasos
-
I was going to say that a lot of this has to do with how the motion controller starts up. Specifically what state the inputs are in. If the inputs are steady, you will see no cycling. It is important to note that the SigLib is called when the state of the input changes. So if the code is cycling, that means the input itself is cycling. I would go so far as to say that my Galil does NOT exhibit this behavior. And it certainly isn't Mach cycling the inputs. So you must concentrate on how to mitigate the issue. First, I would ask for support from the motion controller vendor. Failing that, try to fix hardware in software (like we do every day!) and see if some script changes and switch wiring can help.
The below code will ONLY respond to signal changes AFTER the screen has loaded. However, this may not always be optimal as you may miss the initial state of the input. If you have toggle switches, it may be better to use momentary on switches.
[mc.ISIG_INPUT9] = function (S20ActivateCoolantPump)
if (scr.IsLoaded()) then --- only process if the screen has completely loaded.
local inst = mc.mcGetInstance();
local hsig = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON);
if (S20ActivateCoolantPump == 1) then
mc.mcSignalSetState(hsig, 1);
mc.mcCntlSetLastError(inst, "Flood coolant is ON")
else
mc.mcSignalSetState(hsig, 0);
mc.mcCntlSetLastError(inst, "Flood coolant is OFF")
end
end
end,
Another thing you can do is see if you can shut the power off to the inputs while the machine is starting up and then once it is stable, power the inputs so that their state is then immediately seen.
Steve
-
Thanks a lot Steve.
I will try your suggestions. I will also contact CS LAB and see what they have to say about it.
Kind regards,
Tasos