Digital Input (Quadrature Decoder)


Operator Menu Location: Generic Hardware Operators Digital Inputs

Operator Bitmap:
 

Functional Description:
The Quadrature Decoder Digital Input generic hardware operator provides access to a pair of high-speed digital input channel resources in the physical hardware capable of decoding quadrature encoders. When the generic operator is linked to a specific hardware resource, its output values will correspond to the physical signals attached to the hardware.

A quadrature encoder is a device that translates rotational motion into two digital signals that can be processed to determine position and direction of rotation. Quadrature decoding is the process of taking the encoder output signals and determining position (and any derivatives of interest) and direction of rotation. In its most basic form, a quadrature decoder produces count pulses that indicate a fixed unit of rotational motion and a direction signal that indicates either clockwise or counter-clockwise rotation.

There are three different resolutions that quadrature decoders can operate at---1x, 2x, and 4x. A 1x decoder produces a count pulse and updates the direction signal only on the rising edge of one of the channels. A 2x decoder produces a count pulse and updates the direction signal on each edge of one of the channels. A 4x decoder produces a count pulse and updates the direction signal on each edge of both channels. The Quadrature Decoder operator in Design Pad is a 4x decoder.

The Quadrature Decoder operator maintains scaled position, velocity, acceleration and jerk information for the associated digital inputs. Initial values can be provided for all of these quantities.

As some quadrature encoder applications require more than the 7 digits of precision for position information that the analog signal types used in Design Pad provide, the operator provides a set of 5 position outputs that together provide much greater precision. Each one of these outputs provides 4 decimal digits of precision, except the most significant one, which provides 3. A corresponding set of inputs is also provided for setting a high-precision initial position.

The Quadrature Decoder operator inputs are listed below.

Input

Name

Description

Range

R

Reset/Load

Sets the position outputs to the value given on the load inputs
(0 if not connected), and sets the other outputs to their initial values

[LOW, HIGH]

Load 5

Digits 16-18 of the scaled high-precision position

[-922, 922] with same sign as others

Load 4

Digits 12-15 of the scaled high-precision position

[-9999, 9999] with same sign as others

Load 3

Digits 8-11 of the scaled high-precision position

Same as above

Load 2

Digits 4-7 of the scaled high-precision position

Same as above

Load 1

Digits 0-3 of the scaled high-precision position

Same as above


And the operator outputs are:

Output

Name

Description

Range

D

Direction

Indicates direction of rotation

[LOW, HIGH]

LC

Low-precision position

Scaled position output as a single number,
but limited to 7 decimal digits of precision

Approximately [-3.402823E+38, 3.401823E+38] with 7 digits of precision

V

Velocity

Scaled velocity (counts/sec when scale factor is 1)

Same as above

A

Acceleration

Scaled acceleration (counts/sec/sec when scale factor is 1)

Same as above

J

Jerk

Scaled jerk (counts/sec/sec/sec when scale factor is 1)

Same as above

HC1

High-precision position 5

Digits 16-18 of the scaled high-precision position

[-922, 922] with same sign as others

HC2

High-precision position 4

Digits 12-15 of the scaled high-precision position

[-9999, 9999] with same sign as others

HC3

High-precision position 3

Digits 8-11 of the scaled high-precision position

Same as above

HC4

High-precision position 2

Digits 4-7 of the scaled high-precision position

Same as above

HC5

High-precision position 1

Digits 0-3 of the scaled high-precision position

Same as above


If the quadrature encoder being used has counts per revolution, then the value of the position output after one revolution, will be as follows:

where SF is a scaling factor.
The factor of 4 in the numerator of the above expression is there because we have a 4x quadrature decoder, meaning we count two events for each pulse on each of the two phases of the quadrature encoder output.
If , SF = 1, and the decimal point position is 0, then the values on the high-precision outputs would be as follows:

Output

5

 

 

 

4

 

 

 

3

 

 

 

 

2

 

 

 

 

1

 

 

Digit

18

17

16

15

14

13

12

11

 

10

9

8

7

 

6

5

4

3

2

1

0

Value

0

0

0

0

0

0

0

0

 

0

0

0

0

 

0

0

0

1

2

0

0


If the decimal point position is changed to 2, then the values on the high-precision outputs would be as follows, since we have requested that two decimal places be shown in the high-precision outputs:

Output

5

 

 

 

4

 

 

 

 

3

 

 

 

 

2

 

 

 

 

1

 

 

 

Digit

18

17

16

15

 

14

13

12

11

 

10

9

8

7

 

6

5

4

3

 

2

1

0

Value

0

0

0

0

 

0

0

0

0

 

0

0

0

0

 

0

1

2

0

 

0

0

0


User-Defined Properties:
Object Name. A string label that identifies the operator

Display Reset/Load Input. This property determines if reset input pin R is visible in the schema diagram. Design Pad issues a warning upon processing the schema when the pin is visible but not connected. The warning message is not issued when the pin is not visible (when this property is not checked).

Units. Engineering units label used for readability.

Odometer Mode. If checked, all pulses increase position independent of direction, just like an odometer. If unchecked, pulses in one direction will increase position and pulses in the other direction will decrease position.

Invert Direction. Swap which direction of rotation is considered positive. Not relevant if odometer mode is used.

Scaling Factor. Raw counts will be divided by this value

Decimal Point Position. Location of decimal point in high-precision output. If n is the decimal point position, then the high precision output is multiplied by .

Initial Velocity. Velocity at reset

Initial Acceleration. Acceleration at reset

Initial Jerk. Jerk at reset

Comments:
Consider the following example usage. Suppose you have a piece of rotating machinery with a main shaft, and you wish to know the RPM of that shaft, the direction of rotation, and also maintain a count of the total number of revolutions. You have a quadrature encoder that provides 600 counts per revolution, and it is connected to the shaft of interest with 1:2 gearing (one revolution of the main shaft yields two revolutions of the quadrature encoder shaft).
Because this is a 4x quadrature decoder, one revolution of the encoder shaft will yield 2400 counts. Because of the 1:2 gearing, one revolution of the main shaft will yield two revolutions of the encoder shaft, and thus 4800 counts.

If we create a quadrature decoder operator and set its scale factor to 4800, the position output would give revolutions of the main shaft, and the velocity output would give revolutions per second, which could then be multiplied by 60 external to the operator to yield RPM. The direction output will indicate the direction of rotation. We want to check Odometer Mode in the property settings so that we keep track of total revolutions. Otherwise, the revolutions count would increase or decrease depending on direction. Note that when Odometer Mode is checked, the velocity output is really the speed, as it will always be positive.
If an odometer type function is desired, along with a velocity output whose sign depends on direction of rotation, then two quadrature decoder operators could be used, with each one configured accordingly.

See Also:
Digital Input (Event Timer), Digital Input (Frequency), Digital Input (Pulse Counter), Digital Input (Pulse Width)