Example Initialization Sequences For High-Speed Counters - Siemens SIMATIC S7 System Manual

Hide thumbs Also See for SIMATIC S7:
Table of Contents

Advertisement

7.6.6

Example initialization sequences for high-speed counters

HSC0 is used as the counter in the following descriptions of the initialization and operation
sequences.
● HSC0, HSC2, HSC4, and HSC5 support counting modes (0, 1), (3, 4), (6, 7), and (9, 10).
● HSC1 and HSC3 only support counting mode 0.
The initialization descriptions assume that you have just placed the CPU in RUN mode, and,
for that reason, the first scan memory bit is true. If this is not the case, remember that you
can execute the HDEF instruction only one time for each high-speed counter, after entering
RUN mode. Executing HDEF for a high-speed counter a second time generates a run-time
error and does not change the counter setup from the way it was set up on the first execution
of HDEF for that counter.
Note
Although the following sequences show how to change direction, current value, and preset
value individually, you can change all or any combination of them in the same sequence by
setting the value of SMB37 appropriately and then executing the HSC0 instruction.
Initialization of modes 0 and 1
The following steps describe how to initialize HSC0 for single-phase up/down counter with
internal direction (modes 0 and 1):
1. Use the first scan memory bit to call a subroutine in which the initialization operation is
performed. Since you use a subroutine call, subsequent scans do not make the call to the
subroutine, which reduces scan time execution and provides a more structured program.
2. In the initialization subroutine, load SMB37 according to the desired control operation.
For example: SMB37 = 16#F8 produces the following results:
– Enables the counter
– Writes a new current value
– Writes a new preset value
– Sets the direction to count up
– Sets the reset input to be active high
3. Execute the HDEF instruction with the HSC input set to 0 and the MODE input set to one
of the following:
– Mode 0 for no external reset
– Mode 1 for external reset
4. Load SMD38 (double-word-sized value) with the desired current value (load with 0 to
clear it).
5. Load SMD42 (double-word-sized value) with the desired preset value.
S7-200 SMART
System Manual, V2.3, 07/2017, A5E03822230-AF
Program instructions
7.6 Counters
277

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic s7-200 smart

Table of Contents