Pages

Ultra-Sonic Parking Assistant


Do you have a garage that is nearly too small for your automobile? Do you ever park farther than necessary from objects simply because you are scared to pull any closer? The Ultra-Sonic Parking Assistant allows you to park your car in front of any obstacle at any desired distance with no guesswork.

It works by emmitting a continuous stream of ultrasonic pulses from the front of your car and using the return times of the pulses to calculate distance. The current distance is then displayed on your dashboard, so you can easily judge how much farther you have to go. At the same time, the device emmits a sequence of audible beeps, the rate of which varies with distance. At close range, the beeps fade into a constant tone. You can quickly then learn to park as close as possible without diverting your eyes from your windshield.

This Parking Assistant is the perfect gift for the person in your household who enjoys useful gadgets. In addition, anyone who has a visual impairment due to age, disease, or otherwise can appreciate the benefits the Parking Assistant provides.


The point of the Parking Assistant is to record and accurately relay to the driver the distance to the closest obstacle in front of his or her car. In addition, It gives the driver audible cues so that he or she may park without diverting his or her attention. To perform these tasks, we knew that the system had to be relatively accurate, and perform updates at a high enough rate to be useful.
The parking assistant utilizes two Atmel AT90S8515 microcontrollers connected via one-way radio link. One microcontroller is mounted to the front of the car in a protected area or even behind the grill. Connected to it are an ultrasonic ranger capable of measuring distances in the range of 3cm to 3m and an AM digital radio transmitter. This controller continually transmits ultrasonic pulses via the ranger and measures their return times.

Following each return pulse, the microcontroller calculates the distance to the obstacle based on a fixed formula. It then transmits each distance using the attached transmitter to the second Atmel MPU which is equipped with a matched receiver.

In addition to the receiver, the second MPU is connected to a miniature speaker and an LCD. The LCD displays the current distance in centimeters, while the speaker emits short pulses with a period that varies directly with distance.

Three additional features are available through 3 of the pushbuttons available on the STK200. Button 7 calibrates the distance to 0 every time it is pressed, button 6 resets the receiver to report absolute distance, and button 4 toggles the speaker on and off, in case it becomes an annoyance to the driver.

This project uses two STK-200 boards with AT90S8515 microcontrollers, split into transmitter and receiver assemblies.

The transmitter would be mounted in a weatherproof module in the front of the vehicle. The 8515 instructs the Devantech SRF04 sonic ranger to send out a pulse by holding the pulse input trigger high for 10 microseconds, and measures the time until the pulse returns. The output of the ranger is connected to the input capture pin of the 8515, which waits for a falling edge on the pin. This edge causes a Timer1 capture event, which stores the time in a variable, then sets a flag. In the main program loop, the flag is detected, and the time is converted to a distance. Since we measure the time in clock cycles, we multiply the time by 29/4 to get the distance in centimeters (sound travels one centimeter in roughly 29 microseconds). Timer1 is preloaded to overflow if no echo is returned within about 36 milliseconds. The input capture is then ignored until another pulse is sent out.

Since the range of the ranger can be up to three meters, we store the distance as a 16 bit value, and wish to transmit all the bits over our serial link. Note that we use the serial transmit and receive pins on the 8515 itself, not the RS-232 output. This is due to the undesirable signaling levels of RS-232. The ports themselves are inverted RS-232, which caused us some problems. In inverted RS-232, the channel is held high between bytes; however our receiver could not hold the line high for more than about 10-13 microseconds. To solve this problem, we put high-speed inverters (HC7404s) on both transmitter and receiver to convert to regular RS-232. Once this is done, we are ready to transmit. To be sure that we are correctly receiving both bytes, we put the link in 9-bit mode. We first transmit the high byte of the distance with a '1' in the ninth bit, followed by the low byte with a '0' in the ninth bit. This ensures that a single byte missed will not propagate errors to further updates. If the bytes are not sent in the proper order, the receiver ignores the update. Since the updates are sent at 10 Hz, missing a few, or having a few transfer incorrectly, is not noticeable to the user.

The radiolink consists of an Abacom AM-TX1 transmitter and AM-HRR3 receiver, both operating at 433 MHz. Though the manual recommended a tuned-loop antenna on the transmitter, we found a l/4 dipole worked well. The transmitting board outputs the distance measurements through a blocking functions, so all measurements are transmitted. PortD.1 (TXD) is connected to the CMOS inverter, which in turn, drives the transmitter circuit. We connected the receiver through the inverter to PortD.0 (RXD), which is the serial receive. This board has a few more functions. First, it receives the two byte updates, correctly ordered, via the RXC ISR. Once a complete update is received, the main loop displays the distance on the attached LCD.

The second STK-200 also polls three buttons, which use the upper part of PortD (remember that Port0 and 1 are used by the serial communication). PortD.7 allows the user to recalibrate the distance measurement. The idea here is that the user can specify a position that they want to be at, and the calibrated distance will be zero at that position. The second button resets the calibration distance. This is needed, since the variable is stored in EEPROM, and is preserved even after reset.

The third button serves as a sound toggle. When sound is enabled, a speaker on PortA is driven with a 1 kHz square wave. The currently stored distance controls the pulse repetition frequency. The distance multiplied by four serves as the time between pulses. This means that at the maximum usable range of about 2.5m, there is a one second pause between pulses. As the car approaches an obstacle, the pulses become more rapid, until they become continuous at about 10 cm. This works off the calibrated distance, so a driver could set the calibrated distance for their favorite position, and simply more forward slowly until the sound is continuous.


The ranging system works fairly reliably, with only a few false updates. The distance measurement appears to be accurate out to over a meter, though detection at longer ranges is intermittent. It can track an object down to about 10 cm. Averaging several of the last updates would produce a distance reading less prone to jumps. The transmitter and receiver assemblies work well, but their range is disappointing. Despite trying a variety of antennas, we were unable to get reliable links past about 5 feet. We could try using a FM transmitter/receiver pair, which are less susceptible to noise, but have more problems with line of sight.

We also considered sending the data over the RS-232 link to a PC, which could serve as a data gathering mechanism. This would allow the device to serve as a distance/velocity/acceleration meter, using MATLAB to plot the curves based on the data sent.

We could also make several enhancements to the existing design. We would like to get the antennas tuned a bit better to operate at longer distances. The transmitter and ranger should be placed in a sealed, weatherproof shell for mounting on the front of a car. In addition, we could replace the sonic ranger with an IR detection system, which would be more resilient to the rough conditions encountered during operation on a real automobile.

There was also a lockup that occurred a few times on the receiver after using the calibration routine. However, we could not reproduce the effect or find a deadlock condition in the code.

CODE:


Block diagram of the transmitter. It consists of an Atmel board controlling the ultrasonic ranger and the RF transmitter.



 
Method Summary
init()
          Initialize all variables.
measure()
          Transmits a single pulse from the ultrasonic emitter.
t0_ovfl()
          Used to set system timer
t1_capt()
          Capture event happens on falling edge of ICP.
t1_ovfl()
          Timer1 overflow ends waiting for a pulse after 16.384 ms Stops timer1
TransmitDistance()
          Transmits the latest position reading out the RF transmitter

Method Detail

measure

void measure()
Transmits a single pulse from the ultrasonic emitter. Hold the ranger's input trigger high for > 10ms Starts timer1 at full clock to record time

init

void init()
Initialize all variables. Set serial port to 9 bit mode@1200 baud Sets ICP to capture on falling edge

TransmitDistance

void TransmitDistance()
Transmits the latest position reading out the RF transmitter

t0_ovfl

void t0_ovfl()
Used to set system timer

t1_capt

void t1_capt()
Capture event happens on falling edge of ICP. If waiting for response, load capture reg into currDist and stop timer1

t1_ovfl

void t1_ovfl()
Timer1 overflow ends waiting for a pulse after 16.384 ms Stops timer1
Source code
#include "90s8515.h"
#include <stdio.h>
#include <stdlib.h
#include <string.h >> #include <delay.h>
//number of milliseconds between measurements //measuring vars ch
#define pulseReload 20 ar done = 0; //set when a returning pulse is detected to indicate success
d returning pulse is valid unsigned int currTime; //the return time of the most recent pulse unsigned
char waiting = 0; //set when sending a pulse to determine whether a detect e int currDist; //the distance calculated from the most recently returned pulse. int pulseCount = pulseReload; //init time to next pulse
mitDistance(void); //sends the current distance measurement to the o
char reload0 = 256-62; //timer0 reload value (gives 1 ms interrupts) //function prototypes void measure(void); void init(void); void Tran sther 8515 void measure() { // printf("measuring\r\n"); TCNT1 = 0; //reset timer1 for measuring PORTC = 0xff; //raise pulse trigger line waiting = 1; delay_us(11); //hold high to send pulse
16*(207+1)) =
PORTC = 0x00; TCCR1B = 0x01; //start timer1, full clock } void init() { //setup UART UCR = 0x08 | 0x04; //enable transmit and 9th bit UBRR = 207; //set baud rate to approximately 1200 (4e6/ (1201.9 ~ 1200) //setup ranger on PortC DDRC = 0xff; //use PORTC as ranger output //setup timer0 TCNT0 = reload0; //preload timer 0 so that is interrupts after 1 mSec.
B = 0x00; //turn off timer1
TCCR0 = 3; //prescalar to 64 TIMSK = 0x02 | 0x08 | 0x80; //turn on timer 0 overflow ISR, timer1 overflow ISR, and input capture //setup timer1 for measuring, capture on falling edge TCCR 1 // printf("init complete\r\n"); #asm sei ;enable all interrupts #endasm } void TransmitDistance(void) { while(!USR.5) {}; UCR.0 = 1; //load one in 9th bit to indicate high byte
e(); //measure every pulseReload ms } if(do
UDR = currDist >> 8; //send the current distance while(!USR.5) {}; UCR.0 = 0; UDR = currDist & 0xff; } void main(void) { init(); while(1) { if(pulseCount <= 0) { pulseCount = pulseReload; measu rne) { done = 0; currTime >>= 3; currDist = currTime / 29; TransmitDistance(); //send the distance to be displayed to the driver } } } interrupt [TIM0_OVF] void t0_ovfl(void) { TCNT0 = reload0;
errupt [TIM1_OVF] void t1_ovfl(vo
if(pulseCount > 0) pulseCount--; } interrupt [TIM1_CAPT] void t1_capt(void) { TCCR1B = 0x00; if(waiting) { currTime = ICR1; //record captured time done = 1; //set flag to process in main waiting = 0; } } in tid) { waiting = 0; //if the pulse takes longer than 65535*0.25us = 16.384ms to return, stop waiting (failed pulse) TCCR1B = 0x00; //stop timer1
}


Daigrams:

Photographs

Transmitter Assembly
Receiver Assembly

0 comments:

Post a Comment

Share your knowledge

Related Posts Plugin for WordPress, Blogger...

Popular Projects

program for Dual DAC 8051 Microcontroller Based DC Motor Control A Microcontroller Based Turbidity Meter A m -Controller Based Thermostat ASCII to BCD conversion in 8051 AT90LS8515 Digital Message Machine Audio Frequency Response Analyzer Audio Homing Robot Automated Juice Mixer Automated Pet Feeder Autonomous Car Autonomous Parallel Parking RC Car Autonomous Search Robot Autonomous Tank Autonomous Vehicle Contrast Following Rover Autonomous navigating robot BCD number to ASCII in 8051 Balance Bot Blind Bot Blood Pressure Monitor Bloodshed Dev-C++ 5 Compiler/IDE Breath Alcohol Tester Converters on TI MSP430 CrossStudio MSP430 IDE Design of a Real-Time Digital Guitar Tuner Digital Oscilloscope Digital Stethoscope Digital clock project using PIC16C54A microcontroller Digital thermometer ECG monitoring system GPS Data Logger with Wireless Trigger Handwriting Recognition Systm Home Security System Home energy managment IAR Embedded Workbench IDE INFRARED TRACKING SYSTEM IntelliBOT Laser Communications System Line following van MSP-EXP430FG4618 Development Tool and the eZ430 kits MSP430FG4618 device implement a Buzzer tone generator MSP430FG4618 device implement a Real Time Clock MSP430FG4618 device implement a voltage ramp generator MSP430FG4618 device present a message on the LCD Basic Microcontroller(8051) Lab Mivo- RFID based mobile payment system Multi-Zone Fire Alarm System PC based temperature control PIC 16f877 RPM Meter PIC16C54 dual dice electronic project circuit PIC16F84A digital thermometer microcontroller project PIC16F886 horn driver PWM motor contoller with MSP430 Program Block data transfer in 8051 Program to add two BCD numbers in 8051 Program to check whether a 4th bit of a byte is 1 Program to convert ASCII to hex in 8051 Program to count from 0-9 in 8051 Program to count number of 1's in a given data byte in 8051 Program to divide an 8 bit no by another 8 bit number in 8051 Program to find largest of n numbers in 8051 Program to find the LCM of two numbers in 8051 Program to find the square of an 8 bit number in 8051 Program to generate 50msec delay in 8051 Program to implement BCD counter to count from 0-99 in 8051 Program to implement BCD counter to count from 99-0 in 8051 Program to interchange two blocks of data in 8051 Program to multiply 16 bit number by 8 bit number in 8051 Program to search an element in an array in 8051 Program to sort an array of 10 elements in 8051 Programming the ez430 Proximity Security System RAMP wave in 8051 RC Car Controller RObo Dog Radio-controlled Truck Retina color tracker Robotic Arm Controller with GUI Robotic Car Traction Control Safety-sensor vehicle Security Entrance System Self-Powered Solar Data Logger Snake Arm Ultrasonic Positioning Control System Store FFh if 1 Super Train Controller TI MSP430 Microcontrollers Timers on the MSP430 TouchPad Drawing Board Ultra-Sonic Parking Assistant Ultrasonic Parking Controller Ultrasonic Range finder Voice Activated Alarm Clock Voice Recognition Robotic Car Voting Machine Weather Station Web-Monitored Thermostat Wireless Drawing Device Wireless Telemetry Wireless message Communicator Write a C program to display the code of the key pressed in 8051 Zigbee Wireless Relay Control and Power Monitoring System add two multibyte numbers in 8051 convert a decimal number to hex number in 8051 convert an 8bit Hex number to decimal number in 8051 convert hex number to ASCII number in 8051 eZ430-F2013 Development Tool use SD16_A ADC eZ430-RF2500 Development Tool use ADC10 else store 00 in the same location in 8051 find the GCF of two numbers in 8051 find the average of 10 numbers in 8051 generate Fibonacci series in 8051 metal detector project microcontroller using IAR Embedded Workbench program for Elevator Interface in 8051 program for Stepper motor interface in 8051 spectrum analyser square wave in 8051 triangle wave in 8051 voice recognition security system

Sites U missed

Hint

Open Pictures in new page by right click on it, if it is not shown full image.