0% found this document useful (0 votes)
10 views21 pages

UNIT V Notes

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views21 pages

UNIT V Notes

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Unit-V

Q1. What is Bluetooth technology. How it is interfaced with microcontroller 8051?

Ans. Bluetooth is primarily open wireless protocol for exchanging data over short distance (using
short and length radio waves) from fixed and mobile devices creating personal area network. It is
majorly alternative to RS232.data cables.

It is used for short distances communications. RXD and TXD OF Bluetooth and 8051 are
connected together.. The HC-05 Bluetooth Module is an easy-to-use Bluetooth serial module. It
is designed for transparent wireless serial connection setup. Its communication is via the serial
mode, which makes it easy to interface it with any microcontroller.

he HC-05 Bluetooth module provides a switching mode between master and slave mode. A
single master device can be connected to up to several different slave devices. But, a slave device
in the Bluetooth network can only be connected to a single master. The master device can send
data to any of its slaves and request data from them as well, but, the slaves are only allowed to
transmit to and receive from their master. They can’t talk to other slaves in the network.

To enable Bluetooth communication, the HC-05 module is interfaced with the 8051
microcontroller via the built-in UART circuitry present in the microcontroller. And the data is
transmitted in the form of packets. The 8051 microcontrollers have inbuilt pins P3.0 (RXD) and
P3.1 (TXD) for receiving and transmitting the data from/to the HC-05 Bluetooth module
respectively.
Pin
Pin Name Description
Number

This pin is used to toggle between Connection Mode and AT


Enable /
1 command mode. By default, it is in Connection mode. LOW –
Key
Connection Mode, HIGH – AT command mode.

2 VCC Powers the module. Connect to +5V Supply voltage

3 GND Ground pin of the module, connect to system ground.

TXD – Transmits Serial Data. Everything received via Bluetooth will be


4
Transmitter given out by this pin as serial data.

RXD – Receive Serial Data. Every serial data given to this pin will be
5
Receiver broadcasted/ transmitted via Bluetooth.

The state pin is connected to an on-board LED, and it can be used


6 State
as feedback to check if Bluetooth is working properly.

Indicates the status of Module

Repeated Blinking: Waiting for connection in Connection Mode


7 LED
Blink twice in 1 sec: Connection successful in Connection Mode

Blink once in 2 sec: Module has entered AT Command Mode

Used to control the Key/Enable pin to toggle between Connection


8 Button
and command Mode

Circuit diagram to interface Bluetooth module and relay with 8051

• Step 1: Connect a 12 MHz oscillator between pin 18 and 19.


• Step 2: Connect two capacitors of 22pF, with one terminal on either side of the oscillator
and the other terminal to ground, as shown below.

• Step 3: Set Pin 31, i.e., EA pin to HIGH by connecting it to the +5V DC source.

• Step 4: Now, to make the RESET circuit, connect Pin 9 (RST) to +5V through a
capacitor of 10µF and connect the same pin to +0V (GND) through a 10kΩ resistor or a
potentiometer.

• Step 5: Connect two LEDs to the microcontroller such that they turn ON when a low
pulse is given through Port 0’s output. For this, ULN2003a driver is used, pin P0.0 and
P0.1 are connected to 1B and 2B of ULN2003A respectively.

• Step 6: The output pins 1C and 2C of ULN2003a are given to one terminal of the coil of
the relay and the other terminal of the coil of the relay is connected to the COM pin of
ULN2003A which is connected to a DC supply.

• Step 7: One side of the contactor of the relay is connected to the cathode of the LED, and
the anode is connected to the power supply. Connect the other side of the contactor to the
COM pin of ULN2003A.

• Step 8: Here comes the main part, connect the RXD (P3.0) and TXD (P3.1) of the 8051
microcontrollers to TXD and RXD pins of HC-05 Bluetooth module respectively.

• Step 9: VCC and GND pins of the HC-05 Bluetooth module are to be given to +5V/3.3V
and GND, respectively, for the module to turn ON.

• Step 10: Ignore the other pins of HC-05, as they do not contribute to our project.
Circuit diagram of microcontroller with Bluetooth module

Q2. define zigbee protocol. How it is interfaced with 8051. What are its advantage over
Bluetooth technology.

Ans. ZigBee is a specification for a suite of high level communication protocols using small,
low-power digital radios based on an IEEE 802 standard for personal area networks.

The Digi Xbee 802.15.4 modules are the easiest to use, most reliable and cost-effective RF
devices we’ve experienced. The 802.15.4 Xbee modules provide two friendly modes of
communication – a simple serial method of transmit/receive or a framed mode providing
advanced features. These modules can communicate point to point, from one point to a PC, or in
a mesh network.

The Xbee modules work at the 2.4 GHz frequency which means smaller board and antenna size
.Xbee modules have the ability to transmit Digital PWM Analog or Serial RS232 signals
wirelessly. To communicate over UART or USART, we just need three basic signals which are
namely, RXD (receive), TXD (transmit), GND (common ground). So, to interface UART with
8051, we just need the basic signals
ZIGBEE MODEM MAX-232 MICROCONTROLLER

We now want to interface the ZigBee module with8051 Primer Board for accessing the mobiles
without wires through UART0. The data communication is done in internet by using the ZigBee
module through MAX232 into the SBUF register of 8051 microcontroller (refer serial interfacing
with 8051). The serial data from the Zigbee receiver is taken by using the Serial Interrupt of the
controller. +5V and ground is connected to provide power to the module. While TX and RX
pin is connected for communication.

PIN ASSIGNMENT WITH 8051

UART DB-9 Connector 8051 lines


TXD-0 P3.0
UART0 (Port-1)
RXD-0 P3.1
TXD-1- P1.2
UART1(Port-2)
RXD1 P1.3
Q3. Explain interfacing of LED interfacing to microcontrollers.

Ans. Interfacing is a method, that provides communication between Microcontroller and the
interface device. An interface is either Input device, or output device, or a storage device, or
processing device.

Input Interface Devices: Push button switch, Keypad, Infrared sensor, Temperature sensor, gas
Sensor etc. These devices provide some information to the Microcontroller, and this is called
input data.
Output Interface Devices: LED, LCD, Buzzer, Relay driver, DC Motor Driver, 7-Segment
Display etc.

Storage Interface Devices: Used to store/ retain the data, example, SD card, EEPROM,
DataFlash, Real Time Clock, etc.

Observe carefully the interface LED 2 is in forward biased because the input voltage of 5v
connected to the positive terminal of the LED, So here the Microcontroller pin should be at LOW
level. And vice versa with the interface 1 connections.

The resistor is important in LED interfacing to limit the flowing current and avoid damaging the
LED and/or MCU.

• Interface 1 will glow LED, only if the PIN value of the MC is HIGH as current flows
towards the ground.

• Interface 2 will glow LED, only if the PIN value of the MC is LOW as current flows
towards PIN due to its lower potential.
The circuit diagram for LED interfacing with 8051 microcontroller 89S52 is shown in above
figure. Pin 31 (EA) is connected to Vcc, which is an active low pin. This should be connected to
Vcc when we are not using the any external memory. Pin 30(ALE) and pin 29 (PSEN) are used
to connect microcontroller to the external memory and Pin 31 tells microcontroller to use
external memory, when connected to Ground. We are not using any external memory so we
connected Pin31 to Vcc.

Pin 9 (RST) is the reset PIN, used to reset the microcontroller and program again starts from the
beginning. It resets the microcontroller when connected to HIGH. We have used standard reset
circuitry, 10k ohm resistor and 1uF Capacitor to connect the RST pin.

Now the interesting part here is that we connect the LED in reverse, means negative leg with
microcontroller PIN, because microcontroller don’t provide enough power to glow an LED, so
here the LED run on the negative logic like when, pin P1_0 is 1 then LED will be tuned OFF and
when pin output is 0 then LED will be turned ON. When PIN output is 0, it behaves like ground
and LED glows.

Q4. Explain interfacing of LCD interfacing to microcontrollers.

Ans, to understand and connect 16 pins of LCD to the microcontroller. So first let's understand
the 16 pins of LCD module.

We can divide it in five categories, Power Pins, contrast pin, Control Pins, Data pins and
Backlight pins.

Category Pin NO. Pin Name Function

1 VSS Ground Pin, connected to Ground


Power Pins
2 VDD or Vcc Voltage Pin +5V

Contrast Setting, connected to Vcc thorough a


Contrast Pin 3 V0 or VEE
variable resistor.

Register Select Pin, RS=0 Command mode,


4 RS
RS=1 Data mode

Read/ Write pin, RW=0 Write mode,


Control Pins 5 RW
RW=1 Read mode

Enable, a high to low pulse need to enable the


6 E
LCD

Data Pins, Stores the Data to be displayed on


Data Pins 7-14 D0-D7
LCD or the command instructions

Backlight Pins 15 LED+ or A To power the Backlight +5V


16 LED- or K Backlight Ground

All the pins are clearly understandable by their name and functions, except the control pins, so
they are explained below:

RS: RS is the register select pin. We need to set it to 1, if we are sending some data to be
displayed on LCD. And we will set it to 0 if we are sending some command instruction like clear
the screen (hex code 01).

RW: This is Read/write pin, we will set it to 0, if we are going to write some data on LCD. And
set it to 1, if we are reading from LCD module. Generally, this is set to 0, because we do not
have need to read data from LCD. Only one instruction “Get LCD status”, need to be read
sometimes.

E: This pin is used to enable the module when a high to low pulse is given to it. A pulse of 450
ns should be given. That transition from HIGH to LOW makes the module ENABLE.
Q5 explain interfacing of keyboard with microcontroller with 8051

Ans. Keypads are widely used input devices being used in various electronics and embedded
projects. They are used to take inputs in the form of numbers and alphabets, and feed the same
into system for further processing.

4X4 Matrix Keypad

Before we interface the keypad with microcontroller, first we need to understand how it works.
Matrix keypad consists of set of Push buttons, which are interconnected. Like in our case we are
using 4X4 matrix keypad, in which there are 4 push buttons in each of four rows. And the
terminals of the push buttons are connected according to diagram. In first row, one terminal of all
the 4 push buttons are connected together and another terminal of 4 push buttons are representing
each of 4 columns, same goes for each row. So we are getting 8 terminals to connect with a
microcontroller.
First we need to interface a LCD module to display the data which will be feed through
KEYPAD, so please go through “LCD Interfacing with 8051 Microcontroller” article before
interfacing KEYPAD.

As shown in above circuit diagram, to interface Keypad, we need to connect 8 terminals of the
keypad to any port (8 pins) of the microcontroller. Like we have connected keypad terminals to
Port 1 of 8051. Whenever any button is pressed we need to get the location of the button, means
the corresponding ROW an COLUMN no. Once we get the location of the button, we can print
the character accordingly.
Now the question is how to get the location of the pressed button? I am going to explain this in
below steps and also want you to look at the code:

1. First we have made all the Rows to Logic level 0 and all the columns to Logic level 1.

2. Whenever we press a button, column and row corresponding to that button gets shorted and
makes the corresponding column to logic level 0. Because that column becomes connected
(shorted) to the row, which is at Logic level 0. So we get the column no. See main() function.

Now we need to find the Row no., so we have created four functions corresponding to each
column. Like if any button of column one is pressed, we call function row_finder1(), to find the
row no.

4. In row_finder1() function, we reversed the logic levels, means now all the Rows are 1 and
columns are 0. Now Row of the pressed button should be 0 because it has become connected
(shorted) to the column whose button is pressed, and all the columns are at 0 logic. So we have
scanned all rows for 0.

So whenever we find the Row at logic 0, means that is the row of pressed button. So now we
have column no (got in step 2) and row no., and we can print no. of that button using lcd_data
function.

Same procedure follows for every button press, and we are using while(1), to continuously
check, whether button is pressed or not.

Q6. Explain interfacing of microcontroller with stepper motor?

Ans. Stepper motor is brushless DC motor, which can be rotated in small angles, these angles are
called steps. Generally stepper motor use 200 steps to complete 360 degree rotation, means its
rotate 1.8 degree per step. Stepper motor used in many devices which needs precise rotational
movement like robots, antennas, hard drives etc. We can rotate stepper motor to any particular
angle by giving it proper instructions.

Interfacing Stepper Motor with 8051 Microcontroller

Interfacing with 8051 is very easy we just need to give the 0 and 1 to the four wires of stepper
motor according to the above tables depending on which mode we want to run the stepper motor.
And rest two wires should be connected to a proper 12v supply (depending on the stepper
motor).
8051 doesn’t provide enough current to drive the coils so we need to use a current driver IC
that is ULN2003A. ULN2003A is the array of seven NPN Darlington transistor pairs.
Darlington pair is constructed by connecting two bipolar transistors to achieve high current
amplification. In ULN2003A, 7 pins are input pins and 7 pins are output pins, two pins are for
Vcc (power supply) and Ground. Here we are using four input and four output pins. We can also
use L293D IC in place of ULN2003A for current amplification.

You need to find out four coil wires and two common wires very carefully otherwise motor will
not rotate. You can find it out by measuring resistance using multimeter, multimeter won’t show
any readings between the wires of two phases. Common wire and the other two wire in the same
phase should show the same resistance, and the two end points of the two coils in the same phase
will show the twice resistance in compared with resistance between common point and one end
point.

Q7. Explain interfacing of DC motor interfacing with microcontroller.

Ans. DC motor converts electrical energy in the form of Direct Current into mechanical energy.

• In the case of the motor, the mechanical energy produced is in the form of a rotational
movement of the motor shaft.

• The direction of rotation of the shaft of the motor can be reversed by reversing the
direction of Direct Current through the motor.

• The motor can be rotated at a certain speed by applying a fixed voltage to it. If the
voltage varies, the speed of the motor varies.

• Thus, the DC motor speed can be controlled by applying varying DC voltage; whereas
the direction of rotation of the motor can be changed by reversing the direction of current
through it.
Let’s interface the DC motor with the AT89S52 microcontroller and control the DC motor speed
by using the Speed Increment Switch and Speed Decrement Switch connected to the
Microcontroller port and direction by using Direction Switch.

We are going to use the L293D motor driver IC to control the DC motor movement in both
directions. It has an in-built H-bridge motor drive.

• As shown in the above figure we have connected two toggle switches on the P1.0 and
P1.1 pin of the AT89S52 microcontroller to change the speed of the DC motor by 10%.

• One toggle switch at pin P1.2 controls the motor's rotating direction.
• P1.6 and P1.7 pins are used as output direction control pins. It provides control to motor1
input pins of the L293D motor driver which rotate the motor clockwise and anticlockwise
by changing their terminal polarity.

• And Speed of the DC Motor is varied through PWM Out pin P2.0.

• Here we are using the timer of AT89S52 to generate PWM.

Q8. Explain interfacing of DC motor interfacing with microcontroller.

Ans. DHT11 Sensor

DHT11 is a single-wire digital humidity and temperature sensor, which provides humidity and
temperature values serially.

It can measure the relative humidity in percentage (20 to 90% RH) and temperature in degree
Celsius in the range of 0 to 50°C.

It has 4 pins of which 2 pins are used for supply, 1 is not used and the last one is used for data.

The data is the only pin used for communication. Pulses of different TON and TOFF are decoded
as logic 1 or logic 0 or start pulse or end of the frame.
• The above circuit diagram shows the interfacing of 8051 with the DHT11 sensor.

• In that, a DHT11 sensor is connected to P2.1(Pin No 22) of the microcontroller.

DHT11 Sensor 8051 Programming Steps

• First, initialize the LCD16x2_4bit.h library.


• Define pin no. to interface the DHT11 sensor, in our program we define P2.1 (Pin no.22)

• Send the start pulse to the DHT11 sensor by making low to high on the data pin.

• Receive the response pulse from the DHT11 sensor.

• After receiving the response, receive 40-bit data serially from the DHT11 sensor.

• Display this received data on LCD16x2 along with the error indication.

You might also like