Professional Documents
Culture Documents
MINI PROJECT11
INTRODUCTION
All fans which are used now a day are controlled manually by voltage regulators which have different stages of speed. This process is done manually which can be done automatically by the use of this circuit. Here we are introducing an efficient fan speed regulation circuit, by which the speed of a fan can be controlled depending up on the room temperature. The circuit is highly efficient since energy loss can be minimized by power saving as the circuit automatically adjusts the fans speed.
1
DEPARTMENT OF EEE,VAST
MINI PROJECT11
PRINCIPLE OF OPERATION
This circuit uses thermistor as the temperature sensor, i.e. one having a negative temperature coefficient. This circuit is designed in such a way that the speed of the fan increases/decreases with respect to the room temperature with a minimum parts counting and avoiding the use of special-purpose ICs, often difficult to obtain.
2
DEPARTMENT OF EEE,VAST
MINI PROJECT11
BLOCK DIAGRAM
LOAD
3
DEPARTMENT OF EEE,VAST
MINI PROJECT11
COMPONENTS USED
NAME OF COMPONENT
SPECIFICATION 22K
QUANTITY 1
Linear Potentiometer-P1 Thermistor-R1 SCR-D2 Zener Diode-D1 Diodes-D3,D4,D5,D6 Transistors-Q1,Q2 Transistor-Q3 Polyester Capacitor-C1 Resistor-R2 Resistors-R3,R6 Resistors-R4,R5 Resistor-R7 Resistor-R8
15K @ 20C n.t.c TYN612 BZX79C18 1N4007 1000V BC327 BC337 10nF 63V 100K 1/4W 10K 1/4W 22K 1/4W 100R 1/4W 470R 1/4W
1 1
1 4 2
1 1 1
2
2 1 1
4
DEPARTMENT OF EEE,VAST
MINI PROJECT11
68K 2W -
2 1 1 1 1 As required
5
DEPARTMENT OF EEE,VAST
MINI PROJECT11
8051 microcontroller
6
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Introduction
The term microcomputer is used to describe a system that includes at minimum a microprocessor, program memory, data memory, and an input-output (I/O) device. Some microcomputer systems include additional components such as timers, counters, and analog-todigital converters. Thus, a microcomputer system can be anything from a large computer having hard disks, floppy disks, and printers to a single-chip embedded controller.
We are going to consider only the type of microcomputers that consist of a single silicon chip. Such microcomputer systems are also called microcontrollers, and they are used in many household goods such as microwave ovens, TV remote control units, cookers, hi-fi equipment, CD players, personal computers, and refrigerators. Many different microcontrollers are available on the market. In this book
we shall be looking at programming and system design for the 8051 series of microcontrollers .
7
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Microcontroller System:
In today present a lot of microcontroller manufactures appeared almost every major electronic company produce their own microcontroller to use into their own devices each
8
DEPARTMENT OF EEE,VAST
MINI PROJECT11
microcontroller type may add or improve existing features but all microcontrollers share basic features that is microprocessor (CPU), memory and an input-output (I/O) device.
The input components would consist of digital devices such as, switches, push buttons, pressure mats, float switches, keypads, radio receivers etc. and analogue sensors such as light dependent resistors, thermistors, gas sensors, pressure sensors, etc.
The control unit is of course the microcontroller. The microcontroller will monitor the inputs and as a result the program would turn outputs on and off. The microcontroller stores the program in its memory, and executes the instructions under the control of the clock circuit.
The output devices would be made up from LEDs, buzzers, motors, alpha numeric displays, radio transmitters, 7 segment displays, heaters, fans etc.
The most obvious choice then for the microcontroller is how many digital inputs, analogue inputs and outputs does the system require. This would then specify the minimum number of inputs and outputs (I/O) that the microcontroller must have. If analogue inputs are used then the microcontroller must have an Analogue to Digital (A/D) module inside. The next consideration would be what size of program memory storage is required. This should not be too much of a problem when starting out, as most programs would be relatively small. The clock frequency determines the speed at which the instructions are executed. This is important if any lengthy calculations are being undertaken. The higher the clock frequency the quicker the micro will finish one task and start another. Other considerations are the number of interrupts and timer circuits required how much data EEPROM if any is needed.
9
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Microcontrollers have traditionally been programmed using the assembly language of the target device. Although the assembly language is fast, it has several disadvantages. An assembly program makes learning and maintaining a program written using the assembly language difficult. Also, microcontrollers manufactured by different firms have different assembly languages, so the user must learn a new language with every new microcontroller he uses. Microcontrollers can also be programmed using a high-level language, such as BASIC, PASCAL, or C. High-level languages are much easier to learn than assembly languages. They also facilitate the development of large and complex programs. A microcontroller is a very powerful tool that allows a designer to create sophisticated input-output data manipulation under program control. Microcontrollers are classified by the number of bits they process. 12 Microcontrollers with 8 bits are the most popular and are used in most microcontroller-based applications. Microcontrollers with 16 and 32 bits are much more powerful, but are usually more expensive and not required in most small- or medium-size general purpose applications that call for microcontrollers.
10
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Arithmetical Logical Unit (ALU): performs all mathematical and logical operations upon data.
Accumulator: is a SFR closely related to the operation of ALU. It is a kind of working desk used for storing all data upon which some operation should be performed (addition, shift/move etc.). It also stores results ready for use in further processing.
Status Register (PSW): One of SFRs is close to the accumulator. It shows at any moment the status of a number stored in the accumulator (number is greater or less than zero etc.)..
Memory unit
Memory, an important part of a microcontroller system, can be classified into two types: program memory and data memory. Program memory stores the program written by the programmer and is usually nonvolatile (i.e., data is not lost after the power is turned off). Data memory stores the temporary data used in a program and is usually volatile (i.e., data is lost after the power is turned off).
11
DEPARTMENT OF EEE,VAST
MINI PROJECT11
RAM
RAM, random access memory, is a general purpose memory that usually stores the user data in a program. RAM memory is volatile in the sense that it cannot retain data in the absence of power (i.e., data is lost after the power is turned off). Most microcontrollers have some amount of internal RAM, 256 bytes being a common amount, although some microcontrollers have more, some less. The AT89C52 microcontroller, for example, has 256 bytes of RAM. Memory can usually be extended by adding external memory chips.
ROM
ROM, read only memory, usually holds program or fixed user data. ROM is nonvolatile. If power is removed from ROM and then reapplied, the original data will still be there. ROM memory is programmed during the manufacturing process, and the user cannot change its contents. ROM
12
DEPARTMENT OF EEE,VAST
MINI PROJECT11
memory is only useful if you have developed a program and wish to create several thousand copies of it.
2.4.2.3 PROM
PROM, programmable read only memory, is a type of ROM that can be programmed in the field, often by the end user, using a device called a PROM programmer. Once a PROM has been programmed, its contents cannot be changed. PROMs are usually used in low production applications where only a few such memories are required.
EPROM
13
DEPARTMENT OF EEE,VAST
MINI PROJECT11
EPROM, erasable programmable read only memory, is similar to ROM, but EPROM can be programmed using a suitable programming device. An EPROM memory has a small clear-glass window on top of the chip where the data can be erased under strong ultraviolet light. Once the memory is programmed, the window can be covered with dark tape to prevent accidental erasure of the data. An EPROM memory must be erased before it can be reprogrammed. Many developmental versions of microcontrollers are manufactured with EPROM memories where the user program can be stored. These memories are erased and reprogrammed until the user is satisfied with the program. Some versions of EPROMs, known as OTP (one time programmable), can be programmed using a suitable programmer device but cannot be erased. OTP memories cost much less than EPROMs. OTP is useful after a project has been developed completely and many copies of the program memory must be made.
EEPROM
EEPROM, electrically erasable programmable read only memory, is a nonvolatile memory that can be erased and reprogrammed using a suitable programming device. EEPROMs are used to save configuration information, maximum and minimum values, identification data, etc. Some microcontrollers have built-in EEPROM memories. For instance, the PIC18F452 contains a 256-byte EEPROM memory where each byte can be programmed and erased directly by applications software. EEPROM memories are usually very slow. An EEPROM chip is much costlier than an EPROM chip.
Flash EEPROM
Flash EEPROM, a version of EEPROM memory, has become popular in microcontroller applications and is used to store the user program. Flash EEPROM is nonvolatile and usually very fast. The data can be erased and then reprogrammed using a suitable programming device. Some microcontrollers have only 1K flash EEPROM while others have 32K or more. The AT89C52 microcontroller has 1K bytes of flash memory.
14
DEPARTMENT OF EEE,VAST
MINI PROJECT11
MINI PROJECT11
Supply Voltage
Most microcontrollers operate with the standard logic voltage of + 5V. Some microcontrollers can operate at as low as + 2.7V, and some will tolerate + 6V without any problem. The manufacturers data sheet will have information about the allowed limits of the power supply voltage. At89c52 microcontrollers can operate with a power supply of + 2V to 5.5V. Usually, a voltage regulator circuit is used to obtain the required power supply voltage when the device is operated from a mains adapter or batteries. For example, a 5V regulator is required if the microcontroller is operated from a 5V supply using a 9V battery.
The Clock
All microcontrollers require a clock (or an oscillator) to operate, usually provided by external timing devices connected to the microcontroller. In most cases, these external timing devices are a crystal plus two small capacitors. In some cases they are resonators or an external resistor-capacitor pair. Some microcontrollers have built-in timing circuits and do not require external timing components. If an application is not time-sensitive, external or internal (if available) resistor-capacitor timing components are the best option for their simplicity and low cost. An instruction is executed by fetching it from the memory and then decoding it. This usually takes several clock cycles and is known as the instruction cycle. Thus the microcontroller operates at a clock rate that is one-quarter of the actual oscillator frequency. The 8051 series of microcontrollers can operate with clock frequencies up to 40MHz.
Timers
Timers are important parts of any microcontroller. A timer is basically a counter which is driven from either an external clock pulse or the microcontrollers internal oscillator. A timer can be 8 bits or 16 bits wide. Data can be loaded into a timer under program control, and the timer can be stopped or started by program control. Most timers can be configured to
16
DEPARTMENT OF EEE,VAST
MINI PROJECT11
generate an interrupt when they reach a certain count (usually when they overflow). The user program can use an interrupt to carry out accurate timing-related operations inside the microcontroller. Microcontrollers in the 8051 series have at least three timers. For example, the AT89C52 microcontroller has three built-in timers. Some microcontrollers offer capture and compare facilities, where a timer value can be read when an external event occurs, or the timer value can be compared to a preset value, and an interrupt is generated when this value is reached.
Reset Input
A reset input is used to reset a microcontroller externally. Resetting puts the microcontroller into a known state such that the program execution starts from address 0 of the program memory. An external reset action is usually achieved by connecting a push-button switch to the reset input. When the switch is pressed, the microcontroller is reset.
Interrupts
Interrupts are an important concept in microcontrollers. An interrupt causes the microcontroller to respond to external and internal (e.g., a timer) events very quickly. When an interrupt occurs, the microcontroller leaves its normal flow of program execution and jumps to a special part of the program known as the interrupt service routine (ISR). The program code inside the ISR is executed, and upon return from the ISR the program resumes its normal flow of execution. The ISR starts from a fixed address of the program memory sometimes known as the interrupt vector address. Some microcontrollers with multi-interrupt features have just one interrupt vector address, while others have unique interrupt vector addresses, one for each interrupt source. Interrupts can be nested such that a new interrupt can suspend the execution of another interrupt. Another important feature of multi-interrupt capability is that different interrupt sources can be assigned different levels of priority. The at89c52 microcontroller has 8 interrupts source.
Analog-to-Digital Converter
17
DEPARTMENT OF EEE,VAST
MINI PROJECT11
An analog-to-digital converter (A/D) is used to convert an analog signal, such as voltage, to digital form so a microcontroller can read and process it. Some microcontrollers have builtin A/D converters. External A/D converter can also be connected to any type of microcontroller. A/D converters are usually 8 to 10 bits, having 256 to 1024 quantization levels. Most 8051 microcontrollers with A/D features have multiplexed A/D converters which provide more than one analog input channel. The A/D conversion process must be started by the user program and may take several hundred microseconds to complete. A/D converters usually generate interrupts when a conversion is complete so the user program can read the converted data quickly. A/D converters are especially useful in control and monitoring applications, since most sensors (e.g., temperature sensors, pressure sensors, force sensors, etc.) produce analog output voltages.
Serial Input-Output
Serial communication (also called RS232 communication) enables a microcontroller to be connected to another microcontroller or to a PC using a serial cable. Some microcontrollers have built-in hardware called USART (universal synchronous-asynchronous receiver-transmitter) to implement a serial communication interface. The user program can usually select the baud rate and data format. If no serial input-output hardware is provided, it is easy to develop software to implement serial data communication using any I/O pin of a microcontroller.
All 8051 microcontrollers are 40 pin devices. The pin configuration of AT89C52 or AT89S52 (DIP package) is shown in figure.
18
DEPARTMENT OF EEE,VAST
MINI PROJECT11
19
DEPARTMENT OF EEE,VAST
MINI PROJECT11
20
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Port 0
The P0 port is characterized by two functions. If external memory is used then the lower address byte (addresses A0-A7) is applied on it. Otherwise, all bits of this port are configured as inputs/outputs. The other function is expressed when it is configured as an output. Unlike other ports consisting of pins with built-in pull-up resistor connected by its end to 5 V power supply, pins of this port have this resistor left out. This apparently small difference has its consequences:
21
DEPARTMENT OF EEE,VAST
MINI PROJECT11
If any pin of this port is configured as an input then it acts as if it floats. Such an input has unlimited input resistance and in determined potential.
When the pin is configured as an output, it acts as an open drain. By applying logic 0 to a port bit, the appropriate pin will be connected to ground (0V). By applying logic 1, the external output will keep on floating. In order to apply logic 1 (5V) on this output pin, it is necessary to built in an external pull-up resistor.
Port 1
P1 is a true I/O port, because it doesn't have any alternative functions as is the case with P0, but can be configured as general I/O only. It has a pull-up resistor built-in and is completely compatible with TTL circuits.
Port 2
22
DEPARTMENT OF EEE,VAST
MINI PROJECT11
P2 acts similarly to P0 when external memory is used. Pins of this port occupy addresses intended for external memory chip. This time it is about the higher address byte with addresses A8-A15. When no memory is added, this port can be used as a general input/output port showing features similar to P1.
Port 3
All port pins can be used as general I/O, but they also have an alternative function. In order to use these alternative functions, a logic one (1) must be applied to appropriate bit of the P3 register. In terms of hardware, this port is similar to P0, with the difference that its pins have a pull-up resistor built-in. Pin's Current limitations When configured as outputs (logic zero (0)), single port pins can receive a current of 10mA. If all 8 bits of a port are active, a total current must be limited to 15mA (port P0: 26mA). If all ports (32 bits) are active, total maximum current must be limited to 71mA. When these pins are configured as inputs (logic 1), built-in pull-up resistors provide very weak current, but strong enough to activate up to 4 TTL inputs of LS series.
23
DEPARTMENT OF EEE,VAST
MINI PROJECT11
A Register (Accumulator)
A register is a general-purpose register used for storing intermediate results obtained during operation. Prior to executing an instruction upon any number or operand it is necessary to store it in the accumulator first. All results obtained from arithmetical operations performed by the ALU are stored in the accumulator. Data to be moved from one register to another must go through the accumulator. In other words, the A register is the most commonly used register and it is impossible to imagine a microcontroller without it. More than half instructions used by the 8051 microcontroller use somehow the accumulator.
B Register
Multiplication and division can be performed only upon numbers stored in the A and B registers. All other instructions in the program can use this register as a spare accumulator (A).
24
DEPARTMENT OF EEE,VAST
MINI PROJECT11
R Registers (R0-R7)
This is a common name for 8 general-purpose registers (R0, R1, R2 ...R7). Even though they are not true SFRs, they deserve to be discussed here because of their purpose. They occupy 4 banks within RAM. Similar to the accumulator, they are used for temporary storing variables and intermediate results during operation. Which one of these banks is to be active depends on two bits of the PSW Register. Active bank is a bank the registers of which are currently used. The following example best illustrates the purpose of these registers. Suppose it is necessary to perform some arithmetical operations upon numbers previously stored in the R registers: (R1+R2) - (R3+R4). Obviously, a register for temporary storing results of addition is needed. This is how it looks in the program:
25
DEPARTMENT OF EEE,VAST
MINI PROJECT11
ADD A,R4; Means: add number from R4 to accumulator (result remains in accumulator) MOV R5,A; Means: temporarily move the result from accumulator into R5 MOV A,R1; Means: move number from R1 to accumulator ADD A,R2; Means: add number from R2 to accumulator SUBB A,R5; Means: subtract number from R5 (there are R3+R4)
PSW register is one of the most important SFRs. It contains several status bits that reflect the current state of the CPU. Besides, this register contains Carry bit, Auxiliary Carry, two register bank select bits, Overflow flag, parity bit and user-definable status flag.
P - Parity bit:
If a number stored in the accumulator is even then this bit will be automatically set (1), otherwise it will be cleared (0). It is mainly used during data transmit and receive via serial communication.
Bit 1:
occurs when the result of an arithmetical operation is larger than 255 and cannot be stored in one register. Overflow condition causes the OV bit to be set (1). Otherwise, it will be cleared (0).
RS0, RS1 - Register bank select bits:
These two bits are used to select one of four register banks of RAM. By setting and clearing these bits, registers R0-R7 are stored in one of four banks of RAM.
F0 - Flag 0:
26
DEPARTMENT OF EEE,VAST
MINI PROJECT11
is the (ninth) auxiliary bit used for all arithmetical operations and shift instructions.
DPTR register is not a true one because it doesn't physically exist. It consists of two separate registers: DPH (Data Pointer High) and (Data Pointer Low). For this reason it may be treated as a 16-bit register or as two independent 8-bit registers. Their 16 bits are primarily used for external memory addressing. Besides, the DPTR Register is usually used for storing data and intermediate results.
27
DEPARTMENT OF EEE,VAST
MINI PROJECT11
A value stored in the Stack Pointer points to the first free stack address and permits stack availability. Stack pushes increment the value in the Stack Pointer by 1. Likewise, stack pops decrement its value by 1. Upon any reset and power-on, the value 7 is stored in the Stack Pointer, which means that the space of RAM reserved for the stack starts at this location. If another value is written to this register, the entire Stack is moved to the new memory location.
P0, P1, P2, P3 - Input/Output Registers
If neither external memory nor serial communication system are used then 4 ports with in total of 32 input/output pins are available for connection to peripheral environment. Each bit within these ports affects the state and performance of appropriate pin of the microcontroller. Thus, bit logic state is reflected on appropriate pin as a voltage (0 or 5 V) and vice versa, voltage on a pin reflects the state of appropriate port bit. As mentioned, port bit state affects performance of port pins, i.e. whether they will be configured as inputs or outputs. If a bit is cleared (0), the appropriate pin will be configured as an output, while if it is set (1), the appropriate pin will be configured as an input. Upon reset and power-on, all port bits are set (1), which means that all appropriate pins will be configured as inputs. Counters and Timers As you already know, the microcontroller oscillator uses quartz crystal for its operation. As the frequency of this oscillator is precisely defined and very stable, pulses it generates are always of the same width, which makes them ideal for time measurement. Such crystals are also used in quartz watches. In order to measure time between two events it is sufficient to count up pulses coming from this oscillator. That is exactly what the timer does. If the timer is properly programmed, the value stored in its register will be incremented (or decremented) with each coming pulse, i.e. once per each machine cycle. A single machine-cycle instruction lasts for 12
28
DEPARTMENT OF EEE,VAST
MINI PROJECT11
quartz oscillator periods, which means that by embedding quartz with oscillator frequency of 12MHz, a number stored in the timer register will be changed million times per second, i.e. each microsecond. The 8051 microcontroller has 2 timers/counters called T0 and T1. As their names suggest, their main purpose is to measure time and count external events. Besides, they can be used for generating clock pulses to be used in serial communication, so called Baud Rate.
Timer T0
As seen in figure below, the timer T0 consists of two registers TH0 and TL0 representing a low and a high byte of one 16-digit binary number.
Accordingly, if the content of the timer T0 is equal to 0 (T0=0) then both registers it consists of will contain 0. If the timer contains for example number 1000 (decimal), then the TH0 register (high byte) will contain the number 3, while the TL0 register (low byte) will contain decimal number 232.
two
29
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Since the timer T0 is virtually 16-bit register, the largest value it can store is 65 535. In case of exceeding this value, the timer will be automatically cleared and counting starts from 0. This condition is called an overflow. Two registers TMOD and TCON are closely connected to this timer and control its operation.
TMOD Register (Timer Mode)
The TMOD register selects the operational mode of the timers T0 and T1. As seen in figure below, the low 4 bits (bit0 - bit3) refer to the timer 0, while the high 4 bits (bit4 - bit7) refer to the timer 1. There are 4 operational modes and each of them is described herein.
Bits of this register have the following function: GATE1 : enables and disables Timer 1 by means of a signal brought to the INT1 pin (P3.3): 1 - Timer 1 operates only if the INT1 bit is set. 0 - Timer 1 operates regardless of the logic state of the INT1 bit. C/T1 : selects pulses to be counted up by the timer/counter 1: 1 - Timer counts pulses brought to the T1 pin (P3.5).
30
DEPARTMENT OF EEE,VAST
MINI PROJECT11
0 - Timer counts pulses from internal oscillator. T1M1,T1M0: These two bits select the operational mode of the Timer 1.
T1M1 T1M0 MODE DESCRIPTION
0 0 1 1
0 1 0 1
0 1 2 3
GATE0 enables and disables Timer 1 using a signal brought to the INT0 pin (P3.2): 1 - Timer 0 operates only if the INT0 bit is set. 0 - Timer 0 operates regardless of the logic state of the INT0 bit. C/T0 selects pulses to be counted up by the timer/counter 0: 1 - Timer counts pulses brought to the T0 pin (P3.4). 0 - Timer counts pulses from internal oscillator. T0M1,T0M0 These two bits select the operational mode of the Timer 0.
T0M1
T0M0
MODE
DESCRIPTION
0 0 1
0 1 0
0 1 2
31
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Split mode
o o o o
TF1 bit is automatically set on the Timer 1 overflow. TR1 bit enables the Timer 1.
1 - Timer 1 is enabled. 0 - Timer 1 is disabled.
TF0 bit is automatically set on the Timer 0 overflow. TR0 bit enables the timer 0.
1 - Timer 0 is enabled. 0 - Timer 0 is disabled.
32
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Referring to figure above, the timer 0 operates in mode 1 and counts pulses generated by internal clock the frequency of which is equal to 1/12 the quartz frequency. Turn on the timer:
The TR0 bit is set and the timer starts operation. If the quartz crystal with frequency of 12MHz is embedded then its contents will be incremented every microsecond. After 65.536 microseconds, the both registers the timer consists of will be loaded. The microcontroller automatically clears them and the timer keeps on repeating procedure from the beginning until the TR0 bit value is logic zero (0).
33
DEPARTMENT OF EEE,VAST
MINI PROJECT11
IE Register (Interrupt
34
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Enable)
o o o o o o o o o o o o
Interrupt Priorities
It is not possible to forseen when an interrupt request will arrive. If several interrupts are enabled, it may happen that while one of them is in progress, another one is requested. In order that the microcontroller knows whether to continue operation or meet a new interrupt request, there is a priority list instructing it what to do. The priority list offers 3 levels of interrupt priority:
1. Reset! The apsolute master. When a reset request arrives, everything is stopped and the microcontroller restarts.
35
DEPARTMENT OF EEE,VAST
MINI PROJECT11
2. Interrupt priority 1 can be disabled by Reset only. 3. Interrupt priority 0 can be disabled by both Reset and interrupt priority 1.
The IP Register (Interrupt Priority Register) specifies which one of existing interrupt sources have higher and which one has lower priority. Interrupt priority is usually specified at the beginning of the program. According to that, there are several possibilities:
If an interrupt of higher priority arrives while an interrupt is in progress, it will be immediately stopped and the higher priority interrupt will be executed first. If two interrupt requests, at different priority levels, arrive at the same time then the higher priority interrupt is serviced first. If the both interrupt requests, at the same priority level, occur one after another, the one which came later has to wait until routine being in progress ends. If two interrupt requests of equal priority arrive at the same time then the interrupt to be serviced is selected according to the following priority list: 1. External interrupt INT0 2. Timer 0 interrupt 3. External Interrupt INT1 4. Timer 1 interrupt 5. Serial Communication Interrupt
o o o o
36
DEPARTMENT OF EEE,VAST
MINI PROJECT11
o o o o o o
Priority 0 Priority 1
Handling Interrupt
When an interrupt request arrives the following occurs:
1. Instruction in progress is ended. 2. The address of the next instruction to execute is pushed on the stack. 3. Depending on which interrupt is requested, one of 5 vectors (addresses) is written to the program counter in accordance to the table below: 4.
INTERRUPT SOURCE VECTOR (ADDRESS)
3h Bh 1B h 23 h
5. These addresses store appropriate subroutines processing interrupts. Instead of them, there are usually jump instructions specifying locations on which these subroutines reside. 6. When an interrupt routine is executed, the address of the next instruction to execute is poped from the stack to the program counter and interrupted program resumes operation from where it left off.
37
DEPARTMENT OF EEE,VAST
MINI PROJECT11
From the moment an interrupt is enabled, the microcontroller is on alert all the time. When an interrupt request arrives, the program execution is stopped, electronics recognizes the source and the program jumps to the appropriate address (see the table above). This address usually stores a jump instruction specifying the start of appropriate subroutine. Upon its execution, the program resumes operation from where it left off.
Types of instructions
Depending on operation they perform, all instructions are divided in several groups:
Arithmetic Instructions Branch Instructions Data Transfer Instructions Logic Instructions Bit-oriented Instructions
The first part of each instruction, called MNEMONIC refers to the operation an instruction performs (copy, addition, logic operation etc.). Mnemonics are abbreviations of the name of operation being executed. For example:
INC R1 - Means: Increment register R1 (increment register R1); LJMP LAB5 - Means: Long Jump LAB5 (long jump to the address marked as LAB5);
38
DEPARTMENT OF EEE,VAST
MINI PROJECT11
JNZ LOOP - Means: Jump if Not Zero LOOP (if the number in the accumulator is not 0, jump to the address marked as LOOP);
The other part of instruction, called OPERAND is separated from mnemonic by at least one whitespace and defines data being processed by instructions. Some of the instructions have no operand, while some of them have one, two or three. If there is more than one operand in an instruction, they are separated by a comma. For example:
RET - return from a subroutine; JZ TEMP - if the number in the accumulator is not 0, jump to the address marked as TEMP; ADD A,R3 - add R3 and accumulator; CJNE A,#20,LOOP - compare accumulator with 20. If they are not equal, jump to the address marked as LOOP;
Arithmetic instructions
Arithmetic instructions perform several basic operations such as addition, subtraction, division, multiplication etc. After execution, the result is stored in the first operand. For example: ADD A,R1 - The result of addition (A+R1) will be stored in the accumulator.
ARITHMETIC INSTRUCTI ONS
Mnemonic ADD A,Rn ADD A,direct ADD A,@Ri ADD A,#data ADDC A,Rn ADDC A,direct ADDC A,@Ri
Description Adds the register to the accumulator Adds the direct byte to the accumulator Adds the indirect RAM to the accumulator Adds the immediate data to the accumulator Adds the register to the accumulator with a carry flag Adds the direct byte to the accumulator with a carry flag Adds the indirect RAM to the accumulator with a carry flag
Byte 1 2 1 2 1 2 1
Cycl 1 2 2 2 1 2 2
39
DEPARTMENT OF EEE,VAST
MINI PROJECT11
ADDC A,#data SUBB A,Rn SUBB A,direct SUBB A,@Ri SUBB A,#data INC A INC Rn INC Rx INC @Ri DEC A DEC Rn DEC Rx DEC @Ri INC DPTR MUL AB DIV AB DA A
Adds the immediate data to the accumulator with a carry flag Subtracts the register from the accumulator with a borrow Subtracts the direct byte from the accumulator with a borrow Subtracts the indirect RAM from the accumulator with a borrow Subtracts the immediate data from the accumulator with a borrow Increments the accumulator by 1 Increments the register by 1 Increments the direct byte by 1 Increments the indirect RAM by 1 Decrements the accumulator by 1 Decrements the register by 1 Decrements the direct byte by 1 Decrements the indirect RAM by 1 Increments the Data Pointer by 1 Multiplies A and B Divides A by B Decimal adjustment of the accumulator according to BCD code
2 1 2 1 2 1 1 2 1 1 1 1 2 1 1 1 1
2 1 2 2 2 1 2 3 3 1 1 2 3 3 5 5 1
Branch Instructions
There are two kinds of branch instructions: Unconditional jump instructions: upon their execution a jump to a new location from where the program continues execution is executed.
40
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Conditional jump instructions: a jump to a new program location is executed only if a specified condition is met. Otherwise, the program normally proceeds with the next instruction.
BRANCH INSTRUCTIONS
Mnemonic ACALL addr11 LCALL addr16 RET RETI AJMP addr11 LJMP addr16 SJMP rel JC rel JNC rel JB bit,rel JBC bit,rel JMP @A+DPTR JZ rel JNZ rel CJNE A,direct,rel CJNE A,#data,rel CJNE Rn,#data,rel
Description Absolute subroutine call Long subroutine call Returns from subroutine Returns from interrupt subroutine Absolute jump Long jump Short jump (from 128 to +127 locations relative to the following instruction) Jump if carry flag is set. Short jump. Jump if carry flag is not set. Short jump. Jump if direct bit is set. Short jump. Jump if direct bit is set and clears bit. Short jump. Jump indirect relative to the DPTR Jump if the accumulator is zero. Short jump. Jump if the accumulator is not zero. Short jump. Compares direct byte to the accumulator and jumps if not equal. Short jump. Compares immediate data to the accumulator and jumps if not equal. Short jump. Compares immediate data to the register and jumps if not equal. Short jump.
Byte 2 3 1 1 2 3 2 2 2 3 3 1 2 2 3 3 3
Cy 6 6 4 4 3 4 3 3 3 4 4 2 3 3 4 4 4
41
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Compares immediate data to indirect register and jumps if not equal. Short jump. Decrements register and jumps if not 0. Short jump. Decrements direct byte and jump if not 0. Short jump. No operation
3 2 3 1
4 3 4 1
Mnemonic MOV A,Rn MOV A,direct MOV A,@Ri MOV A,#data MOV Rn,A MOV Rn,direct MOV Rn,#data MOV direct,A MOV direct,Rn MOV direct,direct MOV direct,@Ri
Description Moves the register to the accumulator Moves the direct byte to the accumulator Moves the indirect RAM to the accumulator Moves the immediate data to the accumulator Moves the accumulator to the register Moves the direct byte to the register Moves the immediate data to the register Moves the accumulator to the direct byte Moves the register to the direct byte Moves the direct byte to the direct byte Moves the indirect RAM to the direct byte
Byte 1 2 1 2 1 2 2 2 2 3 2
Cyc 1 2 2 2 2 4 2 3 3 4 4
42
DEPARTMENT OF EEE,VAST
MINI PROJECT11
MOV direct,#data MOV @Ri,A MOV @Ri,direct MOV @Ri,#data MOV DPTR,#data MOVC A,@A+DPTR MOVC A,@A+PC MOVX A,@Ri MOVX A,@DPTR MOVX @Ri,A MOVX @DPTR,A PUSH direct POP direct XCH A,Rn XCH A,direct XCH A,@Ri XCHD A,@Ri
Moves the immediate data to the direct byte Moves the accumulator to the indirect RAM Moves the direct byte to the indirect RAM Moves the immediate data to the indirect RAM Moves a 16-bit data to the data pointer Moves the code byte relative to the DPTR to the accumulator (address=A+DPTR) Moves the code byte relative to the PC to the accumulator (address=A+PC) Moves the external RAM (8-bit address) to the accumulator Moves the external RAM (16-bit address) to the accumulator Moves the accumulator to the external RAM (8-bit address) Moves the accumulator to the external RAM (16-bit address) Pushes the direct byte onto the stack Pops the direct byte from the stack/td> Exchanges the register with the accumulator Exchanges the direct byte with the accumulator Exchanges the indirect RAM with the accumulator Exchanges the low-order nibble indirect RAM with the accumulator
3 1 2 2 3 1 1 1 1 1 1 2 2 1 2 1 1
3 3 5 3 3 3 3
3-1
3-1
4-1
4-1 4 3 2 3 3 3
Logic Instructions
Logic instructions perform logic operations upon corresponding bits of two registers. After execution, the result is stored in the first operand.
LOGIC INSTRUCTIONS
43
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Mnemonic ANL A,Rn ANL A,direct ANL A,@Ri ANL A,#data ANL direct,A ANL direct,#data ORL A,Rn ORL A,direct ORL A,@Ri ORL direct,A ORL direct,#data XRL A,Rn XRL A,direct XRL A,@Ri XRL A,#data XRL direct,A XORL direct,#data CLR A CPL A SWAP A
Description AND register to accumulator AND direct byte to accumulator AND indirect RAM to accumulator AND immediate data to accumulator AND accumulator to direct byte AND immediae data to direct register OR register to accumulator OR direct byte to accumulator OR indirect RAM to accumulator OR accumulator to direct byte OR immediate data to direct byte Exclusive OR register to accumulator Exclusive OR direct byte to accumulator Exclusive OR indirect RAM to accumulator Exclusive OR immediate data to accumulator Exclusive OR accumulator to direct byte Exclusive OR immediate data to direct byte Clears the accumulator Complements the accumulator (1=0, 0=1) Swaps nibbles within the accumulator
Byte 1 2 1 2 2 3 1 2 1 2 3 1 2 1 2 2 3 1 1 1
Cycle 1 2 2 2 3 4 1 2 2 3 4 1 2 2 2 3 4 1 1 1
44
DEPARTMENT OF EEE,VAST
MINI PROJECT11
RL A RLC A RR A RRC A
Rotates bits in the accumulator left Rotates bits in the accumulator left through carry Rotates bits in the accumulator right Rotates bits in the accumulator right through carry
1 1 1 1
1 1 1 1
Bit-oriented Instructions
Similar to logic instructions, bit-oriented instructions perform logic operations. The difference is that these are performed upon single bits.
BIT-ORIENTED INSTRUCTIONS
Mnemonic CLR C CLR bit SETB C SETB bit CPL C CPL bit ANL C,bit ANL C,/bit ORL C,bit ORL C,/bit MOV C,bit MOV bit,C
Description Clears the carry flag Clears the direct bit Sets the carry flag Sets the direct bit Complements the carry flag Complements the direct bit AND direct bit to the carry flag AND complements of direct bit to the carry flag OR direct bit to the carry flag OR complements of direct bit to the carry flag Moves the direct bit to the carry flag Moves the carry flag to the direct bit
Byte 1 2 1 2 1 2 2 2 2 2 2 2
Cycle 1 3 1 3 1 3 2 2 2 2 2 3
45
DEPARTMENT OF EEE,VAST
MINI PROJECT11
A - accumulator; Rn - is one of working registers (R0-R7) in the currently active RAM memory bank; Direct - is any 8-bit address register of RAM. It can be any general-purpose register or a SFR (I/O port, control register etc.); @Ri - is indirect internal or external RAM location addressed by register R0 or R1; #data - is an 8-bit constant included in instruction (0-255); #data16 - is a 16-bit constant included as bytes 2 and 3 in instruction (0-65535); addr16 - is a 16-bit address. May be anywhere within 64KB of program memory; addr11 - is an 11-bit address. May be within the same 2KB page of program memory as the first byte of the following instruction; rel - is the address of a close memory location (from -128 to +127 relative to the first byte of the following instruction). On the basis of it, assembler computes the value to add or subtract from the number currently stored in the program counter;
bit - is any bit-addressable I/O pin, control or status bit; and C - is carry flag of the status register (register PSW).
It is very important to keep a track of the working of almost all the automated and semi-automated devices, be it a washing machine, an autonomous robot or anything else. This is achieved by displaying their status on a small display module. LCD (Liquid Crystal Display) screen is such a display module and a 16x2 LCD module is very commonly used. These modules are replacing seven segments and other multi segment LEDs for these purposes. The reasons being: LCDs are economical, easily programmable, have no limitation of displaying special & even custom characters (unlike in seven segments), animations and so on. LCD can be easily interfaced with a microcontroller to display a message or status of a device.
46
DEPARTMENT OF EEE,VAST
MINI PROJECT11
This topic explains the basics of a 16x2 LCD and how it can be interfaced with AT89C51 to display a character. A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers.
1. Command/Instruction Register- stores the command instructions given to the LCD. A command is an instruction given to LCD to do a predefined task like initializing, clearing the screen, setting the cursor position, controlling display etc. 2. Data Register- stores the data to be displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD.
Hex Code 1 2 4 6 E 80
Command to LCD Instruction Register Clear screen display Return home Decrement cursor Increment cursor Display ON, Cursor ON Force the cursor to the beginning of the 1st line
47
DEPARTMENT OF EEE,VAST
MINI PROJECT11
C0 38
Force cursor to the beginning of the 2nd line Use 2 lines and 5x7 matrix The pin description of this module is given below. Pin configuration:
Description Ground Main power supply Power supply to control contrast Register Select 0V +5 V Contrast adjustment by providing a variable resistor through VCC RS=0 to select Command Register RS=1 to select Data Register
RS
R/W
Read/write
EN
Enable
A high to low pulse (minimum 450ns wide) is given when data is sent to data pins
DB0
To display letters
48
DEPARTMENT OF EEE,VAST
MINI PROJECT11
8 9 10 11 12 13 14 15 16
DB1 DB2 DB3 DB4 DB5 DB6 DB7 Led+ LedBacklight VCC Backlight Ground +5V 0V 8-bit data pins
1. Data pin8 (DB7) of the LCD is busy flag and is read when R/W = 1 & RS = 0. When busy flag=1, it means that LCD is not ready to accept data since it is busy with the internal operations. Therefore before passing any data to LCD, its command register should be read and busy flag should be checked. 2. To send data on the LCD, data is first written to the data pins with R/W = 0 (to specify the write operation) and RS = 1 (to select the data register). A high to low pulse is given at EN pin when data is sent. Each write operation is performed on the positive edge of the Enable signal.
49
DEPARTMENT OF EEE,VAST
MINI PROJECT11
3.
To send a command on the LCD, a particular command is first specified to the data pins with R/W = 0 (to specify the write operation) and RS = 0 (to select the command register). A high to low pulse is given at EN pin when data is sent.
Displaying single character A on LCD The LCD is interfaced with microcontroller (AT89C51). This microcontroller has 40 pins with four 8-bit ports (P0, P1, P2, and P3). Here P1 is used as output port which is connected to data pins of the LCD. The control pins (pin 4-6) are controlled by pins 2-4 of P0 port. Pin 3 is connected to a preset of 10k? to adjust the contrast on LCD screen. This program uses the above concepts of interfacing the LCD with controller by displaying the character A on it.
50
DEPARTMENT OF EEE,VAST
MINI PROJECT11
CIRCUIT DIAGRAM
51
DEPARTMENT OF EEE,VAST
MINI PROJECT11
52
DEPARTMENT OF EEE,VAST
MINI PROJECT11
WORKING
R3-R4 and P1-R1 are wired as a Wheatstone bridge in which R3-R4 generate a fixed two-thirds-supply "reference" voltage, P1-R1 generate a temperature-sensitive "variable" voltage, and Q1 is used as a bridge balance detector. P1 is adjusted so that the "reference" and "variable" voltages are equal at a temperature just below the required trigger value, and under this condition Q1 Base and Emitter are at equal voltages and Q1 is cut off. When the R1 temperature goes above this "balance" value the P1-R1 voltage falls below the "reference" value, so Q1 becomes forward biased, pulse-charging C1. This occurs because the whole circuit is supplied by a 100Hz half-wave voltage obtained from mains supply by means of D3-D6 Diode Bridge without a smoothing capacitor and fixed to 18V by R9 and Zener diode D1. Therefore the 18V supply of the circuit is not true DC but has a rather trapezoidal shape. C1 provides a variable phase-delay pulse-train related to temperature and synchronous with the mains supply "zero voltage" point of each half cycle, thus producing minimal switching RFI from the SCR. Q2 and Q3 form a trigger device, generating a short pulse suitable to drive the SCR.
53
DEPARTMENT OF EEE,VAST
MINI PROJECT11
COMPONENT DESCRIPTION
. SCR
A thyristor, also known as a SCR (silicon controlled rectifier), is a special type of diode with four layers of alternating N and P-type material. They act as bistable switches, conducting when their gate receives a current pulse, and continue to conduct for as long as they are forward biased (that is, as long as the voltage across the device has not reversed). The thyristor is a four-layer, three terminal semiconducting devices, with each layer consisting of alternately N-type or P-type material, for example P-N-P-N. The main terminals, labelled anode and cathode, are across the full four layers, and the control terminal, called the gate, is attached to p-type material near to the cathode. (A variant called an SCS Silicon Controlled Switchbrings all four layers out to terminals.) The operation of a thyristor can be understood in terms of a pair of tightly coupled bipolar junction transistors, arranged to cause the self-latching action.
54
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Thyristors have three states: 1. Reverse blocking mode Voltage is applied in the direction that would be blocked by a diode 2. Forward blocking mode Voltage is applied in the direction that would cause a diode to conduct, but the thyristor has not yet been triggered into conduction 3. Forward conducting mode The thyristor has been triggered into conduction and will remain conducting until the forward current drops below a threshold value known as the "holding current"
55
DEPARTMENT OF EEE,VAST
MINI PROJECT11
The thyristor has three p-n junctions (serially named J1, J2, J3 from the anode).When the anode is at a positive potential VAK with respect to the cathode with no voltage applied at the gate, junctions J1 and J3 are forward biased, while junction J2 is reverse biased. As J2 is reverse biased, no conduction takes place (Off state). Now if VAK is increased beyond the breakdown voltage VBO of the thyristor, avalanche breakdown of
. Fig .6 Layer diagram of thyristor
If a positive potential VG is applied at the gate terminal with respect to the cathode, the breakdown of the junction J2 occurs at a lower value of VAK. By selecting an appropriate value of VG, the thyristor can be switched into the on state suddenly. It should be noted that once avalanche breakdown has occurred, the thyristor continues to conduct, irrespective of the gate voltage, until both: (a) the potential VG is removed and (b) the current through the device (anodecathode) is less than the holding current specified by the manufacturer. Hence VG can be a voltage pulse, such as the voltage output from a UJT relaxation oscillator. These gate pulses are characterized in terms of gate trigger voltage (VGT) and gate trigger current (IGT). Gate trigger current varies inversely with gate pulse width in such a way that it is evident that there is a minimum gate charge required to trigger the thyristor.
56
DEPARTMENT OF EEE,VAST
MINI PROJECT11
In a conventional thyristor, once it has been switched on by the gate terminal, the device remains latched in the on-state (i.e. does not need a continuous supply of gate current to conduct), providing the anode current has exceeded the latching current (IL). As long as the anode remains positively biased, it cannot be switched off until the anode current falls below the holding current (IH).
A thyristor can be switched off if the external circuit causes the anode to become negatively biased. In some applications this is done by switching a second thyristor to discharge a capacitor into the cathode of the first thyristor. This method is called forced commutation.
57
DEPARTMENT OF EEE,VAST
MINI PROJECT11
SCR Phase Control In SCR Phase Control, the firing angle, or point during the half-cycle at which the SCR is triggered, determines the amount of current which flows through the device. It acts as a highspeed switch which is open for the first part of the cycle, and then closes to allow power flow after the trigger pulse is applied.
Figure above shows an AC waveform being applied with a gating pulse at 45 degrees. There are 360 electrical degrees in a cycle; 180 degrees in a half-cycle. The number of degrees from the beginning of the cycle until the SCR is gated ON is referred to as the firing angle, and the number of degrees that the SCR remains conducting is known as the conduction angle. The earlier in the cycle the SCR is gated ON, the greater will be the voltage applied to the load.
58
DEPARTMENT OF EEE,VAST
MINI PROJECT11
For applications with frequencies higher than the domestic AC mains supply (e.g. 50 Hz or 60 Hz), thyristors with lower values of tQ are required. Such fast thyristors are made by diffusing into the silicon heavy metals ions such as gold or platinum which act as charge combination centers. Alternatively, fast thyristors may be made by neutron irradiation of the silicon.
59
DEPARTMENT OF EEE,VAST
MINI PROJECT11
THERMISTOR
A thermistor is a type of resistor whose resistance varies with temperature. The word is a portmanteau of thermal and resistor. Thermistors are widely used as inrush current limiters, temperature sensors, self-resetting over current protectors, and self-regulating heating elements. The material used in a thermistor is generally a ceramic or polymer. The temperature responses of thermistor are typically achieve a higher precision within a limited temperature range [usually 90 C to 130 C].Assuming, as a first-order approximation, that the relationship between resistance and temperature is linear, then:
60
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Thermistors can be classified into two types, depending on the sign of k. If k is positive, the resistance increases with increasing temperature, and the device is called a positive temperature coefficient (PTC) thermistor, or posistor. If k is negative, the resistance decreases with increasing temperature, and the device is called a negative temperature coefficient (NTC) thermistor. Here we are using a thermistor with negative temperature coefficient Resistors that are not thermistors are designed to have a k as close to zero as possible(smallest possible k), so that their resistance remains nearly constant over a wide temperature range. Many NTC thermistors are made from a pressed disc or cast chip of
a semiconductor such as a sintered metal oxide. They work because raising the temperature of a semiconductor increases the number of electrons able to move about and carry charge - it promotes them into the conduction band. The more charge carriers that are available, the more current a material can conduct.
Most PTC thermistors are of the "switching" type, which means that their resistance rises suddenly at a certain critical temperature. The devices are made of doped
polycrystalline ceramic containing barium (BaTiO3) and other compounds. The dielectric constant of this ferroelectric material varies with temperature. Below the Curie point temperature, the high dielectric constant prevents the formation of potential barriers between the crystal grains, leading to a low resistance. In this region the device has a small negative temperature coefficient. At the Curie point temperature, the dielectric constant drops sufficiently to allow the formation of potential barriers at the grain boundaries, and the resistance increases sharply. At even higher temperatures, the material reverts to NTC behaviour.
61
DEPARTMENT OF EEE,VAST
MINI PROJECT11
Another type of PTC thermistor is the polymer PTC, which is sold under brand names such as "Polyswitch" "Semifuse", and "Multifuse". This consists of a slice of plastic with carbon grains embedded in it. When the plastic is cool, the carbon grains are all in contact with each other, forming a conductive path through the device. When the plastic heats up, it expands, forcing the carbon grains apart, and causing the resistance of the device to rise rapidly. This type of thermistors is used for switching, not for proportional temperature measurement.
Applications of Thermistor
PTC thermistors can be used as current-limiting devices for circuit protection, as replacements for fuses.
NTC thermistors are used as resistance thermometers in low-temperature measurements of the order of 10 K.
NTC thermistors can be used as inrush-current limiting devices in power supply circuits. They present a higher resistance initially which prevents large currents from flowing at turnon, and then heat up and become much lower resistance to allow higher current flow during normal operation.
NTC thermistors are regularly used in automotive applications. For example, they monitor things like coolant temperature and/or oil temperature inside the engine and provide data to the ECU and, indirectly, to the dashboard.
Thermistors are also commonly used in modern digital thermostats and to monitor the temperature of battery packs while charging.
62
DEPARTMENT OF EEE,VAST
MINI PROJECT11
ZENER DIODE
A Zener diode is a type of diode that permits current not only in the forward direction like a normal diode, but also in the reverse direction if the voltage is larger than the breakdown voltage known as "Zener knee voltage" or "Zener voltage". A Zener diode exhibits almost the same properties of the conventional solid-state diode, except the device is specially designed so as to have a greatly reduced breakdown voltage, the so-called Zener voltage. By contrast with the conventional device, a reverse-biased Zener diode will exhibit a controlled breakdown and allow the current to keep the voltage across the Zener diode at the Zener voltage. For example, a diode with a Zener breakdown voltage of 3.2 V will exhibit a voltage drop of 3.2 V if reverse bias voltage applied across it is more than its Zener voltage. The Zener diode is therefore ideal for applications such as the generation of a reference voltage (e.g. for an amplifier stage), or as a voltage stabilizer for low-current applications. Zener diodes are widely used as voltage references and as shunt regulators to regulate the voltage across small circuits. When connected in parallel with a variable voltage source so that it is reverse biased, a Zener diode conducts when the voltage reaches the diode's reverse
63
DEPARTMENT OF EEE,VAST
MINI PROJECT11
breakdown voltage. From that point on, the relatively low impedance of the diode keeps the voltage across the diode at that value.A load may be placed across the diode in the circuit, and as long as the Zener stays in reverse breakdown, the diode will provide a stable voltage source to the load. A Zener diode used in this way is known as a shunt voltage regulator (shunt, in this context, meaning connected in parallel, and voltage regulator being a class of circuit that produces a stable voltage across any load). In a sense, a portion of the current through the resistor is shunted through the Zener diode, and the rest is through the load. Thus the voltage that the load sees is controlled by causing some fraction of the current from the power source to bypass ithence the name, by analogy with locomotive switching points.
64
DEPARTMENT OF EEE,VAST
MINI PROJECT11
DIODE
A Diode is a two-terminal electronic component that conducts electric current in only one direction. The term usually refers to a semiconductor diode, the most common type today, which is a crystal of semiconductor connected to two electrical terminals. The most common function of a diode is to allow an electric current to flow through it in one direction (called the diode's forward direction) while blocking current in the opposite direction (the reverse direction). Thus, the diode can be thought of as an electronic version of a check valve. This unidirectional behavior is called rectification, and is used to convert alternating current to direct current, and extract modulation from radio signals in radio receivers. A modern semiconductor diode is made of a crystal of semiconductor like silicon that has impurities added to it to create a region on one side that contains negative charge carriers (electrons), called n-type semiconductor, and a region on the other side that contains positive charge carriers (holes), called p-type semiconductor. The diode's terminals are attached to each of these regions. The boundary within the crystal between these two regions, called a PN junction, is where the action of the diode takes place. The crystal conducts conventional current in a direction from the p-type side (called the anode) to the n-type side (called the cathode), but not in the opposite direction.
65
DEPARTMENT OF EEE,VAST
MINI PROJECT11
TRANSISTOR
NPN
PNP
A transistor is a semiconductor device used to amplify and switch electronic signals. It is made of a solid piece of semiconductor material, with at least three terminals for connection to an external circuit. A voltage or current applied to one pair of the transistor's terminals changes the current flowing through another pair of terminals. A Bipolar transistor has terminals labelled base, collector, and emitter. A small current at the base terminal (that is, flowing from the base to
66
DEPARTMENT OF EEE,VAST
MINI PROJECT11
the emitter) can control or switch a much larger current between the collector and emitter terminals. Here we are using two types of transistors PNP and NPN.
NPN
NPN is one of the two types of bipolar transistors, in which the letters "N" and "P" refer to the majority charge carriers inside the different regions of the transistor. Most bipolar transistors used today are NPN, because electron mobility is higher than hole mobility in semiconductors, allowing greater currents and faster operation. NPN transistors consist of a layer of P-doped semiconductor (the "base") between two Ndoped layers. A small current entering the base in common-emitter mode is amplified in the collector output. In other terms, an NPN transistor is "on" when its base is pulled high relative to the emitter. The arrow in the NPN transistor symbol is on the emitter leg and points in the direction of the conventional current flow when the device is in forward active mode.
PNP
The other type of BJT is the PNP with the letters "P" and "N" referring to the majority charge carriers inside the different regions of the transistor. PNP transistors consist of a layer of N-doped semiconductor between two layers of Pdoped material. A small current leaving the base in common-emitter mode is amplified in the collector output. In other terms, a PNP transistor is "on" when its base is pulled low relative to the emitter. The arrow in the PNP transistor symbol is on the emitter leg and points in the direction of the conventional current flow when the device is in forward active mode.
67
DEPARTMENT OF EEE,VAST
MINI PROJECT11
ADVANTAGES
Circuit is simpler in design. The use of voltage regulators in fans can be avoided. Power saving. Temperature variations can be easily tracked down. Less maintenance. Easily repairable. Since there is no complex circuitry setup involved. Low installation cost.
68
DEPARTMENT OF EEE,VAST
MINI PROJECT11
APPLICATIONS This circuit can be employed in places such as railway stations and such public places where people use to gather and they dont care about the working of these fans. In such places these circuits can be employed so the voltage regulators need not be operated manually. Installing these circuits in such places leads to power saving as the circuit automatically adjusts the fans speed. Another application of these circuit is that this can be used in houses which uses air conditioners for power saving.
69
DEPARTMENT OF EEE,VAST
MINI PROJECT11
RESULT
Automatic temperature controlled fan circuit was setup and connected to 230V mains supply and obtained the required output according to different temperature conditions. The circuit was found to be working as the temperature increased, speed of the fan increased and vice versa.
70
DEPARTMENT OF EEE,VAST
MINI PROJECT11
The circuit can be expanded by incorporating a passive infrared sensor along with the temperature sensor. The passive infrared sensor can include a fresnel lens for sensing a 360 circumference beneath the fan so that the fan can be turned on and off based on motion of persons approaching and leaving a selected area .
71
DEPARTMENT OF EEE,VAST
MINI PROJECT11
CONCLUSION
This circuit is found to be more reliable than a regulator circuit since this seems to be more efficient than conventional regulator circuits. Since power consumption can be minimised to a greater extent. Even though it is simple this has a significant role to play in the development of technology. Every small step is significant in the path of success. Our project though simple is significant in the current status of our country facing energy crisis.
72
DEPARTMENT OF EEE,VAST
MINI PROJECT11
REFERENCES
73
DEPARTMENT OF EEE,VAST
MINI PROJECT11
APPENDIX
74
DEPARTMENT OF EEE,VAST
MINI PROJECT11
DATA SHEET
75
DEPARTMENT OF EEE,VAST
MINI PROJECT11
76
DEPARTMENT OF EEE,VAST
MINI PROJECT11
77
DEPARTMENT OF EEE,VAST
MINI PROJECT11
78
DEPARTMENT OF EEE,VAST
MINI PROJECT11
79
DEPARTMENT OF EEE,VAST
MINI PROJECT11
80
DEPARTMENT OF EEE,VAST
MINI PROJECT11
81
DEPARTMENT OF EEE,VAST
MINI PROJECT11
82
DEPARTMENT OF EEE,VAST
MINI PROJECT11
83
DEPARTMENT OF EEE,VAST
MINI PROJECT11
84
DEPARTMENT OF EEE,VAST
MINI PROJECT11
85
DEPARTMENT OF EEE,VAST