FIRST Robotics Competition Blog

Community Browser
Showing results for 
Search instead for 
Did you mean: 

Encoder Feedback on Motor Control

NI Employee

This example explains how to use an encoder to determine the direction and rate of a motor controlled by your roboRIO. Encoder functions can be found in the Encoder subpalette, within the Sensors subpalette of the WPI Robotics Library palette on the block diagram.

These functions work specifically for a quadrature encoder, which contains two rotating disks A and B. Digital pulse outputs from A and B translate into speed, depending on the frequency of pulses, and direction, depending on the which disk’s pulse is detected first.

Connect your quadrature encoder to the DIO pins on the roboRIO such that encoder outputs A and B represent two separate DIO lines. Refer to the diagram shown on the front panel of the example for further direction. (Help > Find Examples > FRC Robotics > roboRIO > Robot and Motor)

How to include in 2015 Robot Project:

Begin VI

The automatically creates an encoder reference from two DIO inputs. (LabVIEW will generate two’s and convert these to source inputs for this VI). This reference can be passed to, which allows for further configuration of the encoder with inputs that specify the number of pulses to average for rpm calculations, as well as the minimum pulse rate before the encoder is considered stopped.


Robot Main VI

The is used to return information from the encoder about count, direction, and period of pulses, or if the encoder is stopped. Additionally, the can be used to reset the encoder to 0 between code executions.


Finish VI

The is used to close the reference to the encoder.



Kristen M

Automated Test Product Marketing Engineer
National Instruments