Use Concise Programming

Use these recommendations to create concise programming. Concise programming makes your program execute faster and reduces your program scan time.

Execute an Instruction Only When Needed

Because many instructions write tag values whenever executed, strategic and economical use of instructions is needed. Strategic programming techniques include the following:
  • Use preconditions to limit the execution of instructions.
  • Combine preconditions when possible.
  • Divide programming into subroutines that are called only when required.
  • Run noncritical code every two or three scans instead of during every scan.
For example, precondition an ADD instruction to run only when the controller gets new data. As a result, the Dest_Tag is crossloaded only when the ADD instruction produces a new value.
Precondition Used with ADD Instruction
Precondition Used with ADD Instruction
Along with preconditions, try to group instructions together that use the same precondition. In this example, the four preconditions in the two branches can be combined to precede the two branches. Doing so reduces the number of precondition instructions from four to two.
Efficient Precondition Use
Efficient Precondition Use
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal