Report MP MC

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

PSG COLLEGE OF TECHNOLOGY, COIMBATORE-641004

DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING

15E502-MICROPROCESSOR AND MICROCONTROLLER

REPORT ON

AUTOMATIC TRAFFIC CONTROLLER AND


BLUETOOTH CONTROLLED ROBOT

Date of Submission: 01/10/2019

Submitted to:

Dr. Neelaveni R

PROFESSOR(CAS)

DEPARTMENT OF ELECTRICAL AND ELECTRONICS

ENGINEERING,

PSG COLLEGE OF TECHNOLOGY.


Submitted by:

NAME ROLL.NO MARKS

NIRMAL NARAIANAN S 17E135

NITHEESH P 17E136

PRAVEENA P 17E137

RAGUL S 17E138
AUTOMATIC TRAFFIC CONTROLLER AND
BLUETOOTH CONTROLLED ROBOT

Introduction for traffic light signal:

A traffic signal is ensuring that traffic moves as smoothly and safely as possible. The
existing scenarios in the major cities need to implement the flexible traffic signal subsequences
to coordinate the traffic flow. Traffic light/signal controllers are undergone with continual
improvement. The main objective of the traffic signal controller is to provide the sophisticated
control and coordination on traffic. The co-ordination of traffic light control system is achieved
by implementing microcontroller chips to make it a simple and low-cost system, which inbuilt
with microprocessors like 8085, 8051 etc. These microcontrollers are controlling these traffic
lights in a specific manner and auto changing at a specified range of time interval or density
of the traffic.

Traffic Signal Controller (Microprocessor Based) detects traffic data and actuates optimum
management strategies for the regulation of urban traffic. Traffic Signal Control is the
establishment of formal or informal arrangements to share traffic control information as well
as actual control of traffic signal operation across jurisdictions.

Interrupts in microcontroller 8051:

Interrupts are of different types like software and hardware, maskable and non-
maskable, fixed and vector interrupts, and so on. Interrupt Service Routine (ISR) comes into
the picture when interrupt occurs, and then tells the processor to take appropriate action for
the interrupt, and after ISR execution, the controller jumps into the main program.

The 8051 microcontroller can recognize five different events that cause the main
program to interrupt from the normal execution. These five sources of interrupts in 8051are:
1. Timer 0 overflow interrupt- TF0
2. Timer 1 overflow interrupt- TF1
3. External hardware interrupt- INT0
4. External hardware interrupt- INT1
5. Serial communication interrupt- RI/TI

The Timer and Serial interrupts are internally generated by the microcontroller, whereas the
external interrupts are generated by additional interfacing devices or switches that are
externally connected to the microcontroller. These external interrupts can be edge triggered
or level triggered. When an interrupt occurs, the microcontroller executes the interrupt service
routine so that memory location corresponds to the interrupt that enables it.
All these interrupts can be set or cleared by bit in some special function register that
is Interrupt Enabled (IE), and this in turn depends on the priority, which is executed by IP
interrupt priority register.
Interrupt Enable (IE) Register: This register is responsible for enabling and disabling the
interrupt. It is a bit addressable register in which EA must be set to one for enabling interrupts.
The corresponding bit in this register enables particular interrupt like timer, external and serial
inputs. In the below IE register, bit corresponding to 1 activates the interrupt and 0 disables
the interrupt.

Interrupt Enable (IE) Register

Interrupt Priority Register (IP): It is also possible to change the priority levels of the interrupts
by setting or clearing the corresponding bit in the Interrupt priority (IP) register as shown in the
figure. This allows the low priority interrupt to interrupt the high-priority interrupt, but prohibits
the interruption by another low-priority interrupt. Similarly, the high-priority interrupt cannot be
interrupted. If these interrupt priorities are not programmed, the microcontroller executes in
predefined manner and its order is INT0, TF0, INT1, TF1, and SI.

IP register
TCON Register: In addition to the above two registers, the TCON register specifies the type
of external interrupt to the 8051 microcontroller, as shown in the figure. The two external
interrupts, whether edge or level triggered, specify by this register by a set, or cleared by
appropriate bits in it. And, it is also a bit addressable register.

Microcontroller
A microcontroller is a small, low-cost and self contained computer-on-a-chip that can be
used as an embedded system. A few microcontrollers may utilize four-bit expressions and
work at clock rate frequencies, which usually include:

● An 8 or 16 bit microprocessor.
● A little measure of RAM.
● Programmable ROM and flash memory.
● Parallel and serial I/O.
● Timers and signal generators.
● Analog to Digital and Digital to Analog conversion
Microcontrollers usually must have low-power requirements since many devices they control
are battery-operated. Microcontrollers are used in many consumer electronics, car engines,
computer peripherals and test or measurement equipment. And these are well suited for long
lasting battery applications.

Classification of microcontroller

● Classification according to number of bits


● Classification according to memory devices
● Classification according to instruction set
● Classification according to memory architecture

Classification According to Number of Bits

The bits in microcontroller are 8-bits, 16-bits and 32-bits microcontroller.

Classification According to Memory Devices

The memory devices are divided into two types, they are

● Embedded memory microcontroller


● External memory microcontroller
Embedded memory microcontroller: When an embedded system has a microcontroller unit
that has all the functional blocks available on a chip is called an embedded microcontroller.
For example, 8051 having program & data memory, I/O ports, serial communication, counters
and timers and interrupts on the chip is an embedded microcontroller.

External Memory Microcontroller: When an embedded system has a microcontroller unit


that has not all the functional blocks available on a chip is called an external memory
microcontroller. For example, 8031 has no program memory on the chip is an external memory
microcontroller.

Classification According to Instruction Set

CISC: CISC is a Complex Instruction Set Computer. It allows the programmer to use one
instruction in place of many simpler instructions.

RISC: The RISC is stands for Reduced Instruction set Computer, this type of instruction sets
reduces the design of microprocessor for industry standards. It allows each instruction to
operate on any register or use any addressing mode and simultaneous access of program
and data.

Classification According to Memory Architecture

Memory architecture of microcontroller are two types, they are namely:

● Harvard memory architecture microcontroller


● Princeton memory architecture microcontroller
Harvard Memory Architecture Microcontroller: The point when a microcontroller unit has a
dissimilar memory address space for the program and data memory, the microcontroller has
Harvard memory architecture in the processor.

Princeton Memory Architecture Microcontroller: The point when a microcontroller has a


common memory address for the program memory and data memory, the microcontroller has
Princeton memory architecture in the processor.

Applications of Microcontrollers

Microcontroller has many applications electronic equipment’s

● Mobile Phones
● Auto Mobiles
● Washing Machines
● Cameras
● Security Alarms

Bluetooth module.

Bluetooth module is a PCBA board which integrated


Bluetooth functions. Bluetooth module can be used in short-distance wireless communication,
which can be divided into the Bluetooth module and Bluetooth voice module according to its
usage.

HC05
Pin Configuration

Pin Pin Name Description


Number

1 Enable / Key This pin is used to toggle between Data Mode


(set low) and AT command mode (set high). By
default it is in Data mode

2 Vcc Powers the module. Connect to +5V Supply


voltage

3 Ground Ground pin of module, connect to system


ground.

4 TX – Transmitter Transmits Serial Data. Everything received via


Bluetooth will be given out by this pin as serial
data.

5 RX – Receiver Receive Serial Data. Every serial data given to


this pin will be broadcasted via Bluetooth
6 State The state pin is connected to on board LED, it
can be used as a feedback to check if Bluetooth
is working properly.

7 LED Indicates the status of Module

 Blink once in 2 sec: Module has entered


Command Mode
 Repeated Blinking: Waiting for connection in
Data Mode
 Blink twice in 1 sec: Connection successful in
Data Mode

8 Button Used to control the Key/Enable pin to toggle


between Data and command Mode

HC-05 Default Settings

Default Bluetooth Name: “HC-05”

Default Password: 1234 or 0000

Default Communication: Slave

Default Mode: Data Mode

Data Mode Baud Rate: 9600,

HC-05 Technical Specifications

 Serial Bluetooth module for Arduino and other microcontrollers


 Operating Voltage: 4V to 6V (Typically +5V)
 Operating Current: 30mA
 Range: <100m
 Works with Serial communication (USART) and TTL compatible
 Uses Frequency-Hopping Spread spectrum (FHSS)
 Can operate in Master, Slave or Master/Slave mode
 Can be easily interfaced with Laptop or Mobile phones with Bluetooth.
Where to use HC-05 Bluetooth module

The HC-05 is a very cool module which can add two-way (full-duplex) wireless functionality to
your projects. You can use this module to communicate between two microcontrollers like
Arduino or communicate with any device with Bluetooth functionality like a Phone or Laptop.
There are many android applications that are already available which makes this process a
lot easier. The module communicates with the help of USART at 9600 baud rate hence it is
easy to interface with any microcontroller that supports USART. We can also configure the
default values of the module by using the command mode. So if you looking for a Wireless
module that could transfer data from your computer or mobile phone to microcontroller or vice
versa then this module might be the right choice for you. However do not expect this module
to transfer multimedia like photos or songs; you might have to look into the CSR8645 module
for that.

How to Use the HC-05 Bluetooth module

The HC-05 has two operating modes, one is the Data mode in which it can
send and receive data from other Bluetooth devices and the other is the AT Command mode
where the default device settings can be changed. We can operate the device in either of
these two modes by using the key pin as explained in the pin description.It is very easy to pair
the HC-05 module with microcontrollers because it operates using the Serial Port Protocol
(SPP). Simply power the module with +5V and connect the Rx pin of the module to the Tx of
MCU and Tx pin of module to Rx of MCU.During power up the key pin can be grounded to
enter into Command mode, if left free it will by default enter into the data mode. As soon as
the module is powered you should be able to discover the Bluetooth device as “HC-05” then
connect with it using the default password 1234 and start communicating with it. The name
password and other default parameters can be changed by entering into the at.

ADVANTAGES:

1.When we are travelling with the laptop and with the other wireless devices awe don’t need
to carry the connection cables.

2. Hence it is a wireless technology.

3.The cost of the Bluetooth is not an expensive.

4.The Bluetooth modules are standardized protocol because they can connect with the same
Bluetooth as well as with the different Bluetooth as well as with the different Bluetooth projects
models.
5.There is a low energy consumption in the Bluetooth devices in generally we see in mobile
phones.

Applications:

1. Wireless communication between two microcontrollers

2. Communicate with Laptop, Desktops and mobile phones

3. Data Logging application

4. Consumer applications

5. Wireless Robots

6. Home Automation

PROBLEM STATEMENT:

Due to the increased traffic we need to control it smartly. Depending on the


vehicle on each side the signal are to controlled in such a way that waiting time in traffic is
less. Ambulance are considered as interrupt here to stop the current execution and perform
the ISR to make way for the ambulance to move quickly. Here the vehicle is noted using IR
sensor and the interrupt is send through Bluetooth module.

ALGORITHM:

Step 1: Set the initial condition of ports.

Step2: Enable EA,ITx,EXx

Step3: Initiate the traffic controller

Step4: Check for the pins of Port1 and depending on that the controller is set

Step5: When an Interrupt is occurred using Bluetooth module the ISR is executed
PROGRAM: void way1()

#include<reg51.h> {

sbit wy11=P1^0; if((wy12 == 0)&&( wy11 == 0))

sbit wy12=P1^1; {P2=0x56; delay1();


}
sbit wy21=P1^2;
else if(wy11==0)
sbit wy22=P1^3;
{P2=0x56;delay();}
sbit wy31=P1^4;
}
sbit wy32=P1^5;
void way2()
sbit wy41=P1^6;
{ if((wy22==0)&&(wy21==0))
sbit wy42=P1^7;
{P2=0x59;
void delay()
delay1();
{
}
int i,j;
else if(wy21==0)
for(i=0;i<=2000;i++)
{P2=0x59;
for(j=0;j<1000;j++);
delay(); } }
}
void way3()
void extr0(void) interrupt 0
{
{ P2=0x56; delay(); }
if((wy32==0)&&(wy31==0))
void extr1(void) interrupt 2
{P2=0x65;
{ P2=0x59; delay(); }
delay1();
void delay1()
}
{int i,j; for(i=0;i<=1000;i++)
else if(wy31==0)
for(j=0;j<1000;j++);}
{ void main()

P2=0x65; { P1=0xFF;

delay();} EA=1;

} IT0=1;

void way4() IT1=1;

{ EX0=1;

if((wy42== 0)&&(wy41== 0)) EX1=1;

{P2=0x95; while(1)

delay1(); } {P2=0x55;way1();way2();way3();

else if(wy41==0) way4();

{P2=0x95; }

delay();}} }
7 6 5 4 3 2 1 0

P1 Wy42 Wy41 Wy32 Wy31 Wy22 Wy21 Wy12 Wy11

P2 G4 R4 G3 R3 G2 R2 G1 R1

When INT0 or INT1 pin is made low using Bluetooth module the corresponding
service routine is initiated.
BLUETOOTH CONTROLLED ROBOT:

#include<reg51.h> { TMOD = 0x20;


TH1 = 0xFD;
int i; SCON = 0x50;
void delay(unsigned int count) TR1 = 1;
{ TI = 0;
int i,j; while(1)
for(i=0;i<count;i++) { s_tx1('f');
for(j=0;j<100;j++);} delay(10000);
s_tx1('r');
void s_tx1(char dt) delay(10000);
{ s_tx1('b');
delay(10000);
SBUF = dt; s_tx1('l');
while(TI==0); delay(10000);
TI = 0; s_tx1('s');
delay(400); delay(10000);
}
}
}
void main()
In robot module:
#include<reg51.h> L2=0;
sbit L1 = P2^0; R1=1;
sbit L2 = P2^1; R2=0;
sbit R1 = P2^2; }
sbit R2 = P2^3; else if(datarec=='b')
int i,j; {
unsigned char datarec; L1=0;
void delay(unsigned int count) L2=1;
{ R1=0;
int i,j; R2=1;
for(i=0;i<count;i++) }
for(j=0;j<112;j++); else if(datarec=='l')
} {
L1=0;
L2=0;
void s_rec1(void) R1=1;
{ R2=0;
while(RI==0); }
datarec = SBUF; else if(datarec=='r')
RI = 0; {
} L1=1;
L2=0;
R1=0;
void main() R2=0;
{P2 = 0x00; }
TMOD = 0x20; else
TH1 = 0xFD; {
SCON = 0x50; L1=0;
TR1 = 1; L2=0;
while(1) R1=0;
{ R2=0;
s_rec1(); }
if(datarec=='f'){ L1=1; } }
Reference:

1. The 8051 Microcontroller and embedded system – Mazidi


2. Tutorialpoint.com
3. Circuitdigest.com
4. Keil.com

Result:

Thus, a traffic controller and a Bluetooth controlled robot was designed using
8051 microcontroller and Bluetooth module and the results were verified using Keil
and Proteus.

You might also like