Enabling Scan Modes

The Scan Modes tab in the Instruction Definition Editor lets you create and enable execution of the routines for the three Scan modes: Prescan, Postscan, and EnableInFalse.

Prescan Routine

When the controller transitions from Program mode to Run mode or when the controller powers up in Run mode, all logic within the controller is executed in Prescan mode. During this scan, each instruction may initialize itself and some instructions also initialize any tags they may reference. For most instructions, Prescan mode is synonymous with scanning false. For example, an OTE instruction clears its output bit when executed during Prescan mode. For others, special initialization may be done, such as an ONS instruction setting its storage bit during Prescan mode. During Prescan mode, all instructions evaluate false so conditional logic does not execute.

The optional Prescan routine for an Add-On Instruction provides a way for an Add-On Instruction to define additional behavior for Prescan mode. When a Prescan routine is defined and enabled, the Prescan routine executes normally after the primary logic routine executes in Prescan mode. This is useful when you want to initialize tag values to some known or predefined state prior to execution.

An example would be setting a PID instruction to Manual mode with a 0% output prior to its first execution or initializing some coefficient values in your Add-On Instruction.

When an Add-On Instruction executes in Prescan mode, any required parameters have their data passed.

· Values are passed to Input parameters from their arguments in the instruction call.
· Values are passed out of Output parameters to their arguments defined in the instruction call.

These values are passed even when the rung condition is false in Ladder Diagram or when the instruction call is in a false conditional statement in Structured Text. When Function Block Diagram routines execute, the data values are copied to all wired inputs and from all wired outputs, whether or not the parameters are required.

Follow these steps to create a Prescan routine.

1. In the Controller Organizer, right-click an instruction and choose Open Definition.

2. Click the Scan Modes tab.

3. Click New for Prescan Routine.


4. From the Type menu on the New Scan Mode Routine dialog box, choose the type of programming language: Ladder Diagram, Function Block, or Structured Text.


5. Type a description of the Prescan behavior.

6. Click OK to create the routine and return to the Scan Modes tab.

7. Define if the prescan routine executes (or not) by checking or clearing Execute Prescan routine after the logic routine is prescanned.


The Prescan routine can now be edited like any other routine.

Postscan Routine

Postscan mode occurs only for logic in a Sequential Function Chart Action when the Action becomes inactive and the SFC language is configured for Automatic Reset (which is not the default option for SFC). When an SFC Action becomes inactive, then the logic in the Action is executed one more time in Postscan mode. This mode is similar to Prescan in that most instructions simply execute as if they have a false condition. It is possible for an instruction to have different behavior during Postscan mode than it has during Prescan mode.

When an Add-On Instruction is called by logic in an SFC Action or a call resides in a routine called by a JSR from an SFC Action, and the Automatic Reset option is set, the Add-On Instruction executes in Postscan mode. The primary logic routine of the Add-On Instruction executes in Postscan mode. Then, if it is defined and enabled, the Postscan routine for the Add-On Instruction executes. This could be useful in resetting internal states, status values, or de-energizing instruction outputs automatically when the action is finished.

Follow these steps to create a postscan routine.

1. In the Controller Organizer, right-click an instruction and choose Open Definition.

2. Click the Scan Modes tab.

3. Click New for Postscan Routine.


4. From the Type menu on the New Scan Mode Routine dialog box, choose the type of programming language: Ladder Diagram, Function Block, or Structured Text.


5. Type a description of the postscan behavior.

6. Click OK to create the routine and return to the Scan Modes tab.

7. Define if the postscan routine executes (or not) by checking or clearing Execute Postscan routine after the logic routine is postscanned.


The Postscan routine can now be edited like any other routine.

EnableInFalse Routine

When defined and enabled for an Add-On Instruction, the EnableInFalse routine executes when the rung condition is false or if the EnableIn parameter of the Add-On Instruction is false (0). This is useful primarily for scan false logic, when used as an output instruction in a Ladder routine. A common use of scan false is the setting of OTEs to the de-energized state when the preceding rung conditions are false. An Add-On Instruction can use the EnableInFalse capability to let you define behavior for the False conditions.

When the Add-On Instruction is executed in the false condition and has an EnableInFalse routine defined and enabled, any required parameters have their data passed.

· Values are passed to Input parameters from their arguments in the instruction call.
· Values are passed out of Output parameters from their arguments in the instruction call.

If the EnableInFalse routine is not enabled, the only action performed for the Add-On Instruction in the false condition is that the values are passed to any required Input parameters in ladder logic.

Follow these steps to create an EnableInFalse routine.

1. Right-click the instruction and choose Open Definition.

2. Click the Scan Modes tab.

3. Click New on EnableInFalse routine.


4. From the Type menu on the New Scan Mode Routine dialog box, choose the type of programming language: Ladder, Function Block, or Structured Text.


5. Type a description of the EnableInFalse behavior.

6. Click OK to add an EnableInFalse routine to the Add-On Instruction definition.

7. Define if EnableIn False routine executes (or not) by checking or clearing Execute EnableInFalse routine.


The EnableInFalse routine can now be edited like any other routine.



0 comments :