Technical FAQs

Ask a Question

How do you configure a M221 High Speed Counter?

Introduction
The High Speed Counter function block can be configured by SoMachine Basic to perform any one of the following functions:
  • Dual Phase [A=Pulse, B=Direction] (or Up/Down counter)
  • Dual Phase [Quadrature X2] (or Bi-phase counter)
  • Single Counter
  • Frequency Meter
The High Speed Counter supports counting of dual digital inputs up to frequencies of 60 kHz in single word or double word computational mode, and individual digital inputs up to frequencies of 100 kHz.
The High Speed Counter function block uses dedicated inputs and auxiliary inputs and outputs. Refer to the M221 Logic Controller - Hardware Guide for more information on inputs and outputs.
You must initialize the High Speed Counter function in the Configuration tab using the High Speed Counter Assistant before using an instance of the function block. Refer to Configuring High Speed Counters.
 
 
Graphical Representation
 
 
Inputs
The High Speed Counter function block has the following inputs:
Label
Description
Value
IN
Enable (required)
At state 1, the counting function or frequency measurement is enabled.
At state 0, the current value is held at its last value.
0 or 1
S
Preset input.
At state 1:
  • initializes the current value with the preset value for Dual Phase [Quadrature X2] or Dual Phase [A=Pulse, B=Direction] with down function in progress
  • resets the current value to 0 for Single Counter or Dual Phase [A=Pulse, B=Direction] with up function in progress
In addition, this also initializes the operation of the threshold outputs and takes into account any user modifications to the threshold values set in the properties window or the program.
0 or 1
The High Speed Counter function block is associated with the following input objects:
Object
Type
Description
Value
%HSCi.P
%HSCi.PD
WORD
DOUBLE WORD
Preset value
%HSCi.S0
%HSCi.S0D
WORD
DOUBLE WORD
Threshold 0
%HSCi.S1
%HSCi.S1D
WORD
DOUBLE WORD
Threshold 1
%HSCi.T
WORD
Time base
%HSCi.R
BOOL
Enable reflex output 0
At state 1 enables the reflex output 0.
%HSCi.S
BOOL
Enable reflex output 1
At state 1 enables the reflex output 1.
 
 
Outputs
The High Speed Counter function block has the following outputs:
Label
Description
Value
F
Overflow
Set to 1 if an arithmetic overflow occurs.
0 or 1
U
Counting direction
Set by the system, this bit is used by the Dual Phase counting functions to indicate the direction of counting.
0: Down counting
1: Up counting
TH0
Threshold bit 0
Set to 1 when the current value is greater than or equal to the threshold value S0 (%HSCi.S0).
Test this bit only once in the program because it is updated in real time. The user application is responsible for the validity of the value at its time of use.
0 or 1
TH1
Threshold bit 1
Set to 1 when the current value is greater than or equal to the threshold value S1 (%HSCi.S1).
Test this bit only once in the program because it is updated in real time.
0 or 1
The High Speed Counter function block is associated with the following output objects:
Object
Type
Description
Value
%HSCi.V
%HSCi.VD
WORD
DOUBLE WORD
Current value
%HSCi.C
%HSCi.CD
WORD
DOUBLE WORD
Capture value
%HSCi.U
BOOL
Counting direction
0: Down counting
1: Up counting
%HSCi.F
BOOL
Overflow
0: No overflow
1: Counter overflow
 
 
Properties
The High Speed Counter function block has the following properties:
Property
Value
Description
Used
Activated / deactivated checkbox
Indicates whether the address is in use.
Address
%HSCi, where i is from 0 to 3, depending on the type(s) of counters configured.
i is the instance identifier.
Refer to the M221 Programming Guide for the maximum number of High Speed Counter objects.
Symbol
User-defined text
The symbol that uniquely identifies this object. For details, refer to the SoMachine Basic Operating Guide (Defining and Using Symbols).
Preset
  • from 0 to 65535 for %HSCi.P
  • from 0 to 4294967295 for %HSCi.PD
Preset value to initialize the HSC current value (%HSCi.P, %HSCi.PD).
Not valid for the Frequency Meter.
S0
  • from 0 to 65535 for %HSCi.S0
  • from 0 to 4294967295 for %HSCi.S0D
Threshold value 0 is used as a comparator with the current value.
The value of S0 must be less than S1 (%HSCi.S1).
S1
  • from 0 to 65535 for %HSCi.S1
  • from 0 to 4294967295 for %HSCi.S1D
Threshold value 1 is used as a comparator with the current value.
The value of S1 must be greater than S0 (%HSCi.S0).
Time Base
100 ms or 1 s for %HSCi.T
Frequency measurement time base
Comment
User-defined text
A comment to associate with this object.
 
 
Special Cases
This table shows a list of special operating of the High Speed Counter function block:
Special Case
Description
Effect of cold restart (%S0=1)
Resets all the High Speed Counter attributes with the values configured by the program.
Effect of warm restart (%S1=1)
Has no effect.
Effect of controller stop
The High Speed Counter stops its function and the outputs stay in their current state.
NOTE: When the controller stops, the reflex outputs stay in their current state only if the fallback behavior of the tasks is configured to maintain values of the outputs. For more information on configuring fallback behavior, refer to Fallback Behavior.
Was this helpful?
What can we do to improve the information ?