Siemens Simatic S7-200 System Manual page 221

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

Advertisement

Initialization Modes 6, 7, or 8
The following steps describe how to initialize HSC1 for Two Phase Up/Down Counter with
Up/Down Clocks (Modes 6, 7, or 8):
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:
SM47 = 16#F8
3.
Execute the HDEF instruction with the HSC input set to 1 and the MODE set to 6 for no
external reset or start, 7 for external reset and no start, or 8 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.
S7-200 Programmable Controller System Manual
C79000-G7076-C230-02
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
Instruction Set
10-33

Advertisement

Table of Contents
loading

Table of Contents