Siemens SIMATIC S7-200 System Manual page 143

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 SMB47 according to the desired control operation. For
example:
SMB47 = 16#F8
3.
Execute the HDEF instruction with the HSC input set to 1 and the MODE set to one of the
following: 6 for no external reset or start, 7 for external reset and no start, or 8 for both
external reset and start.
4.
Load SMD48 (double-word-sized value) with the desired current value (load with 0 to clear
it).
5.
Load SMD52 (double-word-sized value) with the desired preset value.
6.
In order to capture the current-value-equal-to-preset event, program an interrupt by
attaching the CV = PV interrupt event (event 13) to an interrupt routine. See the section on
interrupts.
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 interrupts.
10. Execute the HSC instruction to cause the S7-200 to program HSC1.
11. Exit the subroutine.
Initialization Modes 9, 10, or 11
The following steps describe how to initialize HSC1 for A/B Phase Quadrature Counter (for 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 SMB47 according to the desired control operation.
Example (1x counting mode):
SMB47 = 16#FC
Example (4x counting mode):
SMB47 = 16#F8
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
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 Instruction Set
Chapter 6
129

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents