Internet PLC Forum
General => Technical support => Topic started by: bahpulo on May 30, 2012, 12:15:44 PM
-
Am back again, can anyone help. I want to be able to switch an output on and off using DM. How can I possibly do this?
I used the following codes below but seems not to be working.
if DM[1]=1 then
setio pump
endif
if DM[1]=0 then
ClRIO pump
endif
-
Your code should work although usually it is more efficient to write it as:
IF DM[1] = 1 THEN
SETIO pump
ELSE
CLRIO pump
ENDIF
"pump" here must be an output or internal relay which is under control of the custom function only. If "pump" is also being controlled by other ladder circuit then you have a conflict where the ladder program may dictate one logic state of the pump while your custom function is trying to change it. The last assigned logic state will be what appears on the physical output or internal relay.
-
I have tried with no success can you refer me to any example, my ladder diagram may contribute but i don't know how to troubleshoot the problem.
-
A couple of questions:
Is the PUMP OUTPUT used in any of your ladder logic?
How is your custom function, that contains the code that is supposed to control PUMP, invoked from the ladder logic? What ladder logic code triggers the custom function? Is the custom function run periodically, say every second?
Gary d
-
Gary thanks for the feedback , i got it working now. I got the trigger wrong for the custom function. Many Thanks.