Vous êtes sur la page 1sur 49

1.

POWER SUPPLY
INTRODUCTION
Almost all basic household electronic circuits need an unregulated AC to
be converted to constant DC, in order to operate the electronic device. All devices will have a
certain power supply limit and the electronic circuits inside these devices must be able to supply
a constant DC voltage within this limit. That is, all the active and passive electronic devices will
have a certain DC operating point (Q-point or Quiescent point), and this point must be achieved
by the source of DC power. The DC power supply is practically converted to each and every
stage in an electronic system. Thus a common requirement for all this phases will be the DC
power supply. All low power system can be run with a battery. But, for long time operating
devices, batteries could prove to be costly and complicated. The best method used is in the form
of an unregulated power supply a combination of a transformer, rectifier and a filter. The
diagram is shown below.

As shown in the figure above, a small step down transformer is used to reduce
the voltage level to the devices needs. In India, a 1 supply is available at 230 volts. The output

of the transformer is a pulsating sinusoidal AC voltage, which is converted to pulsating DC with


the help of a rectifier. This output is given to a filter circuit which reduces the AC ripples, and
passes the DC components. But here are certain disadvantages in using an unregulated power
supply.
1. Poor Regulation When the load varies, the output does not appear constant. The output
voltage changes by a great value due to the huge change in current drawn from the supply. This
is mainly due to the high internal resistance of the power supply (>30 Ohms).
2. AC Supply Main Variations The maximum variations in AC supply mains is give or take
6% of its rated value . But this value may go higher in some countries (180-280 volts). When the
value is higher its DC voltage output will differ largely.
3. Temperature Variation The use of semiconductor devices in electronic devices may cause
variation in temperature.
These variations in dc output voltage may cause inaccurate or erratic operation or even
malfunctioning of many electronic circuits. For instance, in oscillators the frequency will shift, in
transmitters output will get distorted, and in amplifiers the operating point will shift causing bias
instability.
All the above listed problems are overcome with the help of a voltage regulator which is
employed in conjunction with an unregulated power supply. Thus, the ripple voltage is largely
reduced. Thus, the supply becomes a regulated power supply.
The internal circuitry of a regulated power supply also contains certain current limiting circuits
which helps the supply circuit from getting fried from inadvertent circuits. Nowadays, all the
power supplies use ICs to reduce ripples, enhance voltage regulation and for widened control

options. Programmable power supplies are also available to allow remote operation that is useful
in many settings.
REGULATED POWER SUPPLY
Regulated power supply is an electronic circuit that is designed to
provide a constant dc voltage of predetermined value across load terminals irrespective of ac
mains fluctuations or load variations.
As shown in the figure, the two main parts of a regulated power supply are a simple power
supply and a voltage regulating device. The power supply output is given as input to the voltage
regulating device that provides the final output. The voltage output of the power supply remains
constant irrespective of large variations in the input AC voltage or output load current.
Given below is a circuit diagram of a regulated power supply circuit using a transistor series
regulator as a regulating device. The input AC voltage (230 Voltas Vrms), is supplied to a
transformer. The output will be a stepped down ac output appropriate for the desired dc output.
This ac voltage is then given to a bridge rectifier to produce a full-wave rectified output. This is
then given to a pi-filter circuit to produce a dc voltage. The filter output may have some ac
voltage variations and ripples. This is further filtered using a regulating circuit whose output will
be a constant dc voltage. This regulated dc voltage is then given to a voltage divider, which
supplies the different dc voltages that may be needed for different electronic circuits.
The potential divider is a single tapped resistor connected across the output terminals of the
supply. The tapped resistor may consist of two or three resistors connected in series across the
supply. A bleeder resistor may also be employed as a potential divider.

Power Supply Characteristics


The quality of the power supply is determined by various
characteristics like load voltage, load current, voltage regulation, source regulation, output
impedance, ripple rejection, and so on. Some of the characteristics are briefly explained below:
1. Load Regulation The load regulation or load effect is the change in regulated output voltage
when the load current changes from minimum to maximum value.
Load regulation = Vons-load Vfull-load
Vno-load Load Voltage at no load
Vfull-load Load voltage at full load.
From the above equation we can understand that when Vno-load occurs the load resistance is
infinite, that is, the out terminals are open circuited. Vfull-load occurs when the load resistance is
of the minimum value where voltage regulation is lost.
% Load Regulation = [(Vno-load Vfull-load)/Vfull-load] * 100
2. Minimum Load Resistance The load resistance at which a power supply delivers its fullload rated current at rated voltage is referred to as minimum load resistance.
Minimum Load Resistance = Vfull-load/Ifull-load
The value of Ifull-load, full load current should never increase than that mentioned in the data
sheet of the power supply.
3. Source/Line Regulation In the block diagram, the input line voltage has a nominal value of
230 Volts but in practice, there are considerable variations in ac supply mains voltage. Since this
ac supply mains voltage is the input to the ordinary power supply, the filtered output of the
bridge rectifier is almost directly proportional to the ac mains voltage.

The source regulation is defined as the change in regulated output voltage for a specified rage of
line voltage.
4. Output Impedance A regulated power supply is a very stiff dc voltage source. This means
that the output resistance is very small. Even though the external load resistance is varied, almost
no change is seen in the load voltage. An ideal voltage source has an output impedance of zero.
5. Ripple Rejection Voltage regulators stabilize the output voltage against variations in input
voltage. Ripple is equivalent to a periodic variation in the input voltage. Thus, a voltage regulator
attenuates the ripple that comes in with the unregulated input voltage. Since a voltage regulator
uses negative feedback, the distortion is reduced by the same factor as the gain.
REGULATED POWER SUPPLY
Regulated power supply is an electronic circuit that is designed to provide a constant dc voltage
of predetermined value across load terminals irrespective of ac mains fluctuations or load
variations.

Ac input

Power
supply

Voltage
regulator

lo
ad

A regulated power supply essentially consists of an ordinary power supply and a voltage
regulating device, as illustrated in the figure. The output from an ordinary power supply is fed to

the voltage regulating device that provides the final output. The output voltage remains constant
irrespective of variations in the ac input voltage or variations in output (or load) current.
Figure given below shows the complete circuit of a regulated power supply with a transistor
series regulator as a regulating device. The ac voltage, typically 230 V rms is connected to a
transformer which transforms that ac voltage to the level for the desired dc output. A bridge
rectifier then provides a full-wave rectified voltage that is initially filtered by a (or C-L-C)
filter to produce a dc voltage. The resulting dc voltage usually has some ripple or ac voltage
variation. A regulating circuit use this dc input to provide a dc voltage that not only has much
less ripple voltage but also remains constant even if the input dc voltage varies somewhat or the
load connected to the output dc voltage changes. The regulated dc supply is available across a
voltage divider.
Often more than one dc voltage is required for the operation of electronic circuits. A single
power supply can provide as many as voltages as are required by using a voltage (or potential)
divider, as illustrated in the figure. As illustrated in the figure, a potential divider is a single
tapped resistor connected across the output terminals of the supply. The tapped resistor may
consist of two or three resistors connected in series across the supply. In fact, bleeder resistor
may also be employed as a potential divider.

Power Supply Characteristics


There are various factors that determine the quality of the power supply like the load voltage,
load current, voltage regulation, source regulation, output impedance, ripple rejection, and so on.
Some of the characteristics are briefly explained below:

1. Load Regulation The load regulation or load effect is the change in regulated output voltage
when the load current changes from minimum to maximum value.
Load regulation = Vno-load Vfull-load
Vno-load Load Voltage at no load
Vfull-load Load voltage at full load.
From the above equation we can understand that when Vno-load occurs the load resistance is
infinite, that is, the out terminals are open circuited. Vfull-load occurs when the load resistance is
of the minimum value where voltage regulation is lost.
% Load Regulation = [(Vno-load Vfull-load)/Vfull-load] * 100
2. Minimum Load Resistance The load resistance at which a power supply delivers its fullload rated current at rated voltage is referred to as minimum load resistance.
Minimum Load Resistance = Vfull-load/Ifull-load
The value of Ifull-load, full load current should never increase than that mentioned in the data
sheet of the power supply.
3. Source/Line Regulation In the block diagram, the input line voltage has a nominal value of
230 Volts but in practice, here are considerable variations in ac supply mains voltage. Since this
ac supply mains voltage is the input to the ordinary power supply, the filtered output of the
bridge rectifier is almost directly proportional to the ac mains voltage.
The source regulation is defined as the change in regulated output voltage for a specified rage of
lie voltage.
4. Output Impedance A regulated power supply is a very stiff dc voltage source. This means
that the output resistance is very small. Even though the external load resistance is varied, almost
no change is seen in the load voltage. An ideal voltage source has an output impedance of zero.

5. Ripple Rejection Voltage regulators stabilize the output voltage against variations in input
voltage. Ripple is equivalent to a periodic variation in the input voltage. Thus, a voltage regulator
attenuates the ripple that comes in with the unregulated input voltage. Since a voltage regulator
uses negative feedback, the distortion is reduced by the same factor as the gain.

2. MICROCONTROLLER:
2.1 CONCEPTS OF MICROCONTROLLER:

Microcontroller is a general purpose device, which integrates a number of the


components of a microprocessor system on to single chip. It has inbuilt CPU, memory and
peripherals to make it as a mini computer. A microcontroller combines on to the same microchip:

The CPU core


Memory(both ROM and RAM)
Some parallel digital i/o

Microcontrollers will combine other devices such as:


A timer module to allow the microcontroller to perform tasks for certain time periods.
A serial i/o port to allow data to flow between the controller and other devices such as
a PIC or another microcontroller.
An ADC to allow the microcontroller to accept analogue input data for processing.

Microcontrollers are :
Smaller in size
Consumes less power

Inexpensive

Micro controller is a standalone unit ,which can perform functions on its own
without any requirement for additional hardware like i/o ports and external memory.
The heart of the microcontroller is the CPU core. In the past, this has traditionally been based on
a 8-bit microprocessor unit. For example Motorola uses a basic 6800 microprocessor core in
their 6805/6808 microcontroller devices.
In the recent years, microcontrollers have been developed around specifically
designed CPU cores, for example the microchip PIC range of microcontrollers.

2.2 INTRODUCTION TO PIC :

The microcontroller that has been used for this project is from PIC series.
PIC microcontroller is the first RISC based microcontroller fabricated in CMOS
(complementary metal oxide semiconductor) that uses separate bus for instruction and data
allowing simultaneous access of program and data memory.
The main advantage of CMOS and RISC combination is low power
consumption resulting in a very small chip size with a small pin count. The main advantage of
CMOS is that it has immunity to noise than other fabrication techniques.
Various microcontrollers offer different kinds of memories.
EEPROM, EPROM, FLASH etc. are some of the memories of which FLASH is the most
recently developed. Technology that is used in pic16F877 is flash technology, so
that data is retained even when the power is switched off. Easy Programming and
Erasing are other features of PIC 16F877.

PIC START PLUS PROGRAMMER:

The PIC start plus development system from microchip technology


provides the product development engineer with a highly flexible low cost
microcontroller design tool set for all microchip PIC micro devices. The picstart plus
development system includes PIC start plus development programmer and mplab
ide.
The PIC start plus programmer gives the product developer ability to
program user software in to any of the supported microcontrollers. The PIC start
plus software running under mplab provides for full interactive control over the
programmer.

2.3 SPECIAL FEATURES OF PIC MICROCONTROLLER:


CORE FEATURES:

High-performance RISC CPU

Only 35 single word instructions to learn

All single cycle instructions except for program branches which are
two cycle

Operating speed: DC - 20 MHz clock input

DC - 200 ns instruction cycle

Up to 8K x 14 words of Flash Program Memory,

Up to 368 x 8 bytes of Data Memory (RAM)

Up to 256 x 8 bytes of EEPROM data memory

Pin out compatible to the PIC16C73/74/76/77

Interrupt capability (up to 14 internal/external

Eight level deep hardware stack

Direct, indirect, and relative addressing modes

Power-on Reset (POR)

Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)

Watchdog Timer (WDT) with its own on-chip RC Oscillator for


reliable operation

Programmable code-protection

Power saving SLEEP mode

Selectable oscillator options

Low-power, high-speed CMOS EPROM/EEPROM technology

Fully static design

In-Circuit Serial Programming (ICSP) via two pins

Only single 5V source needed for programming capability

In-Circuit Debugging via two pins

Processor read/write access to program memory

Wide operating voltage range: 2.5V to 5.5V

High Sink/Source Current: 25 mA

Commercial and Industrial temperature ranges

Low-power consumption:
2mA typical @ 5V, 4 MHz
20mA typical @ 3V, 32 kHz
1mA typical standby current

PERIPHERAL FEATURES:
Timer0: 8-bit timer/counter with 8-bit prescaler
Timer1: 16-bit timer/counter with prescaler, can be incremented during sleep
via external crystal/clock
Timer2: 8-bit timer/counter with 8-bit period register, presale and postscaler
Two Capture, Compare, PWM modules
Capture is 16-bit, max resolution is 12.5 ns,
Compare is 16-bit, max resolution is 200 ns,
PWM max. resolution is 10-bit
10-bit multi-channel Analog-to-Digital converter
Synchronous Serial Port (SSP) with SPI. (Master Mode) and I2C. (Master/Slave)

Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with


9- bit address detection.
Brown-out detection circuitry for Brown-out Reset (BO

2.4 ARCHITECTURE OF PIC 16F877 :


The complete architecture of PIC 16F877 is shown in the fig 2.1. Table
2.1 gives details about the specifications of PIC 16F877. Fig 2.2 shows the complete
pin diagram of the IC PIC 16F877.

TABLE 2.2 PIN OUT DESCRIPTION

Legend:

I = input O = output I/O = input/output P = power


= Not used

TTL = TTL input

ST = Schmitt Trigger input

Note
1. This buffer is a Schmitt Trigger input when configured as an external interrupt
2. This buffer is a Schmitt Trigger input when used in serial programming mode.
3. This buffer is a Schmitt Trigger input when configured as general purpose I/O and
a TTL

input when used in the Parallel Slave Port mode (for interfacing to a
microprocessor bus).
4. This buffer is a Schmitt Trigger input when configured in RC oscillator mode and a
CMOS input otherwise.

Legend:

I = input O = output I/O = input/output P = power


= Not used TTL = TTL input ST = Schmitt Trigger input

Note :
1. This buffer is a Schmitt Trigger input when configured as an external interrupt.
2. This buffer is a Schmitt Trigger input when used in serial programming mode.
3. This buffer is a Schmitt Trigger input when configured as general purpose I/O and
a TTL
input when used in the Parallel Slave Port mode (for interfacing to a
microprocessor bus).
4. This buffer is a Schmitt Trigger input when configured in RC oscillator mode and a
CMOS input otherwise.

2.5 I/O PORTS :


Some pins for these I/O ports are multiplexed with an alternate
function for the peripheral features on the device. In general, when a peripheral is
enabled, that pin may not be used as a general purpose I/O pin.
Additional Information on I/O ports may be found in the IC
micro Mid-Range Reference Manual,

PORTA AND THE TRISA REGISTER :


PORTA is a 6-bit wide bi-directional port. The corresponding data
direction register is TRISA. Setting a TRISA bit (=1) will make the corresponding
PORTA pin an input, i.e., put the corresponding output driver in a Hi-impedance
mode. Clearing a TRISA bit (=0) will make the corresponding PORTA pin an output,
i.e., put the contents of the output latch on the selected pin. Reading the PORTA
register reads the status of the
pins whereas writing to it will write to the port latch. All write operations are readmodify-write operations. Therefore a write to a port implies that the port pins are

read; this value is modified, and then written to the port data latch. Pin RA4 is
multiplexed with the Timer0 module clock input to become the RA4/T0CKI pin. The
RA4/T0CKI pin is a Schmitt Trigger input and an open drain output. All other RA port
pins have TTL input levels and full CMOS output drivers. Other PORTA pins are
multiplexed with analog inputs and analog VREF input. The operation of each pin is
selected by clearing/setting the control bits in the ADCON1 register (A/D Control
Register1).
The TRISA register controls the direction of the RA pins, even when they are
being used as analog inputs. The user must ensure the bits in the TRISA register are
maintained set when using them as analog inputs.

TABLE 2.3 PORT A FUNCTION

Legend: TTL = TTL input, ST = Schmitt Trigger input

Legend:

x = unknown,

u = unchanged,

- = unimplemented locations

read as '0'. Shaded cells are not used by PORTA.

PORTB is an 8-bit wide bi-directional port. The corresponding data


direction register is TRISB. Setting a TRISB bit (=1) will make the corresponding
PORTB pin an input, i.e., put the corresponding output driver in a hi-impedance
mode. Clearing a TRISB bit (=0) will make the corresponding PORTB pin an output,
i.e., put the contents of the output latch on the selected pin. Three pins of PORTB
are multiplexed with the Low Voltage Programming function; RB3/PGM, RB6/PGC
and RB7/PGD. The alternate functions of these pins are described in the Special
Features Section. Each of the PORTB pins has a weak internal pull-up. A single
control bit can turn on all the pull-ups.
This is performed by clearing bit RBPU (OPTION_REG<7>). The weak pull-up
is automatically turned off when the port pin is configured as an output. The pullups are disabled on a Power-on Reset.
Four of PORT Bs pins, RB7:RB4, have an interrupt on change feature. Only
pins configured as inputs can cause this interrupt to occur (i.e. any RB7:RB4 pin
configured as an output is excluded from the interrupt on change comparison). The
input pins (of RB7:RB4) are compared with the old value latched on the last read of
PORTB. The mismatch outputs of RB7:RB4 are ORed together to generate the RB
Port Change Interrupt with flag bit RBIF (INTCON<0>). This interrupt can wake the
device from SLEEP. The user, in the interrupt service routine, can clear the interrupt
in the following manner:
a) Any read or write of PORTB. This will end the mismatch condition.
b) Clear flag bit RBIF. A mismatch condition will continue to set flag bit
RBIF. Reading PORTB will end the mismatch condition, and allow flag bit RBIF to be
cleared. The interrupt on change feature is recommended for wake-up on key

depression operation and operations where PORTB is only used for the interrupt on
change feature. Polling of PORTB is not recommended while using the interrupt on
change feature. This interrupt on mismatch feature, together with software
configurable pull-ups on these four pins, allow easy interface to a keypad and make
it possible for wake-up on key depression

TABLE 2.6 SUMMARY OF REGISTERS ASSOCIATED WITH PORTB

PORTC AND THE TRISC REGISTER :


PORTC is an 8-bit wide bi-directional port. The corresponding data
direction register is TRISC. Setting a TRISC bit (=1) will make the corresponding
PORTC pin an input, i.e., put the corresponding output driver in a hi-impedance
mode. Clearing a TRISC bit (=0) will make the corresponding PORTC pin an output,
i.e., put the contents of the output latch on the selected pin. PORTC is multiplexed
with several peripheral functions. PORTC pins have Schmitt Trigger input buffers.

When the I2C module is enabled, the PORTC (3:4) pins can be
configured with normal I2C levels or with SMBUS levels by using the CKE bit
(SSPSTAT <6>). When enabling peripheral functions, care should be taken in
defining TRIS bits for each PORTC pin. Some peripherals override the TRIS bit to
make a pin an output, while other peripherals override the TRIS bit to make a pin an
input. Since the TRIS bit override is in effect while the peripheral is enabled, readmodify write instructions (BSF, BCF, XORWF) with TRISC as destination should be
avoided. The user should refer to the corresponding peripheral section for the
correct TRIS bit settings.

TABLE 2.7 PORTC FUNCTIONS

PORTD AND TRISD REGISTERS :


This section is not applicable to the 28-pin devices. PORTD is an 8-bit
port with Schmitt Trigger input buffers. Each pin is individually configurable as an
input or output. PORTD can be configured as an 8-bit wide microprocessor Port
(parallel slave port) by setting control bit PSPMODE (TRISE<4>). In this mode, the
input buffers are TTL.

TABLE 2.9 PORTD FUNCTIONS

PORTE AND TRISE REGISTER :


PORTE has three pins RE0/RD/AN5, RE1/WR/AN6 and RE2/CS/AN7,
which are individually configurable as inputs or outputs. These pins have Schmitt
Trigger input buffers.
The PORTE pins become control inputs for the microprocessor port
when bit PSPMODE (TRISE<4>) is set. In this mode, the user must make sure that
the TRISE<2:0> bits are set (pins are configured as digital inputs). Ensure ADCON1
is configured for digital I/O. In this mode the input buffers are TTL.
PORTE pins are multiplexed with analog inputs. When selected as an
analog input, these pins will read as '0's. TRISE controls the direction of the RE pins,

even when they are being used as analog inputs. The user must make sure to keep
the pins configured as inputs when using them as analog inputs.

TABLE 2.12 SUMMARY OF REGISTERS ASSOCIATED WITH PORTE

2.6 MEMORY ORGANISATION :


There are three memory blocks in each of the PIC16F877 MUCs. The
program memory and Data Memory have separate buses so that concurrent access
can occur.

PROGRAM MEMORY ORGANISATION:


The PIC16f877 devices have a 13-bit program counter capable of
addressing 8K *14 words of FLASH program memory. Accessing a location above the
physically implemented address will cause a wraparound. The RESET vector is at
0000h and the interrupt vector is at 0004h.

DATA MEMORY ORGANISTION:


The data memory is partitioned into multiple banks which contain the
General Purpose Registers and the special functions Registers. Bits RP1 (STATUS<6)
and RP0 (STATUS<5>) are the bank selected bits.
RP1:RP0

Banks

00

01

10

11

Each bank extends up to 7Fh (1238 bytes). The lower locations of each
bank are reserved for the Special Function Registers. Above the Special Function
Registers are General Purpose Registers, implemented as static RAM.
implemented banks contain special function registers.

All

Some frequently used

special function registers from one bank may be mirrored in another bank for code
reduction and quicker access.

GENERAL PURPOSE REGISTER FILE :


The register file can be accessed either directly or indirectly through
the File Selected Register (FSR). There are some Special Function Registers used by
the CPU and peripheral modules for controlling the desired operation of the device.
These registers are implemented as static RAM. The Special Function Registers can
be classified into two sets; core (CPU) and peripheral. Those registers associated
with the core functions.

2.7 INSTRUCTION SET SUMMARY:


Each PIC 16f877 instruction is a 14-bit word, divided into an OPCODE
which specifies the instruction type and one or more operand which further specify
the operation of the instruction. The PIC16F877 instruction set summary in Table
2.13

lists byte-oriented, bit-oriented, and literal and control operations. It

shows the opcode Field descriptions.

For byte-oriented instructions, f represents a file register designator


and d represents a destination designator. The file register designator specifies
which file register is to be used by the instruction.

The destination designator

specified where the result of the operation is to be placed. If d is zero, the result is
placed in the w register. If d is one, the result is placed in the file register specified
in the instruction.

For bit-oriented instructions, b represents a bit field designator


which selects the number of the bit affected by the operation, which f represents
the address of the file in which the bits is located. For literal and control operations,
k represents an eight or eleven bit constant or literal value.

The instruction set is highly orthogonal and is grouped into three basic
categories:
Byte-oriented operations

Bit-oriented operations
Literal and control operations
All instructions are executed within one single instruction cycle, unless
a conditional test is true or the program counter is changed as a result of an
instruction. In this case, the execution takes two instruction cycles with the second
cycle executed as a NOP. One instruction cycle consists of four oscillator periods.
Thus, for an oscillator frequency of 4 MHz, the normal instruction execution time is 1
ms. If a conditional test is true or the program counter is changed as a result of an
instruction, then the instruction execution time is 2 ms.

GENERAL FORMAT FOR INSTRUCTIONS :

3. LCD
There are many display devices used by the hobbyists. LCD displays are one of
the most sophisticated display devices used by them. Once you learn how to interface it, it will
be the easiest and very reliable output device used by you! More, for micro controller based
project, not every time any debugger can be used. So LCD displays can be used to test the
outputs. Obviously, for last possibility, you need to know how to use this stuff pretty well.
Note 1: We have sub divided this article for easy navigation as shown below:1. Pin Configuration
2. Block Diagram
3. Control and Display Commands
4. LCD Interfacing
5. LCD Initialization

Hitachi has set up a mile stone by its LCD controller IC. All the LCD displays use the
same, or any one of the IC s based upon the architecture introduced by Hitachi.
Ok, one minute, all Im talking about is the character LCD display and not Graphical LCD
Display.
Most of the LCD Displays available in the market are 16X2 (That means, the LCD displays are
capable of displaying 2 lines each having 16 Characters a), 20X4 LCD Displays (4 lines, 20
characters). It has 14 pins. It uses 8lines for parallel data plus 3 control signals, 2 connections to
power, one more for contrast adjustment and two connections for LED back light. Let us have a
look to typical pin configurations:

Pin Configuration table for a 16X2 LCD character display:Pin Number


1
2
3
4
5
6

Symbol
Vss
Vcc
Vdd
RS
R/W
E

Function
Ground Terminal
Positive Supply
Contrast adjustment
Register Select; 0Instruction Register, 1Data Register
Read/write Signal; 1Read, 0 Write
Enable; Falling edge

7
8
9
10
11
12
13
14
15
16

DB0
DB1
DB2
DB3
DB4
DB5
DB6
DB7
LED-(K)
LED+(A)

Bi-directional data bus, data transfer is performed once, thru DB0 to


DB7, in the case of interface data length is 8-bits; and twice, through
DB4 to DB7 in the case of interface data length is 4-bits. Upper four
bits first then lower four bits.

Back light LED cathode terminal


Back Light LED anode terminal

Data/Signals/Execution of LCD
Now that was all about the signals and the hardware. Let us come to data, signals and execution.
LCD accepts two types of signals, one is data, and another is control. These signals are
recognized by the LCD module from status of the RS pin. Now data can be read also from the
LCD display, by pulling the R/W pin high. As soon as the E pin is pulsed, LCD display reads
data at the falling edge of the pulse and executes it, same for the case of transmission.
LCD display takes a time of 39-43S to place a character or execute a command.
Except for clearing display and to seek cursor to home position it takes 1.53ms to 1.64ms. Any
attempt to send any data before this interval may lead to failure to read data or execution of the
current data in some devices. Some devices compensate the speed by storing the incoming data
to some temporary registers.
LCD displays have two RAMs, naming DDRAM and CGRAM. DDRAM registers in
which position which character in the ASCII chart would be displayed. Each byte of DDRAM
represents each unique position on the LCD display. The LCD controller reads the information
from the DDRAM and displays it on the LCD screen. CGRAM allows user to define their
custom characters. For that purpose, address space for first 16 ASCII characters are reserved for
users. After CGRAM has been setup to display characters, user can easily display their custom
characters on the LCD screen.

Images of LCD Display:-

LCD - Front View

LCD - Back View

Block Diagram of LCD Display:-

LCD - Block Diagram

Control and display commands


Instruction
Read Data
From RAM
Write data to
RAM

Busy flag &


Address
Set DDRAM
Address
Set CGRAM
Address
Function Set

Instruction Code
Instruction Code
Execution
time
RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Description
Read data from
1.531
1
D7 D6 D5 D4 D3 D2 D1 D0
internal RAM
1.64ms
Write data into
1.531
0
D7 D6 D5 D4 D3 D2 D1 D0 internal RAM
1.64ms
(DDRAM/CGRAM)
Busy flag (BF: 1
LCD Busy) and
0
1
BF AC6 AC5 AC4 AC3 AC2 AC1 AC0 contents of address
39 s
counter in bits AC6AC0.
Set DDRAM address
0
0
1 AC6 AC5 AC4 AC3 AC2 AC1 AC0
39 s
in address counter.
Set CGRAM Address
0
0
0
1 AC5 AC4 AC3 AC2 AC1 AC0
39 s
in address counter.
0
0
0
0
1 DL N
F
X
X Set interface data
39 s
length (DL: 4bit/8bit),

Cursor or
Display Shift

S/C R/L

Display &
0
Cursor On/Off

Entry Mode
Set

I/D

SH

Return Home

Clear Display

AC -Address Counter
Outline
Now the instruction can be divided mainly in four kinds
1)

Function set instructions

2)

Address set instructions

3)

Data transfer instructions with internal RAM

4)

Others

Details of the Instructions

Numbers of display
line (N: 1-line/2-line)
display font type
(F:0 58 dots,
F:1 511 dots)
Set cursor moving
and display shift
control bit, and the
direction without
changing DDRAM
data
Set
Display(D),Cursor(C)
and cursor blink(b)
on/off control
Assign cursor moving
direction and enable
shift entire display.
Set DDRAM Address
to 00H from AC
and return cursor to
its original position if
shifted.
Write 20H to
DDRAM and set
DDRAM Address to
00H from AC

39 s

39 s

0s

43s

43s

1)

Read Data from RAM


RS
1

R/W
1

DB7
D7

DB6
D6

DB5
D5

DB4
D4

DB3
D3

DB2
D2

DB1
D1

DB0
D0

Read 8bit binary data from DDRAM/CGRAM


The selection of RAM is set by the previous address set instruction. If the address set instruction
of RAM is not performed before this instruction, the data that is read first is invalid, because the
direction of AC is not determined. If the RAM data is read several times without RAM address
set instruction before read operation, the correct RAM data from the second, but the first data
would be incorrect, as there is no time to transfer RAM data. In case of DDRAM read operation,
cursor shift instruction plays the same role as DDRAM address set instruction; it also transfers
RAM data to the output data registers.
After read operation, the data address counter is automatically increased or decreased by 1
according to the entry mode. After CGRAM read operation, display shift may not be executed
properly.
*In case of RAM write operation, AC is increased or decreased by 1 like that of the read
operation. In this time AC indicates the next address position, but the previous data can only by
the read instruction.
2)

Write data to ram


RS
1

R/W
0

DB7
D7

DB6
D6

DB5
D5

DB4
D4

DB3
D3

DB2
D2

DB1
D1

DB0
D0

Write binary 8bit data to DDRAM/CGRAM. The selection of CGRAM or DRAM is set by the
previous address set instruction; DDRAM address set, CGRAM address set. RAM set instruction
can also determine the AC direction to RAM.
After write operation, the address is automatically increased or decreased by 1 according to the
entry mode.
3)

Read Busy Flag and Address


RS
0

R/W
1

DB7
BF

DB6
AC6

DB5
AC5

DB4
AC4

DB3
AC3

DB2
AC2

DB1
AC1

By making this read out operation, it can be determined if the LCD is performing some internal
operation or not. If Busy Flag (BF) is high, some internal operation is going inside the LCD at
that particular moment. To perform further operation the data source (e.g. micro controller) must
wait for the BF to go low. Here, the address counter value can also be read.

DB0
AC0

4)

Set DDRAM Address


RS
0

R/W
0

DB7
1

DB6
AC6

DB5
AC5

DB4
AC4

DB3
AC3

DB2
AC2

DB1
AC1

DB0
AC0

Set DDRAM address to AC, this instruction makes DDRAM data available from MPU. In 1-line
display mode, DDRAM address rangers from 00H to 4FH. In 2-line display mode, DDRAM
address in the first line ranges from 00H to 27H, and DDRAM address in the 2 nd line is from
40H to 67H.
5)

Set CGRAM address


RS
0

R/W
0

DB7
0

DB6
1

DB5
AC5

DB4
AC4

DB3
AC3

DB2
AC2

DB1
AC1

DB0
AC0

DB1
X

DB0
X

Set CGRAM address to AC. This instruction makes CGRAM data available from MPU.
6)

Function Set
RS
0

R/W
0

DB7
0

DB6
0

DB5
1

DB4
DL

DB3
N

DB2
F

DL: Interface data length control bit


DL=1 means 8bit mode of data transfer.
DL=0 means 4bit mode of data transfer
When 4 bit mode is activated, the data needs to be transferred in two parts, first higher 4bits, and
then lower 4 bits.
N: display line number control bit
N=1 will allows to characters to display in 2-lines
N=0 will allows to characters to display in the first line only
F: display font control bit
F=0 will use 58 dots format display mode
F=1 will use 511 dots format display mode
7)

Cursor or display Shift

RS
0

R/W
0

DB7
0

DB6
0

DB5
0

DB4
1

DB3
S/C

DB2
R/L

DB1
X

DB0
X

Without writing or reading the display data, shifting right/left cursor position or display.
This instruction is made to correct or search or display data. During 2-line display mode, cursor
moves to the 2nd line after the 40th digit of the 1st line.
When displayed data is shifted repeatedly, each line shifts individually.
When display shift is performed, the contents of the address counter are not changed.
8)

Display On/Off Control


RS
0

R/W
0

DB7
0

DB6
0

DB5
0

DB4
0

DB3
1

DB2
D

DB1
C

DB0
B

DB1
I/D

DB0
SH

This instruction controls Display, Cursor and cursor blink.


D: Display On/Off control bit
D=1 means entire display is turned on
D=0 means entire display is turned off. But Display data remains in DDRAM.
C: cursor On/Off control bit
C=1 turns on the cursor
C=0 turns off the cursor. But I/D register retains the data
B: Cursor blink On/Off control bit
B=1 makes cursor blink periodically.
B=0 stops the cursor to blink and cursor looks steady if the Cursor is turned on.

9)

Entry Mode Set


RS
0

R/W
0

DB7
0

DB6
0

DB5
0

DB4
0

DB3
0

DB2
1

This instruction sets the moving direction of cursor and display.


When I/D= 1 cursor moves to the right and DDRAM address is increased by 1.
When I/D= 0 cursor moves to the left and DDRAM address is decreased by 1.
CGRAM operates in the same way in this setting.
10) Return Home
RS
0

R/W
0

DB7
0

DB6
0

DB5
0

DB4
0

DB3
0

DB2
0

DB1
1

DB0
X

This instruction sets the address counter to 00H, and returns the cursor to the first column of
first line. And if display is shifted previously, this instruction shifts this too. The DDRAM
contents dont change in this instruction.
11) Clear display
RS
0

R/W
0

DB7
0

DB6
0

DB5
0

DB4
0

DB3
0

DB2
0

DB1
0

Clear all the display data by writing 20H (ASCII code of space character) to all DDRAM
address, AND set value DDRAM address counter (AC) to 00H. It returns the cursor to the first
column of first line and sets the entry mode to increment mode (I/D=1).

8-bit and 4-bit interfacing of LCD


Now the question is how to display data in the LCD or give command to it. There is two modes
of data transfer are supported by LCD displays. One is 4bit mode, another is 8 bit mode. To
transfer data In 8 bit mode, first put your data in the 8bit bus, then put command in the command
bus and then pulse the enable signal.
To send data in 4bit mode; first put upper 4bit in the 4 bit data bus connected to 4MSB
pins of LCD display, then put control signals in the control bus, then pulse the E pin once. Next
put the lower 4 bit in the data bus and pulse the E pin again. Here is a flowchart simply
describing it.

LCD Display Interfacing Flowchart:-

DB0
1

LCD Interfacing - Flowchart

LCD Initialisation
We are pretty familiar how to send data. But before displaying characters on the LCD display, it
must be configured first. To configure an LCD display, four command words must be sent to
LCD in either 4 bit mode, or in 8 bit mode. The commands are:
1. Function set
2. Display On/Off control
3. Entry mode set
4. Display Clear
Here is a flow chart of the initialization sequence of LCD display.

LCD Initialization

Displaying Custom Characters


All these character display modules got the feature to create 8 user defined characters (ASCII
Codes 07) in addition to the ROM fixed codes.
1.) The command CG RAM Address Set defines the ASCII code (Bit 3, 4, 5) and the dot line
(Bit 0, 1, 2) of the new character. Example demonstrates creating ASCII code 00H.
2.) Doing 8 times the write command Data Write defines line by line the new character. 8th
byte stands for the cursor line.
3.) The new defined character can be used as a normal ASCII code (07); use with DD
RAM Address Set and Data Write.

Now let us look up the character set that can be displayed using the LCD Displayed
0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 to 0xd0
0xE00xF0
0x00CG1
0
@
P
`
p

0x01CG2
!
1
A
Q
a
q

0x02CG3

2
B
R
b
r

0x03CG4
#
3
C
S
c
s

0x04CG5
$
4
D
T
d
t

0x05CG6
%
5
E
U
e
u

0x06CG7
&
6
F
V
f
v

CUSTOM
0x07CG8
7
G
W
g
w REGIONAL
G

0x08CG1
(
8
H
X
h
x CHARACHTER

S
0x09CG2
)
9
I
Y
i
y

y
0x0ACG3
*
:
J
Z
j
z
J
0x0BCG4
+
;
K
[
k
{
0x0CCG5
,
<
L

l
|
0x0DCG6

=
M
]
m
}
0x0ECG7
.
>
N
^
n

0x0FCG8
/
?
O
_
o

CG CGRAM User Defined Character


Custom Regional characters vary from manufacturer to manufacturer. The Greek letters may or
may not appear. It too depends upon the design.

5. GSM
SIM300 GSM MODULE

This is a plug and play GSM Modem with a simple to interface serial interface. Use it to
send SMS, make and receive calls, and do other GSM operations by controlling it through simple
AT commands from micro controllers and computers. It uses the highly popular SIM300 module
for all its operations. It comes with a standard RS232 interface which can be used to easily
interface the modem to micro controllers and computers.
The modem consists of all the required external circuitry required to start experimenting
with the SIM300 module like the power regulation, external antenna, SIM Holder, etc.
Features

Uses the extremely popular SIM300 GSM module

Provides the industry standard serial RS232 interface for easy connection to computers
and other devices

Provides serial TTL interface for easy and direct interface to microcontrollers

Power, RING and Network LEDs for easy debugging

Onboard 3V Lithium Battery holder with appropriate circuitry for providing backup for
the modules internal RTC

Can be used for GSM based Voice communications, Data/Fax, SMS,GPRS and TCP/IP
stack

Can be controlled through standard AT commands

Modules operation mode can be controlled through the PWR Switch connected to the
PWR pin (refer the SIM300 datasheet for more information)

Comes with an onboard wire antenna for better reception. Board provides an option for
adding an external antenna through an SMA connector

The SIM300 allows an adjustable serial baud rate from 1200 to 115200 bps (9600
default)

Modem a low power consumption of 0.25 A during normal operations and around 1 A
during transmission

Operating Voltage: 7 15V AC or DC (board has onboard rectifier)

Note: The modem consumes current of nearly 1A during transmission; please make sure that
your power supply can handle such currents.

6. INFRARED

Principles of Operation:
We have already discussed how a light sensor works. IR Sensors
work by using a specific light sensor to detect a select light wavelength in the Infra-Red (IR)
spectrum. By using an LED which produces light at the same wavelength as what the sensor is
looking for, you can look at the intensity of the received light. When an object is close to the
sensor, the light from the LED bounces off the object and into the light sensor. This results in a
large jump in the intensity, which we already know can be detected using a threshold.

Detecting Brightness
Since the sensor works by looking for reflected light, it is possible to have a sensor that can
return the value of the reflected light. This type of sensor can then be used to measure how
"bright" the object is. This is useful for tasks like line tracking.

Depiction of the operationof an


IR Sensor to measure brightness

Vous aimerez peut-être aussi