Author Topic: Execution order of ladder diagram.  (Read 8868 times)

cdenk

  • Full Member
  • Posts: 161
  • newbie
    • View Profile
Execution order of ladder diagram.
« on: August 14, 2006, 08:24:39 AM »
Just to confirm my thoughts: (This is for a T100MD888+)
1: The ladder is executed from top to bottom, in order, with all changes to outputs occuring at the very bottom of the ladder.
2: Custom functions are executed as part of the rung that they occupy from top to bottom. Exception a "CALL" would bring a copy of programming related onto that rung.
3: Variables, both A -Z and DM[]'s can be assigned a value in on Custom Function (A = ADC(1) , in a lower rung function, modified (A = A/2), and at a lower yet rung, in a custom function use the value (SETLCD 1,1,STR$(A) ).
The CUstom Functions would do there things and at the end the proper value of "A" would be displayed.

Seems this works with A-Z but may not work with DM[]'s ? The ADC values don't change quickly, and an erroneous result for a cycle or 2 is not a problem.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Execution order of ladder diagram.
« Reply #1 on: August 14, 2006, 09:17:46 AM »
1) Yes, from top to bottom.

2) Custom function are executed at the instant that they are triggered as a {dCusF} or {CusFn}. If within a custom function it calls another custom function using the CALL statement, then the CALLed function is immediately executed and upon return from the CALLed function, execution continue to the next statement.

3)  Yes, the proper value will be displayed. It should works on A to Z or any DM. Just be aware that DM are 16-bit and ensure that you computation does not overflow the 2's complement limits -32768 to +32767.

Note that if you modify any Output variable e.g. OUTPUT[1], only the memory copy of the output is affected. The physical output is not updated until the end of the ladder logic scan unless you execute the REFRESH statement (beware of the 2ms I/O scan time penalty when running this statement). The ladder logic also works on the memory copy of the output and not the physical output so a CF can modify the logic state of output coil if it happens at the lower rung in the ladder program.
« Last Edit: August 14, 2006, 09:22:30 AM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS