Upload
sumit-agarwal
View
51
Download
1
Tags:
Embed Size (px)
Citation preview
1
LOW COST LCD FREQUENCY METER
A PROJECT REPORT
Submitted by
SIJI SASIKUMAR
SIMI A R
SIMNA ANTONY
in partial fulfillment for the award of the degree
of
BACHELOR OF ENGINEERING
in
ELECTRONICS & COMMUNICATION ENGINEERING
SREE NARAYANA GURUKULAM COLLEGE OF
ENGINEERING,KADAYIRUPPU
MG UNIVERSITY : KOTTAYAM
MAY 2011
2
MG UNIVERSITY : KOTTAYAM
Department of Electronics and communication Engineering
MINI PROJECT REPORT 2011
BONAFIDE CERTIFICATE
Certified that this project report ”LOW COST LCD FREQUENCY METER” is the
bonafide work of “SIJI SASIKUMAR, SIMI A R, SIMNA ANTONY” who
carried out the project work under my supervision.
SIGNATURE SIGNATURE
HEAD OF THE DEPARTMENT STAFF IN CHARGE
ELECTRONICS AND COMMUNICATION ENGINEERING DEPARTMENT OF ECE
SREE NARAYANA GURUKULAM COLLEGE OF ENGINEERING SNGCE
KADAYIRUPPU KADAYIRUPU
KOLENCHERY KOLENCHERY
3
ACKNOWLEDGEMENT
Dedicating this project to the God Almighty whose abundant grace and mercies
enabled its successful completion, we would like to express our profound gratitude to
all the people who had inspired and motivated us to make this project a success.
We wish to express our sincere thanks to our Principal, Dr.C.E.KRISHNAN, for
providing an opportunity to undertake this project. We are deeply indebted to our
project coordinator Prof.ARUMUGA SAMY Head of the Department of Electronics
and Communication Engineering for providing us with valuable advice during the
course of the study.
We would like to extend our heartfelt gratitude to our guides Mr.DEEPAK.P, Mr.
VISHNU and Mr. MAHESH for helps extended to us during the completion of the
project. We extend our deep sense of gratitude to our Lecturers of Electronics and
Communication Engineering Department for their valuable guidance as well as timely
advice, which helped us a lot in completing the project successfully. Finally we would
like to express my gratitude to Sree Narayana Gurukulam College of Engineering for
providing us with all the facilities without which the project would not been possible.
4
ABSTRACT
The objective is to design and implement a low cost LCD frequency meter. Frequency
meters have always been expensive tools. Now, with microcontrollers and liquid-
crystal displays (LCDs) having become very economical and popular, it is possible to
build a compact and low-cost LCD based frequency meter that can measure up to 15
kHz. A working system will ultimately be demonstrated to validate the description.
5
LIST OF FIGURES
1. BLOCK DIAGRAM
2. FILTER CAPACITOR OUTPUT
3. POWER SUPPLY
4. CIRCUIT DIAGRAM
5. IC 7805 PINOUT
6. OPTOCOUPLER
7. SCHMITT TRIGGER USING 555
8. ATMEGA 8 PINOUT
6
TABLE OF CONTENTS
CHAPTER NO. TITLE PAGE NO.
ABSTRACT LIST OF FIGURES
1 INTRODUCTION 8 2 BLOCK DIAGRAM 10 3 BLOCK DIAGRAM EXPLANATION 11 4 CIRCUIT DESIGN 13
4.1 POWER SUPPLY 13
5 CIRCUIT DIAGRAM 16
5.1 POWER SUPPLY 16
5.2 CIRCUIT 17
6 WORKING 18 7 WAVEFORMS 24
7.1 POWER SUPPLY 24
7.2 OPTOCOUPLER AND SCHMITT 25
TRIGGER
8 PROGRAM 26 9 PCB FABRICATION 32 10 PCB LAYOUT 33 11 PCB FABRICATION TECHNIQUE 34 12 CONCLUSION 35 13 SCOPE 36 14 REFERENCE 37 15 APPENDIX 38
15.1 ATMEGA 8 DATASHEET 38
15.2 IC 7805 DATASHEET 44
7
15.3 555 DATASHEET 47
15.4 MCT2E DATASHEET 50
15.5 LCD 16X2 DATASHEET 52
8
1.INTRODUCTION
A frequency counter is an electronic instrument, or component of one, that is used for
measuring frequency. Frequency is defined as the number of events of a particular sort
occurring in a set period of time. Most frequency counters work by using a counter
which accumulates the number of events occurring within a specific period of time.
After a preset period (1 second, for example), the value in the counter is transferred to
a display and the counter is reset to zero. If the event being measured repeats itself
with sufficient stability and the frequency is considerably lower than that of the clock
oscillator being used, the resolution of the measurement can be greatly improved by
measuring the time required for an entire number of cycles, rather than counting the
number of entire cycles observed for a pre-set duration (often referred to as the
reciprocal technique). The internal oscillator which provides the time signals is called
the timebase, and must be calibrated very accurately.
If the thing to be counted is already in electronic form, simple interfacing to the
instrument is all that is required. More complex signals may need some conditioning
to make them suitable for counting. Most general purpose frequency counters will
include some form of amplifier, filtering and shaping circuitry at the input. DSP
technology, sensitivity control and hysteresis are other techniques to improve
performance. The accuracy of a frequency counter is strongly dependent on the
stability of its timebase. Highly accurate circuits are used to generate this for
instrumentation purposes, usually using a quartz crystal oscillator within a sealed
temperature-controlled chamber known as a crystal oven or OCXO (oven controlled
crystal oscillator).
9
In this project we can measure line frequency.External signal frequency upto a range
of 15 kHz can also be measured.The microcontroller that we are using is Atmega
8.LCD is used for displaying the output frequency.
10
2. BLOCK DIAGRAM
Figure 1.Block diagram
LCD
11
3. BLOCK DIAGRAM EXPLANATION
A 230V 50Hz supply is applied to a step down transformer.A transformer designed to
reduce voltage from primary to secondary is called astep - down transformer.The
transformer output is 12v ac which is applied to a bridge rectifier.It is an arrangement
of four diodesin a bridgeconfiguration that provides the same polarity of output for
either polarity of input. When used in its most common application, for conversion of
an alternating current (AC) input into direct current a (DC) output, it is known as a
bridge rectifier. A bridge rectifier provides full-wave rectification from a two-wire AC
input, resulting in lower cost and weight as compared to a rectifier with a 3-wire input
from a transformer with a center -tapped secondary winding. The essential feature of a
diode bridge is that the polarity of the output is the same regardless of the polarity at
the input. For many applications, especially with single phase AC where the full-wave
bridge serves to convert an AC input into a DC output, the addition of a capacitor may
be desired because the bridge alone supplies an output of fixed polarity but
continuously varying or pulsating magnitude, an attribute commonly referred to as
ripple.The output of the bridge rectifier is 12V dc and its fed to a power regulator.A
power regulator is an electrical regulator designed to automatically maintain a constant
voltage level.Here we get a 5V dc regulated output.This forms the power supply for
the entire system.
By using this system we can measure both line and external frequency.In order to
measure line frequency the 12V ac output from the transformer is given to an opto-
isolator. In electronics, an opto-isolator, also called an optocoupler, photocoupler, or
optical isolator, is "an electronic device designed to transfer electrical signals by
utilizing light waves to provide coupling with electrical isolation between its input and
output".The main purpose of an opto-isolator is to prevent high voltages or rapidly
changing voltages on one side of the circuit from damaging components or distorting
12
transmissions on the other side. The output from an opto-isolator is given to a signal
conditioner.In electronics, signal conditioning means manipulating an analog signal in
such a way that it meets the requirements of the next stage for further processing.
Signal conditioning can include amplification, filtering, converting, range matching,
isolation and any other processes required to make sensor output suitable for
processing after conditioning.Inorder to measure external frequency upto a range of
15kHz,the signal is directly provided to the signal conditioner.The output from a
signal conditioner is a square wave which is given to PD5(T1 (Timer/Counter 1
External Counter Input) ) of Atmega 8 microcontroller.an LCD is used to display the
output frequency.A liquid crystal display (LCD) is a thin, flat electronic visual display
that uses the light modulating properties of liquid crystals (LCs). LCs do not emit light
directly. Its low electrical power consumption enables it to be used in battery-powered
electronic equipment. It is an electronically-modulated optical device made up of any
number of pixels filled with liqui crystals and arrayed in front of a light source
(backlight) or reflector to produce images in colour or monochrome.
13
4. CIRCUIT DESIGN
4.1. POWER SUPPLY
1. Transformer Selection.
Voltage in = 240V @ 50Hz
Voltage Output required = 12V.
Current required = 300mA.
Transformer Turns ratio = 240/12 ~ 1:20
Current rating of secondary winding = 500mA.
2. Rectifier Design
Bridge configuration.
Current capacity of diode required = 500mA.
Peak Reverse Voltage Required = ½ X 12V = 6V.
Diode Selected = 1N4007.
If = 1A
PRV = 1000V.
3. Filter Capacitor
Since two diode conduct in series the voltage after rectification is 12V- 2 X0.7V =
10.6V
Drop across silicon diode is 0.7V.
Figure 2. Filter capacitor output
14
R4Output voltage Ripple = 10.6 – 7.6 = 3V.
Current Requirement = 350mA.
Total charge supplied by capacitor = 300mA X 10mS
Voltage difference = 2.6V.
Capacitance required = 300mA X 10mS/ 3V = 1000uF.
1. Current limiting Resistor
R1
Voltage drop of LED = 1.6V.
Forward current of LED = 5mA.
Voltage supplayed = 5V
R1 = (5V - 1.6V) / 5mA = 680E.
R2
Current limiting resistor for Opto coupler LED.
Forward voltage of LED = 1.5V
Forward Current = 20mA
Voltage in = 10.6V
R = 10.6V – 1.5V / 20mA = 455E.
Use 470E resistor.
Vce Saturation = 0.25V
VIN = 5V
IC = 5mA.
R4 = 5V – 0.25V / 5mA = 950E
Use 1K resistor.
15
5. Voltage Regulator
The Atmega8 MUC needs a clean 5V power supply. So we are generating the
regulated 5V for National Semiconductors LM7805 Voltage regulator chip. This is
a linear Voltage regulator.It is recommended to use a 1uf capacitor in the output of
regulator .
16
5. CIRCUIT DIAGRAM
5.1. POWER SUPPLY
Figure 3.Power supply
17
5.2. CIRCUIT
Figure 4.Circuit diagram
18
6. WORKING
A 230V 50Hz power supply is provided to a step down transformer. Step down
transformers convert electrical voltage from one level or phase configuration usually
down to a lower level. Step down transformers are made from two or more coils of
insulated wire wound around a core made of iron. When voltage is applied to one coil
(frequently called the primary or input) it magnetizes the iron core, which induces a
voltage in the other coil, (frequently called the secondary or output). The turns ratio of
the two sets of windings determines the amount of voltage transformation. Step down
transformers can be considered nothing more than a voltage ratio device.The output of
the step down transformer is 12V ac.It is then given to a bridge rectifier to get 12Vdc.
It is an arrangement of four diodes in a bridge configuration that provides the same
polarity of output for either polarity of input. When used in its most common
application, for conversion of an alternating current (AC) input into direct current a
(DC) output, it is known as a bridge rectifier. A bridge rectifier provides full-wave
rectification from a two-wire AC input, resulting in lower cost and weight as
compared to a rectifier with a 3-wire input from a transformer with a center-tapped
secondary winding. The essential feature of a diode bridge is that the polarity of the
output is the same regardless of the polarity at the input. For many applications,
especially with singlephase AC where the full-wave bridge serves to convert an AC
input into a DC output, the addition of a capacitor may be desired because the bridge
alone supplies an output of fixed polarity but continuously varying or pulsating
magnitude, an attribute commonly referred to as ripple. One advantage of a bridge
rectifier over a conventional full-wave rectifier is that with a given transformer the
bridge rectifier produces a voltage output that is nearly twice that of the conventional
full-wave circuit.The output of the bridge rectifier is fed to a voltage regulator IC
7805.
19
Figure 5.IC 7805 pin out
C1 is required when the regulator is far from the power-supply filter. C2 is not
required for stability; however, transient response is improved. The circuit has over
overload and therminal protection.The output of 7805 is 5V dc.When the power
supply is ON the led glows.This forms the power supply for the system.
By using this system we can measure line frequency as well as external signal
frequency upto a range of 15kHz.Inorder to measure line frequency the output of the
transformer ie, 12Vac is given to an optocoupler(MCT2E). MCT2E is a Standard
Single Channel Phototransistor Couplers. Each optocoupler consists of gallium
arsenide infrared LED and a silicon NPN phototransistor. The main purpose of an
opto-isolator is to prevent high voltages or rapidly changing voltages on one side of
the circuit from damaging components or distorting transmissions on the other side.
20
Figure 6. Optocoupler
An opto-coupler is a small integrated circuit containing an LED and a photosensitive
transistor located. During the forward biased conditon of the diode, the LED glows,
which inturn provides a drive for the phototransistor used. This allows a signal in one
circuit to be transferred to another circuit without the electrical connections. This
ensures circuit protection. This ensures a galvanic isolation that is easy to apply in
small electronic circuits. The intended effect of optoïsolator is the same as a
transformer, because in this configuration the output is electronically isolated from the
input. The diode can be seen as the emitter and phototransistor as receiver
accordingly. The diode converts the electronic signal to light and the transistor, the
reverse process. The output of the opto-coupler is given to signal conditioner via a
switch. Here the signal conditioner used is Schmitt trigger using a 555 IC.Finally the
square wave output from the Schmitt trigger is fed to timer/counter of the
microcontroller (Atmega 8) and thus the frequency is displayed onto the LCD.Inorder
to measure external signal frequency, the signal is directly applied to the signal
conditioner. A 555 can be wired as a Schmitt Trigger to clean up noise signals and
generate a square wave.
21
Figure 7.Schmitt trigger using 555
The output from the schmitt trigger is provided to T1 (Timer/Counter 1 External
Counter Input) of the microcontroller Atmega 8. The PD0,PD1,PD2 and PD3 pins of
Atmega 8 are connected to pin no. 11, 12,13 and 14 of lcd respectively.
• RXD – Port D, Bit 0
RXD, Receive Data (Data input pin for the USART). When the USART Receiver is
enabled this
pin is configured as an input regardless of the value of DDD0. When the USART
forces this pin
to be an input, the pull-up can still be controlled by the PORTD0 bit.
• TXD – Port D, Bit 1
TXD, Transmit Data (Data output pin for the USART). When the
USART Transmitter is enabled,
this pin is configured as an output regardless of the value of DDD1.
• INT0 – Port D, Bit 2
INT0, External Interrupt source 0: The PD2 pin can serve as an external interrupt
source.
22
• INT1 – Port D, Bit 3
INT1, External Interrupt source 1: The PD3 pin can serve as an external interrupt
source.
The PC0,PC1 and PC2 pins of the Atmega 8 are connected to the pin no. 4,5 and 6 of
the lcd respectively.
Port C (PC5..PC0) Port C is an 7-bit bi-directional I/O port with internal pull-up
resistors (selected for each bit). The Port C output buffers have symmetrical drive
characteristics with both high sink and sourcecapability. As inputs, Port C pins that are
externally pulled low will source current if the pull-upresistors are activated. The Port
C pins are tri-stated when a reset condition becomes active,even if the clock is not
running.
Clock to the microcontroller is given to the pins PB6 and PB7.
Figure 8 .Atmega 8 pin out
23
PB7: XTAL2 (Chip Clock Oscillator pin 2)
TOSC2 (Timer Oscillator pin 2)
PB6 : XTAL1 (Chip Clock Oscillator pin 1 or External clock input)
TOSC1 (Timer Oscillator pin 1)
24
7. WAVEFORMS
7.1. POWER SUPPLY
25
7.2. OPTOCOUPLER AND SCHMITT TRIGGER
26
8. PROGRAM
extern void LCDstring(uint8_t* data, uint8_t nBytes);
extern void LCDnum(unsigned int nNum);
void initCounter1(void);
volatile unsigned int gnCount = 0;
volatile unsigned char gucFlag = 0;
int main()
{
int Freq = 0;
int SampleCount = 0;
int unTemp;
initTimer0();
initCounter1();
LCDinit();
LCDclr ();
Sei ();
LCDstring ("Freq = ", 7);
//LCDclr ();
While (1)
{
If (gucFlag == 1)
{
27
Freq += gnCount;
If (SampleCount == 8)
{ Freq >>= 1;
If (unTemp!= Freq)
{
LCDGotoXY(0,1); //Cursor to X Y position
LCDstring(" ", 8);
LCDGotoXY (0, 1); //Cursor to X Y
position
LCDnum(Freq);
}
unTemp = Freq;
SampleCount = 0;
Freq = 0;
}
SampleCount ++;
gucFlag = 0;
}
}
return 0;
}
ISR (TIMER0_OVF_vect)
{
//This is the interrupt service routine for TIMER0 OVERFLOW Interrupt.
//CPU automatically calls this when TIMER0 overflows.
cli ();
28
gnCount = TCNT1;
gucFlag = 1;
TCNT1 = 0X00;
TCNT0 = 0x0A;
Sei ();
}
void initTimer0(void)
{
// Prescaler = FCPU/1024
TCCR0|= (1<<CS02)|(1<<CS00);
//Enable Overflow Interrupt Enable
TIMSK|=(1<<TOIE0);
//Initialize Counter
TCNT0=0x0A;
}
void initCounter1(void)
{
// Clock sourse is T1 on rising edge;
TCCR1B |= (1<<CS12)|(1<<CS11)|(1<<CS10);
//Initialize Counter
TCNT1=0x00;
}
#ifndef LCD_LIB
29
#define LCD_LIB
#include <inttypes.h>
//Uncomment this if LCD 4 bit interface is used
//******************************************
#define LCD_4bit
//***********************************************
#define LCD_RS 0 //define MCU pin connected to LCD RS
#define LCD_RW 1 //define MCU pin connected to LCD R/W
#define LCD_E 2 //define MCU pin connected to LCD E
#define LCD_D0 0 //define MCU pin connected to LCD D0
#define LCD_D1 1 //define MCU pin connected to LCD D1
#define LCD_D2 2 //define MCU pin connected to LCD D1
#define LCD_D3 3 //define MCU pin connected to LCD D2
#define LCD_D4 0 //define MCU pin connected to LCD D3
#define LCD_D5 1 //define MCU pin connected to LCD D4
#define LCD_D6 2 //define MCU pin connected to LCD D5
#define LCD_D7 3 //define MCU pin connected to LCD D6
#define LDP PORTD //define MCU port connected to LCD data pins
#define LCP PORTC //define MCU port connected to LCD control pins
#define LDDR DDRD //define MCU direction register for port connected to LCD
data pins
#define LCDR DDRC //define MCU direction register for port connected to LCD
control pins
30
#define LCD_CLR 0 //DB0: clear display
#define LCD_HOME 1 //DB1: return to home position
#define LCD_ENTRY_MODE 2 //DB2: set entry mode
#define LCD_ENTRY_INC 1 //DB1: increment
#define LCD_ENTRY_SHIFT 0 //DB2: shift
#define LCD_ON_CTRL 3 //DB3: turn lcd/cursor on
#define LCD_ON_DISPLAY 2 //DB2: turn display on
#define LCD_ON_CURSOR 1 //DB1: turn cursor on
#define LCD_ON_BLINK 0 //DB0: blinking cursor
#define LCD_MOVE 4 //DB4: move cursor/display
#define LCD_MOVE_DISP 3 //DB3: move display (0-> move cursor)
#define LCD_MOVE_RIGHT 2 //DB2: move right (0-> left)
#define LCD_FUNCTION 5 //DB5: function set
#define LCD_FUNCTION_8BIT 4 //DB4: set 8BIT mode (0->4BIT mode)
#define LCD_FUNCTION_2LINES 3 //DB3: two lines (0->one line)
#define LCD_FUNCTION_10DOTS 2 //DB2: 5x10 font (0->5x7 font)
#define LCD_CGRAM 6 //DB6: set CG RAM address
#define LCD_DDRAM 7 //DB7: set DD RAM address
// reading:
#define LCD_BUSY 7 //DB7: LCD is busy
#define LCD_LINES 2 //visible lines
#define LCD_LINE_LENGTH 16 //line length (in characters)
// cursor position to DDRAM mapping
#define LCD_LINE0_DDRAMADDR 0x00
#define LCD_LINE1_DDRAMADDR 0x40
#define LCD_LINE2_DDRAMADDR 0x14
#define LCD_LINE3_DDRAMADDR 0x54
// progress bar defines
31
#define PROGRESSPIXELS_PER_CHAR 6
void LCDsensdChar(uint8_t); //forms data ready to send to 74HC164
void LCDsendCommand(uint8_t); //forms data ready to send to 74HC164
void LCDinit(void); //Initializes LCD
void LCDclr(void); //Clears LCD
void LCDhome(void); //LCD cursor home
void LCDstring(uint8_t*, uint8_t); //Outputs string to LCD
void LCDGotoXY(uint8_t, uint8_t); //Cursor to X Y position
void CopyStringtoLCD(const uint8_t*, uint8_t, uint8_t);//copies flash string to LCD at
x,y
void LCDdefinechar(const uint8_t *,uint8_t);//write char to LCD CGRAM
void LCDshiftRight(uint8_t); //shift by n characters Right
void LCDshiftLeft(uint8_t); //shift by n characters Left
void LCDcursorOn(void); //Underline cursor ON
void LCDcursorOnBlink(void); //Underline blinking cursor ON
void LCDcursorOFF(void); //Cursor OFF
void LCDblank(void); //LCD blank but not cleared
void LCDvisible(void); //LCD visible
void LCDcursorLeft(uint8_t); //Shift cursor left by n
void LCDcursorRight(uint8_t); //shif cursor right by n
// displays a horizontal progress bar at the current cursor location
// <progress> is the value the bargraph should indicate
// <maxprogress> is the value at the end of the bargraph
// <length> is the number of LCD characters that the bargraph should cover
//adapted from AVRLIB - displays progress only for 8 bit variables
void LCDprogressBar(uint8_t progress, uint8_t maxprogress, uint8_t length); #endi
9.
32
9. PCB FABRICATION
9. PCB LAYOUT
33
PCB LAYOUT
34
11. PCB FABRICATION TECHNIQUE
The first step of assembling is to produce a printed circuit board. The fabrication of
the program counter plays a crucial role in the electronic field. The success of the
circuit is also dependent on the PCB. As far as the cost is concerned, more than 25%
of the total cost is for the PCB design and fabrication. The board is designed using a personal computer. The layout is drawn using the
software “Adobe PageMaker 6.5”. The layout is printed in a “buffer sheet” using a
laser procedure. First, a negative screen of the layout is prepared with the help of a
professional screen printer. Then the copper clad sheet is kept under this screen. The
screen printing ink is poured on the screen and brushed through the top of the screen.
The printed board is kept under shade for few hours till the ink becomes dry. The etching medium is prepared with the un-hydrous ferric chloride water. The printed
board is kept in this solution till the exposed copper dissolves in the solution fully.
After that the board is taken out and rinsed in flowing water under a tap. The ink is
removed with solder in order to prevent oxidation.
Another screen, which contains component side layout, is prepared and the same is
printed on the component side of the board. A paper epoxy laminate is used as the
board. Both the component and the track layout of the peripheral PCB is given at the
end of this report.
35
12. CONCLUSION
This project thereby has brought about a more convenient means of measuring the
frequency oof a signal. Using liquid rystal display the measured frequency can also be
displayed instead of calculating the frequency of the signal from its time period,like
the usual procedure.by size,weight and cost also this system pays a better source for
the purpose of measuring signal frequencies. Just like the system as a whole and its
design,handling this also is much simpler than the usual CRO and DSO. Unlike the
complicated systems available in market, these require not much skill on handling
them.
36
13. SCOPE
The circuit thus completed can be used to measure the line as well as the external
frequency of signals fed. Certain modifications to the circuit can be brought into effect
to make it possible to measure and display the voltage n time period of the signal.
37
14. REFERENCE
• Electronic circuits and devices: J.B. Gupta.
• Op-amps and linear integrated circuits: Ramakanth A. Gayakward
• Integrated circuits : K.R. Botkar
38
15. APPENDIX
15.1. ATMEGA 8 DATASHEET
Features
• High-performance, Low-power Atmel®AVR® 8-bit Microcontroller
• Advanced RISC Architecture
– 130 Powerful Instructions – Most Single-clock Cycle Execution
– 32 × 8 General Purpose Working Registers
– Fully Static Operation
– Up to 16MIPS Throughput at 16MHz
– On-chip 2-cycle Multiplier
• High Endurance Non-volatile Memory segments
– 8Kbytes of In-System Self-programmable Flash program memory
– 512Bytes EEPROM
– 1Kbyte Internal SRAM
– Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
– Data retention: 20 years at 85°C/100 years at 25°C
– Optional Boot Code Section with Independent Lock Bits
In-System Programming by On-chip Boot Program
True Read-While-Write Operation
– Programming Lock for Software Security
• Peripheral Features
– Two 8-bit Timer/Counters with Separate Prescaler, one Compare Mode
– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture
Mode
– Real Time Counter with Separate Oscillator
– Three PWM Channels
– 8-channel ADC in TQFP and QFN/MLF package
39
Eight Channels 10-bit Accuracy
– 6-channel ADC in PDIP package
Six Channels 10-bit Accuracy
– Byte-oriented Two-wire Serial Interface
– Programmable Serial USART
– Master/Slave SPI Serial Interface
– Programmable Watchdog Timer with Separate On-chip Oscillator
– On-chip Analog Comparator
• Special Microcontroller Features
– Power-on Reset and Programmable Brown-out Detection
– Internal Calibrated RC Oscillator
– External and Internal Interrupt Sources
– Five Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, and
Standby
• I/O and Packages
– 23 Programmable I/O Lines
– 28-lead PDIP, 32-lead TQFP, and 32-pad QFN/MLF
• Operating Voltages
– 2.7V - 5.5V (ATmega8L)
– 4.5V - 5.5V (ATmega8)
• Speed Grades
– 0 - 8MHz (ATmega8L)
– 0 - 16MHz (ATmega8)
• Power Consumption at 4Mhz, 3V, 25°C
– Active: 3.6mA
– Idle Mode: 1.0mA
– Power-down Mode: 0.5µA
40
Overview
The ATmega8 is a low-power CMOS 8-bit microcontroller based on the AVR RISC
architecture. By executing powerful instructions in a single clock cycle, the ATmega8
achieves throughputs approaching 1 MIPS per MHz, allowing the system designer to
optimize power consumption versus processing speed.
41
Block Diagram Figure 1. Block Diagram
42
Pin Descriptions
VCC Digital supply voltage.
GND Ground.
Port B (PB7..PB0)/XTAL1/
XTAL2/TOSC1/TOSC2
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for
eachbit). The Port B output buffers have symmetrical drive characteristics with both
high sink and source capability. As inputs, Port B pins that are externally pulled low
will source current if the pull-up resistors are activated. The Port B pins are tri-stated
when a resetcondition becomes active, even if the clock is not running.
Depending on the clock selection fuse settings, PB6 can be used as input to the
inverting. Oscillator amplifier and input to the internal clock operating circuit.
Depending on the clock selection fuse settings, PB7 can be used as output from the
inverting oscillator amplifier.
If the Internal Calibrated RC Oscillator is used as chip clock source, PB7..6 is used as
TOSC2.1 input for the Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set.
The various special features of Port B are elaborated on page 56.
Port C (PC5.PC0) Port C is a 7-bit bi-directional I/O port with internal pull-up
resistors (selected for eachbit). The Port C output buffers have symmetrical drive
characteristics with both high sinkand source capability. As inputs, Port C pins that are
externally pulled low will sourcecurrent if the pull-up resistors are activated. The Port
C pins are tri-stated when a resetcondition becomes active, even if the clock is not
running.
PC6/RESET If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note
that the electricalcharacteristics of PC6 differ from those of the other pins of Port C.
If the RSTDISBL Fuse is unprogrammed, PC6 is used as a Reset input. A low level on
this pin for longer than the minimum pulse length will generate a Reset, even if the
clockis not running. Shorterpulses are not guaranteed to generate a Reset.
43
Port D (PD7.PD0) Port D is an 8-bit bi-directional I/O port with internal pull-up
resistors (selected for eachbit). The Port D output buffers have symmetrical drive
characteristics with both high sinkand source capability. As inputs, Port D pins that are
externally pulled low will sourcecurrent if the pull-up resistors are activated. The Port
D pins are tri-stated when a resetcondition becomes active, even if the clock is not
running.
RESET Reset input. A low level on this pin for longer than the minimum pulse length
will generatea reset, even if the clock is not running.
XTAL1 Input to the inverting Oscillator amplifier and input to the internal clock
operating circuit.
XTAL2 Output from the inverting Oscillator amplifier.
AVCC is the supply voltage pin for the A/D Converter, Port C (3..0), and ADC (7..6).
Itshould be externally connected to VCC, even if the ADC is not used. If the ADC is
used, it should be connected to VCC through a low-pass filter. Note that Port C (5..4)
use digitalsupply voltage, VCC.
AREF is the analog reference pin for the A/D Converter.
44
15.2. IC 7805 DATASHEET
FEATURES
· ±1% Output Tolerance at 25°C · Internal Short-Circuit Current
Limiting
· ±2% Output Tolerance Over Full Operating · Pinout Identical to mA7800 Series
Range
· Improved Version of mA7800 Series · Thermal Shutdown
DESCRIPTION/ORDERING INFORMATION
POSITIVE-VOLTAGE REGULATORS
· ±1% Output Tolerance at 25°C · Internal Short-Circuit Current Limiting
· ±2% Output Tolerance Over Full Operating · Pinout Identical to mA7800 Series
Range · Improved Version of mA7800 Series
· Thermal Shutdown
Each fixed-voltage precision regulator in the TL780 series is capable of supplying 1.5
A of load current. A uniquetemperature-compensation technique, coupled with an
internally trimmed band-gap reference, has resulted inimproved accuracy when
compared to other three-terminal regulators. Advanced layout techniques
provideexcellent line, load, and thermal regulation. The internal current-limiting and
thermal-shutdown featuresessentially make the devices immune to overload.
45
46
47
15.3. 555 DATASHEET
DESCRIPTION
The 555 monolithic timing circuit is a highly stable controller capable of
producingaccurate time delays, or oscillation. In the time delaymode of operation, the
time is precisely controlled by one externalresistor and capacitor. For a stable
operation as an oscillator, thefree running frequency and the duty cycle are both
accuratelycontrolled with two external resistors and one capacitor. The circuit
may be triggered and reset on falling waveforms, and the outputstructure can source or
sink up to 200 mA.
FEATURES
• Turn-off time less than 2 ms
• Max. operating frequency greater than 500 kHz
• Timing from microseconds to hours
• Operates in both astable and monostable modes
• High output current
• Adjustable duty cycle
• TTL compatible
• Temperature stability of 0.005% per °C
APPLICATIONS
• Precision timing
• Pulse generation
• Sequential timing
• Time delay generation
• Pulse width modulation
48
49
50
15.4. MCT2E DATASHEET
COMPATIBLE WITH STANDARD TTL INTEGRATED CIRCUITS
_ Gallium Arsenide Diode Infrared Source
Optically Coupled to a Silicon npn
Phototransistor
_ High Direct-Current Transfer Ratio
_ Base Lead Provided for Conventional
Transistor Biasing
_ High-Voltage Electrical Isolation . . .
1.5-kV, or 3.55-kV Rating
_ Plastic Dual-In-Line Package
_ High-Speed Switching:
tr = 5 µs, tf = 5 µs Typical
_ Designed to be Interchangeable with
General Instruments MCT2 and MCT2E
absolute maximum ratings at 25°C free-air temperature (unless otherwise noted) †
Input-to-output voltage: MCT 1.5 kV
MCT2E 3.55 kV
Collector-base voltage 70 V
Collector-emitter voltage 30 V
Emitter-collector voltage 7 V
Emitter-base voltage 7 V
Input-diode reverse voltage 3 V
Input-diode continuous forward current 60 mA
Input-diode peak forward current (tw ≤ 1 ns, PRF ≤ 300 Hz) 3 A
Continuous power dissipation at (or below) 25°C free-air temperature:
Infrared-emitting diode 200 mW
Phototransistor 200 mW
51
Total, infrared-emitting diode plus phototransistor 250 mW
Operating free-air temperature range, TA –55°C to 100°C
Storage temperature range, Tstg –55°C to 150°C
Lead temperature 1,6 mm (1/16 inch) from case for 10 seconds 260°
52
15.5. LCD 16X2 DATASHEET FEATURES
• 5 x 8 dots with cursor
• Built-in controller (KS 0066 or Equivalent)
• + 5V power supply (Also available for + 3V)
• 1/16 duty cycle
• B/L to be driven by pin 1, pin 2 or pin 15, pin 16 or A.K (LED)
• N.V. optional for + 3V power supply
53
54