Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The PAC does not have a built-in first scan flag, but it is very easy to create one using a boolean variable.  A programmer creates a boolean variable, initializes it to TRUE and sets it to FALSE at the bottom of the program where it is used.  Examples are given below in Ladder Diagram (LD), Continuous Function Chart (CFC) and Structured Text (ST).

LADDER DIAGRAM (LD)

...

CONTINUOUS FUNCTION CHART (CFC)

...

STRUCTURED TEXT (ST)

...

On the first scan cycle, the outputs are TRUE:

...

However, the outputs are FALSE on all subsequent scans:

...

NOTES

  • In Ladder Diagram, the last rung should be the one that sets the first scan flag to FALSE.

  • In Continuous Function Chart, keep an eye on the green numbers in the upper right-hand corner of each output element.  This is the execution order.  The first scan flag should have a higher number than all other elements.  If it does not, right-click on it and select Execution Order > Send To Back.

  • If there are multiple programs that need to perform first scan operations, use multiple first scan flags.  This helps to prevent execution order issues between POUs.  This is especially important if programs are running in multiple tasks.

...