Micro Controller

87
1. OVERVIEW 1.1 Introduction: A control system is a device or set of devices to manage, command, direct or regulate the behavior of other devices or systems. So now-a-days every system is automated in order to face new challenges. In the present days automated systems have less manual operations, flexibility, reliability and are accurate. Due to this demand every field prefers automated control systems especially in the field of electronics automated systems are giving good performance. This project is about controlling a street light with out human interference using a Microcontroller, RTC and Relays. The street light automatically switches on/off according to the user’s need. 1.2 Aim of the Project: To design and develop user friendly firmware for auto on/off switching without any human interference. We know that Automation plays an important role in the field of industrial electronics. In the bandwagon of automation the consumption of energy can be reduced to a high degree. As, energy conservation is picked up paramount importance, our 1

Transcript of Micro Controller

1. OVERVIEW1.1 Introduction:A control system is a device or set of devices to manage, command, direct or regulate the behavior of other devices or systems. So now-a-days every system is automated in order to face new challenges. In the present days automated systems have less manual operations, flexibility, reliability and are accurate. Due to this demand every field prefers automated control systems especially in the field of electronics automated systems are giving good performance. This project is about controlling a street light with out human interference using a Microcontroller, RTC and Relays. The street light automatically switches on/off according to the users need.

1.2 Aim of the Project:To design and develop user friendly firmware for auto on/off switching without any human interference. We know that Automation plays an important role in the field of industrial electronics. In the bandwagon of automation the consumption of energy can be reduced to a high degree. As, energy conservation is picked up paramount importance, our effort to conserve energy in Energy Conservation involves avoiding wastage of energy and adopting methods to save energy without sacrificing our comforts and needs. Show accuracy and flexibility of lighting control that will enable the elimination of waste and the 'fine tuning' of burning hours, leading to energy cost savings.

1

1.3 Methodology:The working of STREETLIGHT AUTOMATION SYSTEM is as follows: Initially the 230V ac supply is sent to the step down transformer and the voltage level gets reduced to the order of 19V.This is then regulated by using a series of voltage regulators to obtain 5V DC voltage. This voltage is sufficient for the pic microcontroller to get activated. RTC and LCD are interfaced to Pic microcontroller by using some pull up resistors. The timing data is entered into the micro controller through a series of switches, S2, S3, S4 and S5. This is sent to the RTC and LCD using the same multiplexed address data bus. The RTC and LCD are enabled using the control pins of the pic microcontroller. When the set time of the PIC microcontroller matches with that of the RTC, the microcontroller sends a signal and activates one of its pin which is in turn connected to a relay, through a series of buffers. This relay is further connected to a contactor, in the power saver, which controls the power supply to the street lights. In this way the street light automation system works based on the timings set by the user.

1.4 ORGANISATION OF THE REPORT:Chapter 1 is the introduction to the main board. The methodology gives an idea of how the system is automated. Chapter 2 comprehensively, covers the microcontroller core module with its features, architecture and its working in detail. Chapter 3 gives the introduction of modules such as LCD, DS 12C887 RTC, Crystal oscillator, Relays, Printed circuit board and their explanation. Chapter 4 elucidates on circuit layout, the hardware connections, design of each circuit and its operation.

2

Chapter 5 implementation is done with flowchart that explains the flow of program and their functions. Chapter 6 is results, conclusions and the future scope is touched upon.

1.5 SIGNIFICANCE AND APPLICATIONS: 1.5.1 Street light controller features Micro controller based Photo sensor implemented Two line LCD display IP:55 protection Power consumption less than 1 watt Protected from spikes and surges Protected from wide voltage fluctuation Overload protection Short circuit protection Withstands wide temp. variation 5 deg.C to 60 deg.c High accurate timer Applicable for any load Remote on/off facility Unmanned accurate on-off operations, avoiding the human errors thus power savings in all factories, stockyards, ports, public lighting systems

3

1.6 BLOCK DIAGRAM:

POWER SUPPLY

PIC (16F877A) LCD

MICROCONTROLLER

RELAY

RTC

POWER SAVER

4

Fig 1.1 Circuit Block diagram

2. MICROCONTROLLER2. 1 INTRODUCTIONMicrochip Technology is a manufacturer of microcontroller, memory and analog semiconductors. It was founded in 1989 when a group of venture capitalists acquired Microchip from General Instrument. Its products include microcontrollers (PICmicro, DSPIC / PIC24), Serial EEPROM devices, KEELOQ devices, radio frequency (RF) devices, thermal, power and battery management analog devices, as well as linear, interface and mixed signal devices. Some of the interface devices include ZigBee/MiWi, Controller Area Network, and Ethernet. Corporate Headquarters is located at Chandler, Arizona with wafer fabs in Tempe, Arizona and Gresham, Oregon. Among its chief competitors are Atmel, Infineon, Freescale, STMicroelectronics, Texas Instruments, Analog Devices and Maxim Integrated Products. Microchip is a major sponsor of the FIRST, supplying most of the major electrical components in each kit as standard parts.

2.2 DESCRIPTION OF PIC MICROCONTROLLER2.2.1 Introduction PIC is a family of Harvard architecture microcontrollers made by Microchip Technology, derived from the PIC1650 originally developed by General Instrument's Microelectronics Division. The name PIC initially referred to "Peripheral Interface Controller". PICs are popular with developers due to their low cost, wide availability, large user base, extensive collection of application notes, availability of low cost or free development 5

tools, and serial programming (and re-programming with flash memory) capability. PICs have a set of registers that function as general purpose ram. Special purpose control registers for on-chip hardware resources are also mapped into the data space. The addressability of memory varies depending on device series, and all PIC devices have some banking mechanism to extend the addressing to additional memory. Later series of devices feature move instructions which can cover the whole addressable space, independent of the selected bank. A PIC's instructions vary in number from about 35 instructions for the low-end PICs to about 70 instructions for the high-end PICs. The instruction set includes instructions to perform a variety of operations on registers directly, the accumulator and a literal constant or the accumulator and a register, as well as for conditional execution, and program branching. Some operations, such as bit setting and testing, can be performed on any register, but bi-operand arithmetic operations always involve W -- writing the result back to either W or the other operand register. To load a constant, it is necessary to load it into W before it can be moved into another register. On the older cores, all register moves needed to pass through W, but this changed on the "high end" cores. PIC cores have skip instructions which are used for conditional execution and branching. The skip instructions are: 'skip if bit set', and, 'skip if bit not set'. Because cores before PIC18 had only unconditional branch instructions, conditional jumps are implemented by a conditional skip with the opposite condition followed by an unconditional branch. Skips are also of utility for conditional execution of any immediate single following instruction. The PIC architecture has no hardware support for automatically saving processor state when servicing interrupts. The 18 series improved this situation by implementing shadow registers which save several important register during an interrupt. The microcontroller here we use for this application is Pic 16F877A. 2.2.2 FEATURES OF PIC 16F877A: High-Performance RISC CPU Only 35 single-word instructions to learn All single-cycle instructions except for program Branches, which are two-cycle 6 .

Operating speed: DC 20 MHz clock input DC 200 ns instruction cycle Up to 8K x 14 words of Flash Program Memory, Up to 368 x 8 bytes of Data Memory

(RAM), Up to 256 x 8 bytes of EEPROM Data Memory Pinout compatible to other 28-pin or 40/44-pin

Peripheral Features Timer0: 8-bit timer/counter with 8-bit prescaler Timer1: 16-bit timer/counter with prescaler, Can be incremented during Sleep via external Crystal/clock Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler Two Capture, Compare, PWM modules o Capture is 16-bit, max. Resolution is 12.5 ns o Compare is 16-bit, max. Resolution is 200 ns o PWM max. Resolution is 10-bit Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Master/Slave) Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit address detection Parallel Slave Port (PSP) 8 bits wide with external RD, WR and CS controls (40/44-pin only)

7

Brown-out detection circuitry for Brown-out Reset (BOR)

Analog Features: 10-bit, up to 8-channel Analog-to-Digital Converter (A/D) Brown-out Reset (BOR) Analog Comparator module with: o Two analog comparators o Programmable on-chip voltage reference (VREF) module Programmable input multiplexing from device inputs and internal voltage reference o Comparator outputs are externally accessible

Special Microcontroller Features

100,000 erase/write cycle Enhanced Flash program memory typical

8

memory typical Data EEPROM Retention > 40 years Self-reprogrammable under software control In-Circuit Serial Programming (ICSP) via two pins Single-supply 5V In-Circuit Serial Programming Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation Programmable code protection Power saving Sleep mode Selectable oscillator options In-Circuit Debug (ICD) via two pins Brown-out detection circuitry for Brown-out Reset (BOR)

9

2.3 INTERNAL BLOCK DIAGRAM OF 16F877A

10

Figure 2.1:Internal block diagram of 16F877A

2.4 PINDIAGRAM

Figure 2.2:Microcontroller pin diagram

11

2.4.1 PIN DESCRIPTION: Here in this microcontroller all the ports (PORT A, B, C, D, E) can be used as bidirectional I/O ports and they can serve other purposes too.

Port APort A is a 6-bit bidirectional I/O port from pin 2 to 7. These are designated as RA0-RA5. Port A also serves the functions of various special features of the 16F877A as listed below: Pin name RA0/AN0 RA1/AN1 RA2/AN2/VrefDIP PIN BUFFER TYPE 2 3 4 TTL TTL TTL TTL ST It can be used as analog input0 It can be used as analog input 1 It can be used as analog input2 or negative analog reference voltage RA3/AN3/Vref+ 5 RA4/T0CKI 6 It can be used as analog input3 or positive analog ref. voltage It can be used as clock input to timer0 timer/counter. OUTPUT is open drain type It can be used as analog input4 or the slave RA5/SS/AN4 7 TTL select for the synchronous serial port DESCRIPTION

Table 2.1:Features of portA

PORT B 12

Port B is an 8-bit bidirectional I/O port from pin 33 to 40. These are designated as RB0RB7. Port B can be software programmed for internal weak pull-up on the all inputs Pin name DIP PIN BUFFER TYPE RB0/INT RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC 33 34 35 36 37 38 39 TTL/ST TTL TTL TTL TTL TTL TTL/ST It can be used as external interrupt pin _____ _____ It can be used as low voltage programming input Interrupt on change pin Interrupt on change pin Interrupt on change pin or in-circuit debugger pin. Serial programming clock RB7/PGD 40 TTL/ST Interrupt on change pin or in-circuit debugger pin. Serial programming data. Table 2.2:Features of portB PORT C Port C is an 8-bit bidirectional I/O port from pin 15 to 26. These are designated as RC0RC7. Pin name DIP PIN RC0/T1OSO/T1CKI 15 RC1/T1OSI/CCP2 16 BUFFER TYPE ST ST It can be used as the Timer1 oscillator output or a Timer1 clock input It can be used as the Timer1 oscillator input or Capture2 input/Compare2output/PWM2 output 13 DESCRIPTION DESCRIPTION

RC2/CCP1 RC3/SCK/SCL RC4/SDI/SDA RC5/SDO RC6/TX/CK

17 18 23 24 25

ST ST ST ST ST

It can be used as Capture1 input/Compare1 output/PWM1 output It can be used as synchronous serial clock input/output for both SPI and I^2C(modes) It can be used as SPI data in(SPI mode) or data I/O(I^2C mode) It can be used as SPI data out(SPI mode) It can be used as USART Asynchronous Transmit or Synchronous Clock

RC7/RX/DT

26

ST

It can be used as USART Asynchronous Receive or Synchronous Data

Table 2.3:Features of portC

PORT D Port D is an 8-bit bidirectional I/O port from pin 19 to 22 and 27 to 30. These are designated as RD0/PSP0 to RD7/PSP7. It is also used as parallel slave port when interfacing to a microprocessor bus. PORT E Port E is an 3-bit bidirectional I/O port from pin 8 to 10. These are designated as RE0 to RE2 Pin name DIP PIN 8 RE0/RD/AN5 RE0/WR/AN6 RE0/CS/AN7 9 10 ST/TTL ST/TTL BUFFER TYPE ST/TTL It can be used to read control for the parallel slave port or analog input5 It can be used to write control for the parallel slave port or analog input6 It can be used to select control for the DESCRIPTION

14

parallel slave port or analog input7 Table 2.4:Features of portE

OSC1/CLKIN Pin 13 is an used as Oscillator Input/External Clock Input. OSC2/CLKOUT Pin 14 is used as Oscillator Output /Clock Output. VCC Pin 12, 31 provides Supply voltage to the chip. The voltage source is +5V. Vss Ground reference for logic and I/O pins. Pins 11, 32. MCLR/VPP/THV Pin 1 can be used as Master Clear (Active Low Reset) or Programming voltage input or High voltage input as per the requirement. 2.4.2 Configuration Bits of PIC16F877A PIC16F877A has the special area to say Configuration Word in the program memory. This word is mapped in program memory location 2007h. This address is beyond the user program memory space. This word can be accessed only during programming .

The following system requirements of PIC can be designated by the configuration word.

15

CP1, CP0: Flash Program Memory Code Protection Bits. All of the CP1:CP0 pairs have to be given the same value to enable the code protection scheme listed. CP1 CP0 1 1 1 0 0 1 0 0

Code protection off 1F00h to 1FFFh code protected 1000h to 1FFFh code protected 0000h to 1FFFh code protected DEBUG: In-Circuit Debugger Mode In-Circuit Debugger disabled, RB6 and RB7 are general purpose I/O pins. In-Circuit Debugger enabled, RB6 and RB7 are dedicated to the debugger.

1 0

WRT: Flash Program Memory Write Enable1 0 Un protected program memory may be written to by EECON control Unprotected program memory may not be written to by EECON control

CPD: Data EEPROM memory Code Protection1 0 Code protection off Data EEPROM memory code protected

LVP: Low Voltage In-Circuit Serial Programming Enable bit1 0 RB3/PGM pin has PGM function, low voltage programming enabled The high voltage programming mode is always available, regardless of the state of the LVP bit. RB3 is digital I/O, High Voltage on MCLR must be used for programming

BODEN: Brown-out Reset Enable bit16

1 BOR enabled. 0 BOR disabled

PWRTE: Power-up Timer Enable bit1 PWRT disabled 0 PWRT enabled

WDTE: Watchdog Timer Enable bit1 WDT enabled 0 WDT disabled

FOSC1, FOSC0: Oscillator Selection bits FOSC11 1 0 0

FOSC01 0 1 0 RC : Resistor/Capacitor oscillator ( Less than 1MHz ) HS : High Speed Crystal/Resonator oscillator ( 4MHz to 20MHz ) XT : Crystal/Resonator oscillator ( Less than 4MHz ) LP : Low Power Crystal oscillator ( Less than 200KHz )

3. DESCRIPTION OF MODULES3.1 LIQUID CRYSTAL DISPLAY3.1.1 Introduction A liquid crystal display (LCD) is a thin, flat display device made up of any number of color or monochrome pixels arrayed in front of a light source or reflector. It is often utilized in battery-powered electronic devices because it uses very small amounts of electric power. Passive-matrix and active-matrix addressed LCDs

17

LCDs with a small number of segments, such as those used in digital watches and pocket calculators, have individual electrical contacts for each segment. An external dedicated circuit supplies an electric charge to control each segment. This display structure is unwieldy for more than a few display elements. Small monochrome displays such as those found in personal organizers, or older laptop screens have a passive-matrix structure employing super-twisted nematic (STN) or double-layer STN (DSTN) technologythe latter of which addresses a color-shifting problem with the formerand color-STN (CSTN)wherein color is added by using an internal filter. Each row or column of the display has a single electrical circuit. The pixels are addressed one at a time by row and column addresses. This type of display is called passive-matrix addressed because the pixel must retain its state between refreshes without the benefit of a steady electrical charge. As the number of pixels (and, correspondingly, columns and rows) increases, this type of display becomes less feasible. Very slow response times and poor contrast are typical of passive-matrix addressed LCDs. High-resolution color displays such as modern LCD computer monitors and televisions use an active matrix structure. A matrix of thin-film transistors (TFTs) is added to the polarizing and color filters. Each pixel has its own dedicated transistor, allowing each column line to access one pixel. When a row line is activated, all of the column lines are connected to a row of pixels and the correct voltage is driven onto all of the column lines. The row line is then deactivated and the next row line is activated. All of the row lines are activated in sequence during a refresh operation. Active-matrix addressed displays look "brighter" and "sharper" than passive-matrix addressed displays of the same size, and generally have quicker response times, producing much better images. 3.1.2 16*2 LCD BLOCK DIAGRAM

18

Figure 3.1:Block diagram of LCD 3.1.2 PIN ASSIGNMENT 1) Vss -- Ground 0V 2) Vdd -- Supply Voltage for Logic 5V 3) Vo -- LCD Contrast Adjust By User 4) RS- H/L- Register Select H: Data, L: Instruction Code 5) R/W- H/L- Read / Write H: Data Read, L: Data Write 6) E - HL Enable- Enable Signal 7) DB0- H/L- Data Bit 0- 8-Bit Interface 8) DB1 -H/L- Data Bit 1 -8-Bit Interface 9) DB2- H/L -Data Bit 2 -8-Bit Interface 10) DB3- H/L- Data Bit 3 -8-Bit Interface 11) DB4 -H/L -Data Bit 4- 4 or 8-Bit Interface 12) B5 -H/L- Data Bit 5 -4 or 8-Bit Interface 13) B6 -H/L -Data Bit 6 -4 or 8-Bit Interface 14) B7 -H/L- Data Bit 7 -4 or 8-Bit Interface 19

3.1.3 LCD TIMING DIAGRAMS

Figure 3.2: Timing diagram of LCD

3.2 REAL TIME CLOCK 3.2.1 Introduction R.T.C means Real Time Clock. There are many RTCs such as the 12885 series. The devices provide a real-time clock/calendar, one time-of-day alarm, three maskable interrupts with a common interrupt output a programmable square wave, and 114 bytes of battery backed static RAM (113 bytes in the DS12C887 and DS12C887A). The DS12887 integrates a quartz crystal and lithium energy source into a 24-pin encapsulated DIP package. The DS12C887 adds a century byte at address 32h. For all devices, the date at 20

the end of the month is automatically adjusted for months with fewer than 31 days, including correction for leap years. The devices also operate in either 24-hour or 12-hour format with an AM/PM indicator. A precision temperature-compensated circuit monitors the status of VCC. If a primary power failure is detected, the device automatically switches to a backup supply. A lithium coin-cell battery can be connected to the VBAT input pin on the DS12885 to maintain time and date operation when primary power is absent. The device is accessed through a multiplexed byte-wide interface, which supports both Intel and Motorola modes. The DS12885 family of RTCs provide 14 bytes of real-time clock/calendar, alarm, and control/status registers and 114 bytes (113 bytes for DS12C887 and DS12C887A) of nonvolatile, battery-backed static RAM. A time-of-day alarm, three maskable interrupts with a common interrupt output and a programmable square wave output are available. The devices also operate in either 24-hour or 12-hour format with an AM/PM indicator. A precision temperature-compensated circuit monitors the status of VCC. If a primary power-supply failure is detected, the devices automatically switch to a backup supply. The backup supply input supports a primary battery, such as lithium coin cell. The devices are accessed through a multiplexed address/data bus that supports Intel and Motorola modes.

3.2.2 DS 12C887 PIN DIAGRAM

21

Figure 3.3:Pin diagram of RTC

3.2.3 PIN DISCRIPTION

22

23

24

Table 3.1:Pin configuration and features of RTC 25

3.2.4 Oscillator Circuit The DS12885 uses an external 32.768kHz crystal. The oscillator circuit does not require any external resistors or capacitors to operate. Table.1 specifies several crystal parameters for the external crystal. Figure.1 shows a functional schematic of the oscillator circuit. An enable bit in the control register controls the oscillator. Oscillator startup times are highly dependent upon crystal characteristics, PC board leakage, and layout. High ESR and excessive capacitive loads are the major contributors to long startup times. A circuit using a crystal with the recommended characteristics and proper layout usually starts within one second. An external 32.768kHz oscillator can also drive the DS12885. In this configuration, the X1 pin is connected to the external oscillator signal and the X2 pin is floated. 3.2.5 Clock Accuracy The accuracy of the clock is dependent upon the accuracy of the crystal and the accuracy of the match between the capacitive load of the oscillator circuit and the capacitive load for which the crystal was trimmed. Additional error is added by crystal frequency drift caused by temperature shifts. External circuit noise coupled into the oscillator circuit can result in the clock running fast. Figure 2 shows a typical PC board layout for isolation of the crystal and oscillator from noise..The encapsulated DIP modules are trimmed at the factory to an accuracy of 1 minute per month at +25C. 3.2.6 Power-Down/Power-Up Considerations The real-time clock continues to operate, and the RAM, time, calendar, and alarm memory locations remain nonvolatile regardless of the VCC input level. VBAT must remain within the minimum and maximum limits when VCC is not applied. When VCC is applied and exceeds VPF (power-fail trip point), the device becomes accessible after tRECif the oscillator is running and the oscillator countdown chain is not in reset (Register A). This time allows the system to stabilize after power is applied. If the oscillator is not enabled, the oscillator enable bit is enabled on power-up, and the device becomes immediately accessible.

26

3.3 CRYSTAL OSCILLATOR 3.3.1 Introduction: A crystal oscillator is an electronic circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency. This frequency is commonly used to keep track of time (as in quartz wristwatches), to provide a stable clock signal for digital integrated circuits, and to stabilize frequencies for radio transmitters/receivers. The frequency of oscillator here we are using is 20 M-Hz.

Figure 3.4: Quartz crystal in crystal oscillator.

Crystal oscillatorFigure 3.5:Crystal oscillator

27

3.4 RS 232/4853.4.1 Introduction RS232, RS422, RS423 and RS485 are serial communication methods for computers and devices. RS232 is without doubt the best known interface, because this serial interface is implemented on almost all computers available today. But some of the other interfaces are certainly interesting because they can be used in situations where RS232 is not appropriate. So we also use the RS485 interface.

3.5 AC voltage stabilizersA voltage stabilizer is a type of household mains regulator which uses a continuously variable autotransformer to maintain an AC output that is as close to the standard or normal mains voltage as possible, under conditions of fluctuation. It uses a servomechanism (or negative feedback) to control the position of the tap (or wiper) of the autotransformer, usually with a motor. An increase in the mains voltage causes the output to increase, which in turn causes the tap (or wiper) to move in the direction that reduces the output towards the nominal voltage. 3.6 SWITCH An electrical switch is any device used to interrupt the flow of electrons in a circuit. Switches are essentially binary devices: they are either completely on ("closed") or completely off ("open"). A switch is a mechanical device used to connect and disconnect a circuit at will. Switches cover a wide range of types, from subminiature up to industrial plant switching megawatts of power on high voltage distribution lines. In applications where multiple switching options are required e.g., a telephone service, mechanical switches have long been replaced by electronic switching devices which can be automated and intelligently controlled. The prototypical model is perhaps a mechanical device for example a railroad switch which can be disconnected from one course and connected to another. The switch is referred to as a "gate" when abstracted to mathematical form. In the philosophy of logic, operational arguments are represented as logic gates. The use of electronic gates to function as a system of logical gates is the 28

fundamental basis for the computer i.e. a computer is a system of electronic switches which function as logical gates.The type of switches used here are toggle switches.

Toggle switches are actuated by a lever angled in one of two or more positions. The common light switch used in household wiring is an example of a toggle switch.

3.7 RELAYSA relay is an electrical switch that opens and closes under the 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 to be, in a broad sense, a form of an electrical amplifier. 3.7.1 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 approximately 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. Most 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.

29

Figure 3.6: 4 Lead relay 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. Some automotive relays already include that diode inside the relay case. Alternatively a contact protection network, consisting of a capacitor and resistor in series, may absorb the surge. 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. The diagram below center shows the relay at rest, with the coil not energized. The diagram below right shows the relay with the coil energized. The coil is an electromagnet that causes the arm that is always connected to the common (30) to pivot when energized whereby contact is broken from the normally closed terminal normally open terminal. When energizing the coil of a relay, polarity of the coil does not matter unless there is a diode across the coil. If a diode is not present, you may attach positive voltage to either terminal of the coil and negative voltage to the other, otherwise you must connect positive to the side of the coil that the cathode side (side with stripe) of the diode is connected and negative to side of the coil that the anode side of the diode is connected. and made with the

30

Figure 3.7: Relays Diodes are most often used across the coil to provide a path for current when the current path to the relay is interrupted (i.e. switched off, coil no longer energized). This allows the coil field to collapse without the voltage spike that would otherwise be generated. The diode protects switch or relay contacts and other circuits that may be sensitive to voltage spikes.

3.8 TRANSISTOR :

Figure 3.8:Trasistor The generic transistor is called a bipolar junction transistor and is formed by two p-n junctions formed with the same substrate material, indicated by the middle letter in pnp or npn transistors. The transistor acts as a current amplifier, having many applications for amplification and switching.

3.9 ACTIVE AND PASSIVE COMPONENTS :31

Active components are those which can act as source of power in a circuit. These components are used to supply the required amounts of power in a circuit. Active components are those that have gain or directionality, in contrast to passive components, which have neither. Passive components are those which cannot supply any power but may store the energy in different forms. Passive components are those that do not have gain or directionality. Eg: Resistors, Capacitors, Inductors etc,. 3.9.1 Resistor A resistor is a two-terminal electrical or electronic component that opposes an electric current by producing a voltage drop between its terminals in proportion to the current, that is, in accordance with Ohm's law: V = IR. The electrical resistance R is equal to the voltage drop V across the resistor divided by the current I through the resistor. Resistors are used as part of electrical networks and electronic circuits. 3.9.2 Capacitor A capacitor is an electrical/electronic device that can store energy in the electric field between a pair of conductors (called "plates"). The process of storing energy in the capacitor is known as "charging", and involves electric charges of equal magnitude, but opposite polarity, building up on each plate. 3.9.3 Inductor An inductor is a passive electrical device employed in electrical circuits for its property of inductance. An inductor can take many forms. Inductance (L, measured in henrys) is an effect which results from the magnetic field that forms around a current-carrying conductor. Electric current through the conductor creates a magnetic flux proportional to the current. A change in this current creates a change in magnetic flux that, in turn, generates an electromotive force (EMF) that acts to oppose this change in current.

32

Figure 3.9:Passive components

3.10 PRINTED CIRCUIT BOARDPrinted citcuit boards may be covered in two topics namely 1) Technology 2) Design 3.10.1 Introduction to printed circuit boards It is called PCB in short, printed circuit consists of conductive circuit pattern appied to one or both sides of an insulating base,depending upon that,it is called single sided PCB or double sided PCB,SB and DSB). Conductor materials available are silver, brass,aluminium and copper. Copper is most widely used. The thickness of conducting material depends upon the current carrying capacity of circuit. Thus a thicker copper layer will have more current carrying capacity. The printed circuit boards usually serves three distinct functions. It provides mechanical support for the components mounted on it. It provides necessary electrical interconnections. It acts as heat sink that is provides a conduction path leading to removal of the heat generated in the circuit. 3.10.2 Advantages of PCB 33

When a number of identical assemblies are required . PCBs provide cost saving because once a layout is approved there is no need to check the circuit every time.For large equipments such as computers, the saving on checking connections or wires is substantial. PCBs have controllable and predictable electrical and mechanical properties. A more uniform product is produced because wiring errors are eliminated. The distributed capacitances are constant from one production to another. Soldering is done in one operation instead of connecting discrete components by wires. The PCB construction lands itself for automatic assembly. Spiral type of inductors may be printed. Weight is less. It has miniaturization potential. It has reproducible performance.

All the signals are accessible for testing at any point along conductor track.

3.10.3 Classifications of laminates 34

Laminates

Paper base lamination

glass base lamination

There materials are built from several layers of paper or glass which are bound together under heat and pressure to form rigid sheets. The binder is usually a phenolic resin in the case of glass base. The copper layer is formed on either side or two sides of the laminate. Because of the different filters and binding resins the characteristic properties of copper clad laminates change. The rigid sheets of filters which form reinforcement use paper in the form of alpha

cellulose, craft or rags. These are cheaper and have easy machinbillity. Glass filter uses glass fibers which are woven to give cloth like appearance. This gives a high mechanical strength, they are better moisture resistant than above type. Binding resins are either phenolic or epoxy as mentioned before in addition to these, phenol formaldehyde and polyesters are also used. Of electrical and mechnical properties. 3.10.4 Manufacture of cu clad laminate The base of laminate is either paper or glass fiber cloth, as mentioned before. The copper foil is produced by electroplating a thin layer of copper on a large rotating drum of stainless steel. As the drum runs the deposited copper layer is peeled off and forms a continuous length which is coiled into rolls for use. To ensure good adhesion between copper foils and base material, surface of copper on the laminate and both are kept under hydraulic press for proper adhesion. Types of laminates these, Epoxy resin has good

35

National electrical manufactures association (NEMA) has various grades of laminates that are obtained by different resins and filters. (1) phenolic Phenol and formaldehyde produce phenolic paper base laminate has phenolic resins with proper filter. The colour of this base material is usually brown and it is opaque. Certain additivies and the grid is called FR grade. Disadvantages (1) they are attacked by alkalis (2) they have poor are resistance. (3) moisture resistant property is poor than other laminates. (2) epoxy laminates They can be divided into (a) epoxy glass (b) epoxy paper Epoxy paper : this is also paper base is impregnated with epoxy resin. The colour is yellowish white and it is translucent. Epoxy glass: this base material is more expensive but is combines relative strength and good is mainly because of glass fiber . the colour of this material is usually green and it is semitransparent. Properties of epoxy laminates (a) They are tougher than phenolic and polyesters. (b) Chemical nature of epoxies gives good adhesion. (c) They have better mechanical strength as mentioned before due to low shrinkage. (d) They have high alkali resistance. (e) They exhibit good electrical properties over different temperature. 36

(f) They are moisture resistant. (3) polyster laminates They are mostly used with glass fiber. Their water resistance is good. (4) diallylphthalate laminate These are mostly used with glass fiber. Their maximum temperature limit is 165C. (5) PTEF laminate Advantages (a)It has low dissipation factor over wide rang of temperature, humidity and frequency rang. (b) Electric strength is high. (c) High insulation resistance. (6) Melamine laminates This is normally used with glass. It has high are resistance. (7) Silicon laminates They have good heat resistance and good electrical properties. However their mechanical properties are not good. (8) polyamide laminates This is the best polymer for heat resistance. When used with glass this gives good mechanical properties. They have better adhesion to copper. Normally used for military and space applications.

There are a number of specifications that are applicable to copper clad laminated e.g.

37

DIN is use for German standard. IS is used for join Indian standard. JSS is used for join services specifications (ministry of defense) MIL is used for military standard (U.S.A) NEMA National Electrical Manufactures Association. By these standards, following parameters are checked: (1) Pull off strength (2) Surface resistivity (3) Permittivity and resistance (4) Temperature resistance (5) Blistering after heat shock. Before any pattern is transferred the copper surface is cleaned. Oxides, hydroxides and salts normally treated as contaminants on copper surface. Wet brushing is used after scrubbing. Acid dip may also used. 3.10.5 Manufacturing process of PCB The conductor pattern which is on the master film is transferred on copper clad laminate by two methods. (1) photoresist printing (2) screen printing

1.Photoresist printing 38

Photopolymer resist is a light sensitive organic material like KPR (Kodak photo resist ) which is applied to the board as a film. The photoresist when exposed ultraviolet light hardens ore polymerizes. Once it is polymerized, it becomes insoluble to certain chemical solvents known as developers. The developer dissolves the portion which is masked or which is not exposed to light. Thus the pattern that is to be drawn on PCB is derived from the artwork ,which is a photographical process. This is transferred to a master film on 1:1 scale . This can be reduced to any small size thus miniaturization is possible. The pattern is transferred to a mask. This mask is kept on PCB. The whole process is known as image transfer. Now it is subjected to UV rays. The unpolymerized or masked portion is washed away in developer leaving wanted copper pattern on board. KPR or photoresist is then removed. Requirements of photoresist (1) it should have good resolution and light sensitivity. (2) it should be resistant to developers which are used to remove unwanted copper. (3) it should have good possibility to strip after unwanted copper is removed. (4) its cost must be less. Photoresist is normally applied by (1) flow coating or (2) roller coating or (3) dip coating or (4) spraying coating or (5) whirl coating. The light sources that are used for exposure are 39

(1) mercury vapour lamps (2) pulsed xenon lamps (3) UV fluorescent tubes (4) carbon are lamps.

2.Screen printingThis technique is similar to the used in printing industry.the copper foil is covered with printing ink where the conduction paths are going to be. The screen which is used for pattern is of either stainless steel or polyester mesh which is dimensionally accurate and fine mesh. The open meshes of screen correspond to the pattern. PCB is placed under the screen. Printing ink is placed at one end of the screen,and by means of a rubber of a squeegee it is pushed through open meshes.printed circuit board is then removed for drying. After drying board is washed in ferric chloride which acts as etchant. etching is a chemical process by which unwanted copper is removed. The portion which is covered by ink is not removed, that is the pattern remains intact.later ink stripping is done with tricholoroethylene. Requirements of inks (1) the ink should dry rapidly on PCB. (2) it should be resistant to chemicals. (3) it should have the possibility of easy stripping. After deposition of ink it spreads slightly under the mesh and shows a trapezoidal shape. The printing ink should not be too thin thick to get proper pattern on the board.

40

The time or exposure to light depends upon the properties of ink, distance of board from light source and humidity also. Screen printing can be done mechanically also. The screen cleaning is done from the side on which ink was applied. The cleaning solution is normally a thinner or a solvent.

Protection of copper tracks Copper when exposed to atmosphere for a long time gets tarnished and problems are

created while soldering. The tracks can be protected by applying lacquer or varnishes. However solderability again depends on the lacquer or varnish properties, the thickness of these coatings. Copper is also protected by plating. There are three methods of plating (1) immersion plating (2) electronics plating (3) electroplating (1) Immersion plating utilizes tin and its alloys and good. It is done by chemical replacement from coating material salt solution. This method is simple and less costly. (2) In electronics copper plating , electric current is not used instead from its ionic state. (3) In electroplating a d.c . current is passed between two electrodes and a thin coating is deposited on cathode when immersed in electrolyte. a chemical

reducing agent is used which supplies electrons for reaction in which copper is reduced

41

Etching:Removal of unwanted copper, to give final copper pattern is known as etching. Solution which are used in etching are known as etchants. (1) Ferric chloride (2) cupric chloride (3) chromic acid (4) Alkaline ammonia Of these ferric chloride is widely used because it has short etching time and it can be stored for a longer time rinsing follows etching.

3.10.5 Solders and Soldering Techniques: Solders are special alloys which are used to get either a mechanically strong joint or electric joint of low contact resistance. Solders have low melting points compared to meals to be joined. Therefore when solder is heated, molten solder wets the metal, spreads and joins. Any contamination on the surface of the metal to be joined acts as a barrier and hampers as action of wetting. Solders are divided into two groups, soft and hard. Soft solders have lower melting point and lower tensile strength.soft solders are largely tin lead alloys with 18%to 19% of tin. Hard solders are copper zinc alloys and silver base compostions.fluxs are auxiliary materials used while soldering is done . (1) they dissolve and remove oxides and contaminants from surface of metals to be soldered. (2) they protect the metal surface and molten solder from oxidation 42

(3) they reduce the surface tension of molten solder. (4) they improve the ability of solder to wet the metal.

Fluxes are divided into four types.

(a) Active or acid fluxes:These are corrosive fluxes which use hydrochloric acid, chlorides and fluorides of metals.these are the best fluxes to dissolve oxide film on the metal surface but because of their corrosive nature, the residue must be thoroughly removed after soldering.

(b) Acid free fluxes:These are rosin base materials with addition of glycerine and alcohol.

(c) Activated fluxes:These are rosin base fluxes with activating agents like hydrochlorides and

phosphates of aniline,salicylic acid in small amount.

(d) Corrosion resistant fluxes:These fluxes are based on phosphoric acid with addition of various organic compositions and solvents. Soldering is done with either (1) soldering iron (manually) (2)mass soldering Soldering iron consist of a bit usally made of copper and an insulated handle connected to the bit with a metal shank. The bit is heated which melts solders along with flux to make a joint. 43

Soldering irons of different wattages are available for different kinds of work. Mass soldering is done in factories or electronic industries where the whole PCB assembly can be soldered from one side where the component leads come out. (1) Dip soldering PCB assembly is lowered vertically in the solder bath as shown in fig so that one side makes contact with solder. (2) Drag soldering PCB is dragged on the surface of solder bath. (3) Wave soldering In this, instead of lowering the board, a small solder wave is created in the solder bath by pumping out solder through a narrow slot and PCB side is soldered Since in mass soldering of PCBs a large number of joints are to be soldered together following points must be borne in mind. (1)There should not be different in metal leads that are to be joined (2) The surface should be clean. (3) Physical shapes of the joints must be compartable. (4) PCB must be preheated (5) All the wire leads must be of same length under the board. 3.10.7 Component mounting on PCB Careful mounting of components on PCB increases the reliability of assembly. (1) component leads must be cleaned before they are inserted in PCB holes. Asymmetric lead bending ,too close lead bending must be avoided. The bent leads must fit into holes properly so that they can be soldered.

44

(2) when the space is to be saved then vertical mounting is preferred. The vertical lead must have an insulating sleeve. (3) where jumper wire cross over conductors, they must be insulated. (4) for mounting of ICS, TOS, DIP packages, special jigs must be used for easy insertion. (5) while mounting transistors, each lead must has insulating sleeve, all the leads must be cut with sharp cutter to same lengths seen from the surface that is to be soldered.

Designing of PCBLayout and artwork are the most important aspects of designing of PCB Artwork is normally produced at 1:1 or 2:1 scale. Grid system is also used when drilling of holes for components while preparing layout, bishop graphics inc. puppets or replica of components or IC holders are used. There are certain standard norms that are to be followed while preparing layout or network. Component code is also to be standardized. ANSI or American national standard institute recommends.

45

4. CIRCUIT LAYOUT4.1 CIRCUIT DESCRIPTIONCircuit diagram consists of following blocks. 1. Power supply 2. Controller circuit 4.1.1. POWER SUPPLY

Basic Power Supply Description:Block Diagram:

Figure 4.1:Block diagram of power supply

46

Transformers

Figure 4.2:Transformer circuit A transformer is a device that transfers electrical energy from one circuit to another through inductively coupled electrical conductors. A changing current in the first circuit (the primary) creates a changing magnetic field; in turn, this magnetic field induces a changing voltage in the second circuit (the secondary). By adding a load to the secondary circuit, one can make current flow in the transformer, thus transferring energy from one circuit to the other. The secondary induced voltage VS, of an ideal transformer, is scaled from the primary VP by a factor equal to the ratio of the number of turns of wire in their respective windings:

By appropriate selection of the numbers of turns, a transformer thus allows an alternating voltage to be stepped up by making NS more than NP or stepped down, by making it less.

47

STEP-DOWN TRANSFORMERS:

A Step-down transformer is one whose secondary voltage is less than its primary voltage. The step down transformer is designed to reduce the voltage from the primary winding to the secondary winding. This kind of transformer "step down" the voltage applied to it. They often range in voltage sizes from 0.5 kva to 500 kva. There are many uses for step-down transformer and the larger devices are used in electric power systems, and small units in electronic devices. Industrial and residential power transformers that operate at the line frequency (60 Hz in the U.S.), may be single phase or three-phase, are designed to handle high voltages and currents. Efficient power transmission requires a step-up transformer at the power-generating station to raise voltages, with a corresponding decrease in current. Line power losses are proportional to the square of the current times the resistance of the power line, so that very high voltages and low currents are used for long-distance transmission lines to reduce losses. At the receiving end, step-down transformers reduce the voltage, and increase the current, to the residential or industrial voltage levels, usually 115 to 600 V. In electronic equipment, transformers with capacities in the order of 1 kw are largely used ahead of a rectifier, which in turn supplies direct current (DC) to the equipment. Such electronic power transformers are usually made of stacks of steel alloy sheets, called laminations, on which copper wire coils are wound. Transformers in the 1-to100W power level are used principally as step-down transformers to couple electronic circuits to loudspeakers in radios, television sets, and high-fidelity equipment Working principle of a step-down transformer A transformer is a electrical device with one winding of wire placed close to one or more other windings, used to couple two or more alternating-current circuits together by employing the induction between the windings. A transformer in which the secondary 48

voltage is higher than the primary is called a step-up transformer, if the secondary voltage is less than the primary, then its a step-down transformer. The product of current times voltage is constant in each set of windings, so that in a step-up transformer, the voltage increase in the secondary is accompanied by a corresponding decrease in the current. Factors in choosing a step-down transformer Transformers must be efficient and should dissipate as little power as possible in the form of heat during the transformation process. Efficiencies are normally above 99 percent and are obtained by using special steel alloys to couple the induced magnetic fields between the primary and secondary windings. To increase transformer efficiency and reducing heat one of the most important considerations is choosing the metal type of the windings. Copper windings are more efficient than aluminum and other winding metal choices. Transformers with copper windings cost more initially, but can save on electrical cost and maintenance over time and more than makes up for the initial cost. The dissipation of even 0.5 percent on the power transmitted in a large transformer generates a large amount of heat, which requires special cooling. Typical power transformers are installed in sealed containers that have oil or another substance circulating through the windings to transfer the heat to external radiator-like surfaces, where it can be discharged to the surroundings. Information on a typical step-down transformer A transformer is a device for stepping-up or stepping-down electric signal. Without efficient transformers, the transmission and distribution of ac electric power over long distances would be impossible. Typical transformer There are two circuits; the primary circuit, and the secondary circuit. There is no direct electrical connection between the two circuits, but each circuit contains a winding which links it inductively to the other circuit. In transformers, the two windings are wound onto the same iron core. The purpose of the iron core is to channel the magnetic flux generated by the current flowing around the primary windings, so that as much of it as possible also 49

links the secondary winding. The common magnetic flux linking the two windings is conventionally denoted in circuit diagrams by a number of parallel straight lines drawn between the windings. In other words, the ratio of the peak voltages and peak currents in the primary and secondary circuits is determined by the ratio of the number of turns in the primary and secondary windings; this latter ratio is usually called the turns ratio of the transformer. If the secondary winding contains more turns than the primary winding then the peak voltage in the secondary circuit exceeds that in the primary circuit. This type of transformer is called a step-up transformer, because it steps up the voltage of an ac signal. Note that the peak current in the secondary circuit is less than the peak current in the primary circuit in a step-up transformer (as must be the case if energy is to be conserved). Thus, a step-up transformer actually steps down the current. Likewise, if the secondary winding contains less turns than the primary winding then the peak voltage in the secondary circuit is less than that in the primary circuit. This type of transformer is called a step-down transformer. Note that a step-down transformer actually steps up the current (i.e., the peak current in the secondary circuit exceeds that in the primary circuit). The use of step-up and step-down transformers in power distribution stations: Electricity is generated in power stations at a fairly low peak voltage (sometime like 440V), and is consumed at a peak voltage of 110V to 220V for households and businesses in the U.S. AC electricity is transmitted from the power station to the location where it is consumed at a very high peak voltage (typically 50,000V). As soon as a ac signal comes out of the generator in a power station it is fed into a step-up transformer and fed into a high tension transmission line, and transports the electricity over many miles, and once the electricity has reached its point of consumption, it is fed through a series of step-down transformers until its peak voltage is often reduced down to 110V. If Electricity is both generated and consumed at low peak voltages, why go to the trouble of stepping up the peak voltage to a very high value at the power station and then stepping down the voltage again once the electricity has reached its point of consummation? Why not generate, transmit, and distribute the electricity at a voltage of 110V? Consider an electric power line which transmits a peak electric power between a 50

power station and a city. We can think of the number of consumers in the city and the nature of the electrical devices which they operate, as essentially a fixed number. Suppose that the peak voltage and peak current of the ac signal are transmitted along the line. We can think of these numbers as being variable, since we can change them using a transformer. However, since, the product of the peak voltage and the peak current must remain constant. The resistance of the line causes power loses that are greater at lower voltages over distance. The peak rate at which electrical energy is lost due to ohmic heating in the line is high. If the power transmitted down the line is a fixed quantity, as is the resistance of the line, then the power lost in the line due to ohmic heating varies like the inverse square of the peak voltage in the line. It turns out that even at very high voltages, such as 50,000 V, the ohmic power losses in transmission lines which run over ten kilometers can amount to up to 20% of the transmitted power. It can readily be appreciated that if an attempt were made to transmit ac electric power at a peak voltage of 110V then the ohmic losses would be so severe that virtually none of the power would reach it destination. It is only possible to generate electric power at a central location, transmit it over large distances, and then distribute it at its point of consumption, if the transmission is performed at a very high peak voltage (the higher, the better). Transformers play a vital role in this process because they allow us to step-up and step-down the voltage of an ac electric signal very efficiently A well designed transformer typically has a power loss which is only a few percent of the total power flowing through it. Rectifiers Rectifier is defined as an electronic device used for converting a.c. voltage into unidirectional voltage. A rectifier utilizes unidirectional conducting device like a vacuum diode or PN junction diode. Rectifiers are classified depending upon the period of conduction as Half-wave rectifier and Full-wave rectifier.

51

Here in our circuit we use the most popular full-wave rectifier design , which is built around a four-diode bridge configuration. So for this obvious reasons, this design is called a full-wave bridge. (Figure below)

Figure 4.3: Full-wave bridge rectifier. Current directions for the full-wave bridge rectifier circuit are as shown in Figure below for positive half-cycle and Figure below for negative half-cycles of the AC source waveform. Note that regardless of the polarity of the input, the current flows in the same direction through the load. That is, the negative half-cycle of source is a positive halfcycle at the load. The current flow is through two diodes in series for both polarities. Thus, two diode drops of the source voltage are lost (0.72=1.4 V for Si) in the diodes. This is a disadvantage compared with a full-wave center-tap design. This disadvantage is only a problem in very low voltage power supplies. IC Voltage Regulators Voltage regulators comprise a class of widely used ICs. Regulator IC units contain the circuitry for reference source, comparator amplifier, control device, and overload protection all in a single IC. Although the internal construction of the IC is somewhat different from that described for discrete voltage regulator circuits, the external operation is much the same. IC units provide regulation of either a fixed positive voltage, a fixed negative voltage, or an adjustably set voltage. A power supply can be built using a transformer connected to the ac supply line to step the ac voltage to desired amplitude, then rectifying that ac voltage, filtering with a 52

capacitor and RC filter, if desired, and finally regulating the dc voltage using an IC regulator. The regulators can be selected for operation with load currents from hundreds of mill amperes to tens of amperes, corresponding to power ratings from mill watts to tens of watts. Three-Terminal Voltage Regulators IN OUTVin C1

78XXC2

Vout

GND Figure 4.4: Fixed Positive Voltage Regulators: Fig shows the basic connection of a three-terminal voltage regulator IC to a load. The fixed voltage regulator has an unregulated dc input voltage, Vi, applied to one input terminal, a regulated output dc voltage, Vo, from a second terminal, with the third terminal connected to ground. While the input voltage may vary over some permissible voltage range, and the output load may vary over some acceptable range, the output voltage remains constant within specified voltage variation limits. A table of positive voltage regulated ICs is provided in table. For a selected regulator, IC device specifications list a voltage range over which the input voltage can vary to maintain a regulated output voltage over a range of load current. The specifications also list the amount of output voltage change resulting from a change in load current (load regulation) or in input voltage (line regulation).

53

IC No.

Output voltage(v)

Maximum input voltage(v)

7805 7806 7808 7810 7812 7815 7818 7824

+5 +6 +8 +10 +12 +15 +18 +24 40V 35V

Table 4.1 Positive Voltage Regulators in 7800 series

54

4.1.2 Controller circuit:

Fig:4.5: controller circuit The working of circuit is as follows: Initially the 230V ac supply is sent to the step down transformer and the voltage level gets reduced to the order of 19V.Then this 19V AC is converted to unidirectional DC voltage using a rectifier circuit. This is then regulated by using a series of voltage

55

regulators to obtain 18V, 12V and finally 5V DC voltage. These voltages are used to drive various components in the circuit like PIC microcontroller, LCD and Relays. The finally regulated voltage of 5V is sufficient for the pic microcontroller to get activated. RTC and LCD are interfaced to Pic microcontroller by using some pull up resistors. The timing data is entered into the micro controller through a series of toggle switches, S2, S3, S4 and S5. This is sent to the RTC and LCD using the same multiplexed address -data bus. The RTC and LCD are enabled using the control pins of the pic microcontroller. When the set time of the PIC microcontroller matches with that of the RTC, the microcontroller sends a signal and activates one of its pin which is in turn connected to a relay, through a series of buffers. This relay is further connected to a contactor, in the power saver, which controls the power supply to the street lights. In this way the street light automation system works based on the timings set by the user. Here actually street lights are switched on for the 230V power but according to application the usage of power can be reduced using a saver and super saver modes. This can be obtained by switching the relays not only for 230V but also for 220V and 190V and thus the power can be saved. When the set time of PIC microcontroller matches with that of RTC, the microcontroller sends signal to the relay using a transistor where the relay can operate for 220/190V according to the type of mode selected i.e saver mode or super saver mode. For the SUPER SAVER mode to get activated a minimum of 15 minutes is required between the switching times of saver mode and the super saver mode, this time is required for full charging of capacitor.

56

4.2 MODES AND PRINCIPLE OF OPERATIONSThere are two modes of operations

Auto Mode Manual ModeIn Auto mode the microcontroller is controlled according to the program dumped on it and the timings cannot be changed, whereas, in the Manual mode the microcontroller is programmed according to the user. Here, we can change each and every parameter to get the user defined output. In the system, a toggle switch is provided for selecting manual/auto function mode. The working principle is as follows: Initially when the circuit is switched ON the default setting is the Manual mode, where, a cursor is blinked on the lcd screen as an indication to the user. Now, the user can change each and every parameter accordingly. Here, in Manual mode the time function is divided into 24 time zones per year i.e. in one month, for 15 days there will be one ON time/one OFF time and for remaining 15 days there will be different ON/OFF times. By the above logic, we can change the complete date (day, month, year) and ON/OFF timings. The basic operation of Street Light Automation System (SLAS) is programmed to switch ON in the evening and switch OFF in the morning. In Auto mode the ON time is 6.00 PM and OFF time is 6.00 AM whereas in Manual mode the ON/OFF timings are changed according to the user. For example, if a user enters the ON time as 5.30 PM then the ON time will be same for the first 15 days of the month and will be different for the next 15 days. The two different ON/OFF timings for one month can be entered in the menu provided.

57

5. IMPLEMENTATION OF SOFTWARE5.1FLOW CHART:Start

Set time ,date saver on,off and super saver on,off times

Read RTC time ( r ) yes no

If ( r =saver on time)

Switch the relay on Operate power saver 220v

If (saver off time>super saver on time; super saver on time-saver on time >=15) yes Operate power saver at 190-220v

no

no If (Super saver off time= r) yes

end

58

6. RESULTS AND CONCLUSIONThis process saves the power of about 40% when a 15KVA power saved is used. With the introduction of a microcontroller, automation of a Street Light Automation System is tested.The project has been successfully designed and tested. It has been developed by integrating features of all the hardware components used. Presence of every module has been reasoned out and placed carefully thus contributing to the best working of the unit. Secondly, using highly advanced ICs and with the help of growing technology the project has been successfully implemented.

Future Scope:By using RTC we can update data, time. At what time device has been operated.

59

REFERENCESwww.alldatasheets.com www.electronicsforu.com www.microchip.com/mplab

60

APPENDIX A

CCS C Compiler (pcm).

The CCS C Compiler was developed exclusively for the PIC MCU - making it the most optimized compiler for Microchip parts. The compiler has a generous library of built-in functions, preprocessor commands, and ready-to-run example programs to quickly jumpstart any project. Drivers for real-time clocks, LCDs, A/D converters, and many more are innate features to the CCS C Compiler. The 24-bit compiler - PCD makes for easy migration from 8-bit processors up to 24-bit processors with minimal user interaction. PCD has a generous CCS math function library, Flash access functions and the full range of common built-in functions and preprocessor commands that emphasize the need for a C compiler.

Compiler Features OverviewThe compiler contains Standard C operators and built-in libraries that are specific to the PIC registers. Access to hardware features from C. Features include:

1, 8, 16 and 32 bit integer types and 32 bit floating point. Standard one bit type (Short Int) permits the compiler to generate very efficient Bit oriented code. #BIT and #BYTE will allow C variables to be placed at absolute addresses to map registers to C variables. Bit Arrays Fixed Point Decimal Constants (including strings and arrays) are saved in program memory. Flexible Handling Of Constant Data 61

Variable Length Constant Strings Address mode Capability To Create User Defined Address Spaces In Memory Device

The CCS C Compiler for PIC10, PIC12, PIC14, PIC16, and PIC18 microcontrollers has over 180 Built-in Functions to access PIC MCU hardware is easy and produces efficient and highly optimized code. Functions such as timers, A/D, EEPROM, SSP, PSP, USB, I2C and more:

Built-in libraries that work with all chips for RS-232 serial I/O, I2C, discrete I/O and precision delays. Serial I/O functions allow standard functions such as GETC() and PRINTF() to be used for RS-232 like I/O. Formatted printf allows easy formatting and display in HEX or decimal. Multiple I2C and RS232 ports may be easily defined. #use rs232() offers options to specify a maximum wait time for getc. Hardware transceiver used when possible, but for all other occasions the compiler generates a software serial transceiver. Microcontroller clock speed may be specified in a PRAGMA to permit built-in functions to delay for a given number of microseconds or milliseconds. Functions such as INPUT() and OUTPUT_HIGH() properly maintain the tri-state registers. Compiler directives determine if tri-state registers are refreshed on every I/O or if the I/O is as fast as possible. #USE SPI () Simple functions like READ_ADC() to read a value from A/D converter. Source code drivers included for LCD modules, keypads, 24xx and 94xx serial EEPROM, X10, DS1302 and NJU6355 real time clocks, Dallas touch memory devices, DS2223 and PCF8570, LTC1298 and PCF8591 A/D converters, temperature sensors, digital pots, I/O expander and much more.

100+ ready-to-run programs included.

62

The compiler can handle inline or separate functions, as well as parameter passing in reusable registers. Transparent to the user, the compiler handles calls across pages automatically and analyzes program structure and call tree processes to optimize RAM and ROM Usage. Additional features include:

Efficient function implementation allows call trees deeper than the hardware stack. Automatic linking handles multiple code pages. Assembly code may be inserted anywhere in the source and may reference C variables. Function Overloading allows for several functions with the same name, but differences in number and type of parameters.

Default Parameters can be used in a function if arguments are not used in a call. Interrupt functions supported on PCM/PCH. The compiler generates all startup and clean up code as well as identifying the correct interrupt function to be called. Reference parameters may be used to improve code readability and inline function efficiency. Generation Of Multiple HEX Files For Chips With External Memory Variable Number Of Parameters in a function. Relocatable Objects / Multiple Compilation Unit (IDE Only) Automatic #fuses Configuration

The compiler runs under Windows 95, 98, ME, NT4, 2000, XP, Vista, or Linux. It outputs hex and debug files that are selectable and compatible with popular emulators and programmers including the MPLAB IDE for source level debugging.

Updates via the Internet for 30 days included. CCS Backwards Compatibility

63

64