Siemens SIMATIC S7-200 System Manual page 144

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

Advertisement

S7-200 Programmable Controller System Manual
3.
Execute the HDEF instruction with the HSC input set to 1 and the MODE input set to one of
the following: 9 for no external reset or start, 10 for external reset and no start, or 11 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
enabling interrupts (ENI) 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 interrupts.
10. Execute the HSC instruction to cause the S7-200 to program HSC1.
11. Exit the subroutine.
Initialization Mode 12
The following steps describe how to initialize HSC0 for counting pulses generated by PTO0
(Mode 12).
1.
Use the first scan memory bit to call a subroutine in which the initialization operation is
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 SMB37 according to the desired control operation. For
example:
SMB37 = 16#F8
3.
Execute the HDEF instruction with the HSC input set to 0 and the MODE input set to 12.
4.
Load SMD38 (double-word-sized value) with the desired current value (load with 0 to clear
it).
5.
Load SMD42 (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 12) to an interrupt routine. See the section that
discusses the Interrupt Instructions for complete details on interrupt processing.
7.
Execute the global interrupt enable instruction (ENI) to enable interrupts.
8.
Execute the HSC instruction to cause the S7-200 to program HSC0.
9.
Exit the subroutine.
Change Direction in Modes 0, 1, 2, or 12
The following steps describe how to configure HSC1 for Change Direction for Single Phase
Counter with Internal Direction (Modes 0, 1, 2, or 12):
1.
Load SMB47 to write the desired direction:
SMB47 = 16#90
SMB47 = 16#98
2.
Execute the HSC instruction to cause the S7-200 to program HSC1.
130
Produces the following results:
Enables the counter
Writes a new current value
Writes a new preset value
Sets the direction to count up
Sets the start and reset inputs to be active high
Enables the counter
Sets the direction of the HSC to count down
Enables the counter
Sets the direction of the HSC to count up

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents