This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Quadrature Encoders

Control quadrature encoders connected to Arduino® hardware

Quadrature encoders are incremental encoders that you can use to measure the speed and direction of a rotating shaft. They convert the angular rotation of the shaft to digital pulses that tell you which direction the shaft moves. By measuring the time difference between the pulses, you can derive the speed. You can use quadrature encoders in bidirectional position sensing and length measuring applications. You can decode quadrature signals to use them as a sensory input to a system to determine the speed, acceleration, and position of the rotary devices. The three types of decoding — X1, X2, and X4 — provide 1, 2, or 4 pulses, respectively, at each rotational cycle. X4 decoding is only supported as it provides the highest accuracy and angular resolution.

Before you use quadrature encoder functions, create an Arduino object using arduino. For more information, see Connect to Arduino Hardware.


rotaryEncoderConnection to quadrature encoder on Arduino hardware
resetCountSet count value to zero or user-specified value
readCountRead current count value from encoder with X4 decoding
readSpeedRead current rotational speed


Control Rotary Encoder Knob

This example shows how to use the MATLAB® Support Package for Arduino® Hardware to control a 12-step rotary encoder with a built-in push button.

Steer Two-Wheel Robot

This example shows how to use the MATLAB® Support Package for Arduino® Hardware to steer a two-wheel Arduino-based robot with closed-loop control.

Related Information