Program instructions   
7.6 Counters 
  S7-200 SMART 
274  System Manual, V2.3, 07/2017, A5E03822230-AF 
Example: Reading and saving the current count value 
 
MAIN 
Save the value of HSC0 into 
VD200 when I3.0 transitions 
from OFF to ON. 
 
LD I3.0 
EU 
MOVD HC0, VD200 
Set current values and preset values with your program 
Each high-speed counter has a 32-bit current value (CV) and a 32-bit preset value (PV) 
stored internally. The current value is the actual count value of the counter, while the preset 
value is a comparison value optionally used to trigger an interrupt when the current value 
reaches the preset value. You can read the current value using the HC data type as 
described in the previous section. You cannot read the preset value directly. To load a new 
current or preset value into the high-speed counter, you must set up the control byte and the 
special memory double-word(s) that hold the desired new current and/or new preset values, 
and also execute the HSC instruction to cause the new values to be transferred to the high-
speed counter. The table below lists the special memory double-words used to hold the 
desired new current and preset values. 
Use the following steps to write a new current value and/or new preset value to the high-
speed counter (steps 1 and 2 can be done in either order): 
1.  Load the value to be written into the appropriate SM new current value and/or new preset 
value (see the table below). Loading these new values does not affect the high-speed 
counter yet. 
2.  Set or clear the appropriate bits in the appropriate control byte to indicate whether to 
update the current and/or preset values (bit x.5 for preset and x.6 for current). 
Manipulating these bits does not affect the high-speed counter yet. 
3.  Execute the HSC instruction referencing the appropriate high-speed counter number. 
Executing this instruction causes the control byte to be examined. If the control byte 
specifies an update for the current, the preset, or both, then the appropriate values are 
copied from the SM new current value and/or new preset value locations into the high-
speed counter internal registers. 
 
New current value (new 
SMD38  SMD48  SMD58  SMD138  SMD148  SMD158 
New preset value (new 
SMD42  SMD52  SMD62  SMD142  SMD152  SMD162 
 
 
Note 
Changes to the control byte and the SM loc
ations for new current value and new preset 
value does not affect the high
-speed counter until the corresponding HSC instruction is