Upload
-
View
214
Download
0
Embed Size (px)
Citation preview
8/15/2019 Com Project_gps guided car
1/19
Course No : EEE 310
Course Name: Communication Laboratory
‘
Submitted To:
Md. Hadiur Rahman Khan
Lecturer, EEE Department
BUET
Project Name :gps guided car
Date of Submission : 04/06/2016
Student ID: 1206017-24
Group NO : 03
8/15/2019 Com Project_gps guided car
2/19
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 beingroad 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 haveto 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.
8/15/2019 Com Project_gps guided car
3/19
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 :
The Mega 2560 is a microcontroller board based on the ATmega2560.We used
this as the processing unit of the car.It has 54 digital input/output pins (of which
15 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial
ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP
header, and a reset button.
https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwi595PA3Y3NAhUjSY8KHasSDckQjRwIBw&url=http://makerflux.com/wiki/electronics-wiki/development_boards/arduino/boards/arduino-mega-adk/&psig=AFQjCNEVAB8L3JWD5GPcmszrrcns5LYAig&ust=1465107658397337
8/15/2019 Com Project_gps guided car
4/19
GPS Module : ( GY-GPS 6Mv2)
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
6-axis Accelerometer (MPU 6050)
8/15/2019 Com Project_gps guided car
5/19
The MPU-6050 devices combine a 3-axis gyroscope and a 3-axis accelerometer
on the same silicon die, together with an onboard Digital Motion Processor™
(DMP™), which processes complex 6-axis MotionFusion algorithms. The device
can access external magnetometers or other sensors through an auxiliary
master I²C bus, allowing the devices to gather a full set of sensor data without
intervention from the system processor.
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 .
8/15/2019 Com Project_gps guided car
6/19
Working principle
GPS Module SatellitePosition Mapping and
Accelerometer Data
Error Calculation
and further
movement
Movement using PIDcontrol
Arduino Megaprocessor
8/15/2019 Com Project_gps guided car
7/19
When the GPS module is powered up , it sends signals to a number of
satellites in close proximity. After receiving data of its positions from
several satellites it determines its precise location and it automatically
conveys its latitude, longitude and angle inclination to the ArduinoMega processor. Based on control code and proportional integral
derivative (PID) calculations Arduino controls the movement of the
motor such that it advances towards the target position we have
initialized. The accelerometer continuously analyzes and senses data to
the Arduino Mega in order to control speed, acceleration and motor
rotations.
Arduino Code#include
#include
#include
#include
LiquidCrystal lcd(47, 43, 33, 31, 29, 27);
#define HMC5883_WriteAddress 0x1E
#define HMC5883_ModeRegisterAddress 0x02
#define HMC5883_ContinuousModeCommand 0x00
#define HMC5883_DataOutputXMSBAddress 0x03
#define pi 3.1416
#define Right_en 9
#define Left_en 6
8/15/2019 Com Project_gps guided car
8/19
#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; //aula road, angle=165~180
//float target_latitude=23.7260,target_longitude=90.3880; // jidpus motorcycle,
angle=270~290(latest)
float target_latitude=23.72610,target_longitude=90.38835; //towards jidpus, angle= 155~160(latest)
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;
8/15/2019 Com Project_gps guided car
9/19
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);
8/15/2019 Com Project_gps guided car
10/19
lcd.print("GPS GUIDED ROVER");
delay(5000);
lcd.clear();
noInterrupts();
TCCR1A = 0;
TCCR1B = 0;
timer1_counter = 49911; // preload timer 65536-16MHz/1024/1Hz
TCNT1 = timer1_counter; // preload timer
TCCR1B |= (1
8/15/2019 Com Project_gps guided car
11/19
void loop()
{
for (k=0;k
8/15/2019 Com Project_gps guided car
12/19
MotorDrive(LeftPulse,RightPulse);
GPSRead();
if ( (abs(target_latitude-current_latitude))
8/15/2019 Com Project_gps guided car
13/19
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()))
8/15/2019 Com Project_gps guided car
14/19
{
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()
{
8/15/2019 Com Project_gps guided car
15/19
Wire.beginTransmission(HMC5883_WriteAddress);
Wire.write(regb);
Wire.write(regbdata);
Wire.endTransmission();
delay(100);
Wire.beginTransmission(HMC5883_WriteAddress); //Initiate a transmission with HMC5883 (Write
address).
Wire.write(HMC5883_ModeRegisterAddress); //Place the Mode Register Address in send-buffer.
Wire.write(HMC5883_ContinuousModeCommand); //Place the command for Continuous operation
Mode in send-buffer.
Wire.endTransmission(); //Send the send-buffer to HMC5883 and end the I2C transmission.
delay(100);
Wire.beginTransmission(HMC5883_WriteAddress); //Initiate a transmission with HMC5883 (Write
address).
Wire.requestFrom(HMC5883_WriteAddress,6); //Request 6 bytes of data from the address specified.
delay(500);
//Read the value of magnetic components X,Y and Z
if(6
8/15/2019 Com Project_gps guided car
16/19
x=outputAngle[0]
8/15/2019 Com Project_gps guided car
17/19
correction_R=0;
if ((Error=0))
correction_L=Error*Max_L/90;
else if((Error-360))
correction_L=(Error+360)*Max_L/90;
else
{
correction_L=Max_L;
correction_R=30;
}
}
else if ((Error>=180 && Error270 && Error
8/15/2019 Com Project_gps guided car
18/19
void MotorDrive(int LeftPulse, int RightPulse)
{
analogWrite(Right_en,LeftPulse);
analogWrite(Left_en,RightPulse);
digitalWrite(Right_1,HIGH);
digitalWrite(Right_2,LOW);
digitalWrite(Left_1,HIGH);
digitalWrite(Left_2,LOW);
}
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-guidedmunitions 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)
8/15/2019 Com Project_gps guided car
19/19