Project Report - 32527
Project Report - 32527
Project Report - 32527
PROJECT REPORT ON
BY
AT
SUNBEAM INSTITUTE OF INFORMATION TECHNOLOGY,
HINJAWADI
1
SUNBEAM INSTITUTE OF INFORMATION TECHNOLOGY,
HINJAWADI.
CERTIFICATE
This is to certify that the project
Authorized Signature
2
ACKNOWLEDGEMENT
3
ABSTRACT
Present Automobiles are being developed by more of electrical parts
for efficient operation. Generally a vehicle was built with an analog driver-
vehicle interface for indicating various vehicle status like speed, fuel level,
Engine temperature etc., This project presents the development and
implementation of a digital driving system for a semi-autonomous vehicle to
improve the driver-vehicle interface. It uses an AVR based data acquisition
system that uses ADC to bring all control data from analog to digital format
and visualize through LCD. The communication module used in this project
is embedded networking by CAN which has efficient data transfer. It also
takes feedback of vehicle conditions like Engine temperature etc., and
controlled by main controller. Additionally this unit equipped with android
application which helps to access data on owners mobile.
Keywords: ECU (Engine Control Unit), CAN (Controller Area Network),
Embedded C, Android application.
4
INDEX
1. INTRODUCTION 8
1.1 Introduction 8
1.2 Overview of Project 10
2. LITERATURE SURVEY 11
2.1 Analysis of operating parameters of vehicles by CAN bus. 12
2.2 . Design of Vehicle Bus Data Acquisition and Fault Diagnosis 13
System using CAN
2.3 . Implementing a Distributed High-Resolution Real-Time Clock 14
using the CAN-Bus
2.4 . Modular CAN-Bus-System for small vehicles 15
2.5 IoT System for Anytime/Anywhere Monitoring and Control of 16
Vehicles’ Parameter
3. PROJECT ARCHITECTURE 18
3.1 Block diagram 20
3.2 Flowchart 21
4. HARDWARE DESCRIPTION 24
4.1 AVR board 24
4.2 LCD 25
4.3 LM35 26
4.4 MCP2515 28
4.5 NodeMCU 30
4.6 RTC-DS1307 31
5. SOFTWARE REQUIREMENTS AND SPECIFICATIONS 32
5.1 Android studio 32
5.2 Arduino IDE 33
5.3 Pycharm community 34
5.4 Minicom 34
5.5 Eclipse 35
5.6 AVRdude Toolchain 36
5.7 Arduino Toolchain 36
5
6. SOURCE CODE EXPLAINATION 37
6.1 CAN functions 37
6.2 UART functions 38
6.3 LCD functions 39
6.4 SPI functions 39
6.5 RTC functions 40
6.6 I2C functions 41
6.7 LM35 functions 42
6.8 NodeMCU functions 43
7. TESTING 44
7.1 CAN Transmitter output 44
7.2 CAN Receiver output 45
7.3 Application output 47
8. FUTURE SCOPE 48
9. CONCLUSION 49
10 REFERNCES 50
.
6
LIST OF TABLES
Section Table Title Page
1. Literature Survey 11
LIST OF FIGURES
7
INTRODUCTION
8
Subsystems are independent or dependent & communications among
dependent sub systems is essential.Traditional systems also satisfy the main
need of vehicle automation but they lag to reduce wiring complexity &
reliability issue. In vehicles networking protocols must satisfy requirements
which include, significant reduction of wiring complexity, reducing body
weight and costs, improving the efficiency of fault diagnosis, low latency
times and configuration flexibility and enhancing the level of intelligent
control.
9
OVERVIEW
This project is about a dashboard of a vehicle. The dashboard of a
vehicle shows parameters like date, time, humidity, temperature, speed, etc.
10
LITERATURE SURVEY
From going through various research papers, we can establish that
significance work has been done in this field of research.Various methods
are used in them are as follows.
Lets go through all the research papers one by one and what they have done.
11
1, Analysis of operating parameters of vehicles via can bus :
For the analysis of the data communications bus CAN-Bus was used
truck DAF XF 105.460 EEV. Selected technical parameters of the vehicle
are shown in Tab. 1: DAF XF 105.460 engine parameters. The car has
several mutually independent communication networks CAN-Bus, namely
the V-CAN 1 (Vehicle) and V-CAN 2, the I-CAN (Instrument), the D-CAN
(Diagnosis) and BB-CAN (Body Builder).
All these CAN data buses are connected in central processing unit
MENDELNET 2013 .VIC-3 (Vehicle Intelligence Centre), where all
information are coordinated. Data bus systems in this truck meet worldwide
standard for communication (SAE J1939/21 – cabling + network, and SAE
J1939/71.
12
After conversion to decimal form it could be found appropriate
message and information contained therein in datasheet for SAE J1939
standard. File with messages was saved to HDD in „csv“ format. After
starting the engine of the vehicle subsequently was higher number of
messages which was available on the bus.
The vehicle bus data acquisition and fault diagnosis system, focusing
on its lower computer system and the upper computer system is designed.
This system is based on the widely used CAN bus technology, to extract the
vehicle's status or fault information. When the vehicle breaks down, the
status of vehicle will be sent as SMS to the control system using GSM
technology. In automotive electronics, engine fault detect units, engine
temperature sensors, air bag release-systems and battery low level detect
system etc. are connected using CAN with bit rates up to 1 M bit/s
13
internal and external communications data interface. It gathered up the
information from all the interior electrical systems nodes sent to the remote
monitoring service center computer via SMS wireless module. This paper
focuses on bus data acquisition and remote monitoring system based on
CAN bus and SMS, which can be used to improve the efficiency of
monitoring, to maintain the system security, to lower the maintenance costs
as well as the operating expensed. With the development of the mobile
technology, the design will be made better; the data transmission based on
wireless communication will be used more widely. The communication
network designed is able to stay stable in a long run in the experiment and
meets the expected target. Here, Keil cross compiler will be used for
building the applications. LPC2148 development board will be used to test
the built application. Flash magic software is used to dump the .Hex file in
to the Microcontroller.
14
standard microcontrollers. Thus, the typical accuracy of these clocks is in the
order of microseconds.
The protocol relies on three basic assumptions about the network, the
controller hardware, and the involved software. The presented approach is
not restricted to the CAN-bus, but it can be used on every network that
fulfils the following requirements:
1. A successfully sent frame arrives at all nodes with a fixed and known
delay. This means, the underlying network has to be a broadcast
network. The delay may be approximated as zero, constant, or even a
function of the receiving node.
2. The delay from the transmission and reception of a frame to an interrupt
service routine that timestamps this event is known and has only a very
small variance. Again, this delay and its variance may be functions of
the receiving node.
3. A time bound for the maximum time between two valid synchronisation
messages tmax can be guaranteed.
15
The implementation of a cable tree into small vehicles can be more
complex than into a normal car. Small vehicles have less space but an
increasing amount of electric actors and sensors. The employment of fast
communication lines (e.g. CAN-Bus) seemed to be not cost-effective up to
now due to the expensive hardware. But the use of the CAN-Bus for small
vehicles has the same advantages as for a normal car: Advantages of a CAN-
Bus environment are:
very high flexibility for the control electronics and for further
modifications,
higher service comfort and less maintenance costs due to the module
structure,
16
system are: a Bluetooth Low Energy (BLE) intra-vehicular wireless sensor
network (IVWSN); a mobile device that acts both as the vehicle’s gateway,
connecting the IVWSN to the Internet, and as the vehicle’s human machine
interface (HMI); an online server/database, based on Firebase; a client,
which can be either a mobile device or a personal computer; and a
residential wireless sensor network (WSN). The use of a wireless network to
collect sensor data inside of the vehicle introduces some advantages when
compared with conventional wired networks, whereas the inclusion of a
residential WSNs in the proposed IoT architecture allows the provision of
additional features, such as automatic control of the EV battery charging
process. Experimental results are provided to assess the performance of the
developed IVWSN and HMI.
The main components of the proposed IoT system for vehicles (Fig. 2)
are an intra-vehicular wireless sensor network (one per vehicle), the
vehicle’s gateway and HMI, which connects to the Internet, an online
server/database (which may serve several users/vehicles), a client mobile
app and the user’s home WSN, which is also connected to the Internet
All the above papers have their respective pros and cons.After
refering and studying above research papers,we had idea of how to do the
project,what we can use in this project.After studying above research papers,
we decided to use CAN protocol for transferring data, RTC to get the date
and time and IoT to connect our dashboard online.
17
PROJECT ARCHITECTURE
18
Requests data from a specified resource and POST Submits data to be
processed to a specified resource. MYSQL is used as a database at the
webserver and PHP is used to fetch data from the database.
Our application will communicate with the PHP page with necessary
parameters and PHP will contact MYSQL database and will fetch the result
and return the results to us.
Run the application and choose a running android device and install the
application on it and verify the results.
19
Block Diagram :
20
Flowchart :-
Fig 2: Flowchart
21
The pins connections of a project is as follows.
22
3. AVR to LCD interfacing :
RS ---PA5
RW---PA6
E---PA7
D4---PA0
D5---PA1
D6---PA2
D7---PA3
23
HARDWARE DESCRIPTION
AVR BOARD:
AVR Development Board is an exclusive general-purpose development
board for the AVR family. The intention of the design is to endorse the
engineers and scholars to exercise and explore the capabilities of AVR
microcontrollers with many communication protocol ease. It uses AVR
studio for design and development .It integrates on board USARTs, LEDs,
keypads, an ADC input and LCD Display to create a stand-alone versatile
test platform. User can easily engage in development in this platform, or use
it as reference to application development.
40pin-ZIF Socket
8 Nos. Point LEDs (Logic Output)
8 Nos. Digital Input (DIP Switch)
4x4 Matrix Keypad
2X16 Character LCD (Background Light)
4 No's of Seven Segment Display
ADC with Analog Input Test (Potentiometer)
Stepper Motor Interface
DS1307 RTC with Batter-Backup
USART(RS232) for serial programming
ISP Device Programmer
Buzzer (Alarm), 3 Interrupts , Reset Button
EEPROM (SPI and I2C)
Digital Temperature Sensor(DS18S20)
PS/2
SPI
I2C
1-Wire
RS-232
24
Evaluate Real Time Applications
Supports Embedded C, ASM
ISP Programming | SPI | I2C Communications
LCD:
25
2=32) 32 characters in total and each character will be made of 5A—8 Pixel
Dots.
Fig 8: 16 * 2 LCD
LM35:
26
and greater accuracy make it popular among hobbyists, DIY circuit makers,
and students.
Many low-end products take advantage of low cost, greater accuracy
and used LM35 in their products. Its approximately 15+ years to its first
release but the sensor is still surviving and is used in any products.
27
MCP2515:
Specifications:
28
Pinouts:
Features:
29
NodeMCU:
NodeMCU Dev Kit has Arduino like Analog (i.e. A0) and Digital
(D0-D8) pins on its board.
30
Fig 11: NodeMCU
RTC-DS1307:
Real time clocks (RTC), as the name recommends are clock modules.
The DS1307 real time clock (RTC) IC is an 8 pin device using an I2C
interface. The DS1307 is a low-power clock/calendar with 56 bytes of
battery backup SRAM. The clock/calendar provides seconds, minutes,
hours, day, date, month and year qualified data. The end date of each month
is automatically adjusted, especially for months with less than 31 days.
Features:
31
SOFTWARE REQUIREMENTS AND
SPECIFICATIONS
ANDROID STUDIO:
The Android Studio IDE is free to download and use. It has a rich UI
development environment with templates to give new developers a
launching pad into Android development.
32
ARDUINO IDE:
Arduino IDE is an open source software that is mainly used for
writing and compiling the code into the Arduino Module.
The IDE environment mainly contains two basic parts: Editor and
Compiler where former is used for writing the required code and later is
used for compiling and uploading the code into the given Arduino Module.
This environment supports both C and C++ languages.
33
PYCHARM Community:
MINICOM:
34
=> Connect to Cisco routers for configuration
=> Connect to dump device i.e. device w/o keyboard and mouse
=> Dialing directory with auto-redial
=> Support for UUCP-style lock files on serial devices
=> Separate script language interpreter
=> Capture to file
=> Multiple users with individual configurations.
ECLIPSE:
35
AVRdude TOOLCHAIN :
ARDUINO TOOLCHAIN :
36
SOURCE CODE EXPLANATION
CAN functions: -
1. INT8U begin(INT8U speedset, const INT8U clockset =
MCP_8MHz): -
This is the setup function of the CAN module. The
speed and the controller CPU clock speed are given as
parameter to the function. This function sets the register
of the MCP2515 and confirms the setting through
register and returns the status code.
2. INT8U sendMsgBuf(INT32U id, INT8U ext, INT8U len, INT8U
*buf)
This function is use to send message string over the bus. The id
defines the message id and also where id filter is used then it acts as
differentiator for receivers. If single receiver receives the messages then id is
use to differentiate the message. Ext is flag bit which defines whether the
CAN frame will be simple or extended. Buffer is a string message buffer
which contains the readings of temperature sensor.
4. INT8U checkReceive(void)
37
This check the buffers of the MCP2515 and returns the status of the
message i.e. buffer has message or it is empty. This function is used for the
polling for the message at the receiver side.
5. INT8U checkError(void)
CAN frame contains CRC code at the end of the frame. This code is
use to detect whether received message is error-free or it gets corrupted. If
message is corrupted then that message has been discarded and receiver can
ask for retransmission of the message.
6. INT32U getCanId(void)
UART Functions: -
To write the data on UART, this function is used. The data is written
char by char till the null char on UDR register. The UDR register contains
the data to be transmitted or the data that has been received.
Argument: String which we want to write. It returns void.
38
LCD Functions:-
1. void lcd_init(void);
This function is used to initialize the LCD. This function sets the data
pins and control pins as output. It sets 4-bit mode, 2 line, 5x10 font LCD by
sending command. It also turns on the display, turn off the cursor and turn of
the blink of LCD. Last thing it does, is clear the LCD display.
This function is used to write the data on LCD. It sets the line address
which we have passed and write the char data one by one.
This function is also writing the data on LCD. But this is basically to
mention the specific line number and position on that line, on which we
want to write.
This function will write the data on given position of given line number.
39
SPI Functions :-
1. void spi_init_master(void);
This function is used for initialized the SPI master and the MCP2515
as a slave. This init the SPI buffer and the speed of the transmission is set.
This function is used to transmit and receive the data over SPI bus.
SPI has single buffer therefore it works as trans receiver in the case of
transmission.
RTC Functions:-
1. RTC_Init();
Prototype:
void RTC_Init(void);
2. RTC_SetDateTime(&rtc);
This function is used to set date and time in RTC.It starts the I2C
communication and connect to DS1307 by sending its ID on I2C bus.Then it
writes sec,min,hour,week day,date,month and year on I2c. It stops the I2C
communication.
Prototype:
void RTC_SetDateTime(rtc_t *rtc);
Argument 1:Pointer to the object of a structure.
It returns void.
40
3. RTC_GetDateTime(&rtc);
This function is used to get date and time in RTC.It starts the I2C
communication and connect to DS1307 by sending its ID on I2C bus.Then it
reads sec,min,hour,week day,date,month and year from I2c. It stops the I2C
communication after reading the date and time.
Prototype:
void RTC_GetDateTime(rtc_t *rtc);
Argument 1:Pointer to the object of a structure.
It returns void.
I2C Functions:-
1. I2C_Init();
This function is used to initialize the I2C module.It sets the prescalar
bits to zero and sets the SCL frequency.Also it enables the TWI module;
Prototype:
void I2C_Init();
2. I2C_Start();
This function is used to generate I2C Start Condition. The I2C start
condition is SDA goes low when SCL is High.
Prototype:
void I2C_Start();
3. I2C_Stop();
This function is used to generate I2C Stop Condition. The I2C stop
condition is SDA goes High when SCL is High.
Prototype:
void I2C_Stop(void);
41
4. I2C_Write(0x80);
Prototype:
void I2C_Write(uint8_t v_i2cData_u8);
Argument 1:uint8_t-->8bit data to be sent.
It returns void.
5. rtc→month=I2C_Read(1);
This fun is used to receive a byte on SDA line using I2C protocol.The
8bit data is received bit-by-bit each clock and finally packed into
Byte.MSB(bit) is received first and LSB(bit) is received at last.
Prototype:
uint8_t I2C_Read(uint8_t v_ackOption_u8);
Argument 1:Acknowledgement.
It returns uint8_t(received byte).
LM35 Functions:
1. lm35_Init();
Prototype:
void lm35_Init(void);
2. temp = lm35_Read(0);
42
This function is used to read the input data.It sets input channel to
read.It reads the bytes and return digital value.
Prototype:
int lm35_Read(int channel);
Argument 1:Channel number from which we want to
read the data.
It returns digital value of input data.
1. Serial.begin(9600);
This function sets the data rate in bits per second (baud) for serial data
transmission. For communicating with Serial Monitor, make sure to use one
of the baud rates listed in the menu at the bottom right corner of its screen.
You can, however, specify other rates - for example, to communicate over
pins 0 and 1 with a component that requires a particular baud rate.
Prototype:
Serial.begin(speed);
2. Serial.available();
Get the number of bytes (characters) available for reading from the
serial port. This is data that’s already arrived and stored in the serial receive
buffer (which holds 64 bytes).
Serial.available() inherits from the Stream utility class.
3. Serial.read();
This function reads the incoming data. It returns the first byte of
incoming data available.
43
4. Serial.println(value);
Prints data to the serial port as human-readable ASCII text followed
by a carriage return character (ASCII 13, or '\r') and a newline character
(ASCII 10, or '\n'). This command takes the same forms as Serial.print().
Println() returns the number of bytes written, though reading that
number is optional.
TESTING
CAN Transmitter :
1. We first prepare the code for CAN transmitter which will transmit
temperature, date and time to CAN receiver.
2. Then we burn that code hex file on ATMega32 board by using
following command.
Avrdude –c usbtiny –p atmega32 –U flash:w:can_tx.hex
3. We connect USB tiny to the board to check the output.
4. We got the following ouput after giving command sudo minicom on
VI editor.
5. This shows that message is sent successfully.
44
Fig 17: CAN transmitter output
CAN Receiver :
1. On the receiver side,the first step is same.We prepare a code for CAN
transmitter.
2. Then we burn the hex file of that code using following command.
Avrdude –c usbtiny –p atmega32 –U
flash:w:can_tx.hex
3. We connect the USB tiny to see the ouput.
4. After connecting the high pin of transmitter’s MCP2515 to the high
pin of receiver’s MCP2515 and the low pin of transmitter’s MCP2515
to the high pin of receiver’s MCP2515,We can get the following
ouput after giving command sudo minicom on VI editor.
5. This shows that message is sent successfully.
45
Fig 18: CAN receiver output
46
Fig 19: Dashboard output
Application :
47
9. The application will look like this.
FUTURE SCOPE
The project has a very vast scope in future. Project can be updated in near
future as and when requirement for the same arises, as it is very flexible in
terms of expansion. The following are the future scope for the project.
48
Set the date and time manually by using keypad.
49
CONCLUSION
50
REFERENCES
1. https://www.tutorialspoint.com/android/android_php_mysql.htm
2.https://en.wikipedia.org/wiki/CAN_bus
51