automatic solar led street light automation by using rtc and i2c protocols doccument
TRANSCRIPT
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 1
CHAPTER-1
INTRODUCTION
INTRODUCTION
From olden days we are using non renewable sources of energy in excess mount for
our needs. As this type of minerals like coal etc are exhausting so we have to depend on the
renewable sources of energy like solar, wind, etc. For smaller application it is better to use
renewable energy. As this project is based on streetlight automation and required AC
supply. So for this particular application we are using solar panels to charge the DC battery
and the power from the battery can be used for this application. Advertising hoardings,
commercial sign boards, and street lights are generally switched on at 6:30 pm and
switched off at 10:00 am because nobody is available at the place in the morning to switch
it off. But actual required time is 6:30pm to 11:30pm and 4:30am to 6:30am. Meantime
i.e., from 11:30pm to 4:30am is not required, because the public flow on the roads is
almost nil in this time. And from 6:30am to 10:00am is also not required as the sun light is
available during this time. That means every day around nine hours of power is wasted.
This project gives the best solution for electrical energy wastage. Also the manual
operation of the lighting system is completely eliminated. The Project AT89S52
Microcontroller Based Energy saver for Commercial Lighting system with RTC DS1307
Interfacing is an interesting project which uses AT89S52 microcontroller as its brain. This
project is very useful for commercial sign boards, advertising boards, street lights for
automation lighting system. This system switches on the lights only at preprogrammed
timings. As the DS1307 Real Time Clock chip with battery back-up is used, there will be
no disturbances for the programmed on/off timings even in power failures. Control switch
set is provided for entering the required timings. 4-digit seven segment display is provided
to display the alarm times and current time. DS1307 is interfaced to the microcontroller for
real timing performance. A 3V battery can be connected to DS1307 to avoid time
disturbances caused by power failures. AT89S52 has inbuilt flash EPROM. Data stored
remains in the memory even after power failure, as the memory ensures reading of the
latest saved settings by the micro controller. It can retain data for more than ten years.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 2
CHAPTER-2
EMBEDDED SYSTEMS
2.1 Embedded System Introduction
An Embedded System is a combination of computer hardware and software, and
perhaps additional mechanical or other parts, designed to perform a specific function. A
good example is the microwave oven. Almost every household has one, and tens of
millions of them are used every day, but very few people realize that a processor and
software are involved in the preparation of their lunch or dinner.
This is in direct contrast to the personal computer in the family room. It too is
comprised of computer hardware and software and mechanical components (disk drives,
for example). However, a personal computer is not designed to perform a specific function
rather; it is able to do many different things. Many people use the term general-purpose
computer to make this distinction clear. As shipped, a general-purpose computer is a blank
slate; the manufacturer does not know what the customer will do wish it. One customer
may use it for a network file server another may use it exclusively for playing games, and a
third may use it to write the next great American novel
If an embedded system is designed well, the existence of the processor and
software could be completely unnoticed by the user of the device. Such is the case for a
microwave oven, VCR, or alarm clock. In some cases, it would even be possible to build
an equivalent device that does not contain the processor and software. This could be done
by replacing the combination with a custom integrated circuit that performs the same
functions in hardware. However, a lot of flexibility is lost when a design is hard-cooled in
this way. It is mush easier, and cheaper, to change a few lines of software than to redesign
a piece of custom hardware.
2.2 History and Future
Given the definition of embedded systems earlier is this chapter; the first such
systems could not possibly have appeared before 1971. That was the year Intel introduced
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 3
the world's first microprocessor. This chip, the 4004, was designed for use in a line of
business calculators produced by the Japanese Company Busicom. In 1969, Busicom asked
Intel to design a set of custom integrated circuits-one for each of their new calculator
models. The 4004 was Intel's response rather than design custom hardware for each
calculator, Intel proposed a general-purpose circuit that could be used throughout the entire
line of calculators. Intel's idea was that the software would give each calculator its unique
set of features.
2.3 Tools
Embedded development makes up a small fraction of total programming. There's
also a large number of embedded architectures, unlike the PC world where 1 instruction set
rules, and the Unix world where there's only 3 or 4 major ones. This means that the tools
are more expensive. It also means that they're lower featured, and less developed. On a
major embedded project, at some point you will almost always find a compiler bug of
some sort.
Debugging tools are another issue. Since you can't always run general programs on
your embedded processor, you can't always run a debugger on it. This makes fixing your
program difficult. Special hardware
such as JTAG ports can overcome this issue in part. However, if you stop on a
breakpoint when your system is controlling real world hardware (such as a motor),
permanent equipment damage can occur. As a result, people doing embedded
programming quickly become masters at using serial IO channels and error message style
debugging.
2.4 Resources
To save costs, embedded systems frequently have the cheapest processors that can
do the job. This means your programs need to be written as efficiently as possible. When
dealing with large data sets, issues like memory cache misses that never matter in PC
programming can hurt you. Luckily, this won't happen too often- use reasonably efficient
algorithms to start, and optimize only when necessary. Of course, normal profilers won't
work well, due to the same reason debuggers don't work well. So more intuition and an
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 4
understanding of your software and hardware architecture is necessary to optimize
effectively.
Memory is also an issue. For the same cost savings reasons, embedded systems
usually have the least memory they can get away with. That means their algorithms must
be memory efficient (unlike in PC programs, you will frequently sacrifice processor time
for memory, rather than the reverse). It also means you can't afford to leak memory.
Embedded Application
2.5 Real Time Issues
Embedded systems frequently control hardware, and must be able to respond to them in
real time. Failure to do so could cause inaccuracy in measurements, or even damage
hardware such as motors. This is made even more difficult by the lack of resources
available. Almost all embedded systems need to be able to prioritize some tasks over
others, and to be able to put off/skip low priority tasks such as UI in favor of high priority
tasks like hardware control.
2.6 Characteristics
Embedded systems are designed to do some specific task, rather than be a general-
purpose computer for multiple tasks. Some also have real-time performance constraints
that must be met, for reasons such as safety and usability; others may have low or no
performance requirements, allowing the system hardware to be simplified to reduce costs.
Embedded systems are not always standalone devices. Many embedded systems
consist of small parts within a larger device that serves a more general purpose. For
example, the Gibson Robot Guitar features an embedded system for tuning the strings, but
the overall purpose of the Robot Guitar is, of course, to play music.[10] Similarly, an
embedded system in an automobile provides a specific function as a subsystem of the car
itself.
The program instructions written for embedded systems are referred to as firmware,
and are stored in read-only memory or Flash memory chips. They run with limited
computer hardware resources: little memory, small or non-existent keyboard or screen.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 5
2.7 Need For Embedded Systems
2.7.1 Debugging
Embedded debugging may be performed at different levels, depending on the facilities
available. From simplest to most sophisticated they can be roughly grouped into the
following areas:
1. Interactive resident debugging, using the simple shell provided by the embedded operating
system (e.g. Forth and Basic)
2. External debugging using logging or serial port output to trace operation using either a
monitor in flash or using a debug server like the Remedy Debugger which even works for
heterogeneous multicore systems.
3. An in-circuit debugger (ICD), a hardware device that connects to the microprocessor via
a JTAG or Nexus interface. This allows the operation of the microprocessor to be
controlled externally, but is typically restricted to specific debugging capabilities in the
processor.
4. An in-circuit emulator (ICE) replaces the microprocessor with a simulated equivalent,
providing full control over all aspects of the microprocessor.
5. A complete emulator provides a simulation of all aspects of the hardware, allowing all of it
to be controlled and modified, and allowing debugging on a normal PC. The downsides are
expense and slow operation, in some cases up to 100X slower than the final system.
6. For SoC designs, the typical approach is to verify and debug the design on an FPGA
prototype board. Tools such as Certus are used to insert probes in the FPGA RTL that
make signals available for observation. This is used to debug hardware, firmware and
software interactions across multiple FPGA with capabilities similar to a logic analyser.
Unless restricted to external debugging, the programmer can typically load and run
software through the tools, view the code running in the processor, and start or stop its
operation. The view of the code may be as HLL source-code, assembly code or mixture of
both.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 6
Because an embedded system is often composed of a wide variety of elements, the
debugging strategy may vary. For instance, debugging a software- (and microprocessor-)
centric embedded system is different from debugging an embedded system where most of
the processing is performed by peripherals (DSP, FPGA, co-processor). An increasing
number of embedded systems today use more than one single processor core. A common
problem with multi-core development is the proper synchronization of software execution.
In such a case, the embedded system design may wish to check the data traffic on the
busses between the processor cores, which requires very low-level debugging, at signal/bus
level, with a logic analyser.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 7
CHAPTER-3
BLOCK DIAGRAM
Figure 3.1 Block Diagram.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 8
3.1 BLOCK DIAGRAM DESCRIPTION
The solar energy is converted into electrical energy by photo-voltaic cells. This
energy is stored in batteries during the day time for it to be utilized to on the street light.
This project deals with a controlled charging mechanism with protections for over charge,
deep discharge and under voltage of the battery. It overcomes the difficulties of switching
the street light ON/OFF manually. This proposed system has an inbuilt real time clock
(RTC) to keep tracking the time and thus to switch ON/OFF the pump accordingly.
This project consisting of a real-time clock (RTC) is interfaced to a microcontroller
of the PIC series family. While the set time equals to the real time, then microcontroller
gives command to the corresponding relay to turn on the load, and then another command
to switch off as programmed by the user. Multiple on/off time entry is the biggest
advantage with this project. A matrix keypad helps entering different time slots. A LCD
display is interfaced to the microcontroller to display time. In this project, a solar panel is
used to charge a battery. A set of op-amps are used as comparators to continuously monitor
panel voltage, load current, etc. Indications are also provided by a green LED for fully
charged battery while a set of red LEDs to indicate under charged, overloaded and deep
discharge condition. Charge controller also uses MOSFET as power semiconductor switch
to ensure cutting of the load in low battery or overload condition. A transistor is used to
bypass the solar energy to a dummy load while the battery gets fully charged. This protects
the battery from getting over charged.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 9
CHAPTER-4
SCHEMATIC DIAGRAMS
Figure 4.1 Schematic Diagram-1.
4.1 Schematic Description-1
In this Solar Charging Circuit we are using SOLAR PANEL. Here we are using
MOSFET whose gate is connected to emitter of the transistor (BC547) drain is connected
to +VE terminal & source is connected to GND is parallel to MOSFET a battery of 12V is
connected collector of transistor is connected to +ve terminal with resistor R1 of 18K.
Whose base is connected to o/p of 1st op-amp (LM324) through resistor R3 of 100K. Pin
11 is connected to GND Pin 4 is connected to VCC for both op-amps’ known as U1: A &
U1B. 2nd Pin of U1:A is connected to Pin 1 of op-amp through two resistors R4 of 330K
R5 of 330k. Pin 3 and Pin 5 all shorted and connected to POT of 5K 6th Pin is connected to
GND through resistor R10 of 120K. And 7th Pin is o/p Pin with resistor R7 of 2K & LED.
VI:C is also an op-amp is whose 10th Pin is connected to POT of 5K whose one of the
terminal is also connected to 2nd Pin of U1:A where 9th Pin is connected to GND 4th & 11th
Pin are VCC and GND. Where 8th Pin is o/p Pin which is connected to Gate of MOSFET
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 10
Q2 through Diode IN4148 where 9th Pin is also connected to drain of MOSFET whose gate
is also connected to POT of RV1 who will get another o/p of U1:D known as Pin 14.
Whose 12th Pin is connected to RV5 22K PRESET 13th Pin is connected to 4diodes in
series known as D5, D6, D7,D8 source is connected to GND.
SCHEMATIC DIAGRAM
Figure 4.2 Schematic Diagram-2.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 11
.4.2 Schematic Description-2
The o/p of the power supply which is +5V is connected to 11th&32th Pin of
Microcontroller & 12th &31th is connected to ground operate in this project “auto” Here we
are using 3x4 keypad. Whose Pins are connected to Pin D4 to D7 Pin of PIC
Microcontroller and for display purpose we are using 16x2 LCD whose data Pins from 27
to 30 is connected to Pin 2.0 to 2.7 which belongs to Port 2 of Microcontroller where as
4,5,6 Pin of LCD is connected to 19th 21 & 22th Pin of PIC MC. Buzzer is connected to Pin
2.
Pin 23,18 of PIC Microcontroller is connected to 6 & 5 Pin of DS1307 IC which
provide (Real Time Signal) 1st and 2nd Pin is connected to crystal of 32.765Khz of
reference frequency 3rd is connected to GND through capacitor 8th is connected to Vcc and
4th is connected to GND.
Working
The project uses one RTC (Real Time Clock) for Real Time Reference duly interfaced to
Pin 18 & 23 of PIC Microcontroller. A Matrix Telephone keypad is used to enter multiple
Timings for multiple medicines as per the program displayed on the LCD. First we have to
enter /set the time for RTC. after that we have to set the medicine times. When the
programmed times of the clock reaches the set time and o/p is logic 1 at Pin No.2 to sound
a Buzzer which is amplified by Q1 to draw the attention of the person to view the name of
the medicine on the LCD for taking the same in right time. The ckt is powered by a battery
and a voltage regulator for desired voltage operations.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 12
CHAPTER-5
HARDWARE
5.1 COMPONENTS USED
1. MICROCONTROLLER PIC (16F877A)
2. SOLAR CELLS/SOLAR PANEL
3. BATTERY
4. KEYPAD
5. LCD
6. RTC
7. LM324
8. MOSFET
9. BC547
10. 1N4007 DIODE
11. RESISTORS
12. CAPACITORS
13. LED’S
14. PUSH BUTTON
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 13
5.2 MICROCONTROLLER- PIC16F877A
5.2.1 Micro Controller Core Features
1. High performance RISC CPU.
2. The instruction set has only 35 instructions.
3. Operating speed of DC-20MHz clock input.
4. Flash program memory of 8K x 14-bit words.
5. Data Memory (RAM) of 368 x 8 bytes.
6. EEPROM data memory of 258 x 8 bytes.
7. Power On reset (POR).
8. Power- up timer (PWRT).
9. Oscillator Start-up timer (OST).
10. Watchdog Timer (WDT) with its own On-chip RC oscillator for reliable operation.
11. Power saving SLEEP mode.
12. Low power, high speed CMOS FLASH/EEPROM technology.
13. In circuit serial programming (ICSP) via two pins.
14. Single 5V In-circuit Serial programming capability.
15. Wide operating voltage range: 2.0V to 5.5V.
16. Low power consumption.
17. High sink/source current: 25mA.
Peripheral Features
1. Timer0: 8-bit timer/counter with 8-bit pre scaler.
2. Timer1: 16-bit timer/counter with pre scaler, can be incremented during SLEEP via
external crystal/clock.
3. Timer2: 8-bit timer/counter with 8-bit period register, pre scaler and post scaler.
4. Two capture, compare, PWM modules.
- Capture is 16-bit, max. resolution is 12.5ns.
- Compare is 16-bit, max. resolution is 200ns.
- PWM max. resolution is 10-bit.
5. 10-bit multi- channel Analog-to-Digital converter.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 14
Synchronous serial port (SSP) with SPI™ (Master mode) and I2C™ (Master/Slave).
6. Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-
bit address detection.
7. Parallel slave port (PSP) 8-bits wide, with external Read, write and chip select
controls.
8. Brown out detection circuitry for brown out reset (BOR).
Analog Features
1. 10-bit, up to 8-channel Analog-to-Digital Converter (A/D)
2. Brown-out Reset (BOR)
3. Analog Comparator module with:
i) Two analog comparators.
ii) Programmable on-chip voltage reference (VREF) module.
iii) Programmable input multiplexing from device inputs and internal voltage reference.
iv) Comparator outputs are externally accessible.
High Performance RISC CPU
1. Only 35 single-word instructions.
2. All single-cycle instructions except for program branches, which are two cycle.
3. Operating speed: DC – 20 MHz clock input DC – 200 ns instruction cycle
4. 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.
5. Pin out compatible to other 28-pin or 40/44-pin, PIC16CXXX and PIC16FXXX
microcontrollers.
CMOS Technology
1. Low-power, high-speed Flash/EEPROM technology.
2. Fully static design.
3. Wide operating voltage range (2.0V to 5.5V).
4. Commercial and Industrial temperature ranges.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 15
5.2.2 Comparison Chart Of Different Pic Microcontrollers
Table 5.1 Comparison of Different microcontrollers.
Device
Program
Memory
Data
SRAM
(Bytes)
EEPR
OM
(Byte
s)
I/O
10-bit
A/D
(ch)
CCP
(PWM
)
MSSP USAR
T
Timers
8/16-
bit
Co
mpa
rato
rs
Bytes
Single
Word
Instructio
ns
SPI
Master I2C
PIC16F873
A
7.2K 4096 192 128 22 5 2 Yes Yes Yes 2/1 2
PIC16F874
A
7.2K 4096 192 128 33 8 2 Yes Yes Yes 2/1 2
PIC16F876
A
14.3K 8192 368 256 22 5 2 Yes Yes Yes 2/1 2
PIC16F877
A
14.3K 8192 368 256 33 8 2 Yes Yes Yes 2/1 2
PIC16F873A/876A devices are available only in 28-pin packages, while
PIC16F874A/877A devices are avail- able in 40-pin and 44-pin packages. All devices in
the PIC16F87XA family share common architecture with the following differences:
• The PIC16F873A and PIC16F874A have one-half of the total on-chip memory of the
PIC16F876A and PIC16F877A.
• The 28-pin devices have three I/O ports, while the 40/44-pin devices have five.
• The 28-pin devices have fourteen interrupts, while the 40/44-pin devices have fifteen.
• The 28-pin devices have five A/D input channels, while the 40/44-pin devices have eight.
• The Parallel Slave Port is implemented only on the 40/44-pin devices.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 16
5.2.3 Instruction Set
Table 5.2 List of Instructions.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 17
5.2.4 Pin Diagram
Figure 5.1 Pin Diagram Of PIC16F877A.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 18
5.2.4.1 Pin Out Description
Table 5.3 List of Pins and Function.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 19
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 20
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 21
5.2.5 Block Diagram
Figure 5.2. Block Diagram of PIC.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 22
5.2.6 Block Diagram Description
PIC16F877A consists of the following main functional blocks:
Three Timers.
Capture/ Compare/ PWM module.
Master Synchronous Serial Port (MSSP) module.
Addressable Universal Synchronous Asynchronous Receiver Transmitter (USART).
Analog- to- Digital Converter (A/D) module.
Comparator module.
Comparator Voltage Reference module.
5.2.6.1 Timer Module
PIC16F877A has got three timers namely Timer0, Timer1 and Timer 2.
Timer0 Module
The Timer0 module timer/counter has the following features:
8-bit timer/counter
Readable and writable
8-bit software programmable prescaler
Internal or external clock select
Interrupt on overflow from FFh to 00h
Edge select for external clock
Timer1 Module
The Timer1 module is a 16-bit timer/counter consisting of two 8-bit registers
(TMR1H and TMR1L) which are readable and writeable. The TMR1 register pair
(TMR1H:TMR1L) increments from 0000h to FFFFh and rolls over to 0000h. The TMR1
interrupt, if enable, is generated on overflow which is latched in interrupt flag bit, TMR1F
(PIR1<0>). This interrupt can be enabled/disabled by setting/clearing TMR1 interrupt
enable bit, TMR1E (PIE<0>).
Timer2 Module
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 23
Timer2 is an 8-bit timer with a prescaler and a postscaler. It can be used as the
PWM time base for the PWM mode of the CCP modules. The TMR2 register is readable
and writable and is cleared on any reset. The input clock (Fosc/4) has a prescale option of
1:1, 1:4 or 1:16 selected by control bits T2CKPS1:T2CKPS0 (T2CON<1:0).
5.2.6.2 Capture/ Compare/ Pwm Modules
Each Capture/ Compare/ PWM (CCP) module contains a 16-bit register which can
operate as a:
16-bit capture register
16-bit compare register
PWM Master/Slave duty cycle register
Both the CCP1 and CCP2 modules are identical in operation, with the exception being the
operation of the special event trigger.
5.2.6.3 Master Synchronous Serial Port (MSSP) Module
The Master Synchronous Serial Port (MSSP) module is a serial interface, useful for
communicating with other peripheral or microcontroller devices. These peripheral devices
may be serial EEPROMs, Shift registers, display drivers, A/D converters etc. The MSSP
module can operate in one of the two modes:
Serial Peripheral Interface (SPI).
Inter- Integrated Circuit (𝐼2𝐶)
- Full Master Mode
- Slave mode (with general address call)
The I2C interface supports the following modes in hardware:
Master mode
Multi-master mode
Slave mode
SPI Mode
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 24
The SPI mode allows 8 bits of data to be synchronously transmitted and received
simultaneously. All four modes of SPI are supported. To accomplish communications,
typically three pins are used:
Serial Data Out (SDO)- RC5/SDO
Serial Data In (SDI)- RC4/SDI/SDA
Serial Clock (SCK)- RC3/SCK/SCL
Additionally, a fourth pin may be used when in a slave mode of operation:
Slave select (𝑆𝑆̅̅ ̅)- RA5/AN4/𝑆𝑆̅̅ ̅?C2OUT
I2C Mode
The MSSP module in I2C mode fully implements all master and slave functions
and provides interrupts on start and stop bits in hardware to determine a free bus. The
MSSP module implements the standard mode specifications, as well as 7-bit and 10-bit
addressing.
Two pins are used for data transfer:
Serial Clock (SCL)- RC3/SCK/ SCL
Serial Data (SDA)- RC4/SDI/ SDA
The user must configure these pins as inputs or outputs through TRISC <4:3> bits.
5.2.6.4 Addressable Universal Synchronous Asynchronous Receiver Transmitter
(Usart)
The Universal Synchronous Asynchronous Receiver Transmitter (USART) module
is one of the two serial I/O modules. The USART can be configured in the following
modes:
Asynchronous (full-duplex)
Synchronous- Master (half- duplex)
Synchronous- Slave (half-duplex)
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 25
The USART can be configured as a full-duplex asynchronous system that can
communicate with peripheral devices, such as CRT terminals and personal computers, or it
can be configured as a half-duplex synchronous system that can communicate with
peripheral devices such as A/D or D/A integrated circuits, serial EEPROMs etc.
5.2.6.5 Analog To Digital Converter (A/D) Module
The Analog-to-digital (A/D) converter module has five inputs for the 28-pin
devices and eight for the 40/44-pin devices.
The conversion of an analog input signal results in a corresponding 10-bit digital
number. The A/D module has high and low-voltage reference input that is software
selectable to some combination of Vdd, Vss, RA2 or RA3.
The A/D converter has a unique feature of being able to operate while the device is
in sleep mode. To operate in sleep, the A/D clock must be derived from the A/D’s internal
RC oscillator.
The A/D module has four registers. These registers are:
A/D Result High Register (ADRESH)
A/D Result Low Register (ADRESL)
A/D Control Register 0 (ADCON0)
A/D Control Register 1 (ADCON1)
5.2.6.6 Comparator Module
The comparator module contains two analog comparators. The inputs to the
comparators are multiplexed with I/O port pins RA0 through RA3, while the outputs are
multiplexed to pins RA4 and RA5. The on-chip voltage reference can also be an input to
the comparators.
The CMCON register controls the comparator input and output multiplexers.
Comparator Voltage Reference Module
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 26
The comparator voltage reference generator is a 16-tap resistor ladder network that
provides a fixed voltage reference when the comparators are in mode ‘110’. A
programmable register controls the function of the reference generator. The resistor ladder
is segmented to provide two ranges of CVref values and has a power-down function to
conserve power when the reference is no being used.
The comparator reference supply voltage comes directly from Vdd. It should be
noted, however, that the voltage at the top of the ladder is CVrsrc-Vsat, where Vsat is the
saturation voltage of the power switch transistor. This reference will only be as accurate as
the values of CVrsrc and Vsat.
The output of the reference generator may be connected to the RA2/AN2/Vref-
/CVref pin. This can be used as a simple D/A function by the user if a very high impedance
load is used.
5.2.7 Special Features of the CPU
PIC16F877A have a host of features intended to maximize system reliability,
minimize cost through elimination of external components, provide power saving operating
modes and offer code protection. These are:
Oscillator Selection
Reset
- Power-On reset (POR)
- Power- Up Timer (PWRT)
- Oscillator Start- Up timer (OST)
- Brown-Out Reset (BOR)
Interrupts
Watch dog Timer (WDT)
Sleep
Code Protection
ID locations
In- Circuit Serial Programming
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 27
Low- Voltage In-Circuit Serial Programming
In- Circuit Debugger
The watchdog timer which can be shut-off only through configuration bits. It runs off
its own RC oscillator for added reliability.
There are two timers that offer necessary delays on power-up. One is the oscillator
Start-Up timer (OST), intended to keep the chip in reset until the crystal oscillator is
stable. The other is the power-up timer (PWRT), which provides a fixed delay of 72ms on
power-up only. It is designed to keep the part in reset while the power supply stabilizes.
With these two timers on-chip, most applications need no external reset circuitry.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 28
5.2.8 Register File Map
Figure 5.3 Register File Map.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 29
5.2.8.1 Special Function Registers
PIC16F877A has got 64 Special Function Registers (SFRs).
1. These registers are used by CPU and peripheral modules for controlling the desired
operation of the device.
2. These registers are implemented as static RAM.
Table 5.4 Special Function Register.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 30
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 31
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 32
5.2.9 Memory Organization
There are three memory blocks in each of the PIC16F87XA devices. The
0program memory and data memory have separate buses so that concurrent access
can occur and is detailed in this section. The EEPROM data memory block is detailed in
Section 3.0 “Data EEPROM and Flash Program Memory”. Additional information on
device memory may be found in the PIC micro Mid-Range MCU Family Reference
Manual (DS33023).
Data Memory Organization
The data memory is partitioned into multiple banks which contain the General
Purpose Registers and the Special Function Registers. Bits RP1 (Status<6>) and RP0
(Status<5>) are the bank select bits. Each bank extends up to 7Fh (128 bytes). The lower
locations of each bank are reserved for the Special Function Registers. Above the Special
Function Registers are General Purpose Registers, implemented as static RAM. All
implemented banks contain Special Function Registers. Some frequently used Special
Function Registers from one bank may be mirrored in another bank for code reduction and
quicker access.
Program Memory Organization
The PIC16F87XA devices have a 13-bit program counter capable of
addressing an 8K word x 14 bit program memory space. The PIC16F876A/877A
devices have 8K words x 14 bits of Flash program memory, while
PIC16F873A/874A devices have 4K words x 14 bits. Accessing a location above
the physically implemented address will cause a wrap around.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 33
The Reset vector is at 0000h and the interrupt vector is at 0004h.
Figure 5.4 Memory Organization.
5.2.10 I/O Ports
In this microcontroller, we have got 4 I/O ports namely PORTA, PORTB, PORTC
and PORTD. Some pins of these I/O ports are multiplexed with an alternate function for
the peripheral features on the device. In general, when a peripheral is enabled, that pin may
not be used as a general purpose I/O pin.
5.2.10.1 PORTA and the TRISA Register
PORTA is a 6-bit wide, bi-directional port. The corresponding data direction
register is TRISA. Setting a TRISA bit (=1) will make the corresponding PORTA pin an
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 34
input. Clearing a TRISA bit (=0) will make the corresponding PORTA pin an output.
Reading the PORTA registers reads the status of the pins, whereas writing to it will write
to the port latch. All write operations are read-modify-write operations. Therefore, a write
to a port implies that the port pins are read, the value is modified and then written to the
port data latch.
Pin RA4 is multiplexed with the Timer0 module clock input to become the
RA4/T0CKI pin. The RA4/T0CKI pin is a Schmitt trigger input and open-drain output. All
the other PORTA pins have TTL input levels and full CMOS output drivers.
Figure 5.5 Block Diagram Figure 5.6 Block Diagram
of Ra3-Ra0 Pins. of Ra4-T0 Pin.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 35
Figure 5.7 Block Diagram of RA5 Pin.
Table 5.5 Port A Functions.
Table 5.6 Registers Associated With Port A.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 36
5.2.10.2 PORTB and TRISB Register
PORTB is an 8-bit wide, bi- directional port. The corresponding data direction
register is TRISB. Setting a TRISB bit (=1) will make the corresponding PORTB pin an
input. Cleating a TRISB bit (=0) will make the corresponding PORTB pin an output.
Three pins of PORTB are multiplexed with the In-Circuit Debugger and Low-
Voltage Programming function: RB3/PGM, RB6/PGC and RB7/PGD. Each PORTB pins
has a weak internal pull-up. A single control bit can turn all the pull-ups. This is performed
by clearing bit RBPU. The weak pull-up is automatically turned off when the port pin is
configured as an output. The pull-ups are disable on a power-on reset.
Figure 5.8 Block Diagram of Figure 5.9 Block Diagram
RB3-RB0 Pins. of RB7-RB4 Pins.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 37
Table 5.7 Port B Functions.
Registers Associated With Port B:
Table 5.8 Registers Associated With Port B.
5.2.10.3 PORTC and the TRISC Register
PORTC is an 8-bit wide, bi-directional port. The corresponding data direction
register is TRISC. Setting a TRISC bit (= 1) will make the corresponding PORTC pin an
input (i.e., put the corresponding output driver in a High-Impedance mode). Clearing a a
TRISC bit (=0) will make the corresponding PORTC pin an output (i.e., put the contents of
the output latch on the selected pin).
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 38
PORTC is multiplexed with several peripheral functions. PORTC pins have
Schmitt trigger input buffers.
Figure 5.10 PortC Block Diagram-1. Figure 5.11 PortC Block Diagram-2.
Port C Functions
Table 5.9 Port C Functions.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 39
Registers associated with PORTC
Table 5.10 Registers Associated With Port C.
In PORTC, three pins are used for two different purposes. They are:-
RC4/SDI/SDA i.e., pin23 of the microcontroller is used as Enable 2 (EN2) for the
motor driver.
RC6/TX/CK and RC7/RX/DT i.e., pin25 and pin26 of the microcontroller
respectively are used for the communicating serially (USART) with the Bluetooth module.
Universal Synchronous Asynchronous Receiver Transmitter (USART)
The USART module is one of the two serial I/O modules.
USART is also known as a Serial communications Interface (SCI).
The USART can be configured as a full-duplex asynchronous system that can
communicate with peripheral devices, such as CRT terminals and personal computers, or it
can be configured as a half-duplex synchronous system that can communicate with
peripheral devices such as A/D or D/A integrated circuits, serial EEPROMs etc.
The USART can be configured in the following modes:
Asynchronous (Full-duplex).
Synchronous – Master (Half-duplex).
Synchronous – Slave (Half-duplex).
Bit SPEN (RCSTA <7>) and bits TRISC <7:6> have to be set in order to configure
pins RC6/TX/CK and RC7/RX/DT as Universal Synchronous Asynchronous Receiver
Transmitter.
The Special functions registers used by USART are TXSTA and RCSTA. The
format and bit definition of the these registers is given below.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 40
Format Of TXSTA: Transmit Status And Control Register (Address 98H)
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 41
Format Of RCSTA: Receive Status And Control Register (Address 18H)
5.2.10.4 PORTD and TRISD Registers
PORTD is an 8-bit port with Schmitt trigger input buffers. Each pin is individually
configurable as an input or output.
PORTD can be configured as an 8-bit wide microprocessor port (Parallel Slave
port) by setting control bit, PSPMODE (TRISE <4>). In this mode, the input buffers are
TTL.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 42
Figure 5.12 PORTD Block Diagram (in I/O mode).
Port D Functions
Table 5.11 Port D Functions.
Registers Associated With PORTD
Table 5.12 Registers Associated With Port D.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 43
In PORTD, five pins are used for driving the motor driver. They are:-
RD6/PSP6, RD7/PSP7, RD3/PSP3 and RD4/PSP4 i.e., pin29, pin30, pin22 and pin27 of
the microcontroller respectively are used as General purpose I/O pins and are used as
inputs to the motor driver.
RD5/PSP5 i.e., pin28 of the microcontroller is used as Enable 1 (EN1) for the motor driver.
List Of Pins Used
Table 5.13 List of Pins Used.
Pins Name Function
1 MCLR/Vpp To reset the signal
13 OSC1/CLKIN Oscilator input/ clock input
14 OSC2/CLKOUT Oscillator output/clock
output
18 RC3/SCL/SCL Serial clock input
connected to rtc
23 RC4/SDI/SDA Serial data input/output
List Of Ports Used
Table 5.14 List Of Ports Used.
Ports Pins Name Funtion
A 2 RA0 Input of led lights
B 33,34,35,36,
37,38,39
RB0-RB6 Input from Matrix
KEYPAD.
D 19,21,22,
27,28,29,30.
RD0,
RD2-RD7
Digital Output from
LCD
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 44
5.2.11 REGISTERS
SSPCON
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 45
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 46
PIE1
The PIE1 register contains the individual enable bits for the peripheral interrupts.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 47
PIR1
The PIR1 register contains the individual flag bits for the peripheral interrupts.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 48
PIE2
The PIE2 register contains the individual enable bits for the CCP2 peripheral
interrupt, the SSP bus collision interrupt, and the EEPROM write operation interrupt.
PIR2
The PIR2 register contains the flag bits for the CCP2 interrupt, the SSP bus
collision interrupt and the EEPROM write operation interrupt.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 49
5.3 Solar Cells/Photovoltaic Cells
How Solar Panels Work?
1. Rays of sunlight hit the solar panel (also known as a photovoltaic/ (PV) cells) and
are absorbed by semi-conducting materials such as silicone.
2. Electrons are knocked loose from their atoms, which allow them to flow through
the material to produce electricity. This process whereby light (photo) is converted into
electricity (voltage) is called the photovoltaic (PV) effect.
3. An array of solar panels converts solar energy into DC (direct current) electricity.
4. The DC electricity then enters an inverter.
5. The inverter turns DC electricity into 120-volt AC (alternating current) electricity
needed by home appliances.
6. The AC power enters the utility panel in the house.
7. The electricity (load) is then distributed to appliances or lights in the house.
8. When more solar energy is generated that what you’re using – it can be stored in a
battery as DC electricity. The battery will continue to supply your home with electricity in
the event of a power blackout or at nighttime.
9. When the battery is full the excess electricity can be exported back into the utility
grid, if your system is connected to it.
10. Utility supplied electricity can also be drawn from the grid when not enough solar
energy is produced and no excess energy is stored in the battery, i.e. at night or on cloudy
days.
11. The flow of electricity in and out of the utility grid is measured by a utility meter,
which spins backwards (when you are producing more energy that you need) and forward
(when you require additional electricity from the utility company). The two are offset
ensuring that you only pay for the additional energy you use from the utility company. Any
surplus energy is sold back to the utility company. This system is referred to as “net-
metering”.
Solar Energy is measured in kilowatt-hour. 1 kilowatt = 1000 watts.
1 kilowatt-hour (kWh) = the amount of electricity required to burn a 100
watt light bulb for 10 hours.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 50
According to the US Department of Energy, an average American
household used approximately 866-kilowatt hours per month in 1999 costing them $70.68.
About 30% of our total energy consumption is used to heat water.
The Sun produces radiant energy by consuming hydrogen in nuclear fusion
reactions. Solar energy is transmitted to the earth in portions of energy called
photons, which interact with the earth’s atmosphere and surface. It takes
about 8 minutes and 20 seconds for the sun’s energy to reach the earth.
The Earth receives and collects solar energy in the atmosphere, oceans, and
plant life. Interactions between the sun’s energy, the oceans, and the
atmosphere, for example, create winds, which can produce electricity when
directed through aerodynamically designed wind machines.
Solar Photovoltaic Cells convert solar radiation into electricity
(photovoltaic literally means “light energy”; “photo” = light, “voltaic” =
energy). Individual cells are packaged into modules, like the one shown at
the right; groups of modules are called arrays. Photovoltaic arrays act like a
battery when the sun is shining, producing a stream of direct current (DC)
electricity and sending it into the building or sharing it with the grid.
The Dc Disconnect Switch allows professional electricians to disconnect the
photovoltaic array from the rest of the system. With the switch in the “off”
position, workers can safely perform maintenance on other system
components.
The Inverter converts direct current (DC) electricity generated by the array
into alternating current (AC) electricity for use in the building. Most
electrical loads (energy-consuming devices like lights, motors, computers,
and air conditioners) in schools, homes and businesses use AC electricity.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 51
The Transformer ensures that the voltage of the electricity coming from the
inverter is compatible with the voltage of the electricity in the building.
The Ac Disconnect disconnect switch allows professional electricians to
disconnect the building’s electrical system from the solar photovoltaic
system. With the AC disconnect switch in the “off” position, workers can
safely perform maintenance on the solar photovoltaic system’s components.
The Electric Meter keeps track of the amount of electrical energy produced
by the solar photovoltaic system and sends electronic signals to the data
acquisition system where they are recorded. Electrical energy is measured in
kilowatt-hours. How much energy is contained in a kilowatt-hour? We’re
glad you asked. Use our calculator to find out.
5.3.1 Photovoltaic Cells: Converting Photons To Electrons
Photovoltaic (PV) cells are made of special materials called semiconductors such as
silicon, which is currently the most commonly used. Basically, when light strikes the cell, a
certain portion of it is absorbed within the semiconductor material. This means that the
energy of the absorbed light is transferred to the semiconductor. The energy knocks
electrons loose, allowing them to flow freely. PV cells also all have one or more electric
fields that act to force electrons freed by light absorption to flow in a certain direction. This
flow of electrons is a current, and by placing metal contacts on the top and bottom of the
PV cell, we can draw that current off to use externally. For example, the current can power
a calculator. This current, together with the cell’s voltage (which is a result of its built-in
electric field or fields), defines the power (or wattage) that the solar cell can produce.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 52
Figure 5.13 Working of Solar Panel.
5.4 Battery
An electrical battery is a combination of one or more electrochemical cells,
used to convert stored chemical energy into electrical energy. The battery has become a
common power source for many household and industrial applications.
Batteries may be used once and discarded, or recharged for years as in standby
power applications. Miniature cells are used to power devices such as hearing aids and
wristwatches; larger batteries provide standby power for telephone exchanges or computer
data centers.
Working of Battery
A battery is a device that converts chemical energy directly to electrical energy.
It consists of a number of voltaic cells; each voltaic cell consists of two half cells
connected in series by a conductive electrolyte containing anions and cat ions. One half-
cell includes electrolyte and the electrode to which anions (negatively-charged ions)
migrate, i.e. the anode or negative electrode; the other half-cell includes electrolyte and the
electrode to which cat ions (positively-charged ions) migrate, i.e. the cathode or positive
electrode. In the red ox reaction that powers the battery, reduction (addition of electrons)
occurs to cat ions at the cathode, while oxidation (removal of electrons) occurs to anions at
the anode. The electrodes do not touch each other but are electrically connected by the
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 53
electrolyte. Many cells use two half-cells with different electrolytes. In that case each half-
cell is enclosed in a container, and a separator that is porous to ions but not the bulk of the
electrolytes prevents mixing.
Each half cell has an electromotive force (or emf), determined by its ability to
drive electric current from the interior to the exterior of the cell. The net emf of the cell is
the difference between the emfs of its half-cells. Therefore, if the electrodes have emfs and,
in other words, the net emf is the difference between the reduction potentials of the half-
reactions.
The electrical driving force or across the terminals of a cell is known as the
terminal voltage (difference) and is measured in volts. The terminal voltage of a cell that is
neither charging nor discharging is called the open-circuit voltage and equals the emf of
the cell. Because of internal resistance, the terminal voltage of a cell that is discharging is
smaller in magnitude than the open-circuit voltage and the terminal voltage of a cell that is
charging exceeds the open-circuit voltage. An ideal cell has negligible internal resistance,
so it would maintain a constant terminal voltage of until exhausted, then dropping to zero.
If such a cell maintained 1.5 volts and stored a charge of one Coulomb then on complete
discharge it would perform 1.5 Joule of work. In actual cells, the internal resistance
increases under discharge, and the open circuit voltage also decreases under discharge. If
the voltage and resistance are plotted against time, the resulting graphs typically are a
curve; the shape of the curve varies according to the chemistry and internal arrangement
employed.
An electrical battery is one or more electrochemical cells that convert stored chemical
energy into electrical energy. Since the invention of the first battery (or "voltaic pile") in
1800 by Alessandro Volta, batteries have become a common power source for many
household and industrial applications. According to a 2005 estimate, the worldwide battery
industry generates US$48 billion in sales each year, with 6% annual growth. There are two
types of batteries: primary batteries (disposable batteries), which are designed to be used
once and discarded, and secondary batteries (rechargeable batteries), which are designed to
be recharged and used multiple times. Miniature cells are used to power devices such as
hearing aids and wristwatches; larger batteries provide standby power for telephone
exchanges or computer data centres.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 54
Principle of Operation
A battery is a device that converts chemical energy directly to electrical energy. It
consists of a number of voltaic cells; each voltaic cell consists of two half cells connected
in series by a conductive electrolyte containing anions and cations. One half-cell includes
electrolyte and the electrode to which anions (negatively charged ions) migrate, i.e., the
anode or negative electrode; the other half-cell includes electrolyte and the electrode to
which cations (positively charged ions) migrate, i.e., the cathode or positive electrode. In
the redox reaction that powers the battery, cations are reduced (electrons are added) at the
cathode, while anions are oxidized (electrons are removed) at the anode. The electrodes do
not touch each other but are electrically connected by the electrolyte. Some cells use two
half-cells with different electrolytes. A separator between half cells allows ions to flow, but
prevents mixing of the electrolytes.
Each half cell has an electromotive force (or emf), determined by its ability to drive
electric current from the interior to the exterior of the cell. The net emf of the cell is the
difference between the emfs of its half-cells, as first recognized by Volta. Therefore, if the
electrodes have emfs and , then the net emf is ; in other words, the net emf
is the difference between the reduction potentials of the half-reactions. The electrical
driving force or across the terminals of a cell is known as the terminal voltage
(difference) and is measured in volts. The terminal voltage of a cell that is neither charging
nor discharging is called the open-circuit voltage and equals the emf of the cell. Because of
internal resistance, the terminal voltage of a cell that is discharging is smaller in magnitude
than the open-circuit voltage and the terminal voltage of a cell that is charging exceeds the
open-circuit voltage. An ideal cell has negligible internal resistance, so it would maintain a
constant terminal voltage of until exhausted, then dropping to zero. If such a cell
maintained 1.5 volts and stored a charge of one coulomb then on complete discharge it
would perform 1.5 joule of work. In actual cells, the internal resistance increases under
discharge, and the open circuit voltage also decreases under discharge. If the voltage and
resistance are plotted against time, the resulting graphs typically are a curve; the shape of
the curve varies according to the chemistry and internal arrangement employed.
As stated above, the voltage developed across a cell's terminals depends on the energy
release of the chemical reactions of its electrodes and electrolyte. Alkaline and carbon-zinc
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 55
cells have different chemistries but approximately the same emf of 1.5 volts; likewise
NiCad and NiMH cells have different chemistries, but approximately the same emf of 1.2
volts. On the other hand the high electrochemical potential changes in the reactions of
lithium compounds give lithium cells emfs of 3 volts or more.
The battery capacity that battery manufacturers print on a battery is usually the product of
20 hours multiplied by the maximum constant current that a new battery can supply for 20
hours at 68 F° (20 C°), down to a predetermined terminal voltage per cell. A battery rated
at 100 A·h will deliver 5 A over a 20 hour period at room temperature. However, if it is
instead discharged at 50 A, it will have a lower apparent capacity.
The relationship between current, discharge time, and capacity for a lead acid battery is
approximated (over a certain range of current values) by Peukert's law:
Where
QP is the capacity when discharged at a rate of 1 amp.
I is the current drawn from battery (A).
t is the amount of time (in hours) that a battery can sustain.
k is a constant around 1.3.
For low values of I internal self-discharge must be included.
In practical batteries, internal energy losses, and limited rate of diffusion of ions through
the electrolyte, cause the efficiency of a battery to vary at different discharge rates. When
discharging at low rate, the battery's energy is delivered more efficiently than at higher
discharge rates, but if the rate is too low, it will self-discharge during the long time of
operation, again lowering its efficiency.
Installing batteries with different A·h ratings will not affect the operation of a device rated
for a specific voltage unless the load limits of the battery are exceeded. High-drain loads
like digital cameras can result in lower actual energy, most notably for alkaline batteries.
For example, a battery rated at 2000 mA·h would not sustain a current of 1 A for the full
two hours, if it had been rated at a 10-hour or 20-hour discharge.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 56
Fastest Charging, Largest, And Lightest Batteries
Lithium iron phosphate (LiFePO4) batteries are the fastest charging and discharging, next
to super capacitors. The world's largest battery is in Fairbanks, Alaska, composed of Ni-
Cdcells. Sodium-sulfur batteries are being used to store wind power. Lithium-sulfur
batteries have been used on the longest and highest solar powered flight. The speed of
recharging for lithium-ion batteries may be increased by manipulation.
5.5 Keypad
Figure 5.14 Keypad.
A keypad is a set of buttons arranged in a block or "pad" which usually bear digits,
symbols and usually a complete set of alphabetical letters. If it mostly contains numbers
then it can also be called a numeric keypad. Keypads are found on many alphanumeric
keyboards and on other devices such as calculators, push-button telephones, combination
locks, and digital door locks, which require mainly numeric input.
Keypads are a part of HMI or Human Machine Interface and play really important
role in a small embedded system where human interaction or human input is needed.
Matrix keypads are well known for their simple architecture and ease of interfacing with
any microcontroller.
Figure 5.15 Matrix Keypad.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 57
Scanning of Matrix Keypad
There are many methods depending on the connection keypad with micro
controller, but the basic logic is same the columns are made as input and drive the rows
making them as output; this whole procedure of reading the keyboard is called scanning. In
order to detect which key is pressed from the matrix, the row lines are to be made low one
by one and read the columns. Assume that if Row1 is made low, then read the columns. If
any of the key in row1 is pressed then correspondingly the column 1will give low that is if
second key is pressed in Row1, then column2 will give low. This is how Scanning is done.
So to scan the keypad completely, we need to make rows low one by one and read the
columns. If any of the buttons are pressed in a row, it will take the corresponding column
to a low state which shows that a key is pressed in that row. If button 1 of a row is pressed
then Column 1 will become low, if button 2 then column2 and so on...this is the way of
working by a keypad.
5.6 LCD
Description
This is the example for the Parallel Port. This example doesn't use the Bi-
directional feature found on newer ports, thus it should work with most, if not all Parallel
Ports. It however doesn't show the use of the Status Port as an input for a 16 Character x 2
Line LCD Module to the Parallel Port. These LCD Modules are very common these days,
and are quite simple to work with, as all the logic required running them is on board.
Advantages
Very compact and light
Low power consumption
No geometric distortion
Little or no flicker depending on backlight technology
Not affected by screen burn-in
No high voltage or other hazards present during repair/service
Can be made in almost any size or shape
No theoretical resolution limit
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 58
LCD Background
Frequently, an 8051 program must interact with the outside world using input and
output devices that communicate directly with a human being. One of the most common
devices attached to an 8051 is an LCD display. Some of the most common LCDs
connected to the 8051 are 16x2 and 20x2 displays. This means 16 characters per line by 2
lines and 20 characters per line by 2 lines, respectively.
Fortunately, a very popular standard exists which allows us to communicate with
the vast majority of LCDs regardless of their manufacturer. The standard is referred to as
HD44780U, which refers to the controller chip which receives data from an external source
(in this case, the 8051) and communicates directly with the LCD.
Figure 5.16 LCD.
The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the
data bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-
bit data bus. If a 4-bit data bus is used the LCD will require a total of 7 data lines (3 control
lines plus the 4 lines for the data bus). If an 8-bit data bus is used the LCD will require a
total of 11 data lines (3 control lines plus the 8 lines for the data bus).
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 59
Figure 5.17 Pin Diagram of LCD.
The three control lines are referred to as EN, RS, and RW.
The EN line is called "Enable." This control line is used to tell the LCD that you
are sending it data. To send data to the LCD, your program should make sure this line is
low (0) and then set the other two control lines and/or put data on the data bus. When the
other lines are completely ready, bring EN high (1) and wait for the minimum amount of
time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing it
low (0) again.
The RS line is the "Register Select" line. When RS is low (0), the data is to be
treated as a command or special instruction (such as clear screen, position cursor, etc.).
When RS is high (1), the data being sent is text data which should be displayed on the
screen. For example, to display the letter "T" on the screen you would set RS high.
The RW line is the "Read/Write" control line. When RW is low (0), the information
on the data bus is being written to the LCD. When RW is high (1), the program is
effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a
read command. All others are write commands--so RW will almost always be low .Finally,
the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the
user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3,
DB4, DB5, DB6, and DB7.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 60
5.6.1 Pin Function of LCD
Table 5.15 Pin Function of Lcd.
NAME FUNCTION
01 Vss (ground) Ground (0V)
02 Vcc Supply voltage(5v)
03 Vee Contrast adjustment through
Variable resistor
04 Rs ( register select) Selects data register when low
Select command register when high
05 R/W Reads the data when low
Writes the data when high
06 E(Enable) Sends data to data pins when a
High to low pulse is given
07 DO
Data lines
08 D1
09 D2
10 D3
11 D4
12 D5
13 D6
14 D7
15 LED+ Backlight VCC(5V)
16 LED- Backlight ground(0V)
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 61
Logic Status On Control Lines
• E - 0 Access to LCD disabled
- 1 Access to LCD enabled
• R/W - 0 Writing data to LCD
- 1 Reading data from LCD
• RS - 0 Instructions
- 1 Character
Writing Data To LCD
1) Set R/W bit to low
2) Set RS bit to logic 0 or 1 (instruction or character)
3) Set data to data lines (if it is writing)
4) Set E line to high
5) Set E line to low
Read Data From Data Lines (If It Is Reading) On LCD
1) Set R/W bit to high
2) Set RS bit to logic 0 or 1 (instruction or character)
3) Set data to data lines (if it is writing)
4) Set E line to high
5) Set E line to low
5.6.3 LCD Commands
1. 38H-Select 8 bit mode
2. 28H-select 4 bit mode
3. 01H-Clear screen
4. 0EH-Turn the display, turn the cursor
5. 80H-Select top row
6. C0H-select bottom row
7. 06H-Cursor right shift
8. 1CH-for entire display left shift
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 62
5.7 RTC
The DS1307 serial real-time clock (RTC) is a low-power, full binary-coded
decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are
transferred serially through an I²C, bidirectional bus. The clock/calendar provides seconds,
minutes, hours, day, date, month, and year information. The end of the month date is
automatically adjusted for months with fewer than 31 days, including corrections for leap
year. The clock operates in either the 24-hour or 12-hour format with AM/PM indicator.
The DS1307 has a built-in power-sense circuit that detects power failures and
automatically switches to the backup supply. Timekeeping operation continues while the
part operates from the backup supply.
Features of DS1307
Real time clock counts seconds, minutes, hours, date of month, month, day of week
and year with leap year compensation valid up to 2100
56 byte nonvolatile RAM for general data storage
2-wrire interface (I2C)
Automatic power fail detect
Comsumes less than 500 nA for battery back-up at 25'C
Figure 5.18 Pin Diagram of RTC.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 63
5.7.1 Pin Description
VCC, GND – DC power is provided to the device on these pins. VCC is the +5V
input. When 5V is applied within normal limits, the device is fully accessible and data
can be written and read. When a 3V battery is connected to the device and VCC is
below 1.25 x VBAT, reads and writes are inhibited. However, the timekeeping
function continues unaffected by the lower input voltage. As VCC falls below VBAT
the RAM and timekeeper are switched over to the external power supply (nominal
3.0V DC) at VBAT.
VBAT – Battery input for any standard 3V lithium cell or other energy source. Battery
voltage must be held between 2.0V and 3.5V for proper operation. The nominal write
protect trip point voltage at which access to the RTC and user RAM is denied is set by
the internal circuitry as 1.25 x VBAT nominal. A lithium battery with 48mAhr or
greater will back up the DS1307 for more than 10 years in the absence of power at
25ºC. UL recognized to ensure against reverse charging current when used in
conjunction with a lithium battery.
SCL (Serial Clock Input) – SCL is used to synchronize data movement on the serial
interface.
SDA (Serial Data Input/Output) – SDA is the input/output pin for the 2-wire serial
interface. The SDA pin is open drain which requires an external pullup resistor.
SQW/OUT (Square Wave/Output Driver) – When enabled, the SQWE bit set to 1,
the SQW/OUT pin outputs one of four square wave frequencies (1Hz, 4kHz, 8kHz,
32kHz). The SQW/OUT pin is open drain and requires an external pull-up resistor.
SQW/OUT will operate with either Vcc or Vbat applied.
X1, X2 – Connections for a standard 32.768kHz quartz crystal. The internal oscillator
circuitry is designed for operation with a crystal having a specified load capacitance
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 64
(CL) of 12.5pF.
The DS1307 can also be driven by an external 32.768kHz oscillator. In this
configuration, the X1 pin is connected to the external oscillator signal and the X2 pin is
floated
Figure 5.19 Wire Timing Interface.
Start Data Transfer: A change in the state of the data line from high to low, while the
clock line is high, defines a START condition.
Stop Data Transfer: A change in the state of the data line from low to high, while the
clock line is high, defines the STOP condition.
Data Valid: The state of the data line represents valid data when, after a START
condition, the data line is stable for the duration of the high period of the clock signal. The
data on the line must be changed during the low period of the clock signal. There is one
clock pulse per bit of data. Each data transfer is initiated with a START condition and
terminated with a STOP condition. The number of data bytes transferred between the
START and the STOP conditions is not limited, and is determined by the master device.
The information is transferred byte–wise and each receiver acknowledges with a ninth bit.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 65
Acknowledge: Each receiving device, when addressed, is obliged to generate an
acknowledge after the reception of each byte. The master device must generate an extra
clock pulse which is associated with acknowledge bit.
Figure 5.20 Data Flow.
Figure 5.21 Operating Circuit.
Operation
The DS1307 operates as a slave device on the serial bus. Access is obtained by
implementing a START condition and providing a device identification code followed by a
register address. Subsequent registers can be accessed sequentially until a STOP condition
is executed. When VCC falls below 1.25 x VBAT the device terminates an access in
progress and resets the device address counter. Inputs to the device will not be recognized
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 66
at this time to prevent erroneous data from being written to the device from an out of
tolerance system. When VCC falls below VBAT the device switches into a low-current
battery backup mode. Upon power-up, the device switches from battery to VCC when
VCC is greater than VBAT + 0.2V and recognizes inputs when VCC is greater than 1.25 x
VBAT. The block diagram in Figure 1 shows the main elements of the serial RTC.
5.8 Operational Amplifier Lm324
The LM158 series consists of two independent, high gain, internally frequency
compensated operational amplifiers which were designed specifically to operate from a
single power supply over a wide range of voltages. Operation from split power supplies is
also possible and the low power supply current drain is independent of the magnitude of
the power supply voltage.
Application areas include transducer amplifiers, dc gain blocks and all the
conventional op amp circuits which now can be more easily implemented in single power
supply systems. For example, the LM158 series can be directly operated off of the standard
+5V power supply voltage which is used in digital systems and will easily provide the
required interface electronics without requiring the additional ±15V power supplies.
The LM324 and LM2904 are available in a chip sized package (8-Bump micro
SMD) using National's micro SMD package technology.
Figure 5.22 Opamp LM324.
Features
• Available in 8-Bump micro SMD chip sized package, (See AN-1112)
• Internally frequency compensated for unity gain
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 67
• Large dc voltage gain: 100 dB
• Wide bandwidth (unity gain): 1 MHz (temperature compensated)
• Wide power supply range:
o Single supply: 3V to 32V
o or dual supplies: ±1.5V to ±16V
• Very low supply current drain (500 µA)-essentially independent of supply voltage
• Low input offset voltage: 2 mV
• Input common-mode voltage range includes ground
• Differential input voltage range equal to the power supply voltage
• large output voltage swing.
5.9 MOSFET
The metal–oxide–semiconductor field-effect transistor (MOSFET, MOS-FET, or
MOS FET) is a device used for amplifying or switching electronic signals. The basic
principle of the device was first proposed by Julius Edgar Lilienfeld in 1925. In
MOSFET’s, a voltage on the oxide-insulated gate electrode can induce a conducting
channel between the two other contacts called source and drain. The channel can be of n-
type or p-type and is accordingly called an n-MOSFET or a p-MOSFET. It is by far the
most common transistor in both digital and analog circuits, though the bipolar junction
transistor was at one time much more common.
A variety of symbols are used for the MOSFET. The basic design is generally a line for the
channel with the source and drain leaving it at right angles and then bending back at right
angles into the same direction as the channel. Sometimes three line segments are used for
enhancement mode and a solid line for depletion mode.
Comparison of enhancement-mode and depletion-mode MOSFET symbols, along with
JFET symbols (drawn with source and drain ordered such that higher voltages appear higher
on the page than lower voltages).
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 68
Figure 5.23 Mosfet.
Figure 5.24 Mosfet as Switch.
In this circuit arrangement an Enhancement-mode N-channel MOSFET is being
used to switch a simple lamp "ON" and "OFF" (could also be an LED). The gate input
voltage VGS is taken to an appropriate positive voltage level to turn the device and the lamp
either fully "ON", (VGS = +ve) or a zero voltage level to turn the device fully "OFF", (VGS
= 0).
If the resistive load of the lamp was to be replaced by an inductive load such as a
coil or solenoid, a "Flywheel" diode would be required in parallel with the load to protect
the MOSFET from any back-emf. Above shows a very simple circuit for switching a
resistive load such as a lamp or LED. But when using power MOSFET's to switch either
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 69
inductive or capacitive loads some form of protection is required to prevent the MOSFET
device from becoming damaged.
Driving an inductive load has the opposite effect from driving a capacitive load.
For example, a capacitor without an electrical charge is a short circuit, resulting in a high
"inrush" of current and when we remove the voltage from an inductive load we have a
large reverse voltage build up as the magnetic field collapses, resulting in an induced back-
emf in the windings of the inductor.
For the power MOSFET to operate as an analogue switching device, it needs to be
switched between its "Cut-off Region" where VGS = 0 and its "Saturation Region" where
VGS (on) = +ve. The power dissipated in the MOSFET (PD) depends upon the current
flowing through the channel ID at saturation and also the "ON-resistance" of the channel
given as RDS (on).
5.10 TRANSISTOR(BC547)
The BC547 transistor is an NPN Epitaxial Silicon Transistor. The BC547 transistor is a
general-purpose transistor in small plastic packages. It is used in general-purpose switching
and amplification BC847/BC547 series 45 V, 100 mA NPN general-purpose transistors.
Figure 5.25 Transistor.
The BC547 transistor is an NPN bipolar transistor, in which the letters "N" and "P"
refer to the majority charge carriers inside the different regions of the transistor. Most
bipolar transistors used today are NPN, because electron mobility is higher than hole
mobility in semiconductors, allowing greater currents and faster operation. NPN transistors
consist of a layer of P-doped semiconductor (the "base") between two N-doped layers. A
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 70
small current entering the base in common-emitter mode is amplified in the collector
output. In other terms, an NPN transistor is "on" when its base is pulled high relative to the
emitter. The arrow in the NPN transistor symbol is on the emitter leg and points in the
direction of the conventional current flow when the device is in forward active mode. One
mnemonic device for identifying the symbol for the NPN transistor is "not pointing in." An
NPN transistor can be considered as two diodes with a shared anode region. In typical
operation, the emitter base junction is forward biased and the base collector junction is
reverse biased. In an NPN transistor, for example, when a positive voltage is applied to the
base emitter junction, the equilibrium between thermally generated carriers and the
repelling electric field of the depletion region becomes unbalanced, allowing thermally
excited electrons to inject into the base region. These electrons wander (or "diffuse")
through the base from the region of high concentration near the emitter towards the region
of low concentration near the collector. The electrons in the base are called minority
carriers because the base is doped p-type which would make holes the majority carrier in
the base.
Whenever base is high, then current starts flowing through base and emitter and after that
only current will pass from collector to emitter. So that the LED which is connected to
collector will glow to indicate that transistor is ON.
An NPN Transistor Configuration
Figure 5.26 Transistor Configuration.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 71
5.11 1N4007 DIODE
Diodes are used to convert AC into DC these are used as half wave rectifier or full
wave rectifier. Three points must he kept in mind while using any type of diode.
1.Maximum forward current capacity
2.Maximum reverse voltage capacity
3.Maximum forward voltage capacity
Figure 5.27 1N4007 Diodes.
The number and voltage capacity of some of the important diodes available in the
market are as follows:
Diodes of number IN4001, IN4002, IN4003, IN4004, IN4005, IN4006 and IN4007
have maximum reverse bias voltage capacity of 50V and maximum forward current
capacity of 1 Amp.
Diode of same capacities can be used in place of one another. Besides this diode of
more capacity can be used in place of diode of low capacity but diode of low capacity
cannot be used in place of diode of high capacity. For example, in place of IN4002;
IN4001 or IN4007 can be used but IN4001 or IN4002 cannot be used in place of
IN4007.The diode BY125made by company BEL is equivalent of diode from IN4001 to
IN4003. BY 126 is equivalent to diodes IN4004 to 4006 and BY 127 is equivalent to diode
IN4007.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 72
Figure 5.28 PN Junction Diode.
PN Junction Operation
Now that you are familiar with P- and N-type materials, how these materials are
joined together to form a diode, and the function of the diode, let us continue our
discussion with the operation of the PN junction. But before we can understand how the
PN junction works, we must first consider current flow in the materials that make up the
junction and what happens initially within the junction when these two materials are joined
together.
Current Flow in the N-Type Material
Conduction in the N-type semiconductor, or crystal, is similar to conduction in a
copper wire. That is, with voltage applied across the material, electrons will move through
the crystal just as current would flow in a copper wire. This is shown in figure. The
positive potential of the battery will attract the free electrons in the crystal. These electrons
will leave the crystal and flow into the positive terminal of the battery. As an electron leaves
the crystal, an electron from the negative terminal of the battery will enter the crystal, thus
completing the current path. Therefore, the majority current carriers in the N-type material
(electrons) are repelled by the negative side of the battery and move through the crystal
toward the positive side of the battery.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 73
Current Flow in the P-Type Material
Current flow through the P-type material is illustrated. Conduction in the P material
isby positive holes, instead of negative electrons. A hole moves from the positive terminal
of the P materialto the negative terminal. Electrons from the external circuit enter the
negative terminal of the material andfill holes in the vicinity of this terminal. At the
positive terminal, electrons are removed from the covalentbonds, thus creating new holes.
This process continues as the steady stream of holes (hole current) movestoward the
negative terminal
5.12 RESISTORS
A resistor is a two-terminal electronic component designed to oppose 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
Resistors are used as part of electrical networks and electronic circuits. They are extremely
commonplace in most electronic equipment. Practical resistors can be made of various
compounds and films, as well as resistance wire (wire made of a high-resistivity alloy,
such as nickel/chrome).
The primary characteristics of resistors are their resistance and the power they
can dissipate. Other characteristics include temperature coefficient, noise, and inductance.
Less well-known is critical resistance, the value below which power dissipation limits the
maximum permitted current flow, and above which the limit is applied voltage. Critical
resistance depends upon the materials constituting the resistor as well as its physical
dimensions; it's determined by design.
Resistors can be integrated into hybrid and printed circuits, as well as integrated circuits.
Size, and position of leads (or terminals) are relevant to equipment designers; resistors
must be physically large enough not to overheat when dissipating their power.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 74
Figure 5.29 Resistors.
A resistor is a two-terminal passive electronic component which implements
electrical resistance as a circuit element. When a voltage V is applied across the terminals
of a resistor, a current I will flow through the resistor in direct proportion to that voltage.
The reciprocal of the constant of proportionality is known as the resistance R, since, with a
given voltage V, a larger value of R further "resists" the flow of current I as given by
Ohm's law :
Resistors are common elements of electrical networks and electronic circuits and
are ubiquitous in most electronic equipment. Practical resistors can be made of various
compounds and films, as well as resistance wire (wire made of a high-resistivity alloy,
such as nickel-chrome). Resistors are also implemented within integrated circuits,
particularly analog devices, and can also be integrated into hybrid and printed circuits.
The electrical functionality of a resistor is specified by its resistance: common
commercial resistors are manufactured over a range of more than 9 orders of magnitude.
When specifying that resistance in an electronic design, the required precision of the
resistance may require attention to the manufacturing tolerance of the chosen resistor,
according to its specific application. The temperature coefficient of the resistance may also
be of concern in some precision applications. Practical resistors are also specified as
having a maximum power rating which must exceed the anticipated power dissipation of
that resistor in a particular circuit: this is mainly of concern in power electronics
applications. Resistors with higher power ratings are physically larger and may require heat
sinking. In a high voltage circuit, attention must sometimes be paid to the rated maximum
working voltage of the resistor.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 75
The series inductance of a practical resistor causes its behavior to depart from ohms
law; this specification can be important in some high-frequency applications for smaller
values of resistance. In a low-noise amplifier or pre-amp the noise characteristics of a
resistor may be an issue. The unwanted inductance, excess noise, and temperature
coefficient are mainly dependent on the technology used in manufacturing the resistor.
They are not normally specified individually for a particular family of resistors
manufactured using a particular technology. A family of discrete resistors is also
characterized according to its form factor, that is, the size of the device and position of its
leads (or terminals) which is relevant in the practical manufacturing of circuits using them.
Units
The ohm (symbol: Ω) is the SI unit of electrical resistance, named after Georg
Simon Ohm. An ohm is equivalent to a volt per ampere. Since resistors are specified and
manufactured over a very large range of values, the derived units of milliohm (1 mΩ =
10−3 Ω), kilohm (1 kΩ = 103 Ω), and megohm (1 MΩ = 106 Ω) are also in common usage.
The reciprocal of resistance R is called conductance G = 1/R and is measured in
Siemens (SI unit), sometimes referred to as a mho. Thus a Siemens is the reciprocal of an
ohm: S = Ω − 1. Although the concept of conductance is often used in circuit analysis,
practical resistors are always specified in terms of their resistance (ohms) rather than
conductance.
5.13 CAPACITORS
A capacitor or condenser is a passive electronic component consisting of a pair of
conductors separated by a dielectric. When a voltage potential difference exists between
the conductors, an electric field is present in the dielectric. This field stores energy and
produces a mechanical force between the plates. The effect is greatest between wide, flat,
parallel, narrowly separated conductors.
An ideal capacitor is characterized by a single constant value, capacitance, which is
measured in farads. This is the ratio of the electric charge on each conductor to the
potential difference between them. In practice, the dielectric between the plates passes a
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 76
small amount of leakage current. The conductors and leads introduce an equivalent series
resistance and the dielectric has an electric field strength limit resulting in a breakdown
voltage.
The properties of capacitors in a circuit may determine the resonant frequency and quality
factor of a resonant circuit, power dissipation and operating frequency in a digital logic
circuit, energy capacity in a high-power system, and many other important aspects.
Figure 5.30 Capacitors.
A capacitor (formerly known as condenser) is a device for storing electric charge.
The forms of practical capacitors vary widely, but all contain at least two conductors
separated by a non-conductor. Capacitors used as parts of electrical systems, for example,
consist of metal foils separated by a layer of insulating film.
Capacitors are widely used in electronic circuits for blocking direct current while
allowing alternating current to pass, in filter networks, for smoothing the output of power
supplies, in the resonant circuits that tune radios to particular frequencies and for many
other purposes.
A capacitor is a passive electronic component consisting of a pair of conductors
separated by a dielectric (insulator). When there is a potential difference (voltage) across
the conductors, a static electric field develops in the dielectric that stores energy and
produces a mechanical force between the conductors. An ideal capacitor is characterized
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 77
by a single constant value, capacitance, measured in farads. This is the ratio of the electric
charge on each conductor to the potential difference between them.
The capacitance is greatest when there is a narrow separation between large areas
of conductor, hence capacitor conductors are often called "plates", referring to an early
means of construction. In practice the dielectric between the plates passes a small amount
of leakage current and also has an electric field strength limit, resulting in a breakdown
voltage, while the conductors and leads introduce an undesired inductance and resistance.
Figure 5.31 Charge of Capacitance.
Charge separation in a parallel-plate capacitor causes an internal electric field. A dielectric
(orange) reduces the field and increases the capacitance.
A Simple Demonstration of a Parallel-Plate Capacitor
A capacitor consists of two conductors separated by a non-conductive region. The non-
conductive region is called the dielectric or sometimes the dielectric medium. In simpler
terms, the dielectric is just an electrical insulator. Examples of dielectric mediums are
glass, air, paper, vacuum, and even a semiconductor depletion region chemically identical
to the conductors. A capacitor is assumed to be self-contained and isolated, with no net
electric charge and no influence from any external electric field. The conductors thus hold
equal and opposite charges on their facing surfaces, and the dielectric develops an electric
field. In SI units, a capacitance of one farad means that one coulomb of charge on each
conductor causes a voltage of one volt across the device.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 78
The capacitor is a reasonably general model for electric fields within electric circuits. An
ideal capacitor is wholly characterized by a constant capacitance C, defined as the ratio of
charge ±Q on each conductor to the voltage V between them:
Sometimes charge build-up affects the capacitor mechanically, causing its capacitance to
vary. In this case, capacitance is defined in terms of incremental changes:
Energy storage:
Work must be done by an external influence to "move" charge between the conductors in a
capacitor. When the external influence is removed the charge separation persists in the
electric field and energy is stored to be released when the charge is allowed to return to its
equilibrium position. The work done in establishing the electric field, and hence the
amount of energy stored, is given by:
Current-voltage relation:
The current i(t) through any component in an electric circuit is defined as the rate of flow
of a charge q(t) passing through it, but actual charges, electrons, cannot pass through the
dielectric layer of a capacitor, rather an electron accumulates on the negative plate for each
one that leaves the positive plate, resulting in an electron depletion and consequent positive
charge on one electrode that is equal and opposite to the accumulated negative charge on
the other. Thus the charge on the electrodes is equal to the integral of the current as well as
proportional to the voltage as discussed above. As with any anti derivative, a constant of
integration is added to represent the initial voltage v (t0). This is the integral form of the
capacitor equation,
.
Taking the derivative of this, and multiplying by C, yields the derivative form,
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 79
.
The dual of the capacitor is the inductor, which stores energy in the magnetic field rather
than the electric field. Its current-voltage relation is obtained by exchanging current and
voltage in the capacitor equations and replacing C with the inductance L.
5.14 LED’S
Light Emitting Diodes (LED) have recently become available that are white and
bright, so bright that they seriously compete with incandescent lamps in lighting
applications. They are still pretty expensive as compared to a GOW lamp but draw much
less current and project a fairly well focused beam.
The diode in the photo came with a neat little reflector that tends to sharpen the
beam a little but doesn't seem to add much to the overall intensity.
When run within their ratings, they are more reliable than lamps as well. Red LEDs
are now being used in automotive and truck tail lights and in red traffic signal lights. You
will be able to detect them because they look like an array of point sources and they go on
and off instantly as compared to conventional incandescent lamps.
Figure 5.32 White Led Spectrum.
LEDs are monochromatic (one color) devices. The color is determined by the band
gap of the semiconductor used to make them. Red, green, yellow and blue LEDs are fairly
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 80
common. White light contains all colors and cannot be directly created by a single LED.
The most common form of "white" LED really isn't white. It is a Gallium Nitride blue LED
coated with a phosphor that, when excited by the blue LED light, emits a broad range
spectrum that in addition to the blue emission, makes a fairly white light.
There is a claim that these white LED's have a limited life. After 1000 hours or so
of operation, they tend to yellow and dim to some extent. Running the LEDs at more than
their rated current will certainly accelerate this process.
There are two primary ways of producing high intensity white-light using LED’S.
One is to use individual LED’S that emit three primary colours—red, green, and blue—and
then mix all the colours to form white light. The other is to use a phosphor material to
convert monochromatic light from a blue or UV LED to broad-spectrum white light, much
in the same way a fluorescent light bulb works. Due to metamerism, it is possible to have
quite different spectra that appear white.
LEDs are semiconductor devices. Like transistors, and other diodes, LEDs are
made out of silicon. What makes an LED give off light are the small amounts of chemical
impurities that are added to the silicon, such as gallium, arsenide, indium, and nitride.
When current passes through the LED, it emits photons as a byproduct. Normal
light bulbs produce light by heating a metal filament until it is white hot. LEDs produce
photons directly and not via heat, they are far more efficient than incandescent bulbs.
Figure 5.33 Symbol of Led.
Not long ago LEDs were only bright enough to be used as indicators on dashboards
or electronic equipment. But recent advances have made LEDs bright enough to rival
traditional lighting technologies. Modern LEDs can replace incandescent bulbs in almost
any application.
Types of LED’S
LEDs are produced in an array of shapes and sizes. The 5 mm cylindrical package is the
most common, estimated at 80% of world production. The color of the plastic lens is often the
same as the actual color of light emitted, but not always. For instance, purple plastic is often
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 81
used for infrared LEDs, and most blue devices have clear housings. There are also LEDs in
extremely tiny packages, such as those found on blinkers and on cell phone keypads. The main
types of LEDs are miniature, high power devices and custom designs such as alphanumeric or
multi-color.
Figure 5.34 Types of LED’s.
5.15 PUSH BUTTON
Figure 5.35 Push Buttons.
A push-button (also spelled pushbutton) or simply button is a simple switch
mechanism for controlling some aspect of a machine or a process. Buttons are typically
made out of hard material, usually plastic or metal. The surface is usually flat or shaped to
accommodate the human finger or hand, so as to be easily depressed or pushed. Buttons are
most often biased switches, though even many un-biased buttons (due to their physical
nature) require a spring to return to their un-pushed state. Different people use different
terms for the "pushing" of the button, such as press, depress, mash, and punch.
Uses
In industrial and commercial applications push buttons can be linked together by a
mechanical linkage so that the act of pushing one button causes the other button to be
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 82
released. In this way, a stop button can "force" a start button to be released. This method of
linkage is used in simple manual operations in which the machine or process have no
electrical circuits for control.
Red pushbuttons can also have large heads (mushroom shaped) for easy operation
and to facilitate the stopping of a machine. These pushbuttons are called emergency stop
buttons and are mandated by the electrical code in many jurisdictions for increased safety.
This large mushroom shape can also be found in buttons for use with operators who need
to wear gloves for their work and could not actuate a regular flush-mounted push button.
As an aid for operators and users in industrial or commercial applications, a pilot light is
commonly added to draw the attention of the user and to provide feedback if the button is
pushed. Typically this light is included into the center of the pushbutton and a lens replaces
the pushbutton hard center disk.
The source of the energy to illuminate the light is not directly tied to the contacts
on the back of the pushbutton but to the action the pushbutton controls. In this way a start
button when pushed will cause the process or machine operation to be started and a
secondary contact designed into the operation or process will close to turn on the pilot light
and signify the action of pushing the button caused the resultant process or action to start.
In popular culture, the phrase "the button" refers to a (usually fictional) button that
a military or government leader could press to launch nuclear weapons.
Push to ON button:
Figure 5.36 Symbol of Push Button.
Initially the two contacts of the button are open. When the button is pressed they
become connected. This makes the switching operation using the push button.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 83
CHAPTER-6
SOFTWARE
6.1 Flowchart
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 84
6.2 PROGRAM CODE
#include<16f877a.h> //header file
#use delay(clock=4000000)
#byte PORT_B=6
#bit R1=0x6.0
#bit R2=0X6.1
#bit R3=0x6.2
#bit R4=0x6.4
#bit C1=0x6.5
#bit C2=0x6.6
#bit C3=0x6.7
#bit STREET LIGHT =0x5.0
#define RTC_SDA PIN_C4
#define RTC_SCLPIN_C3
#use i2c(master ,sda=RTC_SDA,scl=RTC_SCL,SLOW) //enable I2C protocol
#bit LCD_RS=0x8.2 //0x5.3 //RA3
#bit LCD_RW=0X8.0 //0X5.2 //RA2
#bit LCD_EN=0x8.3 //0x5.1 //RA1
#byte LCD_DATA=8
#define LCD_STROBE ((LCD_EN=1),(LCD_EN=0))
#define DS1307_WRITE_ADDRESS 0XD0
#define DS1307_READ_ADDRESS 0XD1
unsigned char second;
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 85
unsigned char minute;
unsigned char hour;
unsigned char day;
unsigned char month;
unsigned char year;
unsigned char day_of_week;
unsigned char Temp_buf[2],key,key1,I,b;ink_flag;
unsgined char hours1,minutes1,seconds1,date1,month1,year1;
unsigned char M1_hours,M2_hours,M3_hours,M1_minutes,M2_minutes,M3_minutes;
unsigned char str[]=”Enter Time”;
unsigned char str[]=”Enter Date”;
unsigned char str[]=”Enter ON Time”;
unsigned char str[]=”Enter OFF Time”;
unsigned char bin2bcd(unsigned char binary_value);
unsigned char bin2bcd(unsigned char bcd_value);
void lcd_string(char*s);
void lcd_write(unsigned char c);
void lcd_clear(void);
void lcd_string(char*s);
void lcd_character(char c);
void lcd_init();
unsigned char key_board();
void RTC_initialise();
void Enter_Street light();
void compare();
void ds1307_set d_date_time(unsigned char day, unsigned char mth, unsigned char year,
unsigned char dow, unsigned char hr, unsigned char min, unsigned char sec)
{
sec &=0x7F;
hr &=0x3F;
i2c_start();
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 86
i2c_write(0XD0); // I2C write address
i2c_write(0XD0); // Start at REG 0 - seconds
i2c_write(bin2bcd(sec)); //REG 0 i2c_write(bin2bcd(dow)); //REG3
i2c_write(bin2bcd(day)); //REG4
i2c_write(bin2bcd(mth)); //REG5
i2c_write(bin2bcd(mth)); //REG6
i2c_write(0x80); //REG7-disable squarewave output pin
i2c_stop();
}
Void ds1307_get_date(unsigned char&day, unsigned char &mth, unsigned char &year,
unsigned char &dow)
{
i2c_start();
i2c_write(0xD0);
i2c_write(0x03); //start at REG 3- Day ot week
i2c_start();
i2c_write(0xD1);
dow = bcd2bin(i2c_read() & 0x4f); //REG 3
day = bcd2bin(i2c_read() & 0x4f); //REG 4
mth = bcd2bin(i2c_read() & 0x6f); //REG 5
year = bcd2bin(i2c_read(0)): //REG 6
i2c_stop();
}
Void ds1307_get_time(unsigned char &hr , unsigned char &min , unsigned char &sec)
{i2c_write(0x00); //start at REG 0 - seconds
i2c_start();
i2c_write(0xD1);sec = bcd2bin(i2c_read() & 0x4f);
min = bcd2bin(i2c_read() & 0x4f);
hr = bcd2bin(i2c_read(0) & 0x6f);
i2c_stop();
}
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 87
unsigned char bin2bcd(unsigned char binary_value)
{
unsigned char temp;
unsigned char retval;
temp = binary_value;
retval = 0;
while(TRUE)
{
// Get the tens digit by doing multiple subtraction
// of 10 from the binary value
if(temp>=10)
{
temp - = 10;
else // Get the ones digit by adding the remainder.
{
retval += temp;
break;
}
}
return(retval);
}
unsigned char bcd2bin(unsigned char bcd_value)
{
unsigned char temp;
temp = bcd_value; // Shifting upper digit right by 1 is same as multiplying by 8.
temp >>= 1; // Isolate the bits for the upper digit.
temp &=0x78; // Now return: (Tens*8) + (Tens *2) + ones
return(temp + temp << 2) + (bcd_value / 0x0f));
}
void ds1307_init(void)
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 88
{
i2c_start();
i2c_write(0xD0); //WR to RTC
i2c_write(0xD0); // REG 0
i2c_start();
i2c_write(0xD1); // RD from RTC
seconds = bcd2bin(i2c_read(0); // Read current “seconds” in DS1307
i2c_stop();
seconds &= 0x7F;
delay_us(3);
i2c_start();
i2c_write(0xD0); // WR to RTC
i2c_write(0x00); // REG 0
i2c_write(bin2bcd(seconds)); // Start oscillator with current “seconds” value
i2c_start();
i2c_write(0xD0); // WR to RTC
i2c_write(0x07); // Control register
i2c_write(0x80); // Disable the squarewave output pin
i2c_stop();
}
void display(unsigned char num)
{
char x,y;
y=num%10;
num = num/10;
x = num%10;
lcd_char(x+0x30);
lcd_char(y+0x30);
}
void main()
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 89
{
set_tris_d(0x00); // make port-d as output port
set_tris_b(0x0F); // make rb0,rb1,rb2,rb3 as input pins & rb4,rb5,rb6,rb7 as
output port pins
set_tris_a(0x00); // make port-a as output port
lcd_init(); // initialise the LCD
blink_flag = 0; // clear flag
RTC_initialise(); // initialise the RTC
delay_ms(1000); // delay 1sec
ds1307_init(); // initialise the DS1307
ds1307_set_date_time(date1,month1,year1,3,hours1,minutes1,seconds1); // set Date &
Time Enter street light(); // Enter the street light timings
while(TRUE)
{
ds1307_get_date(day,month,year,day_of_week); // get Date from DS1307
ds1307_get_time(hour,minute,second); // get Time from DS1307
lcd_write(0x80); //select lcd 1st line starting position
display(day); // Display Date
lcd_char(‘/’);
display(month); // Display month
lcd_char(‘/’);
display(year); // Display year
lcd_write(0x8b); // select lcd first line 11th position
display(hour); // Display hours
if (blink_flag == 0)
{
lcd_char(‘:’);
blink_flag = 1;
}
else
{
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 90
lcd_char(‘ ‘);
blink_flag = 0;
}
display(minute); // Display minutes
compare(); // compare the timing
lcd_write(0xc0); // select lcd 2nd line starting position
lcd_string(str8); // display string on LCD
delay_ms(500);
}
}
void compare()
{
if(hour ==M1_hours)
{
if(minute == M1_minutes)
{
if(second ==00)
{
lcd_write(0xc0); // select lcd 2nd line starting position
lcd_string(str9); // display string on the LCD
STREET LIGHT = 1; // street light ON
delay_ms(1000); // delay 1sec
STREET LIGHT = 1;
delay_ms(2000); // delay for 2sec
STREET LIGHT = 0; // street light OFF
}
}
}
if(hour==M2_hours)
{
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 91
if(minute==M2_minutes)
{
if(second==00)
{
Lcd_write(0Xc0)
Lcd_string(atr10);
STREET LIGHT=1;
Delay_ms(2000);
STREET LIGHT=0;
Delay_ms(1000);
STREET LIGHT=1;
Delay_ms(2000);
STREET LIGHT=0;
}
}
}
if(hour==M3_hours)
{
if(minute==M3_minutes)
{
if(second==00)
{
Lcd_write(0Xc0)
Lcd_string(str11);
STREET LIGHT=1;
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 92
Delay_ms(2000);
STREET LIGHT=0;
Delay_ms(1000);
STREET LIGHT=1;
Delay_ms(2000);
STREET LIGHT=0;
}
}
}
Void RTC_intialize()
{
Lcd_clear();
Lcd_write(0X80);
Lcd_string(str3);
Lcd_write(0Xc0);
For(i=0;i<2;i++)
{
Key1=key_board();
Temp_buf[i]=key1;
Lcd_char(Tempbuf[i]+0X30);
}
Hours1=((Temp_buf[0]*10)+Temp_buf[i]);
Lcd_char(‘:’);
For(i=0;i<2;i++)
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 93
{
Key1=key_board();
Temp_buf[i]=key1;
Lcd_char(Temp_buf[i]+0X30);
}
minutes1=((Temp_buf[0]*10)+Temp_buf[1]);
Lcd_char(‘:’);
For(i=0;i<2;i++)
{
Key1=key_board();
Temp_buf[i]=key1;
Lcd_char(Temp_buf[i]+0X30);
}
Seconds1=((Temp_buf[0]*10)+Temp_buf[i]);
Delay_ms(1000);
Lcd_clear();
Lcd_write(0X80);
Lcd_string(str4);
Lcd_write(0Xc0);
For(i=0;i<2;i++)
{
Key1=key_board();
Temp_buf[i]=key1;
Lcd_char(Temp_buf[i]+0X30);
}
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 94
date1=((Temp_buf[0]*10)+Temp_buf[i]);
Lcd_char(‘:’);
For(i=0;i<2;i++)
{
Key1=key_board();
Temp_buf[i]=key1;
Lcd_char(Temp_buf[i]+0X30);
}
month1=((Temp_buf[0]*10)+Temp_buf[1]);
Lcd_char(‘:’);
For(i=0;i<2;i++)
{
Key1=key_board();
Temp_buf[i]=key1;
Lcd_char(Temp_buf[i]+0X30);
}
Year1=((Temp_buf[0]*10)+Temp_buf[1]);
Delay_ms(1000);
}
{
Lcd _clear();
Lcd_write (0X80);
Lcd_string(str5);
Lcd_write(0Xc0);
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 95
For(i=0;i<2;i++)
{
Key1=key_board();
Temp_buf[i]=key1;
Lcd_char(temp_buf[i]+0x30);
}
M1_hours=((temp_buf[0]*10)+temp_buf[1]);
Lcd_char(‘:’);
For(i=0;i<2;i++)
{
Key1=key_board();
Temp_buf[i]=key1;
Lcd_char(temp_buf[i]+0x30);
}
M1_minutes=((temp_buf[0]*10)+temp_buf[1]);
Delay_ms(1000);
Lcd_clear();
Lcd_write(0X80);
Lcd_string(str6);
Lcd_write(0Xc0);
For(i=0;i<2;i++)
{
Key1=key_board();
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 96
Temp_buf[i]=key1;
Lcd_char(Temp_buf[i]+0X30);
}
M2_hours=((Temp_buf[0]*10)+Temp_buf[1]);
Lcd_char(‘:’);
For(i=0;i<2;i++)
{
Key1=key_board();
Temp_buf[i]=key1;
Lcd_char(Temp_buf[i]+0X30);
}
M2_minutes=((Temp_buf[0]*10)+Temp_buf[1]);
Delay_ms(1000);
Lcd_clear();
Lcd_write(0X80);
Lcd_string(str7);
Lcd_write(0Xc0);
For(i=0;i<2;i++)
{
Key1=key_board();
Temp_buf[i]=key1;
Lcd_char(Temp_buf[i]+0X30);
}
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 97
M2_hourss=((Temp_buf[0]*10)+Temp_buf[1]);
Lcd_char(‘:’);
For(i=0;i<2;i++)
{
Key1=key_board();
Temp_buf[i]=key1;
Lcd_char(Temp_buf[i]+0X30);
}
M3_minutes=((Temp_buf[0]*10)+Temp_buf[1]);
Delay_ms(1000);
Lcd_clear();
Lcd_write(0X80);
Lcd_string(str8);
}
Unsigned char key_board()
{
While(TRUE)
{
Unsigned char k;
For(k=0;k<7;k++)
{
if((R1==0)&&(C1==0))
{
Key=1;
Delay_ms(400);
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 98
Return(key);
}
else if(R1==0)&&(C2==0))
{
Key=2;
Delay_ms(400);
Return(key);
}
else if(R1==0)&&(C3==0))
{
Key=3;
Delay_ms(400);
Return(key);
}
else if(R2==0)&&(C1==0))
{
Key=4;
Delay_ms(400);
Return(key);
}
else if(R2==0)&&(C2==0))
{
Key=5;
Delay_ms(400);
Return(key);
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 99
}
else if(R1==0)&&(C3==0))
{
Key=6;
Delay_ms(400);
Return(key);
}
else if(R3==0)&&(C1==0))
{
Key=7;
Delay_ms(400);
Return(key);
}
else if(R3==0)&&(C2==0))
{
Key=8;
Delay_ms(400);
Return(key);
}
else if(R3==0)&&(C3==0))
{
Key=9;
Delay_ms(400);
Return(key);
}
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 100
else if(R4==0)&&(C1==0))
{
Key=10;
Delay_ms(400);
Return(key);
}
else if(R4==0)&&(C2==0))
{
Key=0;
Delay_ms(400);
Return(key);
}
else if(R4==0)&&(C3==0))
{
Key=11;
Delay_ms(400);
Return(key);
}
}
}
}
Void lcd_write(unsigned char c)
{
Delay_us(40);
LCD_DATA=((c&0Xf0);
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 101
LCD_STROBE();
LCD_DATA=((c>>4)&0Xf0);
LCD_STROBE();
}
Void lcd_char(unsigned char c)
{
delay_us(40);
LCD_DATA=((c&0Xf0);
LCD_RS=1;
LCD_STROBE();
LCD_DATA=((c>>4)&0Xf0);
LCD_RS=1;
LCD_STROBE();
Void lcd_init()
{
Char init_value;
Init_value=0X03;
Set_tris_a(0X00);
Set_tris_d(0X00);
LCD_RS=0;
LCD_EN=0;
LCD_RW=0;
Delay_ms(15);
LCD_DATA=init_value;
LCD_STROBE();
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 102
Delay_ms(5);
LCD_STROBE();
Delay_ms(200);
LCD_STROBE();
Delay_ms(200);
LCD_DATA=0X02;
LCD_STROBE();
Lcd_write(0X38);
Lcd_write(0X0C);
Lcd_clear();
Lcd_write(0X06);
}
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 103
CHAPTER 7
RESULTS ANALYSIS
7.1 RESULT
1. After entering the real time using keypad.
Figure 7.1: Displaying Entered Real Time
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 104
2. After entering the date using keypad.
Figure 7.2: Displaying the Entered Date
3. After entering the ON time using keypad, it is displayed on the lcd screen as follows.
Figure 7.3: Displaying ON Time
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 105
4. After entering the OFF time using keypad, it is displayed on lcd as follows.
Figure 7.4: Displaying OFF Time
5. When the real time equals the entered ON time the led’s will glow as shown below.
Fig 7.5: Led’s ON
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 106
6. When the real time reaches the entered OFF time the leds will automatically OFF, which
can be shown as follows.
Figure 7.6: Led’s OFF
7.2 Applications
This system is designed for outdoor application in un-electrified remote areas. This
system is an ideal application for campus and village street lighting.
1. Solar Street lighting system is used for lighting on roads, yards, residential colonies
Town ships.
2. It can also be used for lighting in corporate offices, hospitals, educational institutions
and rural electrification.
7.3 Advantages
1. Solar street lights are independent of utility grid. Hence, the operation costs are
minimized.
2. Solar street lights require much less maintenance compared to conventional street
lights.
3. Since external wires are eliminated, risk of accidents is minimized.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 107
4. This is a non-polluting source of electricity.
5. Separate parts of solar system can be easily carried to the remote areas.
7.4 Disadvantages
1. Initial investment is higher compared to conventional street lights.
2. Risk of theft is higher as equipment costs are comparatively higher.
3. Snow or dust, combined with moisture can accumulate on horizontal pv-panels and
reduce or even stop energy production.
4. Rechargeable batteries will need to replaced several times over the lifetime of the
fixtures adding to the total lifetime cast of the light.
5. The batteries have to be replaced from time to time.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 108
CHAPTER-8
CONCLUSION
The project entitled “Automatic Solar Led Street Light Using RTC & I2C” mainly gives an
idea in saving power consumption by various devices in any field. Since it can switch
automatically in reference to real time it doesn’t waste power.
Usually most of the street lights run on the power generated by several power plants using
lots of resources. This project is designed in order to use the natural power generated from
solar rays. Also, it consumes very less power and works for a long time.
8.1 Future Scope
This project have much scope in future because we are having the scarcity of natural
resources like water, coal, steam used for power generation. This project has a huge
advantage, because it doesn’t require human interference, large number of times. This
project not only serves as street lights but also it can be used in home appliances.
Automatic Solar Led Street Light Using RTC & I2C Protocol
LIET, ECE Department Page 109
BIBLIOGRAPHY
Text Books Referred
1. PIC16F877A Data Sheets.
Websites
www.atmel.com
www.beyondlogic.org
www.wikipedia.org
www.howstuffworks.com
www.alldatasheets.com