Anda di halaman 1dari 57

Minor project report SOLAR RECORDER |1

1. INTRODUCTION

Solare ne rgyisor igina


tesinthes un’sc orea ndt rave l
st otheEa rth.Int hi sa ct
ivitywede sig nade vic e
,
using this you can find how energy is distributed at the surface of the earth, in both space and time. This
strategy, of exploring how some parameter of interest varies in space and time, is a common strategy in
Earth and environmental science. In this activity, we are also be practicing making solar recorder for
accurate measurement and safe recording of both temperature and intensity at a place for a long time.

The device used for measuring daily temperature and intensity, using this we can calculate solar energy
incident at a place at a time. The device was built with a PIC16F873 and the 512MB flash
memory24LC512c. The solar radiation is measured by a calculator solar cell. The PIC chip interfaces the
flash memory using i2c mode. The interval between samples is set to one minute. The firmware detects the
chip, assigns the memory location and begins recording automatically. The LCD displays the intensity
,temperature & memory location where data is stored. With the flash memory technology and a serial
communication technology, the devices will be able to record huge amount of data and quick data uploading
to the PC.

To estimate the sun energy for a given location, we record the intensity and temperature with time. The
total incident can be computed easily by integrating the intensity curve and add with sum of temperature.
For accurate total radiation measurement, we use the expensive pyranometer. However for simplicity and
cheap instrument we can replace it with a small solar cell as the input sensor. The device use LM35 as input
temperature sensor instead of thermistor to improve accuracy of measurement.

Solar energy is the main returnable source of energy. To avoid the energy deficiency we have a
maximum use of solar energy. So this device has great importance to study about the solar energy for its
maximum usage. Solar radiation contain different radiation which have a great dependence in human life (
ultra-violet radiation in large quantity may cause cancer , IR radiation has great important temperature
maintenance ). This will accelerate importance in study of solar radiation. The solar recorder that we are
developed should help a large extend to solve this problem.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER |2

2. CIRCUIT EXPANSION

As in every embedded system the solar recorder system can be divided


into a number of units with each unit have specified task to do in the system. Each block and detailed
explanation of each is given bellow.

2.1FUNCTIONAL BLOCK DIAGRAM

SERIAL

COMMUNICATION

UNIT

SENSING STORING

UNIT MICROCONTROLLER UNIT

DISPLAY

UNIT

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER |3

2.2BLOCK DIAGRAM DESCRIPTION

The different units are

1. Sensing unit
2. Microcontroller unit
3. Storing unit
4. Display unit
5. Serial communication unit

2.2.1. SENSING UNIT

The function of sensing unit is to sense (measure or convert to equivalent electrical


signal) different parameters like temperature, pressure, humidity from a system for further processing. In
solar recorder the function of sensing unit is to measure temperature of environment (due to incident solar
radiation) and intensity of incident light. For first function we use LM35 & a solar panel for intensity
measurement. The sensing unit send its electrical signal (voltage) output to microcontroller unit.

A. LM35
The LM35 series are precision integrated-circuit temperature sensors, whose output
voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage
over linear temperature sensors calibrated in ° Kelvin, as the user is not required to subtract a large constant
voltage from its output to obtain convenient Centigrade scaling. The LM35 does not require any external
calibration or trimming to provide typical accuracies of ±1⁄ 4°Ca tr oomtemperature and ±3⁄ 4° Cove raf
ull
−55t o+150° Ct empe rat
ur erange. Low cost is assured by trimming and calibration at the wafer level. The
LM35’ slowout putimpe da nce,l ine aroutput, and precise inherent calibration make interfacing to readout or
control circuitry especially easy. It can be used with single power supplies, or with plus and minus supplies.
Asi tdr awsonl y60μAf romi t
ss uppl y,i
tha sve ryl owself-heating, less than 0.1°C in still air. The LM35 is
rated to operate over a −55° to +150°C temperature range, while the LM35C is rated for a −40°t o+110°C
range (−10°wi thi mprove daccuracy).

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER |4

A. SOLAR PANEL

Solar modules are vital in order to convert sunlight directly into electricity. Solar modules are made of
semiconductors which are very similar to those used in the manufacturing of integrated circuits for
electronic equipment. The most popular type of semiconductor currently in use is silicon crystal. Silicon
crystals are laminated into n-type and p-type. When light is applied, a photoelectric effect is induced which
generates power. The electricity produced is called direct current High purity silicon crystals are used in
solar cells. The crystals are processed into solar cells using a melt and 'cast' method. The cast 'cube' is then
cut into 'ingots', and then sliced into very thin wafers.
When the sunlight hits the semiconductor, an electron springs up and is attracted toward
the n-type semiconductor. This will cause more negatives in the n-type and more positives in the p-type
semiconductors, generating a higher flow of electricity. This is the photovoltaic effect. In this circuit we
use a solar panel of 2v as intensity sensor which produce a voltage between 0V & 2V depending on the
intensity of incident beam.

2.2.2 MICROCONTROLLER UNIT


The function of microcontroller unit is to process the electrical signal from sensing unit.
Processing means converting the sensed value to slandered value with a standard unit. The conversion
should be capable to reduce the errors in sensing element. The microcontroller unit decide what to do with
input data.

In solar recorder microcontroller unit take sensors data in every time using ADC port.
After convert to standard digital value it will display and/or store that value depending on the input that we
given through the switches The microcontroller should be capable of read or write the external flash
memory and can be communicate with external peripherals like computer. The important factor is all this
operations should be complete at a particular time interval. Because of all these we are using pic16f877a
with 11GHz crystal oscillator is used as micro controller.

A. PIC16F877A
B.
I. MEMORY ORGANIZATION PIC16877A
There are three memory blocks in each of these PIC micro MCUs. The Program Memory and
Data Memory have separate buses so that concurrent access can occur and is detailed in this section.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER |5

a. PROGRAM MEMORY ORGANIZATION


The PIC16F87X devices have a 13-bit program counter capable of addressing an 8K x 14
program memory space. The PIC16F877/876 devices have 8K x 14 words of FLASH program memory.
Accessing a location above the physically implemented address will cause a wraparound. The reset vector is
at 0000h and the interrupt vector is at 0004h.

b. 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 Func tionRe gi
sters.Some“ hi
g hus e”
Special Function Registers from one bank may be mirrored in another bank for code reduction and quicker
access.

II. TIMER2 MODULE


In solar recorder timer2 module is to produce 1 sec time calculation for writing data to flash memory
chip. 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 module(s). The TMR2 register is readable and writable, and is cleared
on any device 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>). The Timer2 module has an 8-bit period register
PR2. Timer2 increments from 00h until it matches PR2 and then resets to 00h on the next increment
cycle. PR2 is a readable and writable register. The PR2 register is initialized to FFh upon reset. The
match output of TMR2 goes through a 4-bit postscaler (which gives a 1:1 to 1:16 scaling inclusive) to
generate a TMR2 interrupt (latched in flag bit TMR2IF, (PIR1<1>)). Timer2 can be shut off by
clearing control bit TMR2ON (T2CON<2>) to minimize power consumption.

I. 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
two modes:

•Se
ria
lPe
riphe
ralI
nte
rfa
ce(
SPI
)

•I
nte
r-Integrated Circuit (I2C)

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER |6

a. INTER-INTEGRATED CIRCUIT (I2C)

In solar recorder it is used for serial communication with external memory chip.
The MSSP module in I2C mode fully implements all master and slave functions (including
general call support) and provides interrupts-on-start and stop bits in hardware to determine a
free bus (multi-master function). The MSSP module implements the standard mode
specifications, as well as 7-bit and 10-bit addressing. A "glitch" filter is on the SCL and SDA
pins when the pin is an input. This filter operates in both the 100 kHz and 400 kHz modes. In
the 100 kHz mode, when these pins are an output, there is a slew rate control of the pin that is
independant of device frequency. Two pins are used for data transfer. These are the SCL pin,
which is the clock, and the SDA pin, which is the data. The SDA and SCL pins are
automatically configured when the I2C mode is enabled. The SSP module functions are
enabled by setting SSP Enable bit SSPEN (SSPCON<5>). The MSSP module has six registers
for I2C operation. They are the:
a. SSP Control Register (SSPCON)
b. SSP Control Register2 (SSPCON2)
c. SSP Status Register (SSPSTAT)
d. Serial Receive/Transmit Buffer (SSPBUF)
e. SSP Shift Register (SSPSR) - Not directly accessible
f. SSP Address Register (SSPADD)

Before selecting any I2C mode, the SCL and SDA pins must be programmed to inputs by setting the
appropriate TRIS bits. Selecting an I2C mode, by setting the SSPEN bit, enables the SCL and SDA pins to
be usedas the clock and data lines in I2C mode. The CKE bit (SSPSTAT<6:7>) sets the levels of the SDA
and SCL pins in either master or slave mode. When CKE = 1, the levels will conform to the SMBUS
specification. When CKE = 0, the levels will conform to the I2C specification.

The SSPSTAT register gives the status of the data transfer. This information includes
detection of a START (S) or STOP (P) bit, specifies if the received byte was data or address, if the next byte
is the completion of 10-bit address, and if this will be a read or write data transfer. SSPBUF is the register to
which the transfer data is written to or read from. The SSPSR register shifts the data in or out of the device.
In receive operations, the SSPBUF and SSPSR create a doubled buffered receiver. This allows reception of
the next byte to begin before reading the last byte of received data. When the complete byte is received, it is
transferred to the SSPBUF register and flag bit SSPIF is set. If another complete byte is received before the
SSPBUF register is read, a receiver overflow has occurred and bit SSPOV (SSPCON<6>) is set and the byte
in the SSPSR is lost. The SSPADD register holds the slave address. In 10-bit mode, the user needs to write
the high byte of the address (1111 0 A9 A8 0). Following the high byte address match, the low byte of the
address needs to be loaded . The MSSP module will override the input state with the output data when

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER |7

required (slave transmitter). When an address is matched or the data transfer after an address match is
received, the hardware automatically will generate the acknowledge (ACK) pulse, and then load the
SSPBUF register with the received value currently in the SSPSR register. There are certain conditions that
will cause the MSSP module not to give this ACK pulse. These are if either (or both):

II. 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 other devices. The analog input charges a sample and hold capacitor. The output of the sample and
hold capacitor is the input into the converter. The converter then generates a digital result of this analog
level via successive approximation. The A/D conversion of the 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
bede ri
ve df romt heA/ D’sinternal RC oscillator. The A/D module has four registers. These registers are:

a. A/D Result High Register (ADRESH)


b. A/D Result Low Register (ADRESL)
c. A/D Control Register0 (ADCON0)
d. A/D Control Register1 (ADCON1)

. The port pins can be configured as analog inputs (RA3 can also be the voltage reference) or as digital I/O.

The ADRESH:ADRESL registers contain the 10-bit result of the A/D conversion. When
the A/D conversion is complete, the result is loaded into this A/D result register pair, the GO/DONE bit
(ADCON0<2>) is cleared and the A/D interrupt flag bit ADIF is set. After the A/D module has been
configured as desired, the selected channel must be acquired before the conversion is started. The analog
input channels must have their corresponding TRIS bits selected as inputs. Determine sample time. After
this acquisition time has elapsed, the A/D conversion can be started. The following steps should be followed
for doing an A/D conversion:

1. Configure the A/D module:

a. Configure analog pins / voltage reference / and digital I/O (ADCON1)


b. Select A/D input channel (ADCON0)
c. Select A/D conversion clock (ADCON0)
d. Turn on A/D module (ADCON0)

2. Configure A/D interrupt (if desired):

a. Clear ADIF bit


b. Set ADIE bit
c. Set GIE bit

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER |8

3. Wait the required acquisition time.

4. Start conversion:

a. Set GO/DONE bit (ADCON0)

5. Wait for A/D conversion to complete, by either:

a. for the GO/DONE bit to be cleared


b. Waiting for the A/D interrupt

6. Read A/D Result register pair (ADRESH:ADRESL), clear bit ADIF if required.

7. For next conversion, go to step 1 or step 2 as required. The A/D conversion time per bit is defined as
TAD. A minimum wait of 2TAD is required before next acquisition starts.

I. ADDRESSABLE UNIVERSAL SYNCHRONOUS ASYNCHRONOUS


RECEIVER TRANSMITTER (USART)

The Universal Synchronous Asynchronous Receiver Transmitter (USART) module is one of the two serial
I/O modules. (USART is also known as a Serial Communications Interface or 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:

•As
ync
hronous(
ful
l duplex)

•Sy
nchr
onous- Master (half duplex)

•Sy
nchr
onous- 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 the Universal Synchronous Asynchronous Receiver Transmitter. The USART module also
has a multi-processor communication capability using 9-bit address detection.

a. USART Asynchronous Mode

In this mode, the USART uses standard non-return-to zero (NRZ) format (one start bit, eight or nine data
bits,and one stop bit). The most common data format is 8 bits. An on-chip, dedicated, 8-bit baud rate

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER |9

generator can be used to derive standard baud rate frequencies from the oscillator. The USART transmits
and receives t
heLSbf irst.TheUSART’ strans mittera ndrece i
ve rare

functionally independent, but use the same data format and baud rate. The baud rate generator produces a
clock either x16 or x64 of the bit shift rate, depending on bit BRGH (TXSTA<2>). Parity is not supported
by the hardware, but can be implemented in software (and

stored as the ninth data bit). Asynchronous mode is stopped during SLEEP. Asynchronous mode is selected
by clearing bit SYNC (TXSTA<4>). The USART Asynchronous module consists of the following

important elements:

•Ba
udRa
teGe
ner
ator

•Sa
mpl
ingCi
rcuit

•As
ync
hronousTr
ans
mit
ter

•As
ync
hronousRe
cei
ver

b. USART Synchronous Master Mode

In Synchronous Master mode, the data is transmitted in a half-duplex manner (i.e., transmission and
reception do not occur at the same time). When transmitting data, the reception is inhibited and vice versa.
Synchronous mode is entered by setting bit SYNC (TXSTA<4>). In addition, enable bit SPEN
(RCSTA<7>) is set in order to configure the RC6/TX/CK and RC7/RX/DT I/O pins to CK (clock) and DT
(data) lines respectively. The Master mode indicates that the processor transmits the master clock on the CK
line. The Master mode is entered by setting bit CSRC (TXSTA<7>).

c. USART Synchronous Slave Mode


Synchronous slave mode differs from the Master mode in the fact that the shift clock is supplied externally
at the RC6/TX/CK pin (instead of being supplied internally in master mode). This allows the device to
transfer or receive data while in SLEEP mode. Slave mode is entered by clearing bit CSRC (TXSTA<7>).

C. CRYSTAL OSCILLATOR

Cristal oscillator is to provide the necessary clock for the operation of microcontroller .Quartz
crystal is a tuned circuit with a very high Q. This and many other desirable attributes make the crystal an
excellent component choice for oscillators.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 10

Upon start-up, the amplitude of oscillation builds up to the point where nonlinearities in the amplifier
decrease the loop gain to unity. During steady-state operation, the crystal, which has a large reactance-
frequency Slope as we saw in Figure 10, is located in the feedback network at a point where it has the
maximum influence On the frequency of oscillation. A crystal oscillator is unique in that the impedance of
the crystal changes so rapidly with frequency that all other circuit components can be considered to be of
constant reactance, this reactance being calculated at the nominal frequency of the crystal. The frequency of
oscillation will adjust itself so that the crystal presents a reactance to the circuit which will satisfy the
Barkhausen phase requirement

2.2.3 STORING UNIT


The function of storing unit is to permanently store data. Solar recorder use 24lc512 for this
application. The pic microcontroller can communicate(read / write )continuously with this chip using i2c
ports. Data in this chip can also read or delete using serial communication with computer. Pic write a data
in every minute and read when corresponding key press is occur. Each data write need four bytes (temp-
H,temp-L,volt-L,volt-H). Detail of 24lc512 is given bellow

A. FEATURES of 24LC512
The 24LC512B provides 524,288 bits of serial electrically erasable and programmable read
only memory (EEPROM) organized as 65,536 words of 8 bits each. The devi ce’sca scadablefeatureallows
up to eight devices to share a common two-wire bus. The device is optimized for use in many industrial and
commercial applications where low-power and low-voltage operation are essential. The devices are
available in space-saving 8-pin PDIP, 8-lead JEDEC SOIC, 8-lead EIAJ SOIC, 8-lead TSSOP, 8-ball
dBGA2 and 8-lead Ultra Thin SAP packages. In addition, the entire family is available in 1.8V (1.8V to
3.6V) and 2.5V (2.5V to 5.5V) versions. Pin name and function is shown in bellow.

Pin Name Function

A0–A2 Address Inputs

SDA Serial Data

SCL Serial Clock Input

WP Write Protect

a. PIN DESCRIPTION
1. SERIAL CLOCK (SCL): The SCL input is used to positive edge clock data into each
EEPROM device and negative edge clock data out of each device.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 11

2. SERIAL DATA (SDA): The SDA pin is bidirectional for serial data transfer. This pin is open
drain driven and may be wire-OR ed with any number of other open-drain or open collector
devices.
3. DEVICE/PAGE ADDRESSES (A2, A1, A0): The A2, A1, and A0 pins are device address
inputs that are hardwired (directly to GND or to Vcc) for compatibility with other AT24Cxx
devices. When the pins are hardwired, as many as eight 512K devices may be addressed on a
single bus s y ste
m.( De vic ea ddr ess i
ngi sdisc
ussedi nde t
a ilunde r“ De viceAddr essing
,”page
8.) A device is selected when a corresponding hardware and software match is true. If these
pins are left floating, the A2, A1, and A0 pins will be internally pulled down to GND.
However, due to capacitive coupling that may appear during customer applications, Atmel®
recommends always connecting the address pins to a known state. When using a pull-up
resistor, Atmel recommends u s i
ng10kΩorl ess.
4. WRITE PROTECT (WP): The write protect input, when connected to GND, allows normal
write operations. When WP is connected directly to Vcc, all write operations to the memory
are inhibited. If the pin is left floating, the WP pin will be internally pulled down to GND.
However, due to capacitive coupling that may appear during customer applications, Atmel
recommends always connecting the WP pins to a known state. When using a pull-up resistor,
Atmel recommends us ing10k Ωorl ess.

b. MEMORY ORGANIZATION
24LC512B, 512K SERIAL EEPROM: The 512K is internally organized as 512 pages of 128-
bytes each. Random word addressing requires a 16-bit data word address.

c. DEVICE OPERATION
1. CLOCK and DATA TRANSITIONS: The SDA pin is normally pulled high with an external
device. Data on the SDA pin may change only during SCL low time periods Data changes
during SCL high periods will indicate a start or stop condition as defined below.
2. START CONDITION: A high-to-low transition of SDA with SCL high is a start condition
which must precede any other command.
3. STOP CONDITION: A low-to-high transition of SDA with SCL high is a stop condition. After
a read sequence, the stop command will place the EEPROM in a standby power mode
ACKNOWLEDGE: All addresses and data words are serially transmitted to and from the
EEPROM in 8-bit words. The EEPROM sends a zero during the ninth clock cycle to
acknowledge that it has received each word.
4. STANDBY MODE: The AT24C512B features a low power standby mode which is enabled: a)
upon power-up and b) after the receipt of the STOP bit and the completion of any internal
operations.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 12

5. Software Reset: After an interruption in protocol, power loss or system reset, any 2-wirepart
can be protocol reset by following these steps: (a) Create a start bit condition, (b)clock 9
cycles, (c) create another start bit followed by stop bit condition The device is ready for next
communication after above steps have been completed.

2.2.4 DISPLAY UNIT


The function of display unit is to display the output of a embedded system. In solar recorder display
unit has to display both previous (2nd line) and current(1st line) intensity, temperature &memory location
that store the data. For this purposes we use a 16*2 LCD unit as output unit .Details of LCD is given bellow.

This LCD contain 16pin. LCD contain two internal registers. Data register and control register
.The input data is write to data register and commands are write to control register. The name and function
of pins are given bellow. Data should be in ASCI format .

NUMBER NAME FUNCTION

1 VSS provide ground for LCD

2 VDD Provide ide Vcc for LCD ,connect to +5V supply

3 VEE For the control of contrast of LCD display

4 RS (register select) 0: command register will be selected for read /


write operations.
1: 1: Data register will be selected for read/write operations

5 R/W(read / write ) 0: to write to control/data register

1: To read from data/control register

6 E (enable) high to low pulse : Enable the LCD read/write operation

low to high pulse : Disable the LCD read/write operation

7 14 D0 D7 bus line to/from control/data registers in ASCI number format

16 V+& V- supply to the led inside the LED black light.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 13

2.2.5 SERIAL COMMUNICATION UNIT

In solar recorder serial communication unit is connect to pic microcontrollers PORTC


(C6&C7). Through this we can modify the software of the microcontroller. A computer connect to this unit
can directa ccessda tawr iteint hee xterna lfl
ashme mor ybys impl ysendac haract
e rexcept‘ c’.Ifyousend
‘c’tot hi
suni tthiswi l
lc learthee xterna lfla
shme mor y.Thes erialcommuni cati
onuni tcont ainRS2 32for
serial communication & MAX232 to convert RS232 output & input to usable values. Detailed explanation
of each is given bellow.

A. RS232

In RS-232, user data is sent as a time series of bits. Both synchronous and asynchronous transmissions
are supported by the standard. In addition to the data circuits, the standard defines a number of control
circuits used to manage the connection between the DTE and DCE. Each data or control circuit only
operates in one direction, that is, signaling from a DTE to the attached DCE or the reverse. Since transmit
data and receive data are separate circuits, the interface can operate in a full duplex manner, supporting
concurrent data flow in both directions. The standard does not define character framing within the data
stream, or character encoding.

a. VOLTAGE LEVELS

The RS-232 standard defines the voltage levels that correspond to logical one and logical zero levels. Valid
signals are plus or minus 3 to 15 volts. The range near zero volts is not a valid RS-232 level; logic one is
defined as a negative voltage, the signal condition is called marking, and has the functional significance of
OFF. Logic zero is positive, the signal condition is spacing, and has the function ON. The standard specifies
a maximum open-circuit voltage of 25 volts; signal levels of ±5 V,±10 V,±12 V, and ±15 V are all
commonly seen depending on the power supply available within a device. RS-232 drivers and receivers
must be able to withstand indefinite short circuit to ground or to any voltage level up to ±25 volts. The slew
rate or how fast the signal changes between levels, is also controlled.

Because the voltage levels are higher than logic levels typically used by integrated circuits, special
intervening driver circuits are required to translate logic levels. These also protect the device's internal
circuitry from short circuits or transients that may appear on the RS-232 interface, and provide sufficient
current to comply with the slew rate requirements for data transmission. Because both ends of the RS-232
circuit depend on the ground pin being zero volts, problems will occur when connecting machinery and
computers where the voltage between the ground pin on one end, and the ground pin on the other is not zero.
This may also cause a hazardous ground loop

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 14

b. MAX232

The MAX232 is a dual driver/receiver that includes a capacitive voltage generator to supply TIA/EIA-232-F
voltage levels from a single 5-V supply. Each receiver converts TIA/EIA-232-F inputs to 5-V TTL/CMOS
levels. These receivers have a typical threshold of 1.3 V, a typical hysteresis of 0.5 V, and can accept 30-V
inputs. Each driver converts TTL/CMOS input levels into TIA/EIA-232-F levels. The driver, receiver, and
voltage-generator functions are available as cells in the Texas Instruments Lin ASIC library.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 15

2.2 CIRCUIT DIAGRAM

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 16

3. PROGRAM SECTION
2.3 FLOWCHART
2.4
START

Initialize port A as

input port

Initialize portB ,port C ,

port D as output

Initialize ADC
d
TIMER2,USART b

Write_e=0

Read ADC.0 voltage & store in


volt-H & volt-L

Read ADC.1 voltage & store in


temp-H & temp-L

Volt=volt * multi factor


temp=temp/2

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 17

Display volt, temp, location in 1st line &


previous volt,temp, location in 2nd line

NO

Is write-e=

=0

YES

Location=Location+4

Write volt-H,volt-L ,temp-L,temp-H in flash


memory location

Is any key NO
press
YES

NO

Is portD.0= Is portD.1=
0 YES c
0
NO

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 18

YES

m
Prev.location++

YES Is location

<= 0

NO

Location--

Read volt-H ,volt-L,

from chip

Read temp-L ,temp-H

from chip

Call delay

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 19

3.2 PROGRAM

list p=16f877a
#include<p16f877.inc>
cblock 0x20
del1,del2
VoltH,VoltL
TempH,TempL
adh,adl,eep_dat
tenMs,sec
NumH,NumL,TenK,Thou,Hund,Tens,Ones
ACCH,ACCL,ACC2
TEMP0,TEMP1
PreVH,PreVL,PreTH,PreTL,Pre_adh,pre_adl
adh_t,adl_t
ad_cH,ad_cL
count,temp,d1,d2,d3
endc
cblock 0x70
Flag,W_TEMP,S_TEMP
endc
#define ADDHH Flag,0
#defineWrite_e Flag,1
#define Plus portd,0
#defineMinus portd,1
#defineDebon Flag,2
org 0x00
goto main
org 0x04
MOVWF W_TEMP
SWAPF STATUS,W
MOVWF S_TEMP
BANKSEL PIR1
BTFSC PIR1,TMR2IF

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 20

CALL TMR2_INTR
SWAPF S_TEMP,W
MOVWF STATUS
MOVF W_TEMP,W
RETFIE
main
;{ banksel trisc
bsf Plus
bsf Minus
banksel tenMs
clrf tenMs
clrf sec
clrf adh
clrf adl
banksel adcon1
movlw 0x02
movwf adcon1
banksel trisb
clrf trisb
clrf trise
movlw 0xff
movwf trisa
movlw 0xf0
movwf trisd
;}
;lcd initialisation
;{ movlw 0x30
call lcd_cmd
movlw 0x30
call lcd_cmd
movlw 0x30
call lcd_cmd
movlw 0x38
call lcd_cmd
movlw 0x38
call lcd_cmd
movlw 0x38
call lcd_cmd
movlw 0x08
call lcd_cmd

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 21

movlw 0x01
call lcd_cmd
movlw 0x06
call lcd_cmd
movlw 0x0C
call lcd_cmd
movlw 0x80
call lcd_cmd
bcf ADDHH
bsf Write_e
call i2c_init
call TMR2_INIT
clrf PreVH
clrf PreVL
clrf PreTH
clrf PreTL
clrf Pre_adh
clrf pre_adl
clrf ad_Ch
clrf ad_cl
loop
call adc_readV
banksel ACCH
movfw VoltH
movwf NumH
movfw VoltL
movwf NumL
call B_to_ASC
movlw 0x80
call lcd_cmd
; movlw 'V'
; call lcd_dat
; movlw '='
; call lcd_dat
movf Hund,w
call lcd_dat
movlw '.'
call lcd_dat
movf Tens,w
call lcd_dat

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 22

movf Ones,w
call lcd_dat
call adc_readT
banksel ACCH
movfw TempH
movwf NumH
movfw TempL
movwf NumL
call B_to_ASC
movlw ' '
call lcd_dat
movlw ' '
call lcd_dat
movf Hund,w
call lcd_dat
movf Tens,w
call lcd_dat
movf Ones,w
call lcd_dat
banksel ACCH
movfw ad_cH
movwf NumH
movfw ad_Cl
movwf NumL
call B_to_ASC
movlw ' '
call lcd_dat
movlw ' '
call lcd_dat
movf Thou,w
call lcd_dat
movf Hund,w
call lcd_dat
movf Tens,w
call lcd_dat
movf Ones,w
call lcd_dat
movlw 0xC0
call lcd_cmd
banksel ACCH

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 23

movfw PreVH
movwf NumH
movfw PreVL
movwf NumL
call B_to_ASC
movf Hund,w
call lcd_dat
movlw '.'
call lcd_dat
movf Tens,w
call lcd_dat
movf Ones,w
call lcd_dat
banksel ACCH
movfw PreTH
movwf NumH
movfw PreTL
movwf NumL
call B_to_ASC
movlw ' '
call lcd_dat
movlw ' '
call lcd_dat
movf Hund,w
call lcd_dat
movf Tens,w
call lcd_dat
movf Ones,w
call lcd_dat
banksel ACCH
movf pre_adh,w
movwf NumH
movf pre_adl,w
movwf NumL
call B_to_ASC
movlw ' '
call lcd_dat
movlw ' '
call lcd_dat
movf Thou,w

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 24

call lcd_dat
movf Hund,w
call lcd_dat
movf Tens,w
call lcd_dat
movf Ones,w
call lcd_dat;}
btfss Plus
call plus_press
btfss Minus
call minus_press
btfsc write_e
call write_data
goto loop
minus_press
banksel pre_adh
movf pre_adh,f
btfss status,z
goto non_zer_minus
movf pre_adl,f
btfss status,z
goto non_zer_minus
banksel VoltH
movfw VoltH
movwf PreVH
movfw VoltL
movwf PreVL
movfw TempH
MovwfPreTH
movfw TempL
movwf PreTL
movfw ad_ch
movwf pre_adh
movfw ad_cl
movwf pre_adl
return
non_zer_minus
movlw 0xff
addwf pre_adl,f
btfss status,c

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 25

addwf pre_adh,f
banksel pre_adh
movf pre_adh,f
btfss status,z
goto non_zer_minus_jmp1
movf pre_adl,f
btfss status,z
goto non_zer_minus_jmp1
banksel VoltH
movfw VoltH
movwf PreVH
movfw VoltL
movwf PreVL
movfw TempH
MovwfPreTH
movfw TempL
movwf PreTL
movfw ad_ch
movwf pre_adh
movfw ad_cl
movwf pre_adl
return
non_zer_minus_jmp1
clrc
rlf pre_adl,w
movwf adl
rlf pre_adh,w
movwf adh
clrc
bcf ADDHH
rlf adl
rlf adh
btfsc status,z
bsf ADDHH
call i2c_eep_read
banksel eep_dat
movf eep_dat,w
movwf preVH
banksel adl
incf adl

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 26

btfsc status,z
incf adh
call i2c_eep_read
banksel eep_dat
movf eep_dat,w
movwf preVL
banksel adl
incf adl
btfsc status,z
incf adh
call i2c_eep_read
banksel eep_dat
movf eep_dat,w
movwf PreTH
banksel adl
incf adl
btfsc status,z
incf adh
call i2c_eep_read
banksel eep_dat
movf eep_dat,w
movwf preTL
banksel adl
incf adl
btfsc status,z
incf adh
return
plus_press
banksel pre_adh
movf pre_adh,f
btfss status,z
goto non_zer_plus
movf pre_adl,f
btfss status,z
goto non_zer_plus
banksel VoltH
movfw VoltH
movwf PreVH
movfw VoltL
movwf PreVL

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 27

movfw TempH
MovwfPreTH
movfw TempL
movwf PreTL
movfw ad_ch
movwf pre_adh
movfw ad_cl
movwf pre_adl
return
non_zer_plus
movf pre_adh,w
subwf ad_ch,w
btfss status,z
goto $+3
movf ad_cl,w
subwf pre_adl,w
btfsc status,z
return
incf pre_adl,f
btfsc status,z
incf pre_adh,f
clrc
rlf pre_adl,w
movwf adl
rlf pre_adh,w
movwf adh clrc
bcf ADDHH
rlf adl
rlf adh
btfsc status,z
bsf ADDHH
call i2c_eep_read
banksel eep_dat
movf eep_dat,w
movwf preVH
banksel adl
incf adl
btfsc status,z
incf adh
call i2c_eep_read

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 28

banksel eep_dat
movf eep_dat,w
movwf preVL
banksel adl
incf adl
btfsc status,z
incf adh
call i2c_eep_read
banksel eep_dat
movf eep_dat,w
movwf PreTH
banksel adl
incf adl
btfsc status,z
incf adh
call i2c_eep_read
banksel eep_dat
movf eep_dat,w
movwf preTL
banksel adl
incf adl
btfsc status,z
incf adh
return
write_data
;{ banksel VoltH
; movfw VoltH
; movwf PreVH
; movfw VoltL
; movwf PreVL
; movfw TempH
; MovwfPreTH
; movfw TempL
; movwf PreTL
; movfw adh
; movwf pre_adh
; movfw adl
; movwf pre_adl
banksel VoltH
movfw VoltH

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 29

movwf eep_dat
clrc
rlf ad_cL,w
movwf adl
rlf ad_cH,w
movwf adh
clrc
bcf ADDHH
rlf adl
rlf adh
btfsc status,z
bsf ADDHH
call i2c_eep_write
banksel adl
incf adl
btfsc status,z
incf adh
banksel VoltL
movfw VoltL
movwf eep_dat
call i2c_eep_write
banksel adl
incf adl
btfsc status,z
incf adh
banksel TempH
movfw TempH
movwf eep_dat
call i2c_eep_write
banksel adl
incf adl
btfsc status,z
incf adh
banksel TempL
movfw TempL
movwf eep_dat
call i2c_eep_write
banksel adl
incf adl
btfsc status,z

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 30

incf adh
incf ad_cL,f
btfsc status,z
incf ad_cH,f
bcf write_e
return;}
#include <Timer2.inc>
#include <lcd.inc>
#include <adc.inc>
#include <i2c.inc>
end
adc_readV
banksel adcon0
clrf adcon0
movlw 0x80
banksel adcon0
movwf adcon0
banksel adcon1
movlw 0x82
movwf adcon1
banksel adcon0
bsf adcon0,adon
call delayus
banksel adcon0
bsf adcon0,go
adc_jmpV
btfsc adcon0,go
goto adc_jmpV
banksel adcon0
bcf adcon0,adon
call delayus
banksel adresh
movf adresh,w
banksel VoltH
movwf ACCH
banksel adresl
movf adresl,w
banksel VoltL
movwf ACCL
call Volt_multply

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 31

banksel ACCH
movfw ACCH
movwf VoltH
movfw ACCL
movwf VoltL
return
adc_readT
banksel adcon0
clrf adcon0
movlw 0x88
banksel adcon0
movwf adcon0
banksel adcon1
movlw 0x82
movwf adcon1
banksel adcon0
bsf adcon0,adon
call delayus
banksel adcon0
bsf adcon0,go
adc_jmpT
btfsc adcon0,go
goto adc_jmpT
banksel adcon0
bcf adcon0,adon
call delayus
banksel adresh
bcf status,c
rrf adresh,w
banksel TempH
movwf TempH
banksel adresl
rrf adresl,w
banksel TempL
movwf TempL
return
delayus
banksel del1
movlw 0x30
movwf del1

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 32

pageseldelayus_jmp
delayus_jmp
decfsz del1,f
goto delayus_jmp
return
i2c_eep_write
call i2c_wait_till_idle ;wait for idle condition
call i2cstart ;calling start condition
movlw 0xA0
btfsc ADDHH
iorlw 0x02
call i2c_trans
banksel sspcon2
btfsc sspcon2,ackstat ;waiting for acknowledgement
goto trend

banksel adh ;address location of eeprom higher byte


movf adh,0
call i2c_trans
banksel sspcon2
btfsc sspcon2,ackstat
goto trend
banksel adl ;address location of eeprom lower byte
movf adl,0
call i2c_trans
banksel sspcon2
btfsc sspcon2,ackstat
goto trend
banksel eep_dat ;data to be transmitted
movf eep_dat,0
call i2c_trans
banksel sspcon2
btfsc sspcon2,ackstat
goto trend
call i2cstop
return
trend
call i2cstop
goto i2c_eep_write
i2c_eep_read ;read condition

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 33

call i2c_wait_till_idle
call i2cstart
movlw 0xA0
btfsc ADDHH
iorlw 0x02 ;sending device address
call i2c_trans ;transmitting address/data via I2C Data
;pin
banksel sspcon2
btfsc sspcon2,ackstat; wait to get aknowledgement (low) from
; slave
goto rend ;goto read end
banksel adh
movf adh,0
call i2c_trans
banksel sspcon2
btfsc sspcon2,ackstat
goto rend
banksel adh
movf adl,0
call i2c_trans
banksel sspcon2
btfsc sspcon2,ackstat
goto rend
call i2c_restart ;calling restart condition
movlw 0xA1
btfsc ADDHH
iorlw 0x02
call i2c_trans
banksel sspcon2
pagesel rend
btfsc sspcon2,ackstat
goto rend
call i2cread
call i2c_sendnack ;send no acknowledgment
call i2cstop
return
rend
call i2cstop
goto i2c_eep_read

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 34

i2c_init
banksel sspstat
bsf trisc,3 ;clock scl
bsf trisc,4 ;data sda

clrf sspstat ;enable slew rate control for 400khz mode

movlw 0x06
movwf sspadd ;sspadd=(fosc/(bit rate*4))-1
;here bit rate is 400khz
clrf sspcon2
banksel sspcon
movlw 0x28
movwf sspcon
return
i2c_trans
banksel sspbuf ;put the data to be transmitted into
; sspbuf
movwf sspbuf
pageseli2c_trans_jmp
banksel sspstat
i2c_trans_jmp
btfsc sspstat,r_w ;wait for transmission to complete
goto i2c_trans_jmp
return
i2cread
banksel sspcon2
bsf sspcon2,rcen ;receive enable bit
pagesel i2c_read_jmp
i2c_read_jmp
btfsc sspcon2,rcen
goto i2c_read_jmp
banksel sspbuf ;received data taken from SSPBUF to
;working register
movf sspbuf,0
banksel eep_dat
movwf eep_dat
return
i2cstart
banksel sspcon2

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 35

bsf sspcon2,sen
pageseli2cstart_jmp
i2cstart_jmp
btfsc sspcon2,sen ;flag for start condition over
goto i2cstart_jmp
return
i2c_restart
banksel sspcon2
bsf sspcon2,rsen ; flag for restart condition over
pageseli2c_restart_jmp
i2c_restart_jmp
btfsc sspcon2,rsen
goto i2c_restart_jmp
return
i2cstop
banksel sspcon2
bsf sspcon2,pen ;flag for stop condition over
pageseli2cstop_jmp
i2cstop_jmp
btfsc sspcon2,pen
goto i2cstop_jmp
return
i2c_sendack
banksel sspcon2
bcf sspcon2,ackdt ;to send acknowledgement
bsf sspcon2,acken ;enable acknowledgement
pagesel i2c_sendack_jmp
i2c_sendack_jmp
btfsc sspcon2,acken
goto i2c_sendack_jmp
return
i2c_sendnack
banksel sspcon2
bsf sspcon2,ackdt ;if ackdt is set there is no ack
bsf sspcon2,acken
pagesel i2c_sendnack_jmp
i2c_sendnack_jmp
btfsc sspcon2,acken ;wait for getting acknowledged
goto i2c_sendnack_jmp
return

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 36

i2c_wait_till_idle
banksel sspstat
pagesel i2c_wait_till_idle
btfsc sspstat,r_w ;Wait for any rd/wr to complete
goto i2c_wait_till_idle
pageseli2c_wait_jmp1
i2c_wait_jmp1
movf sspcon2,0
andlw 0x1f ;clearing all flags in sspcon2
;so that we can ensure idle condition
;is reached
btfss status,z
goto i2c_wait_jmp1
return
lcd_cmd
banksel trisb
clrf trisb
banksel portb
movwf portb
banksel trise
clrf trise
banksel porte
bcf porte,0
bcf porte,1
bsf porte,2
nop
nop
nop
nop
nop
bcf porte,2
call lcd_delay
return
lcd_dat
banksel portb
movwf portb
banksel porte
bsf porte,0
bcf porte,1
bsf porte,2

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 37

nop
nop
nop
nop
nop
bcf porte,2
call lcd_delay
return

lcd_init
banksel adcon1
movlw 0x02
movwf adcon1
banksel trisb
clrf trisb
bcf trise,0
bcf trise,1
bcf trise,2
movlw 0xff
movwf trisa
movlw 0xf0
movwf trisd
;}
;lcd initialisation
;{
movlw 0x38
call lcd_cmd
movlw 0x38
call lcd_cmd
movlw 0x38
call lcd_cmd
movlw 0x0c
call lcd_cmd

movlw 0x06
call lcd_cmd
movlw 0x01
call lcd_cmd
movlw 0x80

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 38

call lcd_cmd
return
lcd_delay
banksel d1
;1382393 cycles
movlw 0x6C
movwf d1
movlw 0x04
movwf d2
movlw 0x04
movwf d3
lcd_Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto lcd_Delay_0
;3 cycles
goto $+1
nop
;4 cycles (including call)
return
B_to_ASC
swapf NumH,w
andlw 0x0F
addlw 0xF0
movwf Thou
addwf Thou,f
addlw .226
movwf Hund
addlw .50
movwf Ones
movf NumH,w
andlw 0x0F
addwf Hund,f
addwf Hund,f
addwf Ones,f
addlw .233
movwf Tens

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 39

addwf Tens,f
addwf Tens,f
swapf NumL,w
andlw 0x0F
addwf Tens,f
addwf Ones,f
rlf Tens,f
rlf Ones,f
comf Ones,f
rlf Ones,f
movf NumL,w
andlw 0x0F
addwf Ones,f
rlf Thou,f
movlw 0x07
movwf TenK
movlw .10
Lb1:
addwf Ones,f
decf Tens,f
btfss 3,0
goto Lb1
Lb2:
addwf Tens,f
decf Hund,f
btfss 3,0
goto Lb2
Lb3:
addwf Hund,f
decf Thou,f
btfss 3,0
goto Lb3
Lb4:
addwf Thou,f
decf TenK,f
btfss 3,0
goto Lb4
BANKSEL TENK
movlw '0'
addwf TenK,f

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 40

addwf Thou,f
addwf Hund,f
addwf Tens,f
addwf Ones,f
retlw 0
Volt_multply
movf ACCH, w
movwf TEMP0
movf ACCL, w
movwf TEMP1
movf ACCL, w
movwf ACC2
movf ACCH, w
movwf ACCL
clrf ACCH
rlf ACC2, f
rlf ACCL, f
rlf ACCH, f
rlf ACC2, f
rlf ACCL, f
rlf ACCH, f
comf ACCH, f
comf ACCL, f
incf ACCL, f
skpnz
incf ACCH, f
movf TEMP1, w
addwf ACCL, f
movf TEMP0, w
skpnc
incfsz TEMP0, w
addwf ACCH, f
clrc
rrf ACCH, f
rrf ACCL, f
clrc
rrf ACCH, f
rrf ACCL, f
clrc
rrf ACCH, f

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 41

rrf ACCL, f
movf TEMP1, w
subwf ACCL, f
movf TEMP0, w
skpc
incfsz TEMP0, w
subwf ACCH, f
swapf ACCL, w
andlw 0x0F
movwf ACCL
swapf ACCH, w
movwf ACCH
andlw 0xF0
iorwf ACCL, f
xorwf ACCH, f
movlw 0xF0
skpc
iorwf ACCH, f
rlf ACCH, w
rrf ACCH, f
rrf ACCL, f
movf TEMP1, w
addwf ACCL, f
movf TEMP0, w
skpnc
incfsz TEMP0, w
addwf ACCH, f
swapf ACCL, w
andlw 0x0F
movwf ACCL
swapf ACCH, w
movwf ACCH
andlw 0xF0
iorwf ACCL, f
xorwf ACCH, f
movf TEMP1, w
subwf ACCL, f
movf TEMP0, w
skpc
incfsz TEMP0, w

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 42

subwf ACCH, f
swapf ACCL, w
andlw 0x0F
movwf ACCL
swapf ACCH, w
movwf ACCH
andlw 0xF0
iorwf ACCL, f
xorwf ACCH, f
movlw 0xF0
skpc
iorwf ACCH, f
rlf ACCH, w
rrf ACCH, f
rrf ACCL, f
movf TEMP1, w
addwf ACCL, f
movf TEMP0, w
skpnc
incfsz TEMP0, w
addwf ACCH, f
clrc
rrf ACCH, f
rrf ACCL, f
clrc
rrf ACCH, f
rrf ACCL, f
clrc
rrf ACCH, f
rrf ACCL, f
movf TEMP1, w
addwf ACCL, f
movf TEMP0, w
skpnc
incfsz TEMP0, w
addwf ACCH, f
rrf ACCH, f
rrf ACCL, f
clrc
rrf ACCH, f

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 43

rrf ACCL, f
movf TEMP1, w
subwf ACCL, f
movf TEMP0, w
skpc
incfsz TEMP0, w
subwf ACCH, f
swapf ACCL, w
andlw 0x0F
movwf ACCL
swapf ACCH, w
movwf ACCH
andlw 0xF0
iorwf ACCL, f
xorwf ACCH, f
movlw 0xF0
skpc
iorwf ACCH, f
rlf ACCH, w
rrf ACCH, f
rrf ACCL, f
movf TEMP1, w
addwf ACCL, f
movf TEMP0, w
skpnc
incfsz TEMP0, w
addwf ACCH, f
clrc
rrf ACCH, f
rrf ACCL, f
clrc
rrf ACCH, f
rrf ACCL, f
clrc
rrf ACCH, f
rrf ACCL, f
movf TEMP1, w
addwf ACCL, f
movf TEMP0, w
skpnc

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 44

incfsz TEMP0, w
addwf ACCH, f
rrf ACCH, f
rrf ACCL, f
clrc
rrf ACCH, f
rrf ACCL, f
movf TEMP1, w
subwf ACCL, f
movf TEMP0, w
skpc
incfsz TEMP0, w
subwf ACCH, f
swapf ACCL, w
andlw 0x0F
movwf ACCL
swapf ACCH, w
movwf ACCH
andlw 0xF0
iorwf ACCL, f
xorwf ACCH, f
movlw 0xF0
skpc
iorwf ACCH, f
rlf ACCH, w
rrf ACCH, f
rrf ACCL, f
movf TEMP1, w
addwf ACCL, f
movf TEMP0, w
skpnc
incfsz TEMP0, w
addwf ACCH, f
clrc
rrf ACCH, f
rrf ACCL, f
return
TMR2_INTR
BCF PIR1,TMR2IF
banksel tenms

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 45

incf tenms,f
movf tenms,w
xorlw 0x0B
btfss status,z
goto TMR_INT_EXIT
clrf tenms
bcf debon
incf sec,f
movf sec,w
xorlw .30
btfss status,z
goto TMR_INT_EXIT
clrf sec
bsf write_e

TMR_INT_EXIT
RETURN
;setting for 10 ms delay at 11.0592 crysal
TMR2_INIT
BANKSEL TMR2
CLRF TMR2
MOVLW 0X7b
MOVWF T2CON
BANKSEL PR2
MOVLW .107
MOVWF PR2
BANKSEL PIR1
BCF PIR1,TMR2IF
BANKSEL PIE1
BSF PIE1,TMR2IE
BSF INTCON,PEIE
BSF INTCON,GIE
BANKSEL T2CON
BSF T2CON,TMR2ON
RETURN

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 46

3.3 PROGRAM EXPLANATION

In program we are define what to do when an interrupt is called. When an interrupt is


called program execution will shift to location 0x04. At that time we save the address of location where data
isr eadorwr itefr om me mor yc hi
piss toredt oat empor aryr e gis
ter‘TEMP’ .Allinf orma tiona boutthes t
a tus
or
of last operation is also st ed.Af t
erthee xecutionofc ur renti nt
erruptallinf ormation’ sa r
er estoredinto
corresponding registers.

As a second operation of program we define main section. In it the device reading two
ADC port (PORTA.0 & PORTA.1) one after another in all time. For reading from PORTA ,it should be set
as input port. For that TRISA register should be set to high. Depending on the speed and format of ADC
conversion set the registers ADCON0 &ADCON1. Each ADC value can be read from two registers named
ADRESH (higher bits).ADRESL (lower bits). In pic16f877a we have a ten bit ADC that represent each
analog input using ten bits. By adjusting ADCON ,ADCON1 we storing lower 8bits of ADC output in
ADRESL and higher 2bits in ADRESH. The ADC output is read from this registers. After reading ADC
values are multiplied by a multiplication factor. While reading PORTA.0,we read the value and multiplied
by one and in reading PORTA.1 we divide that value by 2 and store to corresponding temporary registers.

After multiplication corresponding values are displayed on LCD. For it LCD should
have to initialized. For it corresponding codes in ASCII is send to control register of LCD. To send a data to
control register move corresponding data to PORTB (data bus of LCD).Set PORTB as output set TRISB to
zero. The control pins are connected to PORTE. Set PORTE as output by clearing TRISE register. Set
PORTE.0(to select control register),PORTE.1 (to enable write operation) as low and send a high to low
pulse to PORTE.2 (for enable the LCD) with a suitable delay. After LCD initialization modified ADC
output in temporary register is send for display. This display should be in the first line of LCD. The order of
display is PORTA.0,PORTA.1,memory location where the last data is stored. For display this values
corresponding commands should send as explained earlier. Then send data to be display to PORTB. Then
set PORTE.0 (TO select data register) to high.,PORTE.1(to enable write) to low, and send a high to low
pulse to PORTE.2( to enable the LCD).this set of operation should be repeated for each read value from
ADC.

Parallel to this operation the timer2 is operating. The operation of timer2 is controlled
by PR2 register and T2CON register. T2CON is adjusted to turn on timer2 and to get prescalar of 16.and
1:16 postscale. A value of 104 is loaded to PR2 to set the timer to1 secant. A second register of name sec is

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 47

used to make 1 minute time interval. When 1min time interval occurred the software clear the write-e
register. This enable the write to external flash memory

The microcontroller is communicate to external device using i2c protocol. When write-e
is cleared, ADC data from PORTA.0,PORTA.1 (digitalized data from ADRESL,ADRESH ) are moved to
SSPBUF register one after another with a time interval. Firstly ADRESL of PORTA.0 is loaded, then its
higher byte from ADRESH is loaded. This is same for PORTA.1. Before data send to SSPBUF registers of
i2c should be initialized.sspsat,sspcon,sspcon2 are the registers of i2c communication protocol . after
corresponding values are loaded to that registers the first byte is loaded to SSPBUF. Then i2c
communication is initialized. The clock to external device can be through SCL & data through SDA.
initially higher bytes are transmitted. In i2c communication initially a START bit is transmitted (initially
SDA become high to low, then SCL become high to low) then address of receiving device (flash memory
chip) is send alone with information about what operation should perform(read/write , here write) as 8th bit,
if acknowledgement is receive from memory chip higher order address in device where data is to be saved
is send , after receiving ACK lower order address will send, after receiving ACK each data byte will send
one by one only after receiving ACK between each byte transfer. Finally send a STOP (initially SCL
become low to high then SDA ) bit to indicate completion of one data transfer. this cycle is repeat for each
clearing of write-e register.

During the entire operation microcontroller continuously checking PORTD for finding
any key press. The PORTD should be set as input port by setting TRISD to one. There are three switches for
solar recorder one is connect to reset pin of pic so software not has to bother about it if this key is press
device is automatically reset and execution is start from beginning. There are two other key they are plus
key and minus key. If plus key is press i2c communication is initialize as explained earlier and set PORTC
as input by setting TRISC. The only difference is instead of writing reading will occur from the next
location where the data is currently displayed. Four bytes( volt-H,volt-L,temp-H,temp-L ) are transferred
from flash memory chip to microcontroller. Then this is displayed on the second line of the LCD. The order
of display is voltage, temperature, memory location from read occur. If the pressed key is minus key the
operation is same but the only difference is instead of reading from next location, the data is read from the
previous location. If minus key is press the software will check that the current location is 00. If it is true it
will display the data on the current location. In case of plus key press if address pointed is the location
where last data is stored, then data on that location will display. On External memory read operation The
clock to external device can be through SCL & data from SDA. Initially higher bytes are transmitted. In i2c
communication initially a START bit is transmitted (initially SDA become high to low, then SCL become
high to low) then address of receiving device (flash memory chip) is send alone with information about what
operation should perform(read/write, here read) as 8th bit, if acknowledgement is receive from memory chip
higher order address in device where data is to be taken is send , after receiving ACK lower order address
will send, after receiving ACK each data byte will send one by one by memory chip to pic only after
receiving ACK between each byte transfer to memory chip from pic.. Finally send a STOP (initially SCL
become low to high then SDA ) bit to indicate completion of one data transfer.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 48

The next main section is the interface with external devices especially the computer. The serial
communication unit is connect to PORTC (PORTC.6,PORTC.7). So for receiving data from external device
set PORTC as input by setting TRISC and for sending data to external devices clearing TRISC. By sending
anyc ha ra
cterexc ept‘ c’devi ceshoul ds enda llda tafrom externa lfl
as hme mor ytoc omput e randi ti
s
cont inuous l
yupt ode vicebec omeof f.Ifc har acter‘c’issends oftwares houldc leartheflash memory. In
fir
s tc asewhe nac ha ra
c t
ere xcept‘ c’isr ec ei
ve .Thes oft
wa reha vetoi nit
iali
z ei2cr eadinga se xplai
ned
earlier. Read data from location 00 to the last location where data write occur This process should
continuous upto the device made off or external device ends the communication process. When a character
‘c’i sre cei
ves oftwa reshoul dc l
e arthef lashme mor ybys endi ng00orbyha rdwa rec leari
ng .

These are the main operations done by the software of solar recorder. There are some
additional tasks are to be handled by the software. They are introduced for the protection of device and for
safety of program execution.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 49

3 PCB LAYOUT

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 50

4 APPLICATIONS

1. The solar recorder can be used as a intensity meter for light intensity measurements with high accuracy

2. It can be used as a digital thermometer for high accuracy temperature measurements

3.It can be used as an intensity recorder for long range measurements upto 6 months. The data can be
secured for ten years

4.It can be used as a temperature recording instrument and the data can be stored upto ten years.

5. By measuring and recording the temperature and intensity of light for long periods we can analyze that
,that particular place can be used for solar electric power generating station.

.6.The solar recorders can be interfaced with computers and can be controlled by them. So we can extend
the storage memory and can be interfaced with a network.

7. By measuring the temperature and intensity we can maintain the necessary atmospheric conditions for the
agricultural field ,medical field ,film industry etc.

8.The peripherals of the circuit have a wide range of operating temperature. So we can sense the intensity
and temperature in places where human cannot reach

9.By including a few multiplication step we can convert this device into solar power recorder for power
measurement.

10.By measuring the continuous temperature values for a long period we can easily get an idea about the
global warming rate by plotting a graph.

11.It can be used for the study of any radiation which can produce photoelectric effect and/or temperature
variation.

12. It is a real time embedded system so it can be used for real time controlling.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 51

5 ADVANTAGES

1. Solar recorders are very cheap as compare with other solar recorders which using pyranometer as
intensity sensors.

2. LM35 is used in this circuit which is more linear than thermistor which increase accuracy of this circuit.

3. This circuit use pic16f877a as microcontroller which has internal ADC, port for serial communication and
more protection circuits as compared to other microcontrollers (8051) which reduces the number of external
peripherals and hence reduces the size of the circuit

4.Microcontroller, the other peripherals required only +5v power supply this reduces the power usage so
this circuit require battery (9-30v) for driving the circuit this again reduces the cost.

5. Microcontroller has 8kb of internal program memory so there is no need for external memory.

6. Solar recorder has external flash memory of 512kb which can be extended up to 1MB of permanent
storage of data this help to increase the continuous working up to 1 year.

7. By interfacing with computer, we can extend storage space into a large extend

8. Small size of the embedded system made it more reliable , it is very easy to handle

9.Display unit (LCD display) need only low power and it have an internal light source which make it to use
in low light area.

10. Using a computer interface through USART software of solar recorder can be modified to add
additional functions.

11. The solar recorder only using bellow 50% of output port so hardware modification of solar recorder is
possible

12. The wide range of operating range of sensors (LM35 (-55 to+155c) make it possible to operate in wide
range of environment parameters.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 52

6 PRECAUTIONS

1. Temperature to be measured should be lies between -55 & 155 for accurate measurement and
for the safety of temperature sensor (LM35)
2. Use of reset switch should be minimize to minimize the power usage.
3. Power supply applied should be between 9V and 100v for safety operation of solar recorder
(flash memory chip & microcontroller). So battery checking and replacing should be done at
regular intervals. if input voltage is more than 100V it should destroy the capacitors of circuit.
If the input voltage is bellow 9V the voltage regulator unable to produce +5V.That create errors
in operation of device.
4. The memory chip have a maximum capacity to store upto 6 months, so it should be replaced or
data should saved to computer and clear the memory to avoid the erroneous recording of data.
5. There is no protection is provided for the safety of sensor unit for maximum accurate
measurement. So special care should be taken for the safety of sensors (solar panel & LM35).
6. In modification of software some precautions are to be taken, that is the modification not affect
the booting program and the main part of the program.
7. There is no switch provided to control the power supply. So external switch is connected for
safety turn of and turn on.
8. There is a time delay is provided between power supply on and turn on of individual
components of solar recorder for safety and accurate operation of device. So key press and
controlling through serial port should be given only after the display unit display the current
value that the sensor measured.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 53

7 CONCLUSION
Solar energy is the main renewable source of energy . But it have many disadvantages which
are harmful for human beings. So the detecting and recording of solar energy have a great importance in
coming years to control use and handle the solar radiation (solar energy). This system is easy to implement
and have a wide range of applications.

This system provide accurate output values for a wide range of environmental conditions..this make
solarre cordertou seina reaswhe r
ehuma nc an’tdi r
e ctl
yr each.Thi sma ket hi
sembe ddeds ys
te ma soneof
the best human friend.

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 54

8 Reference

a. Microchip reference manual DS30292B from www.Microchip.com


b. Fairchild reference manual KA78XX/KA78XXA from www.fairchildsemi.com
c. Atmel reference manual 5297A from www.atmel.com
d. National semiconductor reference manual DS005516 from www.national.com
e. Microchip reference manual DS00826A from www.microchip.com
f. www.atmel.com
g. Microchip reference manual DS30292C from www.microchip.com
h. Microchip reference manual DS41159Cfrom www.microchip.com
i. Reference manual AXE033 from www.rev-ed.co.uk

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 55

9 APPENDIX

a. COST ESTIMATION

ITEM QUANTITY PART No. COST

SL No.
ELECTRONIC COMPONENTS

1 1 Microcontroller pi16f877a Rs. 170

2 1 LM 7805 Rs. 10

3 1 24lc512 Rs. 300

4 1 RS232 Rs 20

5 20 Resistors Rs.5

6 15 Capacitors Rs. 40

7 6 Diode Rs. 3

8 2 LED Rs. 1

9 1 LM35 Rs18

10 2 Solar panel Rs.300

11 1 LCD Module Rs. 140

12 4 Crystal Oscillator Rs. 32


IC SOCKETS

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 56

1 2 40 Pin Rs. 10

2 2 18 Pin Rs. 10

3 2 8 Pin Rs. 10

4 2 6 Pin Rs. 10

ELECTRICAL COMPONENTS

1 1 Transformer 12-0-12 V Rs. 95

2 2 Bread Board Rs. 160

3 1 Power Cord Rs. 80

4 10 m. Single Strand Wire Rs. 30


REPORT

1 Text Book For Microcontroller Rs. 320

2 Print outs Rs. 500

3 Photostat Rs. 50

4 CD Rs. 20

5 Scanning Emblem Rs. 20

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor
Minor project report SOLAR RECORDER | 57

De
par
tme
ntofe
lec
troni
csa
ndc
ommuni
cat
ion Col
leg
eofe
ngi
nee
ringki
dang
oor

Anda mungkin juga menyukai