Grand PrIEEE

A 1/12th scale, autonomous, line-following car.



This car was designed with a team of four other people for GrandPrIEEE, a competition sponsored by the UCSD IEEE branch. The objective of the competition is for a small, electric car to autonomously navigate around a track made of one-inch-wide white tape. Contestants are ranked by the time it takes to complete the track during a flying or starting lap as well as the accuracy with which they follow the line. The track-following is judged by placing cones at a distance of one foot away from the track; for each cone that is hit by the car, two seconds are subtracted from the time it took to complete the course.


This project began as all projects do, by determining the requirements of the design. We quickly determined that we needed a line scan camera, a microcontroller, an H-bridge motor driver (which the rules specified could not be pre-made), a battery, and a chassis for the car.

Step 1: Designing a Motor Driver:

An H-bridge is a circuit that allows current to flow either forward or backwards across a load. The transistor arrangement is such that when A is high, current will pass from the top left to the bottom right and when B is high, current will pass from the top right to the bottom left. When both A and B are high, the H-bridge will enter shoot-through, an undesirable condition which shorts from VDD to GND. When both A and B are low, no current passes through the motor.

Our H-bridge design consisted of a full H-bridge so that the car would be capable of applying a reverse magnetic field over the motor in order to stop more quickly. The H-bridge would be switched with gate drivers in order to quickly apply charge against the gate capacitance of the high wattage transistors used to switch the motor on and off; a PWM switching scheme was designed to regulate the speed of the car.

The gate driver integrated circuits had an internal diode between VDD and the high-side bootstrap pin. This internal diode was insufficient to handle the amount of current required to rapidly switch the power transistors and failed in the first design of the H-bridge causing an internal short between VDD and the high-side bootstrap. This caused the incorrect gate driver pin to go high and causing a short. Extra precautions were added such as a high-current switch and a 10 amp fuse.

After installing an additional high-power diode to each of the gate drivers and adding the above safety features, the H-bridge design successfully powered a motor in forward drive mode with a PWM signal generated by a microcontroller.

Step 2: Assembling the Chassis:

A carbon fiber RC indoor racing chassis with a rear differential and front and back suspension was selected. The chassis was assembled and tested with the motor driver circuit to ensure proper gear fitting and assembly. The suspension was set slightly tight to minimize body tilt on corners.

Step 3: Collecting Data:

The PCB was designed to accommodate two microcontrollers: a Teensy 3.5 and an ATmega328p. Because we were not certain how long the control loop would take to run on the Teensy, the ATmega chip was provided to alleviate the camera processing workload from the Teensy. The ATmega chip was connected to the Teensy via SPI and had its GPIO routed to header pins. This not only allowed the ATmega328 to communicate with the Teensy but also allowed the Teensy to act as an AVR In-System Programmer to make changes to the code on the ATmega chip. However, in the final version of the code, the control loop was efficient enough that running the control loop and the camera processing on the Teensy was faster than using the ATmega in parallel.

In order to track the line, a one-dimensional line scan camera was chosen. The camera returns an analog value for the brightness at each pixel along a horizontal line. Differentiating the line data shows where the edges of the relatively brighter white line is along the line scan. This allows the microcontroller to determine the center point of the track and to determine its deviation from the car's current direction. Additional filtering algorithms were put in place to compensate for poor, varying room lighting. When the line center is left of the car's direction, the front wheels will turn left to compensate. Additional algorithms were added to account for loss-of-line situations that might occur on sharp turns.

Speed information was collected by hall effect sensors near the front wheels which detected magnets which were attached to the interior of the tires. The rear wheels could not be used for speed detection both because of the differential and because of the potential for wheel slipping at high speeds.

Step 4: The PCB:

In order to fit all of the electronics in the limited space on the car, a stacked board system was designed. The electrical subsystems were separated into the main board, the motor board, and the LED board with the two high current boards sitting above the main board on elevated headers. This had the added benefit of separating the high current systems from the low-current microcontrollers on the main board. The motor board and the LED board were separated into two boards in order to provide space for the rear suspension piston.

The motor board was a two layer board with thick traces to allow for the high current paths to the motor. The header pins down to the main board High lumen LED driver boards were designed to act as headlights handle uneven lighting situations that had reportedly been a problem in previous competitions. LED boards were designed with heat-sinks and vias for more efficient heat distribution. However, in later testing, a ground differential problem between the LED driver board and the main board caused burn-out of ground wires on the main board which were off the primary current path. This ground differential problem was irreparable at the stage this problem was discovered and additional filtering systems were designed in software to accommodate the lack of headlights.

Another benefit of the modular, 3-layer design of the PCB is that if any of the sub-layers fail during operating, they can easily be switched out for another module. This became useful during testing when the car was accidentally stepped on by another team. A quick replacement of the motor driver board allowed up to continue testing while part of the team repaired the damaged motor driver.

Step 5: Testing:

During testing we encountered a problem where the gate driver chips would die unexpectedly. We noticed that the chips that would most frequently die were the forward gate drivers and they died following start ups at high feet-per-second speed and we hypothesized that the reverse current through the bootstrap components of the gate drivers was overloading as the chips shifted from off to a high PWM on-time. This occurred largely because of the omission of the flyback diodes from the MOSFETs on the H-bridge for space reasons. Because the competition allowed for flying laps, we implemented a ramp start which increased the acceleration to the maximum acceleration level over a number of seconds. This reduced the reverse current generated by the motor and resolved the gate driver burn-out issue.

At 4AM on the night before the competition we were about to conclude testing and catch a few hours of sleep before arriving at the competition room at 8AM the next day. On our last run, a member of another team was not paying attention and stepped directly on top of our car. The modular design of the car came in handy here because we were able to remove and replace the damaged motor driver board and test the car again to ensure that no other components had been damaged. The next few hours were spent replacing components on the damaged motor driver board and retesting the car instead of sleeping.

UC San Diego GrandPrIEEE:

Practice for the competition took place in a room with dramatically different lighting and carpet coloration than the competition; as a result, the filtering algorithm used during practice failed during the testing period before the competition and an alternative filtering method was implemented. Prior to the competition, we devised a "pit crew" strategy with an action flowchart to determine settings or methodologies to change based on the success or failure of the car for certain speed and algorithm settings. Switches on the main board determined the target feet-per-second of the car as well as the feet-per-second reduction during turns. Following the repeated success of the car on the track with proportional turning-speed reduction based on wheel angle, the car ultimately failed at a target speed of approximately 10 feet-per-second. Our team had a post-crash reset list which was intended to prevent any performance issues such as loose wires, misaligned cameras, or motor gearing disconnects. After performing the check list, we attempted the track again at 9.5 feet-per-second and beat the previous time for 9.5 feet-per-second target speed with a flying lap. When accounting for corner deceleration, the final average speed of the car was approximately 9 feet-per-second. Ultimately our team finished the race with the most accurate line following and the 3rd place time out of 14 competing teams.


The morning after a long, Friday-night drive from San Diego to Davis we arrived at the UCD competition room and immediately noticed the inconsistent and dim lighting and non-regulation line coloration. Initially this caused issues with line recognition as parts of the floor would be better lit than other parts and the line contrast was significantly diminished; this caused issues with incorrect line identification. After reverting the filtering algorithm to the same one used in the original testing room we were able to get a mostly accurate track on the line but encountered issues with sharp turns. Our initial attempts at the competition course proved successful at lower speeds of 7 feet-per-second but the car failed on dimly lit turns and crashed. Increasing the corner deceleration multiplier allowed us to increase the target speed to 9.5 feet-per-second and to complete the 349 foot course with a time of 41.095 seconds and an average speed of 8.49 feet-per-second.