Академический Документы
Профессиональный Документы
Культура Документы
Submitted To:
Md. Hadiur Rahman Khan
Lecturer, EEE Department
BUET
guided
car
Abstract:
The future of transport is self-driving cars. Advances in the use of GPS mean that
the technology could not only emerge in the next few years, but is already being
road tested by companies such as Google. There will come a time when you go
down the highway and you don't have to have your hand on the steering wheel at
all. It'll be a combination of GPS, radar and other sensors. GPS also has massive
implications in military intelligence.
What we have tried to show in our experiment is a basic version of the paradigm
shifting technological advancement that will have unnerving implications in
driving safety and comfort. While driving on low traffic roads we might not have
to touch our steering wheels at all. We have used a combination of a GPS module,
accelerometer and processing via Arduino Mega to guide the drive of the car.
Component List
1. Arduino Mega
2. GPS module
3. 6-axis Accelerometer
4. LCD display
5. DC Motor
6. Arduino Shield
7. 3 cell Lithium-Polymer battery
Some components of the experiment which deserve special
mention are:
Arduino Mega :
This GPS is a very capable GPS for the price and size. Compatible with UART
capable devices including Arduino, Raspberry Pi, and MSP430. We have a
customized and tested Arduino library for this GPS module
Adruino Shield :
We have designed a custom Arduino shield which contains on board motor
driver using L293D IC , an onboard buck module. This also contains a full
interfacing media with 16X2 LCD display .
Working principle
GPS Module
Error Calculation
and further
movement
Satellite
Arduino Mega
processor
Arduino Code
#include <TinyGPS++.h>
#include <Wire.h>
#include <math.h>
#include <LiquidCrystal.h>
#define Right_1 10
#define Right_2 8
#define Left_1 4
#define Left_2 50
TinyGPSPlus gps;
volatile float current_latitude=0,current_longitude=0;
//float target_latitude=23.7252,target_longitude=90.3922;
//aula; angle=270~290(latest)
//float target_latitude=23.7249,target_longitude=90.3922;
//float target_latitude=23.7260,target_longitude=90.3880;
angle=270~290(latest)
// jidpus motorcycle,
float target_latitude=23.72610,target_longitude=90.38835;
float latitude_difference=0,longitude_difference=0;
float prev_latitude=0,prev_longitude=0;
float x1,y1;
int regb=0x01;
int regbdata=0x40;
int outputAngle[6];
int x=0,y=0,z=0,i=0,j=0,k=0,l=0,m=1,n=0;
float CompassAngle=0;
float target_angular_positon=0;
int correction_L=0;
int correction_R=0;
int Max_L=225,Max_R=230;
int TrigPin=2;
int EchoPin=3;
int Error=0;
int LeftPulse=0,RightPulse=0;
int timer1_counter;
int count=0;
void setup()
{
Serial.begin(9600);
Serial3.begin(9600);
Wire.begin();
pinMode(Right_en,OUTPUT);
pinMode(Left_en,OUTPUT);
pinMode(Right_1,OUTPUT);
pinMode(Right_2,OUTPUT);
pinMode(Left_1,OUTPUT);
pinMode(Left_2,OUTPUT);
pinMode(TrigPin,OUTPUT);
pinMode(EchoPin,INPUT);
lcd.begin(16, 2);
noInterrupts();
TCCR1A = 0;
TCCR1B = 0;
timer1_counter = 49911;
TCNT1 = timer1_counter;
// preload timer
GPSRead();
DriveAngle();
CompassRead();
}
ISR(TIMER1_OVF_vect)
{
TCNT1 = timer1_counter;
count++;
}
// preload timer
void loop()
{
for (k=0;k<200;k++)
{
GPSRead();
DriveAngle();
lcd.setCursor(0, 2);
lcd.print(k);
lcd.setCursor(6,2);
lcd.print(target_angular_positon);
}
lcd.clear();
//target_angular_positon=280;
int goal=0;
int num=0;
while(goal<3)
{
CompassRead();
Error=target_angular_positon-CompassAngle;
PIDCalculation();
LeftPulse=Max_L-correction_L;
RightPulse=Max_R-correction_R;
MotorDrive(LeftPulse,RightPulse);
GPSRead();
if (count>10)
{
DriveAngle();
count=0;
num=num+1;
}
lcd.setCursor(0, 0);
lcd.print(abs(target_latitude-current_latitude)*1e5);
lcd.setCursor(7, 0);
lcd.print(" ");
lcd.print(abs(target_longitude-current_longitude)*1e5);
//lcd.setCursor(0, 1);
//lcd.print(goal);
lcd.setCursor(0,1);
lcd.print(num);
lcd.setCursor(3, 1);
lcd.print(" ");
lcd.print(target_angular_positon);
lcd.setCursor(10, 1);
lcd.print(" ");
lcd.print(CompassAngle);
}
MotorStop();
lcd.clear();
while(1)
{
lcd.setCursor(0, 0);
lcd.print(current_latitude*1e4);
lcd.setCursor(0, 1);
lcd.print(current_longitude*1e4);
}
}
void GPSRead()
{
n=1;
while(n)
{
while (Serial3.available() > 0)
if (gps.encode(Serial3.read()))
if (gps.location.isValid())
{
current_latitude=gps.location.lat();
current_longitude=gps.location.lng();
n=0;
}
else
{
Serial.println("Searching....");
lcd.setCursor(1,0);
lcd.print("Searching....");
}
}
}
if (millis() > 5000 && gps.charsProcessed() < 10)
{
Serial.println("No GPS detected: check wiring.");
while(true);
}
}
void CompassRead()
{
Wire.beginTransmission(HMC5883_WriteAddress);
Wire.write(regb);
Wire.write(regbdata);
Wire.endTransmission();
delay(100);
x=outputAngle[0] << 8 | outputAngle[1]; //Combine MSB and LSB of X Data output register
z=outputAngle[2] << 8 |outputAngle[3]; //Combine MSB and LSB of Z Data output register
y=outputAngle[4] << 8 |outputAngle[5]; //Combine MSB and LSB of Y Data output register
void MotorStop()
{
digitalWrite(Right_en,LOW);
digitalWrite(Left_en,LOW);
}
void DriveAngle()
{
target_angular_positon=gps.courseTo(current_latitude, current_longitude, target_latitude,
target_longitude);
// if(target_angular_positon<0)
// target_angular_positon = target_angular_positon + 360;
}
void PIDCalculation()
{
if ((Error>=0 && Error<180) || (Error<=-180 && Error>-360))
{
correction_R=0;
if ((Error<90 && Error >=0))
correction_L=Error*Max_L/90;
else if((Error<-270 && Error >-360))
correction_L=(Error+360)*Max_L/90;
else
{
correction_L=Max_L;
correction_R=30;
}
}
else if ((Error>=180 && Error<360) || (Error<=0 && Error>-180))
{
correction_L=0;
if ((Error>270 && Error <360))
correction_R=(360-Error)*Max_R/90;
else if((Error<=0 && Error >-90))
correction_R=(-Error)*Max_R/90;
else
{
correction_R=Max_R;
correction_L=30;
}
}
}
Potential Applications
Many civilian applications use one or more of GPS's three basic components:
absolute location, relative movement, and time transfer. Here are a few possible
civilian and military implementations of the concept used in our project:
Automated vehicle: applying location and routes for cars and trucks to
function without a human driver.
Geofencing: vehicle tracking systems, person tracking systems, and pet
tracking systems use GPS to locate a vehicle, person, or pet. These devices
are attached to the vehicle, person, or the pet collar.
Missile and projectile guidance: GPS allows accurate targeting of various
military weapons including ICBMs, cruise missiles, precision-guided
munitions and Artillery projectiles. Embedded GPS receivers able to
withstand accelerations of 12,000 g or about 118 km/s2 have been
developed for use in 155-millimeter (6.1 in)