This project was part of the course Mechatronic Design Laboratory (EE 192) taught by Prof. Ronald Fearing at UC Berkeley in the spring of 2016. I worked with two other graduate students to design an autonomous car that could follow a track defined by a white line with multiple turns, steps, and straightaways.
We were given a 1/10 scale chassis, as well as the following electronic components: line-scanning camera, DC motor, optical encoders, steering servo motor, mbed FRDM-KL25Z microcontroller, and 7.4V battery. We were tasked to do the following:
- Design the circuitry for the power conditioning, motor driver, steering, and sensing (aka, no breakout boards).
- Design a mounting system for the hardware.
- Program the microcontroller to read data from the line-scanning camera and encoders; track the line and estimate velocity; and command the steering servo and DC motor.
Our team designed three PCBs: (1) troubleshooting board, (2) motor driver and power conditioning board, and (3) MCU shield (signal routing and breakout pins). See a schematic of our circuitry below.
We programmed our microcontroller in C using the Keil uVision development environment. We broke the programming tasks into the following functions:
- Velocity sensing: Originally interrupt reads from optical encoders, but later switched to interrupt reads of back-EMF when the encoders were unreliable
- Velocity control: PID control of PWM duty cycle
- Camera read: Double-beat bit banging method to read the camera and automatic gain control to adjust for varying lighting conditions
- Track detection: Thresholded peak detection
- Cross detection: Search for secondary peak in range outside of primary peak
- Steering control: PD control of pulsewidth
- Troubleshooting: Turn on LEDs based on variables of interest and receive input from buttons
For mounting of PCBs and electronics, we considered weight distribution, camera vantage, adjustability, and assembly time. I designed and laser cut acrylic mounting boards for our PCBs and electronic components. I also machined posts to form the struts and rungs of a camera tower (see image below).
Our car demonstrated excellent stability in its steering and velocity control, and it could complete the ~300 ft. track in under 90 seconds. However, our car tended to lose the track on shaded segments, which we attributed to a fault in our automatic gain control. You can watch the final class race (scroll to 14:50). You can also view our final presentation.
Through this course project, I gained experience in the following areas:
- Autonomous system design
- PCB design using Eagle
- Soldering of small components
- Circuit troubleshooting using an oscilloscope
- Hardware design for electronics mounting
- DC motor and servo motor PID control
- Programming in C
Thank you to Prof. Fearing and the teaching staff! Thank you also to my teammates, Brian Cera and Edward Zhu.