Sei sulla pagina 1di 11

Bangladesh University of Engineering and Technology

Course Number: EEE 402


Course Name: Control System I Laboratory

A Report on Automatic Speed Controlled


Car Using Microcontroller

Submitted To
Ehsanur Rahman
Lecturer, Department of EEE
Bangladesh University of Engineering and Technology (BUET)

Submitted By:
0906156, 0906157, 0906159, 0906160,
0906161,0906162, 0906163, 0906164, 0906165

Objective:
The aim of our project is to design a car which will detect the presence of speed breakers and
large obstacles by using ultrasonic sensor and adjust its speed accordingly to avoid damages.

Main Components:
 2 Ultrasonic Sensors (HC-SR04)
 1 ATMEGA 32 microcontroller
 1 Motor Driver (L293D)
 1 SPDT switch
 Resistors

HC-SR04:
Ultrasonic ranging module HC-SR04 provides 2cm-400cm non-contact measurement function,
the ranging accuracy can reach to 3mm. The modules includes ultrasonic transmitters, receiver
and control circuit.

ATMEGA 32:
It is an 8-bit high performance microcontroller of Atmels Mega AVR family with low power
consumption.

L293D:
The L293D device is a quadruple high-current half-H driver. The L293D is designed to provide
bidirectional drive currents of up to 600-mA at voltages from 4.5 V to 36 V. It is designed to
drive inductive loads such as relays, solenoids, dc and bipolar stepping motors, as well as other
high-current/high-voltage loads in positive-supply applications.

Required Softwares:
 Proteus
 Extreme Burner
 Mikro C

Desired Operation:
Let a car be running at a speed of V ms-1. When the car is 2 feet away from the speed breaker, it
reduces its speed and starts running at a speed of V/2 ms-1. Afterwards as the car reaches at a
distance of 1 foot from the speed breaker, it runs at V/4 ms-1.

As the car crosses the speed breaker, it again starts running with a speed of V ms-1.

If there is a large obstacle in front of the car, it stops running when its 6 inch behind the obstacle
to avoid the strike.

How to Identify the Obstacles:


We have used two Ultrasonic ranging modules HC-SR04 which are attached to the car. The
upper one works for large obstacles and the lower one is for speed breakers. As the car moves,
these modules continuously send away high frequency signals. If an obstacle comes in the way,
these signals come back getting reflected. The lower module can detect small heighted
hindrances like speed breakers and the higher module can detect taller objects. From this
travelling time of signal and velocity of sound, test distance is calculated.
The basic principle of work can be described as follows Using IO trigger for at least 10us high level signal,
 The Module automatically sends eight 40 kHz and detect whether there is a pulse signal
back.
 IF the signal back, through high level , time of high output IO duration is the time from
sending ultrasonic to returning. Test distance = (high level time velocity of sound
(340M/S) /2
 Distance in inches = Time / 148

Wiring Connection:

 5V Supply
 Trigger Pulse Input
 Echo Pulse Output
 0V Ground

Timing Diagram:
A short 10us pulse is needed to be supplied to the trigger input to start the ranging, and then the
module will send out an 8 cycle burst of ultrasound at 40 kHz and raise its echo. The Echo is a
distance object that is pulse width and the range in proportion. The range can be calculated
through the time interval between sending trigger signal and receiving echo signal.

Schematic Diagram of the System:

Code:
#define get_tcnt1(x) { (x) = TCNT1L; (x) |= (TCNT1H<<8); }
#define set_tcnt1(x) { TCNT1H = (x)>>8; TCNT1L = (x)&0xff;}
typedef unsigned int byte;
unsigned int distance;
byte motor_th=0;
byte motor_duty1;
bit level2;
void motor_signal() org IVT_ADDR_TIMER0_OVF
{
PORTD.B6 = PORTD.B7 = ((motor_th) < motor_duty1);

motor_th++;
if(level2==1)
{
if (motor_th==2400) motor_th = 0;

}
else
{
if (motor_th==1600) motor_th = 0;
}
}
void move_forward(){
PORTD.B0=1;
PORTD.B1=0;
PORTD.B2=1;
PORTD.B3=0;
}
void move_back(){
PORTD.B0=0;
PORTD.B1=1;
PORTD.B2=0;
PORTD.B3=1;
}
void stop_moving(){
PORTD.B0=0;
PORTD.B1=0;
PORTD.B2=0;
PORTD.B3=0;
}
int main()
{
DDRD=0xff; //OUTPUT
SREG_I_bit = 1;
TOIE0_bit = 1;
TCCR0 = 0b001;
motor_duty1 = 1000;
stop_moving();
move_forward() ;

while(1)
{
DDRA=0xFF;
// Output to Sonar
PORTA.B0=0;
delay_us(10);
PORTA.B0=1;
delay_ms(150);
PORTA.B0=0;
delay_us(20);
// Given a 150 ms pulse to trig pin
DDRA.B4 =0;
// Input from Echo pin of Sonar
while(!PINA.B4); // Wait for the Echo pin to be High
TCCR1A=0x00;
// Initialize Timer 1 Control Register A
TCCR1B=(1<<CS11); // Initialize Timer 1 Control Register B
set_tcnt1(0);
// Start Timer 1
while(PINA.B4);
// Wait for the Echo pin to be Low
get_tcnt1(distance); // Getting time from Timer 1
TCCR1B=0x00;
// Stop Timer 1
distance=distance/148;// Getting Distance in inches
if (distance <=15)
{
PORTA.B3=1;
level2=1;
}
else
{
PORTA.B3=0;
level2=0;
}
}

return 0;
}

Advantages:
 It rules out the scope of rash driving and safeguards the valuable lives and property from
damage.
 Increasing oil prices and insufficient resources for carbon fuels have been pushing car
makers to research electric propulsion alternatives. In this regards electronic speed
control would make the system safe and attractive.
 It would be more effective to the highly populated areas.
 This device can also be used for carrying necessary materials avoiding damage in
hospitals, industries, spaceships etc.
 Automatic speed control is a must for the vehicles which are driven to collect information
from the places where man cannot reach.
 It is a feasible technology to incorporate in practical systems as the used components are
cost effective.

Future Works:
 Addition of WLAN device to communicate with other cars around to avoid collisions.
 Addition of direction change systems.
 Addition of overtaking restricted systems.

Automatic Speed Controller Car

Conclusion:
 L293D is heat sensitive, so operation can be hampered in case of large power drop.
 Heat sink should be used throughout the system.
 The HC-SR04 module is not suggested to connect directly to electric. But if it is
somehow gets connected to electric, the GND terminal should be connected with the
module first to ensure its normal operation.
 While testing objects, the range of area should not be less than 0.5 meters and the surface
should be as smooth as possible. The measurements would be hampered otherwise.

Budget:

Potrebbero piacerti anche