Sei sulla pagina 1di 117

-Automatic power saver

CHAPTER:1

-1-

-Automatic power saver INTRODUCTION


This Project Automatic Room Light Controller with Visitor Counter using Microcontroller is a reliable circuit that takes over the task of controlling the room lights as well us counting number of persons/ visitors in the room very accurately. When somebody enters into the room then the counter is incremented by one and the light in the room will be switched ON and when any one leaves the room then the counter is decremented by one. The light will be only switched OFF until all the persons in the room go out. The total number of persons inside the room is also displayed on the seven segment displays. The microcontroller does the above job. It receives the signals from the sensors, and this signal is operated under the control of software which is stored in ROM. Microcontroller AT89C52 continuously monitor the Infrared Receivers, When any object pass through the IR Receiver's then the IR Rays falling on the receivers are obstructed , this obstruction is sensed by the Microcontroller 2

Visitor counting is simply a measurement of the visitor traffic entering and exiting offices, malls, sports venues, etc. Counting the visitors help to maximize the efficiency and effectiveness of employees, floor area and sales potential of an organization. Visitor counting is not limited to the entry/exit point of a company but has a wide range of applications that provide information to management on the volume and flow of people throughout a location. A primary method for counting the visitors involves hiring human auditors to stand and manually tally the number of visitors who pass by a certain location. But humanbased data collection comes a great expense. Here is a low-cost microcontroller-based visitor counter that can be used to know the number of person at a place. All the components required are readily available in the market and the circuit is easy to build. Two IR transmitter-receiver pairs are used at the passage: one pair comprising IR transmitter IR TX1 and receiver phototransistor T1 is installed at the entry point of the passage, while the other pair comprising IR transmitter IR TX2 and phototransistor T2 is installed at the exit of the passage. The IR signals from the IR LEDs should continuously fall on the respective phototransistors, so proper orientation of the transmitter and phototransistor is necessary. .

-2-

-Automatic power saver


3

CHAPTER: 2

-3-

-Automatic power saver


4

-4-

-Automatic power saver INTRODUCTION


This project is the most common and interesting to start with. The application is counting the number of persons entering in and exiting out like in Delhi Metro stations, Industries, offices, lift, car parking, and many more Our objective is to count the objects (persons) entering and exiting the room so we need some sensors to detect the objects and a control unit which calculates the object, below you can find the block diagram and circuit diagram which illustrate the solution and the Embedded C source code .
5

PRINCIPLE: From the block diagram it is clear that the sensor pairs are placed face to face so that an IR radiations from IR LED are continuously received by phototransistor which makes its emitter base junction forward and collector current Ic equals to emitter current Ie (i.e, Ic=Ie) assuming base current to be negligible. Hence the voltage at collector node becomes zero (logic 0) which is feed to microcontroller port pin P3.2 and P3.3, if any object is placed in between the sensor pair blocks the IR radiation which in turns put the phototransistor in cut-off mode and Ic!=Ie, this makes collector voltage to +5V (logic 1) In our program we have to poll both the inputs from both the sensors at port pin P3.2 and P3.3 to detect for the entry or exit, if sensor pair one is been obstructed (P3.2 becomes one) first, implies persons entry and second pair is obstructed (P3.3 becomes one) first shows exit. After obstructed any one sensor we have to poll for the next sensor to determine a complete entry or exit. CIRCUIT DESCRIPTION

Fig. 1: Transmitter-receiver set -up at the entrance-cum-exit of the passage

-5-

-Automatic power saver


Fig. 1 shows the transmitter-receiver set-up at the entrance-cum-exit of the passage along with block diagram. Two similar sections detect interruption of the IR beam and generate clock pulse for the microcontroller. The microcontroller controls counting and displays the number of persons present inside the hall. Fig. 2 shows the circuit of the microcontroller-based visitor counter, where in the transmitter and the receiver from the IR detection circuit. Control logic is built around transistors, operational amplifier LM324 (IC1) and flip-flop (IC2). When nobody is passing through the entry/exit point, the IR beam continuously falls on phototransistor T1. Phototransistor T1 conducts and the high voltage at its emitter drives transistor T3 into saturation, which makes pin 3 of comparator N1 low and finally output pin 1 of comparator N1 is high. Now if someone enters the place, first the IR beam from IR TX1 is interrupted and then the IR beam from IR TX2. When the beam from IR TX1 is interrupted, phototransistor T1 and transistor T3 cut-off and pin 3 of comparator N1 goes high. The low output (pin 1) of comparator N1 provides negative trigger pulse to pin 1 of J-K flip-flop IC2 (A). At this moment, the high input at J and K pins of flip-flop IC2 (A) toggles its output to low. On the other hand, the low input at J and K pins of IC2(B) due to clock pin 1 of IC2(A) and J input (pin 9) and K input (pin 12) of IC2(B) are connected to pin of comparator N1. The negative-going pulse is applied to clock pin 6 of IC2(B) when the person interrupts the IR beam from IR TX2. There is no change in the output of IC 2(B) flip-flop. This triggers the external interrupt INT0 (pin 12) of microcontroller AT89C52. The AT89C52 is an 8-bit microcontroller with 8 kB of flash-based program memory, 256 bytes of RAM, 32 input/output lines, three 16-bit timers/counters, on-chip oscillator and clock circuitry. A 12MHz crystal is used for providing clock. Ports 0, 1 and 2 are configured for 7segment displays. Port-0 pin is externally pulled up with 10-kilo-ohm resistor network RNW1 because port-0 is an 8-bit, open-drain, bi-directional, input/output (I/O) port. Port-1 and port-2 are 8-bit bi-directional I/O ports with internal pull-ups (no need of external pull-ups). Port pins 3.0 and 3.1 are configured to provide the set pulse to J-K flip-flops IC2(A) and IC2(B), respectively. External interrupts INT0 and INT1 receive the interrupt pulse when the person interrupts the IR beams. Resistor R9 and capacitor C5 provide power-on-reset pulse to the microcontroller. Switch S1 is used for manual reset. When the microcontroller is rest, the flip-flop are brought in set state through the microcontroller at software run time by making their set pin high for a moment. The value of the counter increments by 1 when the interrupt service routine for INT0 is executed. The output of the corresponding J-K flip-flop is set to high again by making its set
6

-6-

-Automatic power saver


input pin low through the microcontroller. The micro-controller is configured as a negative-edgetriggered interrupt sensor. Similarly, if somebody exits the place, first the IR beam from IR TX2 is interrupted and then the IR beam from IR TX1. When the beam from IR TX2 is interrupted, output pin 7 of comparator N2 goes low. This provides clock pulse to pin 6 of J-K flip-lop IC2 (B). At this moment, the high input at J and K pins of flip-flop IC2 (B) toggles its output to low. On the other hand, the low input at Jand Kpins of IC2 (A) due to clock pin 6 of IC2(B) and J input (pin4) and K input (pin16) of IC2(A) are connected to pin 7 of comparator N2. The negative-going pulse is applied to clock pin 1 of IC2(A) when the person interrupts the IR beam from IR TX1. There is no change in the output of IC2(A) flip-flop. This triggers the external interrupt INT1 (pin 13) of microcontroller AT89C52. The value of the counter decrements by 1 when interrupt service routine for INT1 is executed. The output of the corresponding J-K flip-flop is set to high again by making its set input pin low through the microcontroller.
7

Fig. 3: Power supply circuit

The circuit is powered by regulated 5V. Fig.3 shows the circuit of the power supply. The AC mains is stepped down by transformer X1 to deliver secondary output of 7.5V, 250mA, which is rectified by bridge rectifier BR1, filtered by capacitor C6 and regulated by IC 7805 (IC4). Capacitor C7 bypasses any ripple in the regulated output.

-7-

-Automatic power saver


8

PARTS LIST: Semiconductors:


IC1.......................................LM324 quad op-amp IC2.......................................74LS76 J-K flip-flop IC3.......................................AT89C52 Microcontroller IC4.......................................7805 5V regulator T1, T2..................................L14F1 npn Phototransistor T3, T4..................................2N3904 npn transistor IR TX1, IR TX2..................IR transmitting LED BR1.....................................1A bridge rectifier DISI-DIS3...........................LTS543 CC 7-segment display

Resistors (all -watt, 5% carbon): R1, R2...........................68-ohm R3, R4...........................6.8-kilo-ohm R5, R6...........................100-ohm R7, R8, R10, R11.........10-kilo-ohm R9.................................4.7-kilo-ohm R12-R32.......................220-ohm VR1, VR2.....................20-kilo-ohm resistor Network

Capacitors:
C1, C2.................................0.2F ceramic disk C3, C4.................................33PF ceramic disk C5........................................10F, 16V electrolytic C7........................................0.1F ceramic disk

Miscellaneous:
XTAL..............................................12MHz crystal X1....................................................230V primary to 7.5V, 250mA secondary transformer S1....................................................Push-to-on switch S2....................................................On /off switch
-8-

-Automatic power saver


9

-9-

-Automatic power saver


10

- 10 -

-Automatic power saver


11

CHAPTER: 3

WHAT IS EMBEDDED TECHNOLOGY


Embedded technology is software or hardware that is hidden embedded in the large device or system. It typically refers to a fixed function device as compared with a PC which runs general purpose application. Embedded technology is nothing new. It all around us and has been for year. An early example of embedded technology is a engine control unit in a car what setting to give the engine. Your coffee maker has embedded technology in the form of microcontroller,

- 11 -

-Automatic power saver


which is what tells it to make coffee at 6 a.m. the vending has it too. Overall billion of device 12 based on embedded technology. In the past embedded technology existed standalone device vending machine & copier that did their job with little regard for what went on around them. But as technology learned to connect devices to the internet and each other, embedded technology potential has grown. Cell phone companies figured that out along time ago, which is why cell phone are cheap and service plan are expensive. It is not the phone itself that matter, but the connectivity of the vast network of other phone, other people and internet. Until you download software that lets you find a local restaurant and manage your finances. Let say you make a freezer the big, expensive kind that grocery stores buy. You sell me and you are with that customer, when it brakes the customer calls the service person who probably comes from somewhere other than your company. But let us say that freezer knows that it is about to go on fritz. Let say three refrigerator alert the customer before it break. Better yet, let us say the freezer alert the manufacture and are able to send a service person to do preventive work and save a lot of hazardous from melting. Embedded technology allows all of that to happen. You, the freezer company have transformed yourself from Product Company and Service Company.

- 12 -

-Automatic power saver


13

Fig no. 2.1 embedded system

The possibility to go beyond that programming device to communication with business can eliminate the need for costly call centre. Copy machine that can order that replacement cartridge will save time and money. Remember, the fact the technology is not what important, and nighters is the device.

Applications: Telecom:
Mobile phone system (handset and base station), modems and routers.

Automotive application:
Braking system, tracking control, Airbag release system, management unit and Steerby- wire systems .

Domestic application:

- 13 -

-Automatic power saver


Dishwasher, television, washing machine, microwave oven, video recorder, security system, garage door controller, calculator, digital watches, VCRs, digital cameras, 14 remote control, treat mills.

Robotic:
Fire fighting robot, automatic floor cleaner, robotic arm .

Aerospace application:
Flight control systems, Engine controllers, autopilots, passenger entertainment systems .

Medical equipment:
Anesthesia monitoring systems, ECG monitor, pacemaker, drug delivery systems.

Defense system:
Radar systems, fighter aircraft flight controller systems, Radio systems, missile guideline systems .

Office automation:
Laser printers, Fax machines, Pagers, Cash registers, gas pumps, Credit/Davit card readers, Thermostats, Grain analyzers.

Programming Languages Used in New Embedded Designs:


90.0% 80.0% 70.0% 60.0% 50.0% 40.0% 30.0% 20.0% 10.0%

1998-1999 1999-2000

- 14 0.0% Assembly C C++ Java Other

-Automatic power saver


Fig no. 2.2

15

Micro Controllers Trend in the Embedded Systems

- 15 -

-Automatic power saver


Fig no. 2.3

16

CHAPTER: 3

AT89C52 MICROCONTROLLER

- 16 -

-Automatic power saver


17

AT89C52 (8-bit Microcontroller with 8K Bytes Flash) Features: Compatible with MCS-51 Products
8K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz Three-level Program Memory Lock 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Programmable Serial Channel

- 17 -

-Automatic power saver


Low-power Idle and Power-down Modes
18

Description:
The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 and 80C52 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications.

- 18 -

-Automatic power saver


19

- 19 -

-Automatic power saver


The AT89C52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, three 16-bit timer/counters, a six-vector two-level interrupt architecture, full- 20 duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89C52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next hardware reset.

Pin Description:
VCC Supply voltage. GND Ground.

Port 0
Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0 can also be configured to be the multiplexed low order address/data bus during accesses to external program and data memory. In this mode, P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pull-ups are required during program verification.

Port 1
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups.

- 20 -

-Automatic power saver


In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the following table. 21

Port 1 also receives the low-order address bytes during Flash programming and verification.

Port 2
Port 2 is an 8-bit bi-directional I/O port with internal pullups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pullups when emitting 1s. During accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register.
Port 2 also receives the high-order address bits and some control signals during Flash programming and verification.

Port 3
Port 3 is an 8-bit bi-directional I/O port with internal pullups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pullups. Port 3 also serves the functions of various special features of the AT89C51, as shown in the following table.

- 21 -

-Automatic power saver


22

Port 3 also receives some control signals for Flash programming and verification.

RST:
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.

ALE/PROG:
Address Latch Enable is an output pulse for latching the low byte of the address during accesses to external memory.
This pin is also the program pulse input (PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external data memory.

If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.

PSEN:
Program Store Enable is the read strobe to external program memory. When the AT89C52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.

- 22 -

-Automatic power saver EA/VPP:


External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming when 12-volt programming is selected.
23

XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2
Output from the inverting oscillator amplifier.

- 23 -

-Automatic power saver Special Function Registers:


24

A map of the on-chip memory area called the Special Function Register (SFR) space is shown in Table 1. Note that not all of the addresses are occupied, and unoccupied addresses may not be implemented on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect. User software should not write 1s to these unlisted locations, since they may be used in future products to invoke new features. In that case, the reset or inactive values of the new bits will always be 0. Timer 2 Registers Control and status bits are contained in registers T2CON (shown in Table 2) and T2MOD (shown in Table 4) for Timer 2. The register pair (RCAP2H, RCAP2L) is the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode. Interrupt registers the individual interrupt enable bits are in the IE register. Two priorities can be set for each of the six interrupt sources in the IP register.

- 24 -

-Automatic power saver


25

- 25 -

-Automatic power saver Data Memory:


The AT89C52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a parallel address space to the special Function Registers. That means the upper 128 bytes have the same addresses as the SFR space but are physically separate from SFR space. When an instruction accesses an internal location above address 7FH, the address mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR space. Instructions that use direct addressing access SFR space. For example, the following direct addressing instruction accesses the SFR at location 0A0H (which is P2).
26

MOV 0A0H, #data


Instructions that use indirect addressing access the upper 128 bytes of RAM. For example, the following indirect addressing instruction, where R0 contains 0A0H, accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H).

MOV @R0, #data


Note that stack operations are examples of indirect addressing, so the upper 128 bytes of data RAM are available as stack space.

Timer 0 and 1
Timer 0 and Timer 1 in the AT89C52 operate the same way as Timer 0 and Timer 1 in the AT89C51.

Timer 2
Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter. The type of operation is selected by bit C/T2 in the SFR T2CON (shown in Table 2). Timer 2 has three operating modes: capture, auto-reload (up or down counting), and baud rate generator. The modes are selected by bits in T2CON, as shown in Table 3. Timer 2 consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency.

- 26 -

-Automatic power saver


27

In the Counter function, the register is incremented in response to a 1-to-0 transition at its corresponding external input pin, T2. In this function, the external input is sampled during S5P2 of every machine cycle. When the samples show a high in one cycle and a low in the next cycle, the count is incremented. The new count value appears in the register during S3P1 of the Cycle following the one in which the transition was detected. Since two machine cycles (24 oscillator periods) are required to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. To ensure that a given level is sampled at least once before it changes, the level should be held for at least one full machine cycle.

Capture Mode:
In the capture mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0, Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in T2CON. This bit can then be used to generate an interrupt. If EXEN2 = 1, Timer 2 performs the same operation, but a 1- to-0 transition at external input T2EX also causes the current value in TH2 and TL2 to be captured into RCAP2H and RCAP2L, respectively. In addition, the transition at T2EX causes bit EXF2 in T2CON to be set. The EXF2 bit, like TF2, can generate an interrupt. The capture mode is illustrated in Figure 1.

Auto-reload (Up or Down Counter):


Timer 2 can be programmed to count up or down when configured in its 16-bit autoreload mode. This feature is invoked by the DCEN (Down Counter Enable) bit located in the SFR T2MOD (see Table 4). Upon reset, the DCEN bit is set to 0 so that timer 2 will default to count up. When DCEN is set, Timer 2 can count up or down, depending on the value of the T2EX pin.

- 27 -

-Automatic power saver


28

Figure 2 shows Timer 2 automatically counting up when DCEN = 0. In this mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0, Timer 2 counts up to 0FFFFH and then sets the TF2 bit upon overflow. The overflow also causes the timer registers to be reloaded with the 16-bit value in RCAP2H and RCAP2L. The values in Timer in Capture ModeRCAP2H and RCAP2L are preset by software. If EXEN2 = 1, a 16-bit reload can be triggered either by an overflow or by a 1-to-0 transition at external input T2EX. This transition also sets the EXF2 bit. Both the TF2 and EXF2 bits can generate an interrupt if enabled. Setting the DCEN bit enables Timer 2 to count up or down, as shown in Figure 3. In this mode, the T2EX pin controls the direction of the count. A logic 1 at T2EX makes Timer 2 count up. The timer will overflow at 0FFFFH and set the TF2 bit. This overflow also causes the 16-bit value in RCAP2H and RCAP2L to be reloaded into the timer registers, TH2 and TL2, respectively. Logic 0 at T2EX makes Timer 2 count down. The timer underflows when TH2 and TL2 equal the values stored in RCAP2H and RCAP2L. The underflow sets the TF2 bit and causes 0FFFFH to be reloaded into the timer registers. The EXF2 bit toggles whenever Timer 2 overflows or underflows and can be used as a 17th bit of resolution. In this operating mode, EXF2 does not flag an interrupt.

- 28 -

-Automatic power saver


29

- 29 -

-Automatic power saver Baud Rate Generator


Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK in T2CON (Table 2). Note that the baud rates for transmit and receive can be different if Timer 2 is used for the receiver or transmitter and Timer 1 is used for the other function. Setting RCLK and/or TCLK puts Timer 2 into its baud rate generator mode, as shown in Figure 4. The baud rate generator mode is similar to the auto-reload mode, in that a rollover in TH2 causes the Timer 2 registers to be reloaded with the 16-bit value in registers RCAP2H and RCAP2L, which are preset by software. The baud rates in Modes 1 and 3 are determined by Timer 2s overflow rate according to the following equation.
30

The Timer can be configured for either timer or counter operation. In most applications, it is configured for timer operation (CP/T2 = 0). The timer operation is different for Timer 2 when it is used as a baud rate generator. Normally, as a timer, it increments every machine cycle (at 1/12 the oscillator frequency). As a baud rate generator, however, it increments every state time (at 1/2 the oscillator frequency). The baud rate formula is given below.

Where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2L taken as a 16-bit unsigned integer. Timer 2 as a baud rate generator is shown in Figure 4. This figure is valid only if RCLK or TCLK = 1 in T2CON. Note that a rollover in TH2 does not set TF2 and will not generate an interrupt. Note too, that if EXEN2 is set, a 1-to-0 transition in T2EX will set EXF2 but will not cause a reload from (RCAP2H, RCAP2L) to (TH2, TL2). Thus when Timer 2 is in use as a baud rate generator, T2EX can be used as an extra external interrupt.

- 30 -

-Automatic power saver


Note that when Timer 2 is running (TR2 = 1) as a timer in the baud rate generator mode, TH2 or TL2 should not be read from or written to. Under these conditions, the Timer is 31 incremented every state time, and the results of a read or write may not be accurate. The RCAP2 registers may be read but should not be written to, because a write might overlap a reload and cause write and/or reload errors. The timer should be turned off (clear TR2) before accessing the Timer 2 or RCAP2 registers.

Programmable Clock Out:


A 50% duty cycle clock can be programmed to come out on P1.0, as shown in Figure 5. This pin, besides being a regular I/O pin, has two alternate functions. It can be programmed to input the external clock for Timer/Counter 2 or to output a 50% duty cycle clock ranging from 61 Hz to 4 MHz at a 16 MHz operating frequency. To configure the Timer/Counter 2 as a clock generator, bit C/T2 (T2CON.1) must be cleared and bit T2OE (T2MOD.1) must be set. Bit TR2 (T2CON.2) starts and stops the timer.

- 31 -

-Automatic power saver


The clock-out frequency depends on the oscillator frequency and the reload value of 32 Timer 2 capture registers (RCAP2H, RCAP2L), as shown in the following equation.

In the clock-out mode, Timer 2 roll-overs will not generate an interrupt. This behavior is similar to when Timer 2 is used as a baud-rate generator. It is possible to use Timer 2 as a baudrate generator and a clock generator simultaneously. Note, however, that the baud-rate and clockout frequencies cannot be determined independently from one another since they both use RCAP2H and RCAP2L.

UART
The UART in the AT89C52 operates the same way as the UART in the AT89C51.

Interrupts
The AT89C52 has a total of six interrupt vectors: two external interrupts (INT0 and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These interrupts are all shown in Figure 6. Each of these interrupt sources can be individually enabled or disabled by setting or clearing a bit in Special Function Register IE. IE also contains a global disable bit, EA, which disables all interrupts at once. Note that Table shows that bit position IE.6 is unimplemented. In the AT89C51, bit position IE.5 is also unimplemented. User software should not write 1s to these bit positions, since they may be used in future AT89 products. Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register T2CON. Neither of these flags is cleared by hardware when the service routine is vectored to. In fact, the service routine may have to determine whether it was TF2 or EXF2 that generated the interrupt, and that bit will have to be cleared in software. The Timer 0 and Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in which the timers overflow. The values are then polled by the circuitry in the next cycle. However, the Timer 2 flag, TF2, is set at S2P2 and is polled in the same cycle in which the timer overflows.

- 32 -

-Automatic power saver


33

Oscillator Characteristics:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can be configured for use as an on-chip oscillator, as shown in Figure 7. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven, as shown in Figure 8. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.

Idle Mode
In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset.

Note that when idle mode is terminated by a hardware reset, the device normally resumes program execution from where it left off, up to two machine cycles before the internal reset
- 33 -

-Automatic power saver


algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but 34 access to the port Pins are not inhibited. To eliminate the possibility of an unexpected write to a port pin when idle mode is terminated by a reset, the instruction following the one that invokes idle mode should not write to a port pin or to external memory.

Power-down Mode
In the power-down mode, the oscillator is stopped, and the instruction that invokes power-down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the power-down mode is terminated. The only exit from power-down is a hardware reset. Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize.

- 34 -

-Automatic power saver Program Memory Lock Bits:


The AT89C52 has three lock bits that can be left unprogrammed (U) or can be programmed (P) to obtain the additional features listed in the following table.
35

When lock bit 1 is programmed, the logic level at the EA pin is sampled and latched during reset. If the device is powered up without a reset, the latch initializes to a random value and holds that value until reset is activated. The latched value of EA must agree with the current logic level at that pin in order for the device to function properly.

Programming the Flash:


The AT89C52 is normally shipped with the on-chip Flash memory array in the erased state (that is, contents = FFH) and ready to be programmed. The programming interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The Low-voltage programming mode provides a convenient way to program the AT89C52 inside the users system, while the high-voltage programming mode is compatible with conventional third-party

Flash or EPROM programmers.


The AT89C52 is shipped with either the high-voltage or low-voltage programming mode enabled. The respective top-side marking and device signature codes are listed in the following table. The AT89C52 code memory array is programmed byte-bybyte in either programming mode. To program any nonblank byte in the on-chip Flash Memory, the entire memory must be erased using the Chip Erase Mode.

- 35 -

-Automatic power saver


36

Programming Algorithm Before programming the T89C52, the address, data and control

signals should be set up according to the Flash programming mode table and Figure 9 and Figure 10. To program the AT89C52, take the following steps.

1. Input the desired memory location on the address lines.


2. Input the appropriate data byte on the data lines. 3. Activate the correct combination of control signals. 4. Raise EA/VPP to 12V for the high-voltage programming mode. 5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write cycle is self-timed and typically takes no more than 1.5 ms. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached. Data Polling The AT89C52 features Data Polling to indicate the end of a write cycle. During a write cycle, an attempted read of the last byte written will result in the complement of the written data on PO.7. Once the write cycle has been completed, true data is valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated. Ready/Busy The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during Programming to indicate BUSY. P3.4 is pulled high again when programming is done to indicate READY.

Program Verify If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read back via the address and data lines for verification. The lock bits cannot be verified directly. Verification of the lock bits is achieved by observing that their features are enabled.
- 36 -

-Automatic power saver


Chip Erase the entire Flash array is erased electrically by using the proper combination of control signals and by holding ALE/PROG low for 10 ms. The code array is written with all 1s. 37 The chip erase operation must be executed before the code memory can be reprogrammed. Reading the Signature Bytes The signature bytes are read by the same procedure as a normal verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned are as follows. (030H) = 1EH indicates manufactured by Atmel (031H) = 52H indicates 89C52 (032H) = FFH indicates 12V programming (032H) = 05H indicates 5V programming

Programming Interface:
Every code byte in the Flash array can be written, and the entire array can be erased, by using the appropriate combination of control signals. The write operation cycle is self timed and once initiated, will automatically time itself to completion. All major programming vendors offer worldwide support for the Atmel microcontroller series. Please contact your local programming vendor for the appropriate software revision.

- 37 -

-Automatic power saver


38

- 38 -

-Automatic power saver


39

CHAPTER: 4

What are crystal oscillators?

- 39 -

-Automatic power saver


Crystal oscillators are oscillators where the primary frequency determining element is a quartz crystal. Because of the inherent characteristics of the quartz crystal the crystal oscillator 40 may be held to extreme accuracy of frequency stability. Temperature compensation may be applied to crystal oscillators to improve thermal stability of the crystal oscillator. Crystal oscillators are usually, fixed frequency oscillators where stability and accuracy are the primary considerations. For example it is almost impossible to design a stable and accurate LC oscillator for the upper HF and higher frequencies without resorting to some sort of crystal control. Hence the reason for crystal oscillators. The frequency of older FT-243 crystals can be moved upward by crystal grinding. I won't be discussing frequency synthesizers and direct digital synthesis (DDS) here. They are particularly interesting topics to be covered later.

A practical example of a Crystal Oscillator:


This is a typical example of the type of crystal oscillators which may be used for say converters. Some points of interest on crystal oscillators in relation to figure 1.

Figure 1 - schematic of a crystal oscillator

The transistor could be a general purpose type with an Ft of at least 150 MHz for HF use. A typical example would be a 2N2222A. The turns ratio on the tuned circuit depicts an anticipated nominal load of 50 ohms. This allows theoretical 2K5 ohms on the collector. If it is followed by a buffer amplifier (highly recommended) I would simply maintain the typical 7:1 turns ratio. I have included a formula for determining L and C in the tuned circuits of crystal oscillators in case you have forgotten earlier tutorials. Personally I would make L a reactance of around 250 ohms. In this case I'd make C a smaller trimmer in parallel with a standard fixed value.

- 40 -

-Automatic power saver


41

CHAPTER: 5

SEVEN SEGMENT DISPLAY

- 41 -

-Automatic power saver SEVEN SEGMENT DISPLAY:


A popular type consists of seven small, bar-shaped LED segment arranged so that depending on which combinations are energized, the numbers 0 to 9 light up. All the LED cathodes (or sometimes anodes) are joined to form a common connection. Current limiting resistors are required (e.g. 270 ohms), preferably one per segment.
42

- 42 -

-Automatic power saver Common cathode method of connecting an array of display elements.
43

Anode Connection

Common Cathode

The main requirements for a suitable LED material are:-

1) 2) 3)

It must have on energy gap of appropriate width. Both P and N types must exist, preferably with low sensitivities. Efficient radioactive pathways must be present. Generally, energy gaps greater than or equal to about 2 are required.

Commercial LED materials:


Gallium arsenide (Ga As) doped with Si Gallium Phosphide (GaP) doped with N & Bi Gallium arsenide Phosphide (Ga As1-x Px) Gallium aluminum arsenide (Gax Al1-x As)
- 43 -

-Automatic power saver LED CONSTRUCTIONS: To reduce reflection losses in LEDs there are two obvious ways: a) b) The first is to ensure that most rays strike the surface at less than the critical angle. This may be achieved by shaping the semiconductor /air interface into a hemisphere. The second technique is to encapsulate the junction in a transparent medium of high refractive index. This is usually a plastic material with refractive index of about 1.5. Molding the plastic into an approximately hemispherical shape can minimize the losses at the plastic lair interface.
44

- 44 -

-Automatic power saver


45

CHAPTER: 6

- 45 -

-Automatic power saver RELAY


Relay is a common, simple application of electromagnetism. It uses an electromagnet made from an iron rod wound with hundreds of fine copper wire. When electricity is applied to the wire, the rod becomes magnetic. A movable contact arm above the rod is then pulled toward the rod until it closes a switch contact. When the electricity is removed, a small spring pulls the contract arm away from the rod until it closes a second switch contact. By means of relay, a current circuit can be broken or closed in one circuit as a result of a current in another circuit. Relays can have several poles and contacts. The types of contacts could be normally open and normally closed. One closure of the relay can turn on the same normally open contacts; can turn off the other normally closed contacts. Relay requires a current through their coils, for which a voltage is applied. This voltage for a relay can be D.C. low voltages upto 24V or could be 240V a.c.
46

A relay is an electrical switch that opens and closes under control of another electrical circuit. In the original form, the switch is operated by an electromagnet to open or close one or many sets of contacts. It was invented by Joseph Henry in 1835. Because a relay is able to control an output circuit of higher power than the input circuit, it can be considered, in a broad sense, to be a form of electrical amplifier. These contacts can be either Normally Open (NO), Normally Closed (NC), or change-over contacts.

Normally-open contacts connect the circuit when the relay is activated; the circuit is disconnected when the relay is inactive. It is also called Form A contact or "make" contact. Form A contact is ideal for applications that require to switch a high-current power source from a remote device.

- 46 -

-Automatic power saver

Normally-closed contacts disconnect the circuit when the relay is activated; the circuit is connected when the relay is inactive. It is also called Form B contact or "break" contact. 47 Form B contact is ideal for applications that require the circuit to remain closed until the relay is activated. Change-over contacts control two circuits: one normally-open contact and one normallyclosed contact with a common terminal. It is also called Form C contact.

Operation:
When a current flows through the coil, the resulting magnetic field attracts an armature that is mechanically linked to a moving contact. The movement either makes or breaks a connection with a fixed contact. When the current to the coil is switched off, the armature is returned by a force that is half as strong as the magnetic force to its relaxed position. Usually this is a spring, but gravity is also used commonly in industrial motor starters. Relays are manufactured to operate quickly. In a low voltage application, this is to reduce noise. In a high voltage or high current application, this is to reduce arcing. If the coil is energized with DC, a diode is frequently installed across the coil, to dissipate the energy from the collapsing magnetic field at deactivation, which would otherwise generate a spike of voltage and might cause damage to circuit components. If the coil is designed to be energized with AC, a small copper ring can be crimped to the end of the solenoid. This "shading ring" creates a small out-of-phase current, which increases the minimum pull on the armature during the AC cycle. By analogy with the functions of the original electromagnetic device, a solid-state relay is made with a thyristor or other solid-state switching device. To achieve electrical isolation, a light-emitting diode (LED) is used with a photo transistor.

Relays are used:


to control a high-voltage circuit with a low-voltage signal, as in some types of modems, to control a high-current circuit with a low-current signal, as in the starter solenoid of an automobile, to detect and isolate faults on transmission and distribution lines by opening and closing circuit breakers (protection relays), to isolate the controlling circuit from the controlled circuit when the two are at different potentials, for example when controlling a mains-powered device from a low-voltage switch. The latter is often applied to control office lighting as the low voltage wires are easily installed in partitions, which may be often moved as needs change. They may also be controlled by room occupancy detectors in an effort to conserve energy, to perform logic functions. For example, the boolean AND function is realised by connecting NO relay contacts in series, the OR function by connecting NO contacts in parallel. The change-over or Form C contacts perform the XOR (exclusive or) function.
- 47 -

-Automatic power saver


Similar functions for NAND and NOR are accomplished using NC contacts. Due to the failure modes of a relay compared with a semiconductor, they are widely used in safety 48 critical logic, such as the control panels of radioactive waste handling machinery.

to perform time delay functions. Relays can be modified to delay opening or delay closing a set of contacts. A very short (a fraction of a second) delay would use a copper disk between the armature and moving blade assembly. Current flowing in the disk maintains magnetic field for a short time, lengthening release time. For a slightly longer (up to a minute) delay, a dashpot is used. A dashpot is a piston filled with fluid that is allowed to escape slowly. The time period can be varied by increasing or decreasing the flow rate. For longer time periods, a mechanical clockwork timer is installed.

- 48 -

-Automatic power saver


49

- 49 -

-Automatic power saver


CIRCUIT DIAGRAM

50

CIRCUIT DESCRIPTION:
The circuit is simple NPN transistor common emitter switching circuit. The transistor T-1 is supplied through negative at emitter. The base is conducted through the port output from computer and collector gives output to energies the relay commonly connected to +ve supply. The diode prevents back emf produced by relay while working.

- 50 -

-Automatic power saver


51

CHAPTER: 7
- 51 -

-Automatic power saver


52

POWER SUPPLY:
In flow in one direction only. When the anode of the diode is positive with respect to its cathode, it is forward biased, allowing current to flow. But when its anode is negative with alternating current the electron flow is alternate, i.e. the electron flow increases to maximum in one direction, decreases back to zero. It then increases in the other direction and then decreases to zero again. Direct current flows in one direction only. Rectifier converts alternating current to respect to the cathode, it is reverse biased and does not allow current to flow. This unidirectional property of the diode is useful for rectification. A single diode arranged back-to-back might allow the electrons to flow during positive half cycles only and suppress the negative half cycles. Double diodes arranged back-to-back might act as full wave rectifiers as they may allow the electron flow during both positive and negative half cycles. Four diodes can be arranged to make a full wave bridge rectifier. Different types of filter circuits are used to smooth out the pulsations in amplitude of the output voltage from a rectifier. The property of capacitor to oppose any

- 52 -

-Automatic power saver


change in the voltage applied across them by storing energy in the electric field of the capacitor and of inductors to oppose any change in the current flowing through them by storing energy in 53 the magnetic field of coil may be utilized. To remove pulsation of the direct current obtained from the rectifier, different types of combination of capacitor, inductors and resistors may be also be used to increase to action of filtering.

NEED OF POWER SUPPLY:


Perhaps all of you are aware that a power supply is a primary requirement for the Test Bench of a home experimenters mini lab. A battery eliminator can eliminate or replace the batteries of solid-state electronic equipment and the equipment thus can be operated by 230v A.C. mains instead of the batteries or dry cells. Nowadays, the use of commercial battery eliminator or power supply unit has become increasingly popular as power source for household appliances like Tran receivers, record player, cassette players, digital clock etc.

THEORY
USE OF DIODES IN RECTIFIERS: Electric energy is available in homes and industries in India, in the form of alternating voltage. The supply has a voltage of 220V (rms) at a frequency of 50 Hz. In the USA, it is 110V at 60 Hz. For the operation of most of the devices in electronic equipment, a dc voltage is needed. For instance, a transistor radio requires a dc supply for its operation. Usually, this supply is provided by dry cells. But sometime we use a battery eliminator in place of dry cells. The battery eliminator converts the ac voltage into dc voltage and thus eliminates the need for dry cells. Nowadays, almost all-electronic equipment includes a circuit that converts ac voltage of mains supply into dc voltage. This part of the equipment is called Power Supply. In general, at the input of the power supply, there is a power transformer. It is followed by a diode circuit called Rectifier. The output of the rectifier goes to a smoothing filter, and then to a voltage regulator circuit. The rectifier circuit is the heart of a power supply.

Rectification:
Rectification is a process of rendering an alternating current or voltage into a unidirectional one. The component used for rectification is called Rectifier. A rectifier permits current to flow only during the positive half cycles of the applied AC voltage by eliminating the negative half cycles or alternations of the applied AC voltage. Thus pulsating DC is obtained. To obtain smooth DC power, additional filter circuits are required. A diode can be used as rectifier. There are various types of diodes. But, semiconductor diodes are very popularly used as rectifiers. A semiconductor diode is a solid-state device consisting of two elements is being an electron emitter or cathode, the other an electron collector or anode. Since electrons in a semiconductor diode can flow in one direction only-from emitter
- 53 -

-Automatic power saver


to collector- the diode provides the unilateral conduction necessary for rectification. Out of the 54 semiconductor diodes, copper oxide and selenium rectifier are also commonly used.

FULL WAVE RECTIFIER:


It is possible to rectify both alternations of the input voltage by using two diodes in the circuit arrangement. Assume 6.3 V rms (18 V p-p) is applied to the circuit. Assume further that two equal-valued series-connected resistors R are placed in parallel with the ac source. The 18 V p-p appears across the two resistors connected between points AC and CB, and point C is the electrical midpoint between A and B. Hence 9 V p-p appears across each resistor. At any moment during a cycle of vin, if point A is positive relative to C, point B is negative relative to C. When A is negative to C, point B is positive relative to C. The effective voltage in proper time phase which each diode "sees" is in Fig. The voltage applied to the anode of each diode is equal but opposite in polarity at any given instant. When A is positive relative to C, the anode of D1 is positive with respect to its cathode. Hence D1 will conduct but D2 will not. During the second alternation, B is positive relative to C. The anode of D2 is therefore positive with respect to its cathode and D 2 conducts while D1 is cut off. There is conduction then by either D1 or D2 during the entire input-voltage cycle. Since the two diodes have a common-cathode load resistor R L, the output voltage across RL will result from the alternate conduction of D 1 and D2. The output waveform vout across RL, therefore has no gaps as in the case of the half-wave rectifier.

The output of a full-wave rectifier is also pulsating direct current. In the diagram, the two equal resistors R across the input voltage are necessary to provide a voltage midpoint C for circuit connection and zero reference. Note that the load resistor RL is connected from the cathodes to this center reference point C. An interesting fact about the output waveform vout is that its peak amplitude is not 9 V as in the case of the half-wave rectifier using the same power source, but is less than 4 V. The reason, of course, is that the peak positive voltage of A relative to C is 4 V, not 9 V, and part of the 4 V is lost across R. Though the full wave rectifier fills in the conduction gaps, it delivers less than half the peak output voltage that results from half-wave rectification.

BRIDGE RECTIFIER:

- 54 -

-Automatic power saver


A more widely used full-wave rectifier circuit is the bridge rectifier. It requires four diodes instead of two, but avoids the need for a centre-tapped transformer. During the positive 55 half-cycle of the secondary voltage, diodes D2 and D4 are conducting and diodes D1 and D3 are non-conducting. Therefore, current flows through the secondary winding, diode D2, load resistor RL and diode D4. During negative half-cycles of the secondary voltage, diodes D1 and D3 conduct, and the diodes D2 and D4 do not conduct. The current therefore flows through the secondary winding, diode D1, load resistor RL and diode D3. In both cases, the current passes through the load resistor in the same direction. Therefore, a fluctuating, unidirectional voltage is developed across the load.

Filtration:
The rectifier circuits we have discussed above deliver an output voltage that always has the same polarity: but however, this output is not suitable as DC power supply for solid-state circuits. This is due to the pulsation or ripples of the output voltage. This should be removed out before the output voltage can be supplied to any circuit. This smoothing is done by incorporating filter networks. The filter network consists of inductors and capacitors. The inductors or choke coils are generally connected in series with the rectifier output and the load. The inductors oppose any change in the magnitude of a current flowing through them by storing up energy in a magnetic field. An inductor offers very low resistance for DC whereas; it offers very high resistance to AC. Thus, a series connected choke coil in a rectifier circuit helps to reduce the pulsations or ripples to a great extent in the output voltage. The fitter capacitors are usually connected in parallel with the rectifier output and the load. As, AC can pass through a capacitor but DC cannot, the ripples are thus limited and the output becomes smoothed. When the voltage across its plates tends to rise, it stores up energy back into voltage and current. Thus, the fluctuations in the output voltage are reduced considerable. Filter network circuits may be of two types in general:

CHOKE INPUT FILTER:


If a choke coil or an inductor is used as the first- components in the filter network, the filter is called choke input filter. The D.C. along with AC pulsation from the rectifier circuit at first passes through the choke (L). It opposes the AC pulsations but allows the DC to pass through it freely. Thus AC pulsations are largely reduced. The further ripples are by passed through the parallel capacitor C. But, however, a little nipple remains unaffected, which are considered negligible. This little ripple may be reduced by incorporating a series a choke input filters.

CAPACITOR INPUT FILTER:

- 55 -

-Automatic power saver


If a capacitor is placed before the inductors of a choke-input filter network, the filter is called capacitor input filter. The D.C. along with AC ripples from the rectifier circuit starts 56 charging the capacitor C. to about peak value. The AC ripples are then diminished slightly. Now the capacitor C, discharges through the inductor or choke coil, which opposes the AC ripples, except the DC. The second capacitor C by passes the further AC ripples. A small ripple is still present in the output of DC, which may be reduced by adding additional filter network in series.

CIRCUIT DIAGRAM
The 230 ac supply is converted into 12volts by the power supply in which 4 elements are used: Transformer 7805 regulator Diodes 4007(in bridge shape) Capacitor(100microfarad & 470microfarad)

Fig no.5.6 : power supply

BRIDGE RECTIFIER:
Bridge rectifier circuit consists of four diodes arranged in the form of bridge as shown in figure.:

OPERATION:
During the positive half cycle of the input supply, the upper end A of the transformer secondary becomes positive with respect to its lower point B. this makes point 1 of bridge. Positive with respect to

- 56 -

-Automatic power saver


point 2. The diode D1 & D2 becomes forward biased & D3 & D4 become reverse biased. As a result a current starts flowing from point1, through D1 the load & D2 to the negative end. During, negative half cycle, the point 2 becomes positive with respect to point 1. Diodes D1 & D2 now become reverse biased. Thus a current flow from point2 to point1. 57

Fig no. 5.7 : Bridge rectifier

VOLTAGE REGULATOR:
THE ADAPTING 3-TERMINAL VOLTAGE REGULATORS FOR CONSTANT HIGH VOLTAGE POWER SUPPLIES: One can get a constant high-voltage power supply using inexpensive 3-terminal voltage regulators through some simple techniques described below. Depending upon the current requirement, a reasonable load regulation can be achieved. Line regulation in all cases is equal to that of the voltage regulator used. Though high voltage can be obtained with suitable voltage boost circuitry using ICs like LM 723, some advantages of the circuits presented below are: simplicity, low cost, and practically reasonable regulation characteristics. For currents of the order of 1A or less, only one zener and some resistors and capacitors are needed. For higher currents, one pass transistor such as ECP055 is needed. Before developing the final circuits, let us first understand the 3-terminal type constant voltage regulators. Let us see the schematic in Fig. where 78XX is a 3-terminal voltage regulator.

- 57 -

-Automatic power saver


58

Schematic for obtaining low-voltage regulated output using 3-terminal voltage regulators.

Rectified and filtered unregulated voltage is applied at VIN and a constant voltage appears between pins 2 and 2 of the voltage regulator. *The distribution of two currents in the circuit (IBIAS and ILOAD) is as shown. * It is highly recommended to use the two capacitors as shown. Electrically regulator will be at a distance from the rectifier supply. Thus, a tantalum grade capacitor of 5mf and rated voltage is good. Electrolytic capacitor is not suitable for it is poor in response to load transients, which have high frequency components. At the output side a 0.22mf disc ceramic capacitor is useful to eliminate spurious oscillations, which the regulator might break into because of its internal high gain circuitry. These voltage regulators have a typical bias current of 5 mA, which is reasonably constant. By inserting a small resistor Rx between pin 2 and ground, the output voltage in many cases. By this method voltage increment of 5 to 10 per cent is practically feasible. However, if a high-value resistance is used to obtain a higher output voltage, a slight variation in bias current will result in wide variation of the output voltage. Now let us see that what can be done to get a higher but constant output voltage. If to the circuit of Fig. resistor RY and zener Vz are added as shown in Fig., the output voltage is now given by ,

VOUT=VR+VZ + IBIAS RX A constant current flows through RY** because VOUT is constant, and small variations in IBIAS do not change practically the operating point of Vz. This situation is like constant current biasing of zener, which results in a very accurate setting of the zener voltage.

**

As long a sVIN>VOUT+2 volts, VOZ is constant from the reasoning thus current through RY is constant. VOZ=VR + IBIAS Rx

of

Fig,

and

- 58 -

-Automatic power saver


Here the pin 2 of the regulator is raised above ground by Vz + IBIAS Rx. Thus, any 59 combination of zener with a proper selection of RY can be used. For example, Let VR=+15 V for 7815 IBIAS=5mA VZ=39V (standard from ECIL) For a standard 400mW zener of ECIL make, IZ MAX=10 mA. Thus, if we let pass 5mA through RY to make a 55-volt supply 55 - 39 RY = ---------------=3.2k3.3k 5 x 10-3 55 - 39 - 15 RX = ---------------------= ---------- = 200 ohm IBIAS 5 x 10-3 1

Schematic for constant high-voltage power supplies

It should be noted here that the maximum input voltage allowed for 78XX regulators is 35V between pins 1 and 2. We see that the actual voltage betweens pin 1 and 2 of the regulator in this circuit is VIN - VZ - IBIAS RX It is therefore necessary that VIN be so chosen that voltage between pins 1 and 2 of the IC does not exceed the maximum rating. Also, a high input-output differential voltage VIN- 59 -

-Automatic power saver


VOUT means more power dissipation in the series-pass element, the regulator. Thus, with proper 60 selection of the input transformer voltage and capacitor, this should be minimized. For example, if 7805 is used, VR equals + 5V and VZ is 40V, so VOUT=45 volts. For 7805, the maximum input voltage is 35 V and the minimum 7V. Therefore, VIN MAX = 45 + 35 - 5 = 75 VOLTS VIN MIN = 45 + 7 - 5 = 47 VOLTS

Thus, from no-load to full-load condition, the unregulated input voltage-including peak ripple-should be within these limits. This gives a margin of 75-47, i.e. 28 volt. Hence, the designer can work out the maximum transformer voltage from the no-load input voltage chosen on the upper side.

The capacitor's value can be determined from the full load unregulated voltage chosen. Roughly, per 100mA current, 100mf capacitor gives 1-volt peak-to-peak ripple. Hence, capacitor's value can be determined for the desired current. This circuit will have an excellent load and line regulation. For shot-circuit protection, it is recommended to use a fast-blow fuse of suitable value. Although the regulator has inherent short-circuit protection, the maximum current differs from device to device. Adequate heat sink should be used with the regulator.

Schematic for constant high-voltage power supplies providing currents in excess of one ampere

Now if currents in excess of 1A are needed, the circuit shown in fig. is useful. This circuit is similar to that in Fig. except that a pass transistor ECP055 is added besides a 0.5-ohm or more resistor. This transistor bypasses the excessive current. By selecting proper Rz the ratio of two currents passing through the regulator and transistor can be altered.

- 60 -

-Automatic power saver


This circuit will show load and live regulation within 1% and will function properly for VIN-VOUT as low as 4 volt. For short-circuit protection, a fast blow fuse is recommended as 61 this circuit does not have inherent short-circuit protection. Adequate heat sink is to be used for the pass transistors. For negative voltages, use 79XX series regulators and ECN055 as the pass transistor. Some advantages of the circuits described above are: the lowest cost among comparable performance circuits, ability to work at low input-output differential, and flexibility in design for various applications. So audio enthusiasts, if you are troubled by hum emanating from your power amplifier, try this inexpensive alternative for power supply.

FEATURES:
Output current in Excess of 1.0A No external component required Internal thermal overload protection Internal short circuit current limiting Output transistor safe-area compensation Output voltage offered in 2% and 4% tolerance Available in surface mount D2PAK and standard 3-lead transistor packages Previous commercial temperature range has been extended to a junction temperature range of -40 degree C to +125 degree C.

TRANSFORMER:
Transformer is a major class of coils having two or more winding usually wrapped around a common core made from laminated iron sheets. It has two coils named primary and secondary. If the current flowing through primary is fluctuating, then a current will be inducted into the secondary winding. A steady current will not be transferred from one coil to other coil.

- 61 -

-Automatic power saver


62

Fig no. 5.8 : TRANSFORMER

Transformer are of two types:


1. Step up transformer 2. Step down transformer

In the power supply we use step down transformer. We apply 220V AC on the primary of step down transformer. This transformer step down this voltage to 6V AC. We give 6V AC to rectifier circuit, which convert it to 5V DC.

DIODES:
The diodes is ap-n junction device. Diode is the component used to control the flow of the current in any one direction. The diodes widely work in forward bias.

Fig no. 5.9 : DIODE

When the current flow from the P to N direction. Then it is in forward bias. The zener diode is used in reverse bias function i.e N to P direction. Visually the identification of diodes

- 62 -

-Automatic power saver


terminal can be done by identifying silver/black line. The silver/black line is the negative 63 terminal(cathode) and the other terminal is positive terminal (anode).

APPLICATION:
1. Diodes: rectification, free wheeling, etc 2. Zener diodes: voltage control, regulator etc. 3. Tunnel diode: control the current flow, ssnobbier circuit etc.

RESISTANCE:

Resistance is). Allthe opposition of a material to the current. It is measured in Ohms (conductors represent a certain amount of resistance, since no conductor is 100% efficient. To control the electron flow (current) in a predictable manner, we use resistors. Electronic circuits use calibrated lumped resistance to control the flow of current. Broadly speaking, resistor can be divided into two groups viz. fixed & adjustable (variable) resistors. In fixed resistors, the value is fixed & cannot be varied. In variable resistors, the resistance value can be varied by an adjuster knob. It can be divided into (a) Carbon composition (b) Wire wound (c) Special type. The most common type of resistors used in our projects is carbon type. The resistance value is normally indicated by colour bands. Each resistance has four colors, one of the band on either side will be gold or silver, this is called fourth band and indicates the tolerance, others three band will give the value of resistance (see table). For example if a resistor has the following marking on it say red, violet, gold. Comparing these colored rings with the colour code, its value is 27000 ohms or 27 kilo ohms and its tolerance is 5%. Resistor comes in various sizes (Power rating). The bigger, the size, the more power rating of 1/4 watts. The four colour rings on its body tells us the value of resistor value as given below.

COLOURS CODE

Black-----------------------------------------------------0 Brown----------------------------------------------------1

- 63 -

-Automatic power saver


Red-------------------------------------------------------2 Orange---------------------------------------------------3 Yellow---------------------------------------------------4 Green-----------------------------------------------------5 Blue-------------------------------------------------------6 Violet-----------------------------------------------------7 Grey------------------------------------------------------8 White-----------------------------------------------------9
64

The first rings give the first digit. The second ring gives the second digit. The third ring indicates the number of zeroes to be placed after the digits. The fourth ring gives tolerance (gold 5%, silver 10%, No colour 20%). In variable resistors, we have the dial type of resistance boxes. There is a knob with a metal pointer. This presses over brass pieces placed along a circle with some space b/w each of them.

- 64 -

-Automatic power saver


Resistance coils of different values are connected b/w the gaps. When the knob is rotated, the pointer also moves over the brass pieces. If a gap is skipped over, its resistance is included in 65 the circuit. If two gaps are skipped over, the resistances of both together are included in the circuit and so on. A dial type of resistance box contains many dials depending upon the range, which , it will haveit has to cover. If a resistance box has to read up to 10,000 three dials each having ten gaps i.e. ten resistance coils each of resistance. . The third dial will have ten resistances each of 10010 The dial type of resistance boxes is better because the contact resistance in this case is small & constant.

TESTING:
Resistors are checked with an ohm meter/millimeter. For a defective resistor the ohm meter shows infinite high reading.

CAPACITORS:

It is an electronic component whose function is to accumulate charges and then release it.

To understand the concept of capacitance, consider a pair of metal plates which all are placed near to each other without touching. If a battery is connected to these plates the positive pole to one and the negative pole to the other, electrons from the battery will be attracted from the plate connected to the positive terminal of the battery. If the battery is then disconnected, one plate will be left with an excess of electrons, the other with a shortage, and a potential or voltage difference will exists between them. These plates will be acting as capacitors. Capacitors are of two types: - (1) fixed type like ceramic, polyester, electrolytic capacitors-these names refer to the material they are made of aluminum foil. (2) Variable type like gang condenser in radio or trimmer. In fixed type capacitors, it has two leads and its value is written over its body and variable type has three leads. Unit of measurement of a capacitor is farad denoted by the symbol F. It is a very big unit of capacitance. Small unit capacitor are pico-farad denoted by pf (Ipf=1/1000,000,000,000 f) Above all, in case of electrolytic capacitors, it's two terminal are

- 65 -

-Automatic power saver


marked as (-) and (+) so check it while using capacitors in the circuit in right direction. Mistake 66 can destroy the capacitor or entire circuit in operational.

Fig no. 5.12 : CAPACITOR

BASIC:
Like a battery, a capacitor has two terminals. Inside the capacitor, the terminals connect to two metal plates seperated by a dielectric. The dielectric can be air, paper , plastic, or anything else that does not conduct electricity and keeps the plates from touching each other. You can eaisily make a capacitor from two pieces of aluminium foil and piece of paper. It wont be a particularly good capacitor in terms of its storage capacity, but it will work. In an electronic circuit, a capacitor is shown like this:

- 66 -

-Automatic power saver


67

Fig no. 5.13 : SYMBOL OF CAPACITOR

when you connect a capacitor to abattery, heres what happens:

The plate on the capacitor that attaches to the negative terminal of the battery accepts electrons that the battery is producing. The plate on the capacitor that attaches to the positive terminal of the battery loses electrons to the battery.

TESTING:
To test the capacitors, either analog meters or special digital meters with the specified function are used. The non-electrolyte capacitor can be tested by using the digital meter.

Multi-meter mode Positive probe Negative probe

: Continuty : One end : Second end


- 67 -

-Automatic power saver


Display Result : 0(beep sound occur) OL : Faulty OK
68

CHAPTER: 9
- 68 -

-Automatic power saver


69

- 69 -

-Automatic power saver


70

PHOTO SEMICONDUCTOR

A Germanium or silicon diode or transistor, which has a transparent encasing, can serve as a photodiode or transistor because the light photons can initiate conduction in the p-njunction region. Early devices such as the OCP 71 were Ge-devices. Later, silicon types became available with lower leakage current and better light sensitivity. In a phototransistor, the base lead is not used; but, if a resistor is connected form base to emitter it reduced the light sensitivity. Darlington connected photo transistors (two transistors together in one case) such as the 2N5777 are very sensitive with a hFE of 2.5K, a dark current of 100nA and a light current of 0.5-2.0mA for light flux density H=2mW/cm 2. The device is rated 200mW and voltage of 25V maximum. SCRs with a light window are also available, called as LASCR, which are very sensitive and can turn mains power ON and OFF, with light.

The switching speed of phototransistors far exceeds those of LDRs, made of CdS. The s. Maximum switching speeds and fall time is 50rise time for the 2N5777 is 75 is 1KHz. Photo devices are useful in optical encoding, intrusion alarms, tape readers, level control, character recognition etc. Nowadays packing containing an LED and a photodiode, called opto-coupler is used for switching on power or control circuits. Because the light source (LED) and photodiode are physically kept separated (with 2mm) in the package, isolation upto 2500V can be had.

- 70 -

-Automatic power saver


71

LED:

LED falls within the family of P-N junction device. The light emitting device(LED) is a diode that will give off visible light when it is energized. In any forward biased P-N junction there is, with in the structure and primarilyclose to the junction a recombination of hole and electrons. This recombination requires that the energy possessed by the unbound free electron be transferred to another state. This process of giving off light by applying an electrical source is called electroluminescence.

Fig no. 5.15 : LED and LED SYMBOL

LED is a component used for indication. All the function being carried out are displayed by LED. The LED is diode which glows when the current is being flow through it in forward bias condition. This LED are available in the round shell and also in the flat shells. The positive leg is longer than negative leg.

- 71 -

-Automatic power saver


72

- 72 -

-Automatic power saver


73

PHOTODIODE

A photodiode is a semiconductor diode that functions as a photo detector. Photodiodes are packaged with either a window or optical fibre connection, in order to let in the light to the sensitive part of the device. They may also be used without a window to detect vacuum UV or X-rays. If a conventional silicon diode is connected in the reverse-biased circuit of fig. 1, negligible current will flow through the diode and zero voltage will develop across R 1. If the diode casing is now carefully removed so that the diode's semiconductor junction is revealed, and the junction is them exposed to visible light in the same circuit, the diode current will rise, possibly to as

- 73 -

-Automatic power saver


Fig. 1 Reverse-based diode circuit.
74

high as 1 mA, producing a significant output across R1. Further investigation will show that the diode current (and thus the output voltage) is directly proportional to light intensity, and that the diode is therefore photosensitive.

In practice, all silicon junctions are photosensitive, and a photodiode can be regarded as a conventional diode housed in a case that lets external light reach its photosensitive semiconductor junction. Fig. 2 shows the standard photodiode symbol. In use, the photodiode is reverse biased and the output voltage is taken from across a series-connected load resistor. This resistor may be connected between the diode and ground, as in fig. 1, or between the diode and the positive supply line, as in fig. 3

Photodiode symbol

Fig. 2 Photodiode symbol

The human eye is sensitive to a range of light radiation, as shown in fig. 4. It has a peak spectral response to the colour green, which has a wave length of about 550 nm, but has a relatively low sensitivity to the colour violet (400 nm) at one end of the spectrum and to dark red (700 nm) at the other. Photodiodes also have spectral response characteristics, and these are determined by the chemistry used in the semiconductor junction material. Fig. 4 shows typical response curves of a general-purpose photodiode, and infrared (IR) photodiode.

- 74 -

-Automatic power saver


75

Photodiodes have a far lower light-sensitivity than cadmium-sulphide LDRs, but give a far quicker response to changes in light level. Generally, LDRs are ideal for use in slow-acting direct-coupled light-level sensing applications, while photodiodes are ideal for use in fast-acting AC-coupled signalling applications. Typical photodiode applications include IR remote-control circuits, IR beam switches and alarm circuits, and photographic flash slave circuits, etc.

Fig 3 Photodiode circuit with D -to-V + load 1

- 75 -

-Automatic power saver


76

Fig. 4 Typical spectral response curves of (a) the human eye, (b) a general-purpose photodiode, and (c) an infrared photodiode.

PRINCIPLE OF OPERATION: -

A photodiode is a p-n junction or p-i-n structure. When light with sufficient photon energy strikes a semiconductor, photons can be absorbed, resulting in generation of a mobile electron and electron hole. If the absorption occurs in the junction's depletion region, these carriers are swept from the junction by the built-in field of the depletion region, producing a photocurrent. Photodiodes can be used in either zero bias or reverse bias. In zero bias, light falling on the diode causes a voltage to develop across the device, leading to a current in the forward bias direction. This is called the photovoltaic effect,

- 76 -

-Automatic power saver


and is the basis for solar cells in fact, a solar cell is just a large number of big, cheap photodiodes. Diodes usually have extremely high resistance when reverse biased. This resistance is reduced when light of an appropriate frequency shines on the junction. Hence, a reverse biased diode can be used as a detector by monitoring the current running through it. Circuits based on this effect are more sensitive to light than ones based on the photovoltaic effect. Avalanche photodiodes have a similar structure, however they are operated with much higher reverse bias. This allows each photo-generated carrier to be multiplied by avalanche breakdown, resulting in internal gain within the photodiode, which increases the effective responsivity of the device.
77

MATERIALS: -

The material used to make a photodiode is critical to defining its properties, because only photons with sufficient energy to excite an electron across the material's bandgap will produce significant photocurrents.

Materials commonly used to produce photodiodes:


Material Silicon Germanium Indium gallium arsenide Lead sulfide Wavelength range (nm) 1901100 8001700 8002600 <1000-3500

Because of their greater bandgap, silicon-based photodiodes generate less noise than germaniumbased photodiodes, but germanium photodiodes must be used for wavelengths longer than approximately 1 m.

FEATURES: -

Critical performance metrics of a photodiode include: -

- 77 -

-Automatic power saver Rponsivity


78

The ratio of generated photocurrent to incident light power, typically expressed in A/W when used in photoconductive mode. The responsively may also be expressed as a quantum efficiency, or the ratio of the number of photogene rated carriers to incident photons, thus a unit less quantity.

Dark current

The current through the photodiode in the absence of any input optical signal, when it is operated in photoconductive mode. The dark current includes photocurrent generated by background radiation and the saturation current of the semiconductor junction. Dark current must be accounted for by calibration if a photodiode is used to make an accurate optical power measurement, and it is also a source of noise when a photodiode is used in an optical communication system.

Noise-equivalent power

(NEP) The minimum input optical power to generate photocurrent equal to the rms noise current in 1 Hertz bandwidth. The related characteristic detectivity (D) is the inverse of NEP, 1/NEP; and the specific detectivity ( ) is the detectivity normalized to the area (A) of the photodetector, photodiode. . The NEP is roughly the minimum detectable input power of a

- 78 -

-Automatic power saver


When a photodiode is used in an optical communication system, these parameters 79 contribute to the sensitivity of the optical receiver, which is the minimum input power required for the receiver to achieve a specified bit error ratio.

APPLICATIONS: -

P-N photodiodes are used in similar applications to other photo detectors, such as photoconductors, charge-coupled devices, and photomultiplier tubes. Photodiodes are used in consumer electronics devices such as compact disc players smoke detectors, and the receivers for remote controls in VCRs and televisions. In other consumer items such as camera light meters, clock radios (the ones that dim the display when its dark) and street lights, photoconductors are often used rather than photodiodes, although in principle either could be used.

Photodiodes are often used for accurate measurement of light intensity in science and industry. They generally have a better, more linear response than photoconductors. They are also widely used in various medical applications, such as detectors for Computed tomography (coupled with scintillates) or instruments to analyze samples (immunoassay). They are also used in Blood gas monitors. PIN diodes are much faster and more sensitive than ordinary p-n junction diodes, and hence are often used for optical communications. P-N photodiodes are not used to measure extremely low light intensities. Instead, if high sensitivity is needed, avalanche photodiodes, intensified charge-coupled devices or photomultiplier tubes are used for applications such as astronomy, spectroscopy, night-vision equipment and laser range finding.

- 79 -

-Automatic power saver


80

PHOTOTRANSISTOR

Phototransistors are solid-state light detectors with internal gain that are used to provide analog or digital signals. They detect visible, ultraviolet and near-infrared light from a variety of sources and are more sensitive than photodiodes, semiconductor devices that require a pre-amplifier. Phototransistors feed a photocurrent output into the base of a small signal transistor. For each illumination level, the area of the exposed collector-base junction and the DC current gain of the transistor define the output. The base current from the incident photons is amplified by the gain of the transistor, resulting in current gains that range from hundreds to several thousands. Response time is a function of the capacitance of the collector-base junction and the value of the load resistance. Photodarlingtons, a common type of phototransistor, have two stages of gain and can provide net gains greater than 100,000. Because of their ease of use, low cost and compatibility with transistor-transistor logic (TTL), phototransistors are often used in applications where more than several hundred nanowatts (nW) of optical power are available.

- 80 -

-Automatic power saver


Selecting phototransistors requires an analysis of performance specifications. Collector current is the total amount of current that flows into the collector terminal. Collector dark 81 current is the amount of collector current for which there is no optical input. Typically, both collector current and collector dark current are measured in milliamps (mA). Peak wavelength, the wavelength at which phototransistors are most responsive, is measured in nanometers (nm). Rise time, the time that elapses when a pulse waveform increases from 10% to 90% of its maximum value, is expressed in nanoseconds (ns). Collector-emitter

breakdown voltage is the voltage at which phototransistors conduct a specified (nondestructive) current when biased in the normal direction without optical or electrical inputs to the base. Power dissipation, a measure of total power consumption, is measured in milliwatts (mW). Other performance specifications for phototransistors include spectral range, fall time, acceptance angle, and operating temperature. Phototransistors vary in terms of mounting and features. Surface mount technology (SMT) adds components to a printed circuit board (PCB) by soldering component leads or terminals to the top surface of the board. Typically, the PCB pad is coated with a paste-like formulation of solder and flux. Elevated temperatures, usually from an infrared oven, melt the paste and solder the component leads to the PCB pads. Through hole technology (THT), another commonly used mounting style, mounts components by inserting component leads through holes in the board and then soldering the leads in place on the opposite side of the board. In terms of features, some phototransistors include a cutoff filter that blocks visible light. Others have an anti-reflective coating to improve light detection. Devices with a rounded dome lens instead of a flat lens are also availa

Fig. 5 shows the standard symbol of a phototransistor, which can be regarded as a conventional transistor housed in a case that enables its semiconductor junctions to be exposed to external light. The device is normally used with its base open circuit, in either of the configurations shown in fig. 6, and functions as follows.

- 81 -

-Automatic power saver


82

Fig. 5 Phototransistor symbol.

In fig. 6(a), the base-collector junction of the transistor is effectively reverse biased and thus acts as a photodiode. The photo-generated currents of the base-collector junction feed directly into the base of the device, and the normal current-amplifying transistor action causes the output current to appear (in greatly amplified form) as collector current, and in fig. 6(a) R 1 causes this current to generate an output voltage as shown.

In practice, the collector and emitter current of the transistor are virtually identical and, since the base is open circuit, the device is not subjected to significant negative feedback. Consequently, the alternative fig. 6(b) circuit, in which R1 is connected to Q1 emitter, gives a virtually identical performance to that of fig. 6(a).

- 82 -

-Automatic power saver


83

Fig. 6 Alternative phototransistor configuration.

The sensitivity of a phototransistor is typically one hundred times greater than that of a photodiode, but is useful maximum operating frequency (a few hundred kilohertz) is proportionally lower than that of a photodiode by using only its base and collector terminals and ignoring the emitter, as shown in fig. 7.

- 83 -

-Automatic power saver


84

Fig. 7 Phototransistor used as a photodiode

INFRARED LED'S:-

Gallium arsenide is a direct-gap semiconductor with an energy gap of 1.4eV at room temperature. A typical GaPs LED is made by solid-state impurity diffusion with zinc as the ptype impurity diffused into an n-type sub state doped with tin, tellurium or silicon. The external efficiency at room temperature is typically 5 percent.

A GaAs diode can also be fabricated by liquid-phase epitaxy with silicon as both its n and p dopants. If a silicon atom replaces a Ga atom, it provides one additional electron, thus the resulting GaAs in as n-type. If a silicon atom replaces arsenic atoms, an electron is missing and the resulting GaAs is a p-type. In Si doped GaAs diode, the emission peak shifts down to 1.32eV. Since the emission is in infrared region, GaAs light sources are suitable for application such as the optical isolator. The high switching speed, with a recovery time between 2 and 10ns, makes them ideal for data transmission.

- 84 -

-Automatic power saver


85

The disadvantages of the GaAs emitter are emitted wavelength and the associated attenuation an dispersion. A critical issue of using an LED for the fibre optics is the coupling of light from the semiconductor to the fibre. Because of the larger refractive index of GaAs relative to air, the internal efficiency of LED can be quite low.

INFRARED TRANSMITTER

R1=4.7K VR1=10K R2=10K C2=0.001f C3=0.01f C1=10f16v

WORKING

- 85 -

-Automatic power saver


When switch S1 is pressed, circuit is energized. The output of IC1 is square wave. The IR-LED is connected to its output. The transmit IR-beams modulated at same frequency 36-kHz. 86 The oscillator frequency can be shifted by adjusting preset VR-1.

CHAPTER: 10
- 86 -

-Automatic power saver


87

- 87 -

-Automatic power saver


88

P.C.B. DESIGNING

INTRODUCTION
Making a Printed Circuit Board is the first step towards building electronic equipment by any electronic industry. A number of methods are available for making P.C.B., the simplest method is of drawing pattern on a copper clad board with acid resistant (etchants) ink or paint or simple nail polish on a copper clad board and do the etching process for dissolving the rest of copper pattern in acid liquid.

MATERIAL REQUIRED

- 88 -

-Automatic power saver


The apparatus needs for making a P.C.B. is :89

Copper Clad Sheet

Polish or Pain

Ferric Chloride Powder. (Fecl)

Plastic Tray

Tap Water etc.

- 89 -

-Automatic power saver


90

PROCEDURE

The first and foremost in the process is to clean all dirt from copper sheet with say spirit or trichloro ethylene to remove traces grease or oil etc. and then wash the board under running tap water. Dry the surface with forced warm air or just leave the board to dry naturally for some time.

Making of the P.C.B. drawing involves some preliminary consideration such as thickness of lines/ holes according to the components. Now draw the sketch of P.C.B. design (tracks, rows, square) as per circuit diagram with the help of nail polish or enamel paint or any other acid resistant liquid. Dry the point surface in open air, when it is completely dried, the marked holes in P.C.B. may be drilled using 1Mm drill bits. In case there is any shorting of lines due to spilling of paint, these may be removed by scraping with a blade or a knife, after the paint has dried.

After drying, 22-30 grams of ferric chloride in 75 ml of water may be heated to about 60 degree and poured over the P.C.B. , placed with its copper side upwards in a plastic tray of about 15*20 cm. Stirring the solution helps speedy etching. The dissolution of unwanted copper would take about 45 minutes. If etching takes longer, the solution may be heated again and the process repeated. The paint on the pattern can be removed P.C.B. may then be washed and dried. Put a coat of varnish to retain the shine. Your P.C.B. is ready.

REACTION

- 90 -

-Automatic power saver


91

Fecl

+ Cu ----- CuCl

+ Fe

Fecl

+ 3H O --------- Fe (OH) + 3HCL 2 3

- 91 -

-Automatic power saver


92

PRECAUTION

1.

Add Ferric Chloride (Fecl3) carefully, without any splashing. Fecl3 is irritating to the skin and will stain the clothes.

2.

Place the board in solution with copper side up.

3.

Try not to breathe the vapours. Stir the solution by giving see-saw motion to the dish and solution in it.

4.

Occasionally warm if the solution over a heater-not to boiling. After some time the unshaded parts change their colour continue to etch. Gradually the base material will become visible. Etch for two minutes more to get a neat pattern.

5.

Don't throw away the remaining Fecl3 solution. It can be used again for next Printed Circuit Board P.C.B

- 92 -

-Automatic power saver


93

USES

Printed Circuit Board are used for housing components to make a circuit for compactness, simplicity of servicing and case of interconnection. Thus we can define the P.C.B. as : Prinked Circuit Boards is actually a sheet of bakelite (an insulating material) on the one side of which copper patterns are made with holes and from another side, leads of electronic components are inserted in the proper holes and soldered to the copper points on the back. Thus leads of electronic components terminals are joined to make electronic circuit.

In the boards copper cladding is done by pasting thin copper foil on the boards during curing. The copper on the board is about 2 mm thick and weights an ounce per square foot.

The process of making a Printed Circuit for any application has the following steps (opted professionally):

Preparing the layout of the track.

Transferring this layout photographically M the copper.

Removing the copper in places which are not needed, by the process of etching (chemical process)

- 93 -

-Automatic power saver


94

Drilling holes for components mounting.

PRINTED CIRCUIT BOARD

Printed circuit boards are used for housing components to make a circuit, for comactness, simplicity of servicing and ease of interconnection. Single sided, double sided and double sided with plated-through-hold (PYH) types of p.c boards are common today.

Boards are of two types of material (1) phenolic paper based material (2) Glass epoxy material. Both materials are available as laminate sheets with copper cladding.

Printed circuit boards have a copper cladding on one or both sides. In both boards, pasting thin copper foil on the board during curing does this. Boards are prepared in sizes of 1 to 5 metre wide and upto 2 metres long. The thickness of the boards is 1.42 to 1.8mm. The copper on the boards is about 0.2 thick and weighs and ounce per square foot.

- 94 -

-Automatic power saver


95

CONSTRUCTION
An actual-size, single-side PCB for the microcontroller-based visitor counter (Fig2) including its power supply (Fig.3) is shown in Fig.5 and its component layout in Fig6.

Fig. 4: Pin configuration of L14FI and transistor 2N3904

Fig. 5: An actual-size, single-side PCB for (he microcontroller-based visitor counter (Fig. 2) including its power supply (Fig. 3)

- 95 -

-Automatic power saver


96

- 96 -

-Automatic power saver


97

PROCEDURE FOR MAKING PROJECT

Building project in the proper manner is really an art, something which must be prectised and learned through trial and error, it is not all that difficult. The main thing is to remember to take each step slowly and carefully according to the instructions giving making since that everything at it should be before proceeding further.

TOOLS:
The electronics workbench is an actual place of work with comfortably & conveniently & should be supplied with compliment of those tools must often use in project building. Probably the most important device is a soldering tool. Other tool which should be at the electronic work bench includes a pair of needle nose pliers, diagonal wire cutter, a small knife, an assortment of screw driver, nut driver, few nuts & bolts, electrical tape, plucker etc. Diagonal wire cutter will be used to cut away any excess lead length from copper side of P.C.B. 7 to cut section of the board after the circuit is complete. The needle nose pliers are most often using to bend wire leads & wrap them in order to form a strong mechanical connection.

- 97 -

-Automatic power saver


98

MOUNTING & SOLDERING:


Soldering is process of joining together two metallic parts. It is actually a process of function in which an alloy, the solder, with a comparatively low melting point penetrates the surface of the metal being joined & makes a firm joint between them on cooling & solidifying.

THE SOLDERING KIT

1.

SOLDERING IRON:

As soldering is a process of joining together two metallic parts, the instrument, which is used, for doing this job is known as soldering Iron. Thus it is meant for melting the solder and to setup the metal parts being joined. Soldering Iron is rated according to their wattage, which varies from 10- 200 watts.

2.

SOLDER:

The raw material used for soldering is solder. It is composition of lead & tin. The good quality solder (a type of flexible naked wire) is 60% Tin +40% Lead which will melt between 180 degree to 200 degree C temperature.

3.

FLUXES OR SOLDERING PASTE:

- 98 -

-Automatic power saver


When the points to solder are heated, an oxide film forms. This must be removed at once so that solder may get to the surface of the metal parts. This is done by applying chemical 99 substance called Flux, which boils under the heat of the iron remove the oxide formation and enable the metal to receive the solder.

4.

BLADES OR KNIFE:
To clean the surface & leads of components to be soldered is done by this common

instrument.

5.

SAND PAPER:

The oxide formation may attack at the tip of your soldering iron & create the problem. To prevent this, clean the tip with the help of sand paper time to time or you may use blade for doing this job. Apart from all these tools, the working bench for soldering also includes disordering pump, wink wire (used for disordering purpose), file etc. HOW TO SOLDER? Mount components at their appropriate place; bend the leads slightly outwards to prevent them from falling out when the board is turned over for soldering. No cut the leads so that you may solder them easily. Apply a small amount of flux at these components leads with the help of a screwdriver. Now fix the bit or iron with a small amount of solder and flow freely at the point and the P.C.B copper track at the same time. A good solder joint will appear smooth & shiny. If all appear well, you may continue to the next solder connections.

TIPS FOR GOOD SOLDERING


1. Use right type of soldering iron. A small efficient soldering iron (about 10-25 watts with 1/8 or 1/4 inch tip) is ideal for this work.

- 99 -

-Automatic power saver


100

2. Keep the hot tip of the soldering iron on a piece of metal so that excess heat is dissipated.

3. Make sure that connection to the soldered is clean. Wax frayed insulation and other substances cause poor soldering connection. Clean the leads, wires, tags etc. before soldering.

4. Use just enough solder to cover the lead to be soldered. Excess solder can cause a short circuit.

5. Use sufficient heat. This is the essence of good soldering. Apply enough heat to the component lead. You are not using enough heat, if the solder barely melts and forms a round ball of rough flaky solder. A good solder joint will look smooth, shining and spread type. The difference between good & bad soldering is just a few seconds extra with a hot iron applied firmly.

PRECAUTIONS

1.

Mount the components at the appropriate places before soldering. Follow the circuit description and components details, leads identification etc. Do not start soldering before making it confirm that all the components are mounted at the right place.

2.

Do not use a spread solder on the board, it may cause short circuit.

3.

Do not sit under the fan while soldering.

- 100 -

-Automatic power saver 4.


Position the board so that gravity tends to keep the solder where you want it.
101

5.

Do not over heat the components at the board. Excess heat may damage the components or board.

6.

The board should not vibrate while soldering otherwise you have a dry or a cold joint.

7.

Do not put the kit under or over voltage source. Be sure about the voltage either dc or ac while operating the gadget.

8.

Do spare the bare ends of the components leads otherwise it may short circuit with the other components. To prevent this use sleeves at the component leads or use sleeved wire for connections.

9.

Do not use old dark colour solder. It may give dry joint. Be sure that all the joints are clean and well shiny.

10.

Do make loose wire connections especially with cell holder, speaker, probes etc. Put knots while connections to the circuit board, otherwise it may get loose.

- 101 -

-Automatic power saver


102

DRILLING:

After completion of painting work, holes 1/23inch(1mm) diameter are drilled at desired points where we have to fix the components.

ETCHING:

The removal of exess of copper on the plate apart from the printed circuit is known as etching. From this process the copper clad board with printed circuit is placed in the solution of FeCl with 3-4 drops of HCL in it and is kept so far about 10-15 mins. and is taken out when all the exess copper is removed from the P.C.B. After etching, the P.C.B. is kept in clean water for about half an hour in order to get P.C.B. away from acidic,field, which may cause poor performance of the circuit. After the P.C.B. has been thoroughly washed, paint is removed by soft piece of cloth, the P.C.B. is checked as per the layout, now the P.C.B. is ready to use.

- 102 -

-Automatic power saver


103

CHAPTER: 11

- 103 -

-Automatic power saver


104

CODING:

;H/W DECLARATION

sw1 equ P3.0 sw2 equ P3.1 led1 equ p3.4 led2 equ p3.5 led3 equ p3.6 led4 equ p3.7

SEGPORT1 EQU P2 SEGPORT2 EQU P0 SEGPORT3 EQU P1

;RAM DECLARATION

UNIT EQU 31H TEN EQU 32H

- 104 -

-Automatic power saver


HUND EQU 33H KEYNO EQU 34H COUNT EQU 35H
105

;BIT DECLARATION
FLAG BIT #00H INTFLAG BIT #01H

;CONSTANT DECLARATION
STACKVAL EQU 70H

;START

ORG 0000H SETB SW1 SETB SW2 AJMP POWERON

POWERON:
MOV SP,#STACKVAL MOV P0,#0FFH MOV P1,#0FFH

- 105 -

-Automatic power saver


106

MOV P2,#0FFH MOV P3,#0FFH MOV IE,#00H MOV IP,#00H

MOV DPTR,#CODETABLE MOV UNIT,#00H MOV TEN,#00H MOV HUND,#00H MOV KEYNO,#0FFH MOV COUNT,#00H CLR INTFLAG ACALL DISPLAY

MAINLOOP:
ACALL KEYCHECK JNB INTFLAG,MAINLOOP MOV A,COUNT MOV B,#10 DIV AB MOV UNIT,B

MOV B,#10
- 106 -

-Automatic power saver


DIV AB MOV TEN,B
107

MOV B,#10 DIV AB MOV HUND,B ACALL DISPLAY

SJMP MAINLOOP

KEYCHECK:
CLR FLAG

LOOP1: JB SW1,CHECK_2
MOV R1,#255 SJMP DEB_LOOP1

CHECK_2: JB SW2,LOOP1
MOV R2,#255 SJMP DEB_LOOP2

DEB_LOOP1:JB SW1,LOOP1
DJNZ R1,DEB_LOOP1 MOV KEYNO,#01

- 107 -

-Automatic power saver


ACALL KEYACTION
108

L6:

JNB SW1,L6
RET

DEB_LOOP2:JB SW2,LOOP1
DJNZ R2,DEB_LOOP2 MOV KEYNO,#02 ACALL KEYACTION

LOOP2: JNB SW2,LOOP2


RET

KEYACTION:mov a,keyno
cjne a,#0ffh,k1 ret

k1:

cjne a,#01h,k2 jb flag,label setb flag SETB INTFLAG MOV A,COUNT ADD A,#10 MOV COUNT,A CJNE A,#00,LEDON

- 108 -

-Automatic power saver


SETB LED1 SETB LED2 SETB LED3 SETB LED4 ret
109

k2:

cjne a,#02h,label jb flag,label setb flag SETB INTFLAG MOV A,COUNT SUBB A,#10 MOV COUNT,A CJNE A,#00,N2 SETB LED1 SETB LED2 SETB LED3 SETB LED4 RET

N2:

CJNE A,#40,LEDON CLR LED1 CLR LED2 CLR LED3 CLR LED4
- 109 -

-Automatic power saver


RET
110

LEDON:
MOV B,#10 DIV AB CJNE A,#01,NEXT1 CLR LED1 SETB LED2 SETB LED3 SETB LED4 RET

NEXT1:
CJNE A,#02,NEXT2 CLR LED1 CLR LED2 SETB LED3 SETB LED4 RET

NEXT2: CJNE A,#03,NEXT3

- 110 -

-Automatic power saver


CLR LED1 CLR LED2 CLR LED3 SETB LED4 RET
111

NEXT3:
CJNE A,#04,LABEL CLR LED1 CLR LED2 CLR LED3 CLR LED4 RET

LABEL: ret

display:
mov a,unit MOVC A,@A+DPTR mov segport1,a ACALL DELAY

mov a,ten MOVC A,@A+DPTR

- 111 -

-Automatic power saver


112

mov segport2,a

ACALL DELAY
mov a,hund MOVC A,@A+DPTR mov segport3,a ACALL DELAY

ret

delay: lp1: lp2: lp3:

mov r5,#20 mov r6,#50 mov r7,#50 djnz r7,lp3

djnz r6,lp2 djnz r5,lp1 ret

CODETABLE:
db 3Fh ;0

db 06h ;1 db 5Bh ;2

- 112 -

-Automatic power saver


db 4Fh ;3 db 66h ;4 db 6Dh ;5 db 7Dh ;6 db 07h ;7 db 7FH ;8 db 6Fh ;9
113

RET

end

- 113 -

-Automatic power saver


114

- 114 -

-Automatic power saver


115

CONCLUSION

The project was completed successfully with in the given time duration. it was learning experience through which we gained invaluable on hand practical knowledge with project enlightened us on the vastness and unique application of micro controller , which forms the basic framework of our project. Visitor counting is not limited to the entry/exit point of a company but has a wide range of applications that provide information to management on the volume and flow of people throughout a location. Still the advantages of this projects are not negligible hence the it is very useful, considering the evolution of new techniques in this field.

- 115 -

-Automatic power saver


116

- 116 -

-Automatic power saver

REFERENCES:
8051 Microcontroller architecture, programming and application 8051Microcontroller & embedded system Electronic devices and circuit theory Op-amps and linear integrated circuits Digital design Kenneth J Ayala

117

Majidi Robert l.Boylstead and Louis Nashelsky by Ramakant A. Gayakwad M.Morris Mano

WEBSITES

www.atmel.com www.electronics-lab.com www.alldatasheets.com www.google.com www.electroniccircuitschematic.com www.datasheetcatalog.com


www.cetpaindia.com www.futurlec.com

- 117 -

Potrebbero piacerti anche