Example: high-speed counter instruction
LAD
MAIN
SBR0
S7-200 SMART
System Manual, V2.3, 07/2017, A5E03822230-AF
On the first scan, call SBR_0.
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.
Program instructions
7.6 Counters
STL
Network 1
LD SM0.1
CALL SBR_0
Network 1
LD SM0.1
MOVB 16#F8, SMB37
HDEF 0, 10
MOVD +0, SMD38
MOVD +50, SMD42
ATCH INT_0, 12
ENI
HSC 0
283