Author Topic: Control outputs using DM  (Read 11782 times)

bahpulo

  • Newbie
  • *
  • Posts: 7
  • I'm a llama!
    • View Profile
Control outputs using DM
« 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

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Control outputs using DM
« Reply #1 on: May 30, 2012, 11:47:34 PM »
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.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

bahpulo

  • Newbie
  • *
  • Posts: 7
  • I'm a llama!
    • View Profile
Re:Control outputs using DM
« Reply #2 on: June 01, 2012, 12:54:37 PM »
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.

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Control outputs using DM
« Reply #3 on: June 01, 2012, 05:32:20 PM »
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

bahpulo

  • Newbie
  • *
  • Posts: 7
  • I'm a llama!
    • View Profile
Re:Control outputs using DM
« Reply #4 on: June 03, 2012, 11:23:48 AM »
Gary thanks for the feedback , i got it working now. I got the trigger wrong for the custom function. Many Thanks.