HSC Wizard




Select a Counter Type and Operating Mode


Specify Initial Parameters


Program Interrupting Events/Multiple Steps


Generate Code

Note: Your program must be compiled before you use the HSC Wizard. If you have not compiled, the wizard prompts you to do so at the beginning of the HSC configuration process.

The High Speed Counter instruction (HSC) in LAD or STL is provided by the S7-200 to control events that occur at a rate that is faster than the scan rate of the PLC. The operation of an HSC is very flexible, with multiple initialization options that determine the behavior of the counter. To properly configure an HSC, you need to set several parameters in SM memory, configure a specific HSC for a mode of operation, attach interrupt routines to specific counter events, and, finally, enable the operation of the counter.

The HSC wizard queries you for initialization options, and then generates program code and data block code for the specified configuration. After you choose HSC from screen one, the wizard queries you for the following information:

STEP 1 Select a Counter Type and Operating Mode

Choose a counter to configure from the list box (PLC-dependent).

Choose an operating mode from the list box. Your choice of counter determines the modes that are available.

STEP 2 Specify Initial Parameters

Specify a unique name for the subroutine. Do not use the name of an existing subroutine.

Specify initial values for parameters such as the CV, PV, and counter direction.

STEP 3 Program Interrupting Events/ Program Multiple Steps

Your choice of counter type and operating mode determine which interrupting events are available.

When you choose to program the current value equals preset value event (CV = PV), the wizard allows you to specify a multiple-step counter implementation.

To understand multiple-step HSC implementations, consider the following:

Within an interrupt routine that you have programmed, you can choose to re-attach the same interrupting event to a different interrupt routine. This would effectively be adding a "step" to the counterís operation. A common implementation of the high speed counter would be to follow some cyclical event (such as a rotating shaft). For this you might want to program several steps for the counter, where each step changes some of the dynamic parameters of the HSC, and attaches a different interrupt routine to the same interrupting event. The last step might re-attach the original interrupt routine (forming a loop), or it might not. The following example illustrates a simplified, three-step HSC implementation. A description of each step follows.

SBR 0This subroutine contains the initialization of the counter. The counterís current value is assigned to 0 (CV = 0). The counterís Preset is assigned to 1000 (PV = 1000). The counting direction is UP. Event 12 (CV = PV for HSC0) is attached to INT 0, and the counter is started.

INT 0 When the counter has reached its first preset of 1000, INT 0 is executed. The counter Preset is now changed to 1500. The direction is unchanged. Event 12 (CV = PV for HSC0) is re-attached to INT1, and the counter is re-started.

INT 1When the counter has again reached its preset value (1500), INT 1 is executed. At this point, we change the Preset to 1000 (PV = 1000), change the counting direction to DOWN, attach INT 1 to event 12 (CV = PV for HSC0), and re-start the counter.

INT 2When the counter has counted down to the preset of 1000, INT 2 is executed. At this point, we set the current value to 0 (CV = 0), and change the counting direction to UP. Event 12 is re-attached to INT 0, which completes the loop of the counterís operation.

The following diagram shows a graph of the counterís current value over time. Each (CV = PV) interrupting event is labeled with the INT routine that was called for that event.

Time ->

STEP 4 Generate the Code

After you configure parameters for your HSC, you can review the list of subroutines/interrupt routines used by the counter. This list is for reference only.

Click on "Finish" to allow the wizard to generate the necessary program code for the HSC. The code consists of a subroutine that contains the initialization code for your high speed counter. In addition, an interrupt routine is generated for each event that you chose to program. For multiple-step implementations, an interrupt routine is generated for each step.

Note: You must place a call from your main program to the subroutine that holds your initializing code in order to enable the counter to operate.