From MAE/ECE 148 - Introduction to Autonomous Vehicles
Jump to navigation Jump to search

Encoder Project Introduction

Our project involved adding an encoder component to the MAE 148 Autonomous Vehicle we previously built. The motivation for this project was to have access to data concerning the speed and distance travelled in order to improve speed control.

The original configuration of the vehicle controlled the speed of the car by controlling the voltage from the battery to the motor. This voltage was based on data from user inputs(explain in step 1). The encoder allowed the voltage to be based on data concerning the actual current speed, giving the vehicle could have cruise control capability.

Team Members

Selina Wade

Torin Halsted

Sepehr Foroughi

Hoang Thai


Step One: Build the Autonomous Vehicle


Original Wiring Schematic
Original Wiring Schematic Legend

Acrylic Board: We used calipers to measure the dimensions of the mounts on our base and then laser cut an acrylic board with holes to mount our 3D printed camera mount.

Camera Mount: We designed and printed a mount to hold the camera at the appropriate height and angle to capture the track. We also included a slot to pass the cord band through without damaging it.

RPI Holder: We 3D printed a small piece to hold the RPI on our car.

Wiring Schematic: We clearly documented our wiring (right).

Using RPI

GPU Training

Autonomous Success

Step Two: Mount the Encoder

Mounted Encoder and Laser Cut Gear

We used an optical quadrature rotary encoder with a resolution of 600 pulses per revolution. This encoder produces two square wave outputs which can be used to determine the distance, speed, and direction that the encoder is is turned.

Step Three: Ardiuno Communication

As stated before, the encoder that we used sent 600 pulses per revolution. This resolution is amplified by gear ratio so every turn of the wheel causes approximitely three revolutions of the encoder. Additionally, for each pulse from the encoder, four readings can be taken (at the up phase and down phase of each swquare wave). Therefore, the encoder records 27400 data points per meter travelled, meaning at a maximimum velocity of approximately four meters per second, it records at 109.6 kHz. Meanwhile, the Raspberry Pi used for the remainder of our car controls runs its code at only 20 Hz. For this reason, we could not use the Raspberry Pi to directly read the response from the encoder. Instead, we used a Arduino Uno board to read and count the pulses of the encoder, then calculate the distance travelled and current velocity before sending this information over serial to the RPI and an LCD display at a rate of 20 Hz.

When connecting the encoder to the Arduino, we used the digital pin inputs and configured Arduino's built-in pull up resistor. Then, we wrote a code using the attachInterrupt function to signal a change whenever either the A or B phase signal went changed from HIGH to LOW or LOW to HIGH voltage. This ensured maximum resolution and accuracy because the interrupt saves time and ensures that signals are not skipped.

Once the Arduino code was working we calibrated it manually by driving the car 1m ten times and recording then averaging the number of counts the Arduino recorded to find a value of 27400 counts/meter, which gaves us an accuracy of 0.0365mm.

Step Four: MATLAB Simulation

Step Five: Raspberry Pi Communication

Step Six: Testing