Program instructions
7.6 Counters
S7-200 SMART
System Manual, 09/2015, A5E03822230-AC
245
Example: high-speed counter instruction
MAIN
On the first scan, call SBR_0.
LD SM0.1
CALL SBR_0
SBR0
On the first scan, configure HSC0:
1. Enable the counter
– Write a new current value.
– Write a new preset value.
– Set the initial direction to
count up.
– Select the reset input to be ac-
tive high.
– Select 4x mode.
2. Configure HSC0 for AB quadra-
ture phase with reset input.
3. Clear the current value of HSC0.
4. Set the HSC0 preset value to 50.
5. Attach event 12 to interrupt rou-
tine INT_0. The interrupt is exe-
cuted when HSC0 current value =
preset value.
6. Global interrupt enable
7. Configure HSC0.
LD SM0.1
MOVB 16#F8, SMB37
HDEF 0, 10
MOVD +0, SMD38
MOVD +50, SMD42
ATCH INT_0, 12
ENI
HSC 0