Siemens Simatic S7-200 System Manual page 222

Programmable controller
Hide thumbs Also See for Simatic S7-200:
Table of Contents

Advertisement

Instruction Set
Initialization Modes 9, 10, or 11
The following steps describe how to initialize HSC1 for A/B Phase Quadrature Counter
(Modes 9, 10, or 11):
1.
Use the first scan memory bit to call a subroutine in which the initialization operations are
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 SM47 according to the desired control operation.
For example (1x counting mode):
SM47 = 16#FC
For example (4x counting mode):
SM47 = 16#F8
3.
Execute the HDEF instruction with the HSC input set to 1 and the MODE input set to 9
for no external reset or start, 10 for external reset and no start, or 11 for both external
reset and start.
4.
Load SM48 (double word size value) with the desired current value (load with 0 to clear
it).
5.
Load SM52 (double word size value) with the desired preset value.
6.
In order to capture the event of current value equal to preset, program an interrupt by
attaching the CV = PV interrupt event (event 13) to an interrupt routine. See Interrupt
Instructions for complete details on interrupt processing.
7.
In order to capture direction changes, program an interrupt by attaching the direction
changed interrupt event (event 14) to an interrupt routine.
8.
In order to capture an external reset event, program an interrupt by attaching the
external reset interrupt event (event 15) to an interrupt routine.
9.
Execute the global interrupt enable instruction (ENI) to enable HSC1 interrupts.
10. Execute the HSC instruction to cause the S7-200 to program HSC1.
11. Exit the subroutine.
10-34
produces the following results:
Enables the counter
Writes a new current value
Writes a new preset value
Sets the initial direction of the HSC to count up
Sets the start and reset inputs to be active high
produces the following results:
Enables the counter
Writes a new current value
Writes a new preset value
Sets the initial direction of the HSC to count up
Sets the start and reset inputs to be active high
S7-200 Programmable Controller System Manual
C79000-G7076-C230-02

Advertisement

Table of Contents
loading

Table of Contents