Siemens Simatic S7 Series System Manual page 240

Hide thumbs Also See for Simatic S7 Series:
Table of Contents

Advertisement

Program instructions
7.6 Counters
Initialization of modes 3 and 4
The following steps describe how to initialize HSC0 for single-phase up/down counter with
external direction control (modes 3 and 4):
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 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 reset input to be active high
3. Execute the HDEF instruction with the HSC input set to 0 and the MODE input set to one
of the following:
– Mode 3 for no external reset
– Mode 4 for external reset
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. In order to capture direction changes, program an interrupt by attaching the direction
changed interrupt event (event 27) to an interrupt routine.
8. In order to capture an external reset event, program an interrupt by attaching the external
reset interrupt event (event 28) to an interrupt routine.
9. Execute the global interrupt enable instruction (ENI) to enable interrupts.
10. Execute the HSC instruction to cause the CPU to program HSC0.
11. Exit the subroutine.
240
System Manual, 09/2015, A5E03822230-AC
S7-200 SMART

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic s7-200 smart series

Table of Contents