Internet Explorer is not a supported browser for TI.com. For the best experience, please use a different browser.
Video Player is loading.
Current Time 0:00
Duration 8:59
Loaded: 1.84%
Stream Type LIVE
Remaining Time 8:59
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected

[MUSIC PLAYING]

Hello, and welcome to our video over viewing interfacing TI microcontrollers with quadrature encoders. In this video, we take a look at how timers can be used to decode quadrature signals from optical incremental encoders into position and movement information. Note, throughout this presentation features are concepts related to motor control will be mentioned briefly for completeness and context, but are not covered in detail within this video. Refer to the content within the video's description for more information related to this.

To start off, what is it encoder? Encoders, also known as linear, rotary, or position encoders are mechanical devices which are often attached to motors or rotors. They encode information such as position, direction, and speed into a set of pulses, which can then be interpreted by microcontrollers. Different kinds of encoders employ a variety of sensing techniques, such as mechanical, magnetic, optical, and electromagnetic.

Each of these encoder sensing techniques also come in two different measurement types. Absolute encoders encode the absolute position of a motor at any point in time. Every point along the linear, or rotational axis of an absolute encoder is associated with a specific code, meaning, that the instantaneous position of the encoder is known right from powering the encoder.

Incremental encoders, also known as quadrature encoders, describe incremental changes in the position of the encoder. Rather than knowing the absolute position, incremental encoders encode position with respect to a known reference point. Throughout this video, we'll be focusing on optical incremental encoders.

Timers can be used to interface with quadrature encoders and derive important movement information like speed, direction, and position at a specific instant in time. Decoding these quadrature impulses involves feeding these signals into microcontrollers to measure signal information, such as their period and frequency. Some devices feature a specialized timer module specifically for interfacing with quadrature encoders.

Depending on the device, these modules could be called quadrature encoder pulses, or quadrature encoder interfaces. Other devices may also use a generic timer module to interface with incremental encoders. These quadrature encoders are used in various applications, such as sensor-based motor control and robotics.

An optical quadrature encoder is composed of a disk with a pattern of opaque and transparent slots along its periphery. The number of transparent slots on the encoder is known as the encoder resolution. The more slots an encoder has, the more precise the encoder position. Turning the encoder to its side, an optical quadrature encoder also consists of a light source on one side of the disk, and a pair of photo sensors on the other.

These photo sensors are responsible for producing the encoded pulse signals. They are offset from each other with respect to the light sensor, resulting in a phase difference in the generated pulse signals. The light source shines against the encoder disk. Light passes through the transparent slots, and is obstructed by the opaque parts of the disk.

As the shaft of the encoder rotates, the photo sensors detect a series of darkness and light, similar to a PWM consisting of low and high signals. This waveform pattern is known as quadrature signals, and they encode the rotational information of the quadrature encoder. An example of these signals is shown to the right.

Quadrature signals consist of a pair of channels, A and B, that are offset by 90 degrees. Depending on the device, the channels may also be referred to as phase inputs, or QEP inputs. The frequency and relative phase of these waveforms with respect to each other can be decoded into position, direction, and speed information when input into a microcontroller.

Now, let us look at a demonstration of the quadrature signals in motion. On the left is a 2D representation of the encoder. And on the right are the generated quadrature signals from the rotation of the encoder. As the encoder moves clockwise at a constant velocity, notice that channel A is leading channel B.

When the encoder stops, the quadrature signals pause at their current state. As the encoder changes direction, it moves counterclockwise. The most notable observation is that channel B is now leading channel A.

Quadrature encoders can also generate an additional signal known as a quadrature index. This can also be known as the zero position, or the reference point of the quadrature encoder. The quadrature index is an additional row along the encoder that has a single slot located at a fixed point.

This fixed point serves as the reference point for the encoder, and denotes the zero position. This index signal serves many purposes. It can be used to indicate when to begin monitoring the position, signals to the device when a complete resolution of the encoder disk has been made, and aids in position verification in the event of glitch signals.

Now that we've gone over the basics of quadrature encoders, we can move on to the process of decoding the signals into relevant position and movement information. This involves a timer module, which implements a quadrature decoder attached to a position counter. The three quadrature signals serve as inputs into the timer module.

The timer needs to be configured in capture mode, so that information, such as the rising, falling edges of the quadrature signals and the frequency can be captured. The quadrature decoder module decodes the quadrature waveforms into direction and clock signals, which are fed into a position counter that keeps track of the incremental position of the encoder. Both the direction generated by the quadrature encoder, and the current position tracked by the position counter can be read at any point in time.

Let's take a closer look at how the quadrature decoder generates the clock and direction information from the quadrature signals. An internal state machine determines the direction of motion based on the transitions of the two quadrature channels. Typically, a clockwise movement is associated with incrementing the position counter. And a counterclockwise movement decrements the counter.

Since the two channels must always have a phase difference of 90 degrees, they cannot switch states at the same time. This represents an illegal transition in the state machine, and triggers an error interrupt. The generated quadrature clock is sampled from the quadrature inputs. This clock is dependent on which edges are sampled from which channels.

For the highest resolution, the clock can be sampled from the rising and falling edges of both signals, resulting in a quadrature clock that is four times that of the input signals. You can also configure the decoder to sample just the rising, falling edges of a single channel. All of the generated information from the quadrature decoder is fed into the position counter to keep track of the incremental changes in position.

The position counter increments and decrements according to the quadrature direction signal coming from the quadrature decoder, an incremental or incremental change occurs on each pulse of the quadrature clock. When the position counter increments pass the maximum position value, it resets back down to zero. Likewise, when the counter decrements below zero, it will start back from the maximum position value. You can also choose to employ the index position, and have the position counter reset on each index signal to mitigate any potential drift that may occur from glitched signals.

Now, let us look at the quadrature decoder and position counter in tandem by monitoring a more detailed version of the quadrature animation seen before. The current value of the position counter can be seen in the bottom left. On the right, you can see the three quadrature inputs, the generated quadrature clock and direction signals, and the position counter, which operates at four times the frequency of the input signals.

The encoder has 44 slots. Meaning, that the maximum position is four times 44 minus one, which is 175. The position counter continue in increments as the encoder rotates clockwise and resets to zero on the index pulse. As the encoder stops, notice all pulses remain static at their last defined position. The quadrature direction signal drops low as the encoder rotates counterclockwise, and the position counter begins to decrement. The index signal occurs, and the counter is brought back to the maximum position value.

The final movement information that can be calculated is the rotational speed, or velocity of the motor encoder. The velocity is proportional to the frequency of the quadrature waveforms. Meaning, a faster moving encoder generates higher frequency quadrature waveforms. The velocity is given by the following equation, which depends on the frequency of the quadrature waveforms, and the resolution of the encoder being used.

For example, suppose we have a 1,000 slot encoder with quadrature signals pulsing at a constant 16.667 kilohertz. What is the speed of the motor in revolutions per minute? To find this out, simply substitute all of the known values into the velocity equation. The velocity is found as 16,667 multiplied by 60, then divided by 1,000. This equals 1,000.02, which means that the speed of the motor is approximately 1,000 revolutions per minute. This concludes interfacing with quadrature encoders training. For more information and hands-on labs related to encoders, microcontrollers, and motor control, please check out the links below. Thank you.

This video is part of a series