Testing the native encoder utility

30 November 2012

OpenDAQ has a built in feature that allows straight reading of digital quadrature encoders.

Encoders are position and orientation sensors, commonly used as a reference or active feedback to control position. They are commonly based on magnetic or optic means. There are linear and also rotary encoders and they may be absolute or incremental.

The most common type of incremental encoder uses two output channels or phases (A and B) to sense position. Using two code tracks with sectors positioned 90 degrees out of phase, the two output channels of the quadrature encoder indicate both position and direction of rotation. By monitoring the number of pulses and the relative phase of signals A and B, the position and direction of rotation can be tracked. They are called “quadrature encoders”.

The encoder input of openDAQ is based on external interrupts at pin D6. Quadrature encoders must be connected to digital pins D5 and D6. Its functionality consists on counting number of edges coming through the digital input D6 while keeping track of the direction of the movement, by reading D5 on each interrupt.

For this experiment, we will be using inear Encoder MT-42 model of Fagor. It is an optical quadrature encoder with a total length of 420mm, that outputs TTL quadrature signals. The device can be powered directly from openDAQ, as it only needs 5V and 100mA of power supply.

To connect the encoder to the openDAQ, we are using Data Output Cable type EC-3-TD, supplied with the encoder. The encoder signals are available at the following terminals from adapter cable EC-3-TD:


Cable color















The signals A and B are the output pulses of the encoder used to determine their displacement and speed, and according to their relative phase we can know the direction of movement. The signal Io is the difference between the two signals A and B, but it was not used for this experiment.

Reading encoder output with openDAQ is extremely simple: we just connected signals A and B to inputs D5 and D6, as well as the power supply connections.

Using DAQControl demo, we go to the third flange and start Encoder utility. We have to configure first the maximum resolution of the encoder. This parameter sets the maximum distance that the encoder is able to read, to avoid false readings. In this case, we have set 20mm as the maximum displacement to be measured.

As you can see in the figure, interpreting the results is very straightforward: