






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







By: Vasko Popstojanov Ramtin Hosseini Tyler Wickenhauser Jane Tu
ECE 395 - Advanced Digital Projects Laboratory Fall 2008
TA: Zuofu Cheng
December 02, 2008
Auto accidents happen every hour causing severe injuries and damages. Most of these are due to recklessness or lack of attentiveness to the surroundings. Our goal is to design an autonomous control system that will assist drivers in collisions prevention. The control system is to only take over when a possible collision is detected, and default back to user control once it is cleared of hazards. We will be reverse-engineering a toy car and designing a control system using a microprocessor. The idea is to detect the distance between the car and its surrounding objects using sensors and to either redirect, stop, or restrict certain movement of the car. The project involves collaboration between software and hardware.
I. Goal
The goal of this project is to design an additional control system for a car to avoid collision. We implemented our design upon a toy car taken from a previous project to reduce unnecessary troubles and expenses in modeling of the car. The final design incorporates a PIC microcontroller, oscillator, ultrasonic sensors, MOSFETs, capacitors, and NAND-gates. An understanding of those components would provide us a better basic knowledge for future project designs, and the concept behind it may be enhanced for applications to normal vehicles, robots, and any movable objects.
II. Overview
The body of the car consists of a protoboard, mounting bracket, and two motors; the one in the back accelerates the back wheels, and the one in the front turns the front wheels. Initially we familiarized ourselves with MPLAB, PIC microcontrollers, and several on-chip peripherals with simple LED tests. Then we experimented with the analog outputs of the sensors. We also built an H-Bridge with MOSFETs to control the forward/backward movement of the car. Lastly we wrote the software for microcontrollers in C to evaluate its inputs and calculate its outputs to the circuitry. The remaining components and additional sensors are then attached to the circuitry plus some additional minor adjustments for the completion of this project.
I. Components
dsPIC30F
II. Hardware
The logic for the control system is primarily focused on the software inside the microcontroller. The final design uses a 40-pin dsPIC with 20MHz oscillator for clocking. The ultrasonic sensors are soldered, connected to the microcontroller inputs, and glued to the protoboard mounting bracket. The sensors output analog signals based upon their distance from the nearest object. The internal software then analyzes the signals and feed digital signals to H-Bridge that in turn controls the movement of the car to either stop, go backward, or turn.
Digital Signal p-channel MOSFET n-channel MOSFET 0 On Off 1 Off On
(Modes of the motor: forward/left, backward/right, stop/straight)
III. Software
We programmed the microchip in C using the MPLAB software. Originally, we used PIC18F4520 but had no success using its A/D Converter interface. Alternatively, we switched to dsPIC30F4013 and referenced the sample code presented in class. Initially we tested the sensor and microcontroller by lighting an LED. Then we switched to using on-chip UART and set up MAX232 Driver/Receiver and DE-9 Serial Port to display more information on the computer screen through Putty. This benefits us in process of debugging and estimating the sensor ranges by trial-and-error. Lastly we used the PWM to control the outputs to the h-bridge and thus control the car’s speed.
The objective for the software is to analyze the analog outputs from the ultrasonic sensors to detect nearby objects. Then depending on the location and distances of the objects, the dsPIC outputs corresponding digital signals to steer the car and avoid collision. To start off, we defined the I/O of individual pins. Then we created multiple sub-functions include initializing and utilizing the on-chip peripherals (UART, A/D Converter, PWM), and setting the outputs for each possible movement of the car. Below is a list of basic functionality for each function; refer to the code for more details.
Label Distance (approx) ADC output DIST9 ~5 ft 335 DIST8 ~4 ft 275 DIST7 ~30-36 inches 215 DIST6 ~26-30 inches 175 DIST5 ~22-26 inches 150 DIST4 ~16-22 inches 130 DIST3 ~14-16 inches 110 DIST2 ~10-12 inches 95 DIST1 ~6-12 inches 60 DIST0 <6 inches <
I. Obstacles