Counter Triggered Function
The count value is indicated in the
I.Counterxx.Count
tag. You can use an input
trigger (Input Z or Input00) to trigger functions for the counter.You use counter functions to manipulate the count value in the module tags that are
associated with each function. You can configure the input trigger for the counter
functions in Module Properties → Device Definition → Counter → Input Z Function or
Input00 Function.
IMPORTANT:
SA power is required to use Input00.
Store
The Store function lets a counter store its current count, direction, instantaneous
frequency, acceleration, instantaneous pulse width, and revolution count in the
corresponding
I.Counterxx.
<StoredTag> tag.StoredTag | ||
|---|---|---|
StoredCount | StoredPulseWidth | ScaledStoredCount |
StoredRevolutionCount | StoredAccel | ScaledStoredFrequency |
StoredFrequency | StoredDirection | ScaledStoredAccel |
You can trigger the Store function using the input trigger or the
O.Counterxx.Store
tag. You can capture the current count value even when
the counter is counting at the full 1 MHz speed.Hold
The Hold function lets a counter hold its current values, regardless of the incoming
A or B input data. You can set and trigger the Hold function using the input trigger
or the
O.Counterxx.Hold
tag.The counter enters Hold state upon receiving a rising edge of the input trigger or
O.Counterxx.Hold
. The counter holds its last count value until it exits
Hold state upon receiving a falling edge of the input trigger or
O.Counterxx.Hold
.Load
The Load function lets a counter load new count and revolution count values. You can
set and trigger the Load function using the input trigger or the module output
tags.
When a Load function is triggered, the value of
O.Counterxx.LoadCountValue
is
copied to I.Counterxx.Count
and the value of
0.Counterxx.LoadRevolutionValue
is copied to
I.Counterxx.RevolutionCount
.Reset
The Reset function lets the counter reset. When a counter is reset, the
I.Counterxx.Count
tag and I.Counterxx.RevolutionCount
tag are set
to 0.When the
C.Counterxx.ResetTimeDerivedValues
tag is set to 1, the following
values are also reset:- Frequency, Avg Frequency, Scaled Frequency, and Scaled Freq Avg
- Pulse Width and Avg Pulse Width
- Acceleration, Avg Accel, Scaled Accel, and Scaled Avg Accel
You can trigger the Reset function using the input trigger or the
O.Counterxx.Reset
tag.Invert Input Trigger
An input trigger can be configured as active high or active low by inverting the
input. You can invert the input in Module Properties → Device Definition → Counter →
Invert Input Z or Invert Input00.
Inverting the input trigger does not affect the usage of output tag triggers. For
example, Input Z is used as the trigger for Hold and it is inverted. In this case,
the counter enters the Hold state upon receiving a falling edge of Input Z or rising
edge of
O.Counterxx.Hold
. The counter exits the Hold state upon receiving a
rising edge of Input Z or falling edge of O.Counterxx.Hold
.Example of Using Counter Functions
After power on or power recovery, before using the Count and Revolution tags, these
tags must be set to a known value using the Reset or Load function. One method is to
perform a reset operation when a certain position is detected.
For example:
- Input Z is connected to a sensor that detects if the encoder is in the zero position.
- Input Z is configured to trigger the Reset function.
- Activate the device that is connected to the encoder to perform one whole loop. Once the encoder is in the zero position, Input Z is activated and it triggers the Reset function. The Count and Revolution is reset to 0.
If the zero position is not position 0, the Load function can be used to set the
Count and Revolution to a known value.
Provide Feedback