Docu
Docu
Docu
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
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.
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.
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:
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.
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.
All single cycle instructions except for program branches which are
two cycle
Programmable code-protection
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)
Legend:
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:
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.
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.
Legend:
x = unknown,
u = unchanged,
- = unimplemented locations
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
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.
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.
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
special function registers from one bank may be mirrored in another bank for code
reduction and quicker access.
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.
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.
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:
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)
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.
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)
2)
3)
4)
Others
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)
R/W
1
DB7
D7
DB6
D6
DB5
D5
DB4
D4
DB3
D3
DB2
D2
DB1
D1
DB0
D0
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)
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)
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)
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
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)
R/W
0
DB7
0
DB6
0
DB5
0
DB4
0
DB3
1
DB2
D
DB1
C
DB0
B
DB1
I/D
DB0
SH
9)
R/W
0
DB7
0
DB6
0
DB5
0
DB4
0
DB3
0
DB2
1
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).
DB0
1
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
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
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
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
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
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
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.