CHAPTER -1
Introduction
Nowadays accidents are occurring frequently, causing demise of many people by making
modest mistakes while driving (in school zone, hills area, and highways). But sometimes
it may not be possible to view the signboards placed by the Highway Department to alert
the drivers in such kind of places and there is a chance for accident. The advancement in
the processor technology has opened a new system designed to prevent the accidents
caused due to negligence of drivers in seeing traffic signals alongside the road and other
anomalies on the roads. So to intimate the driver about the zones and and to
automatically maintain the speed is accomplished by means GSM technology. The main
objective is to design an Electronic Display controller meant for motor speed control and
monitors the zones. This system if adopted by some state can effectively reduce the
number of road accidents caused by speeding vehicles losing control of the vehicle at
speed breakers or by driver’s negligence towards traffic signals.
1.1 Embedded System: -
    An Embedded System is a combination of computer hardware and software, and
perhaps additional mechanical or other parts, designed to perform a specific function. An
embedded system is a microcontroller-based, software driven, reliable, real-time control
system, autonomous, or human or network interactive, operating on diverse physical
variables and in diverse environments and sold into a competitive and cost conscious
market. An embedded system is not a computer system that is used primarily for
processing, not a software system on PC or UNIX, not a traditional business or scientific
application. High-end embedded & lower end embedded systems. High-end embedded
system - Generally 32, 64 Bit Controllers used with OS. Examples Personal Digital
                                            1
Assistant and Mobile phones etc. Lower end embedded systems - Generally 8,16 Bit
Controllers used with an minimal operating systems and hardware layout designed for
the specific purpose. Examples Small controllers and devices in our everyday life like
Washing Machine, Microwave Ovens, where they are embedded in
1.2 System Design Call:
                                Fig – 1.1
1.3 Embedded System Design Cycle:
                                     Fig-1.2
                                            2
1.4 Characteristic of Embedded System:
         An embedded system is any computer system hidden inside a product other than a
         computer.
         They will encounter a number of difficulties when writing embedded system
         software in addition to those we encounter when we write applications
                Throughput – Our system may need to handle a lot of data in a short
                period of time.
                Response–Our system may need to react to events quickly.
                Testability–Setting up equipment to test embedded software can be
                difficult.
                Debugability–Without a screen or a keyboard, finding out what the
                software is doing wrong (other than not working) is a troublesome
                problem.
                Reliability – embedded systems must be able to handle any situation
                without human intervention.
                Memory space – Memory is limited on embedded systems, and you
                must make the software and the data fit into whatever memory exists.
                Program installation – you will need special tools to get your
                software into embedded systems.
                Power consumption – Portable systems must run on battery power,
                and the software in these systems must conserve power.
                Processor hogs – computing that requires large amounts of CPU time
                can complicate the response problem.
                Cost – Reducing the cost of the hardware is a concern in many embedded
                system projects; software often operates on hardware that is barely
                adequate for the job.
Embedded systems have a microprocessor/ microcontroller and a memory. Some have a
serial port or a network connection. They usually do not have keyboards, screens or disk
drives
                                              3
CHAPTER 2
                           Software & Hardware Used
There is no such a compiler suitable for only one type of microcontrollers nor for all
microcontrollers. It’s   about software used for programming similar microcontrollers of
one manufacturer. We have previously introduced Using Keil Micro-vision
Softwarelanguage which has been especially designed for programming PIC
microcontrollers.
2.1 Software
2.1.1 Introduction of Using Keil Micro –vision software: -
This manual helps you to get acquainted with the Keil software which will enable you to
write the embedded C codes of different modules for interfacing them with PIC16F877A
. It also helps the students to get their hand on the compiling and analysing the codes
which they write. Thus it helps them to understand that how to test.
The Micro-Vision IDE is a Windows-based software development platform that
combines a robust editor, project manager, and makes facility. Micro-Vision integrates
all tools including the C compiler, macro assembler, linker/locator, and HEX file
generator. It helps expedite the development process of your embedded applications by
providing the following:
   1. Full-featured source code editor,
   2. Device database for configuring the development tool setting,
   3. Project manager for creating and maintaining your projects,
   4. Integrated make facility for assembling, compiling, and linking your embedded
   5. applications,
   6. Dialogs for all development tool settings
   7. True integrated source-level Debugger with high-speed CPU and peripheral
                                            4
   8. Simulator.
   9. Advanced GDI interface for software debugging in the target hardware and for
   10. connection to Kei ULINK,
   11. Flash programming utility for downloading the application program into Flash
Links to development tools manuals, device datasheets & user’s guides. The Micro-
Vision IDE offers numerous features and advantages that help you quickly and
successfully develop embedded applications. They are easy to use and are guaranteed to
help you achieve your design goals.
In order to write, compile and convert your code to the corresponding hex codes you
must build a project in the Keil Microvison software. The Steps for creating the project
and converting C code to the corresponding hex code.
2.1.2 Flowchart of complete program: -
      Communicating with GSM modem
      Reading new incoming SMS from Modem
      Finding current RPM of motor
      Displaying results to Screen
      Send feedback SMS to user when desired speed is set.
                                           5
Fig-2.1.2 flow chart of program
                    6
2.2 Hardware Used: -
   PIC 16F877A
   Resistor
   Capacitor
   Diode
   Crystal Oscillator
   GSM module (SIM-900)
   Transformer (Step Down)
   Voltage Regulator
   Motor
   Rectifier
   Capacitive Filter
   PCB
                              7
2.2.1 Pin Diagram of PIC16F877A
   PIC16F877 belongs to a class of 8-bit microcontrollers of RISC architecture. It has
8kb flash memory for storing a written program. Since memory made in FLASH
technology can be programmed and cleared more than once, it makes this
microcontroller suitable for device development. IT has data memory that needs to be
saved when there is no supply. It is usually used for storing important data that must not
be lost if power supply suddenly stops. For instance, one such data is an assigned
temperature in temperature regulators. If during a loss of power supply this data was lost,
we would have to make the adjustment once again upon return of supply.
                             Fig-3 Pin diagram of PIC16f877A
                                            8
2.2.2 PIN DESCRIPTION: -
     RA3/AN3 /Vref+ /C1IN+ for the fifth pin specifies the following functions:
        RA3 Port A third digital input/output
        AN3 Third analog input
        V ref+ Positive voltage reference
        C1IN+ Comparator C1positive input
This small trick is often used because it makes the microcontroller package more
compact without affecting its functionality. These various pin functions cannot be used
simultaneously, but can be changed at any point during operation.
PIN NUMBER                                       DESCRIPTION
1                                                MCLR/VPP - Master Clear Input
2                                                RA0/AN0 - Port A
3                                                RA1/AN1 - Port A
4                                                RA2/AN2/VREF-/CVREF - Port A
5                                                RA3/AN3/VREF+ - Port A
6                                                RA4/T0CKI/C1OUT - Port A
7                                                RA5/AN4/SS/C2OUT - Port A
8                                                RE0/RD/AN5 - Port E
9                                                RE1/WR/AN6 - Port E
10                                               RE2/CS/AN7 - Port E
11                                               VDD - Positive Power Supply
12                                               VSS – Ground
13                                               OSC1/CLKI - Oscillator Input
14                                               OSC2/CLKO - Oscillator Output
                                             9
15            RC0/T1OSO/T1CKI - Port C
16            RC1/T1OSI/CCP2 - Port C
17            RC2/CCP1 - Port C
18            RC3/SCK/SCL - Port C
19            RD0/PSP0 - Port D
PIN NUMBER        DESCRIPTION
20                RD1/PSP1 - Port D
21                RD2/PSP2 - Port D
22                RD3/PSP3 - Port D
23                RC4/SDI/SDA - Port C
24                RC5/SDO - Port C
25                RC6/TX/CK - Port C
26                RC7/RX/DT - Port C
27                RD4/PSP4 - Port D
28                RD5/PSP5 - Port D
29                RD6/PSP6 - Port D
30                RD7/PSP7 - Port D
31                VSS – Ground
32                VDD - Positive Power Supply
33                RB0/INT - Port B
34                RB1 - Port B
35                RB2 - Port B
36                RB3/PGM - Port B
             10
37        RB4 - Port B
38        RB5 - Port B
39        RB6/PGC - Port B
40        RB7/PGD - Port B
     11
 Chapter: 3
                Block and circuit diagram of Project
 3.1 Block diagram
                      Tactile Switch Pad
                                                               LCD Display
MAX 232                                                           16*2
 ddd
                            Micro
                           Controller
                                                                         L293
 GSM                                                                      D
modem
                                                                    MOTOR
                      POWER SUPPLY
              Fig-3.1 Block diagram of vehicle speed control using Gsm
                                    12
3.1.1 POWER SUPPLY:-
                                 Fig-3.1.1 power supply
In this Project basically we are use step down transformer which give output 12 volt to
rectifier and this is convert 12volt dc output and after this ripple are remove by use
capacitive filter and it gives output to voltage regulator which give 5volt dc output for
using internal circuit at which microcontroller are work.
3.1.2 GSM (Global System for Mobile Communication): -
Global System for Mobile Communications, originally is a standard developed by
the European Telecommunications Standards Institute (ETSI) to describe the protocols
for second-generation (2G) digital cellular networks used by mobile phones, first
deployed in Finland in July 1991. As of 2014 it has become the default global standard
for mobile communications - with over 90% market share, operating in over 219
countries and territories.
2G networks developed as a replacement for first generation (1G) analog cellular
networks, and the GSM standard originally described a digital, circuit-switched network
optimized for full duplex voice telephony. This expanded over time to include data
communications, first by circuit-switched transport, then by packet data transport
via GPRS (General Packet Radio Services) and EDGE (Enhanced Data rates for GSM
Evolution or EGPRS)
                                            13
3.1.3 DC Motor: -
DC Motor has two leads. It has bidirectional motion If we apply +ve to one lead and
ground to another motor will rotate in one direction, if we reverse the connection the
motor will rotate in opposite direction. If we keep both leads open or both leads ground it
will not rotate (but some inertia will be there). If we apply +ve voltage to both leads then
braking will occurs.
                              fig -4.1.3 Dc motor
3.1.4 LIQUID CRYSTAL DISPLAY: -
The liquid - crystal display (LCD) consist of a liquid crystal material (normally organic
for LCD’s) that will flow like a liquid but whose molecular structure has some properties
normally associated with solids. The LCD does not generate its own light but depends on
an external or internal source. Under dark conditions, it would be necessary for the unit
to have its own internal light source either behind or to the side of the LCD. During the
day, or in the lighted areas, a reflector can be put behind the LCD to reflect the light back
through the display for maximum intensity. The LCD has the distinct advantage of
                                             14
having the lower power requirement than the LED. It is typical in the order of microwatts
for the display, as compared to the same order of mill watts for LEDs. LCD is limited to
a temperature range of about 0˚ to 60˚ C. Lifetime is an area of concern because LCDs
can chemically degradeLCDs can add a lot to out applications in terms of providing an
useful interface for the user, debugging an application or just giving it a "professional"
                               Fig-3.1.4 LCD
3.1.5 MAX232: -
The MAX232 is an integrated circuit first created in 1987 by Maxim Integrated product
that convert signal from a TIA-232 (Rs-232) serial port to signal suitable for use in TTL
compatible digital logic circuit. The MAX232 is a dual driver receiver and typically
converts the RX, TX, CTS and RTS signals.
The driver provides TIA-232 voltage level output (approx. 7.5 volts) from a single five
volt supply via on-chip charge pumps and external capacitors. The makes it useful for
implementing TIA-232 in device that otherwise to not need any other voltages.
The receiver reduce TIA-232 inputs, which may be as high as +25 volts, -25 volts, to
standerd five volt TTL levels. These have a typical threshold of 1.3 volts and a typical
hysteresis of 0.5 volts.
                                             15
4.2 Circuit Diagram OF Project: -
      Fig-4.2 Circuit diagram of vehicle speed control using gsm
                                       16
 CHAPTER – 5
                          Result and conclusion
 If the device is connected to any system and system get over speed than device
 connected, the connected device informed the message into registered number with the
 help of GSM.
 After the receiving the message, we can either controlled device, by sending the message
 with specific value of speed or ignore the message.
 The speed device can be altered with the help of programming. And with the help of this
 device we can control accidents of the human.
 In this project basically we are discussing about component working how they operate
 and how much power supply give in internal circuit of project so this is following point
 which are discuss during project development: -
   I.   Which type transformer is use in this project and why?
  II.   How much power supply go inside circuit?
 III.   For project which microcontroller use?
 IV.    Why Rectifier is used?
  V.    Which GSM Module is Use?
 VI.    How to work transformer?
VII.    How to convert 12v AC to 5v DC?
VIII.    How can control the speed of motor with the help of GSM?
 IX.    How can use is project in different area?
  X.    How can use to controlling the accident by used this project?
                                            17
CHAPTER-6
         APPLICATION AND ADVANTAGE
6.1 APPLICATION
  To remote control controlling easy in different -different application.
  In any factory can be instil production and safety can be improve.
  Human safety, economy losses can be reducing
  Mapping device application Emergency locator. Personal positioning
  Embedded application which needs to be aware of its location on earth.
6.2 ADVANTAGE
  Effective controlling seed of motor can be done.
  Low cost, high reliable.
  Very compact device
  System is less complex so installation is easy.
  Low power consumption
6.3 FUTURE ENHANCEMENT
  Remote monitoring and controlling of DC motor.
  In gsm more number can be install than safety is increase.
  Police security.
  Any person in different–different can easy control in our factor.
  Road safety.
                                         18
                             REFERENCES
   “The PIC Microcontroller and Embedded systems” by Muhammad Ali
    Mazidi and Janice Gillispie Mazidi, Pearson Education.
   PIC16F877A Data Sheets.
   [1] A. K. Dewangan, N. Chakraborty, S. Shukla3, V. Yadu., ”PWM Based
    Automatic Closed Loop Speed Control of DC Motor”, IJETT,
   Volume3, Issue2, ppt.110-112, 2012.
   [2] Sabedin A. Meha, Besnik Haziri., “CONTROLLING DC MOTOR
    SPEED USING PWM FROM C# WINDOWS APPLICATION,” presented
   at the 15th International Research/Expert Conference on ”Trends in the
    Development of Machinery and Associated Technology” TMT 2011,
   Prague, Czech Republic, 12-18 September 2011.
   [3] Min Kim, Jang-Gyoon Choi.,” PC based DC motor speed and direction
    control using PWM and H-Bridge”, Proc. Of 2000 IEEE International
   Symposium on industrial Electronics, Vol.1, pp.141-144, 2000.
   [4] Oke A. O., Emuoyibofarhe J. O., Adetunji A. B., “ Development of a
    GSM based Control System for Electrical Appliances”, IJET, Vol.3, Issue
   No. 4, pp.443-448, April, 2013.
   [5] P. Chandra, P. Ananda, P. C. Chantola., ”GSM based stepper motor
    monitoring and speed control”, ITSI-TEEE,Vol.1, Issue No.5, pp.86-90,
   2013.
   [6] U. K. Bansal, R. narvey.” Speed Control of DC Motor Using Fuzzy PID
    Controller”, AEEE, Vol.3, Issue No.9, pp.1209-1220, 2013.
   [7] M.Jaiswal, M.Phadnis.”Speed Control of DC Motor Using Genetic
    Algorithm Based PID Controller", Vol.3, Issue N0.7, pp.247-253, 2013.
   [8] Fritzing [Online]. Available: http:/www.fritzing.org
                                      19
BOOKS:
 I.       Design with Pic Microcontroller :- Jhon B Peatman
II.       The Microcontroller and Embedded System- Mazizdi
WEBSITES:
         www.microchip.com
         www.beyondlogic.org
         www.howstuffworks.com
                                            20
                            APPENDICES
program vehiclespeed_control
' Lcd module connections
dim LCD_RS as sbit at RC2_bit
  LCD_EN as sbit at RC3_bit
  LCD_D4 as sbit at RC4_bit
  LCD_D5 as sbit at RC5_bit
  LCD_D6 as sbit at RD0_bit
  LCD_D7 as sbit at RD1_bit
' End Lcd module connections
' set of AT commands
const atc0 = "AT"               ' every GSM comand starts with "AT"
'const atc1 = "ATE0"              ' disable echo
'dim atc3 as char[35]   ' sends SMS to desired number
                                         21
'const atc3 = "AT+CMGS=\"+918800859187\""
' sms AT commands
const atm1 = "AT+CMGF=1"           ' Command for setting SMS text mode
const atm2 = "AT+CMGR=1"            ' Command for reading message from location
1 from inbox
const atm3 = "AT+CMGD=1"           ' Erasing all messages from inbox
' responses to parse
const GSM_OK       =0
const GSM_ready_to_Receive_message= 1
const RELAY_OK = 1
dim parse_type,speed as byte                 ' Determins parsing type, OK response or
SMS message
dim relay_no as byte[3]        ' Message that contains relay number
dim relay,sendsms as byte           ' Relay number
dim gsm_state,i as byte
                                        22
dim response_rcvd as byte
dim responseID, response as short
dim txt1 as char[16]
  txt2 as char[9]
  txt3 as char[8]
  txt4 as char[7]
' uart rx interrupt handler
sub procedure interrupt()
 dim tmp as byte
 if (PIR1.RCIF = 1) then             ' do we have uart rx interrupt request?
  tmp = UART1_Read()                   ' get received byte
  if(parse_type<>RELAY_OK) then              ' If we are parsing OK message
      ' process reception through state machine
      ' we are parsing only "OK" response
      select case gsm_state
                                            23
case 0
   response = -1         ' clear response
   if (tmp = "O") then    ' we have "O", it could be "OK"
    gsm_state = 1        ' expecting "K"
   end if
case 1
   if (tmp = "K") then    ' we have "K" ->
         response = GSM_OK    ' we have "OK" response
         gsm_state = 2   ' expecting CR+LF
   else
    gsm_state = 0        ' reset state machine
   end if
case 2
   if (tmp = 13) then     ' we have 13, it could be CR+LF
    gsm_state = 3        ' expecting LF
   else
                                   24
          gsm_state = 0             ' reset state machine
         end if
    case 3
         if (tmp = 10) then         ' we have LF, response is complete
            response_rcvd = 1         ' set reception flag
            responseID = response       ' set response ID
         end if
         gsm_state = 0              ' reset state machine
    case else
     gsm_state = 0                  ' unwanted character
                              ' reset state machine
    end select
end if
if(parse_type=RELAY_OK)then                    ' Parsing received message
  select case gsm_state
   case 0
                                              25
 response = -1         ' clear response
 if (tmp = "S") then    ' we have "R"
  gsm_state = 10        ' expecting "e"
 end if
case 10
 if (tmp = "p") then    ' we have "e"
  gsm_state = 11        ' expecting "l"
 else
  gsm_state = 0        ' reset state machine
 end if
case 11
 if (tmp = "e") then    ' we have "l"
  gsm_state = 12        ' expecting "a"
 else
  gsm_state = 0        ' reset state machine
 end if
case 12
 if (tmp = "e") then    ' we have "a"
  gsm_state = 13        ' expecting "y"
                                 26
       else
          gsm_state = 0         ' reset state machine
       end if
      case 13
       if (tmp = "d") then       ' we have "y"
          gsm_state = 14         ' expecting first digit
       else
          gsm_state = 0         ' reset state machine
       end if
      case 14
       relay_no[0] = tmp          ' setting first digit into array
       gsm_state = 15            ' expecting second digit
      case 15
end sub
' send ATC command
sub procedure send_atc(dim const s as ^char)
 while(s^ <> 0)
   UART1_Write(s^)
                                           27
   inc(s)
 wend
   UART1_Write(0x0D)
end sub
' get GSM response, if there is any
sub function get_response() as short
  if (response_rcvd <> 0) then
   response_rcvd = 0
   result = responseID
  else
   result = -1
  end if
end sub
' wait for GSM response
sub procedure wait_response(dim const rspns as byte)
 while (get_response() <> rspns)
 wend
end sub
' pause
                                         28
sub procedure wait()
 Delay_ms(3000)
end sub
main:
 parse_type = GSM_OK
ADCON1 = 0x0F                         ' All AN pins as digitall
 CMCON = 0x07                         ' Turn off comparators
 speed=0
' set RTS pin to zero, we will use only RX i TX
 'TRISE = 0xFF
 'PORTE = 0
TRISB = 0x00
 TRISC = 0
 TRISD = 0xF0
PORTB = 0
 'PORTD = 0
 txt1 = "GSM Vehicle"
 txt2 = "Speed Control"
 txt3 = "FINAL YR"
                                           29
 txt4 = "PROJECT"
Lcd_Init()               ' Initialize Lcd
 Lcd_Cmd(_LCD_CLEAR)                   ' Clear display
 Lcd_Cmd(_LCD_CURSOR_OFF)                   ' Cursor off
 Lcd_Out(1,6,txt3)            ' Write text in first row
 Lcd_Out(2,6,txt4)            ' Write text in second row
 Delay_ms(2000)
 Lcd_Cmd(_LCD_CLEAR)                   ' Clear display
Lcd_Out(1,1,txt1)            ' Write text in first row
 Lcd_Out(2,1,txt2)            ' Write text in second row
 Delay_ms(500)
 Lcd_Cmd(_LCD_CLEAR)
 Lcd_Out(1,1,"GSM TESTING...")
' enable uart rx interrupt
 RCIE_bit = 1
 PEIE_bit = 1
 GIE_bit = 1
UART1_init(9600)                        ' initialize USART module
                                               30
 Wait()                        ' wait for the GSM module to initialize it self
' negotiate baud rate
 for i=0 to 10
 send_atc(@atc0)        ' send "AT" string until gsm sets up its baud rade
 delay_ms(1000)
 next i
' set text mode
 for i=0 to 10
send_atc(@atm1)
 delay_ms(500)
 next i
for i=0 to 10
 send_atc(@atm2)
 delay_ms(1000)
 next i
for i=0 to 5
 send_atc(@atm3)
 delay_ms(1000)
                                31
next i
Lcd_Cmd(_LCD_CLEAR)
 Lcd_Out(1,1,"TESTING DONE")
 Lcd_Out(2,1,"START VEHICLE")
 Delay_ms(2000)
 Lcd_Cmd(_LCD_CLEAR)
check4:
 while TRUE
   parse_type = RELAY_OK
   send_atc(@atm2)                    ' Read SMS message on location 1
    if (portd.4=1) then
         check1:
         Lcd_Out(1,1,"Speed = 30 Km/hr")
         PORTB=24
         delay_ms(10)
         PORTB=0
         delay_ms(150)
                                           32
       if (portd.5=1) then
       goto check2
       else if (portd.6=1) then
        goto check3
       else
       goto check1
       end if
       end if
else if (portd.5=1) then
       check2:
       Lcd_Out(1,1,"Speed = 50 Km/hr")
       PORTB=24
       delay_ms(10)
       PORTB=0
       delay_ms(30)
       if portd.4=1 then
       goto check1
       else if portd.6=1 then
        goto check3
                                         33
      else
       goto check2
       end if
       end if
else if (portd.6=1) then
Lcd_Out(1,1,"Speed = 90 Km/hr")
      PORTB=24
      sendsms=4
      if(sendsms=4) then
          UART1_Write_Text("AT+CMGF=1")
          UART1_Write(13)
          UART1_Write(10)
          Delay_ms(2000)
          UART1_Write_Text("AT+CMGS=")
          UART1_Write(0x22)
          UART1_Write_Text("+919555532249")
          Delay_ms(100)
          UART1_Write(0x22)
          UART1_Write(13)
                                    34
         UART1_Write(10)
         Delay_ms(1000)
         UART1_Write_Text("High speed")
         UART1_Write(0x0D)
         UART1_Write(26)
         UART1_Write(0x0D)
         sendsms = 0
  end if
else if (speed=3) then
   goto check4
   else if (speed=1) then
 else if (speed=2) then
end if
end if
end if
end if
 end if
end if
                                    35
if (get_response() = RELAY_OK) then          ' If we have OK response
  relay = Get_Relay_Number()            ' Get relay number
  Lcd_Cmd(_LCD_CLEAR)
    Lcd_Out(1,1,"MESSAGE RECEIVED")
  DELAY_MS(1000)
  Lcd_Cmd(_LCD_CLEAR)
  if(relay = 1) then            ' If relay number is less or equal 8
         speed=1
         Lcd_Out(1,1,"Speed = 30 Km/hr")
  else if(relay = 2) then           ' If relay number is less or equal 8
    Lcd_Out(1,1,"Speed = 50 Km/hr")
  else
   PORTD = %00000000        ' Toggle relay on PORTD
                                      36
         end if
         end if
         while TRUE                  ' Make sure that we deleted messages
          parse_type = GSM_OK
          send_atc(@atm3)              ' Delete all messages
          if (get_response() = GSM_OK) then    ' If messages are deleted
           break                  ' break from while
          end if
          wait()
         went
end if
   wait()
  wend
end.
                                          37