Quadrature Encoder Counter
Purpose
Counts edges generated by a quadrature encoder.
Description
The Quadrature Encoder Counter counts edges which were generated from a quadrature encoder. The \(A\) and \(B\) outputs of the encoder are connected to digital inputs on the RT Box. Optionally, an index signal \(I\) and differential input signals \(\bar{A}\), \(\bar{B}\) and \(\bar{I}\) can be connected.
The block outputs the current counter value (\(c\)), the current velocity in rad/s (\(\omega\)) and status information (\(s\)). The status information output provides a direction signal and a signal indicating whether an index pulse was received during the last simulation step.
The counter counts up or down depending on the sequence of input pulses. The parameter Direction (rising edge) specifies the sequence of rising edges which results in incrementing counter values.
Once the counter reaches the value specified in parameter Maximum counter value it is reset to zero on the next detected edge in positive direction. Vice versa, the counter is set to Maximum counter value when it is zero and detects an edge in negative direction. If connected and configured, the counter is also reset when a positive edge of the index input is detected.
The RT Box contains two independent Quadrature Encoder Counter units.
Parameters
General
- Maximum counter value
The counter is reset to zero when it has reached the Maximum counter value and detects an input edge in positive direction. The counter is set to the Maximum counter value when it is zero and detects an input edge in negative direction.
For correct velocity output, the Maximum counter value must match the number of line pairs of the encoder multiplied by the number of counted edges per line pair (see parameter Counter mode below) minus 1. If, for example, the encoder has 1024 line pairs and all edges of A and B are counted, the resulting value is 4095.
- Counter mode
Selects which edges of the input signal are counted.
- Direction (rising edge)
Selects the sequence of input pulses for incrementing the counter.
- Counter reset method
Selects whether the counter should be reset by a positive pulse on the index input or on overflow only.
- Counter reset condition
Selects the expected values of \(A\), \(B\) and \(I\) to detect a counter reset.
- Offline implementation
With the setting Continuous the inputs \(\theta\) and \(\omega\) are made available for offline simulation. With the setting Quadrature Encoded the block uses \(A\), \(B\) and \(I\) as a vectorized input signal.
Input
- Input type
Selects whether the input signals are differential or single-ended.
- Index input
If the index input is enabled, the counter is reset when an index pulse is detected.
- Digital input(s) for signal [A] or [A, /A]
Indices of the digital inputs for signal \(A\). If the signal is differential the value must be a vector with two elements where the second element specifies the input for the differential signal \(\bar{A}\). For single-ended inputs the value must be a scalar or a vector with one or two elements. The second element is ignored in the latter case.
- Digital input(s) for signal [B] or [B, /B]
Indices of the digital inputs for signal \(B\). If the signal is differential the value must be a vector with two elements where the second element specifies the input for the differential signal \(\bar{B}\). For single-ended inputs the value must be a scalar or a vector with one or two elements. The second element is ignored in the latter case.
- Digital input(s) for index signal [I] or [I, /I]
Indices of the digital inputs for signal \(I\). If the signal is differential the value must be a vector with two elements where the second element specifies the input for the differential signal \(\bar{I}\). For single-ended inputs the value must be a scalar or a vector with one or two elements. The second element is ignored in the latter case. The parameter value is ignored if the index input is disabled.