You are on page 1of 31

DATA LOGGING TO COLLECT AND DISPLAY

TEMPERATURE WITH TIME AND DAY


BY
B.NIHARIKA(07241A0240)
SAYARA SULTANA(07241A0248)
B.PRASANNA (07241A0242)
L.HARIKA (07241A0204)
Under the guidance of Mr.K.SATISH KUMAR
(Assistant Professor)

DEPARTMENT OF ELECTRICAL ENGINEERING
GOKARAJU RANGARAJU INSTITUTEOF ENGINEERING&
TECHNOLOGY

CONTENTS
1.INTRODUCTION
2.BLOCK DIAGRAM
8051 MICROCONTROLLER
RTC
ADC
RS232/MAX232
LM35
PC HYPERTERMINAL
3. SIMULATION CIRCUIT
4.PCB DESIGN
5.APPLICATIONS
6.SOURCE CODE
7.LIST OF HARDWARE COMPONENTS



INTRODUCTION

The main object of our project is to update the analog data to the server with period of
each second, display and store the data with temperature ,time and day through serial
communication.
In this project we are doing simulation in PROTEUS 6.9 using AT89c51,Analog to
Digital converter(ADC),Real time clock(RTC),Temperature sensor(LM35),RS232 and designing
the PCB using EAGLE software.
Here the temperature is obtained as analog value and later it is converted to digital value by
analog-to-digital converter.By using Real time Clock,time and day are displayed.Temperature is
displayed using LM35 sensor(100
o
C). The whole data which is collected is displayed on the PC
screen in the hyperterminal console using RS232.


BLOCK DIAGRAM:
PC
HYPERTERMINAL
RS232 MAX232

TEMPERATURE
SENSOR (LM35)


ADC
RTC


8051
MICRO
CONTROLLER
8051 MICROCONTROLLER:
The 8051 micro controller generic part number actually includes a whole family of
microcontrollers that have numbers ranging from 8031 to 8751 and are available in N-channel
metal oxide silicon (NMOS) and complementary metal oxide silicon (CMOS) construction in
variety of packages.
The Intel 8051 is an 8-bit microcontroller which means that most available operations are
limited to 8-bit. There are 3 basic sizes of the 8051:short, standard, and extended. The short and
standard chips are often available in DIP(dual in-line package) form, but the Extended 8051
models often have a different form factor, and are not drop-in compatible. All these things are
called 8051 because they can all be programmed using 8051 assembly language, and they all
share certain features (although the different models all have their own special features).
FEATURES OF 8051:
8-bit data bus
16-bit address bus
32 general purpose registers each 8 bits
16 bit timers(usually 2, but may have more, or less)
3 internal and 2 external interrupts.
Bit as well as byte addressable RAM area of 16 bytes.
Four 8-bit ports, (short models have two 8-bit ports).
16-bit program counter and data pointer.
8051 models may also have a number of special, model-specific features, such as UARTs, ADC,
OpAmps ,etc..
TMOD is dedicated solely to the two timers and can be considered to be two duplicate 4-
bit registers each of which controls the action of one of the timers. TCON has control bits and
flags for the timers in the upper nibble and control bits and flags for the external interrupts in the
lower nibble.

PIN CONFIGURATION OF 8051:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RXD)P3.0
(TXD)P3.1
(T0)P3.4
(T1)P3.5
XTAL2
XTAL1
GND
(INT0)P3.2
(INT1)P3.3
(RD)P3.7
(WR)P3.6
Vcc
P0.0(AD0)
P0.1(AD1)
P0.2(AD2)
P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
EA/VPP
ALE/PROG
PSEN
P2.7(A15)
P2.6(A14)
P2.5(A13)
P2.4(A12)
P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
8051

INPUT/OUTPUT PORTS:
One major feature of a micro controller is the versatility built into the input/output
circuits that connect the 8051 to the outside world. Given the pin flexibility, the 8051 may be
simply applied as a single component with input/output only, or it may be expanded to include
additional memory, parallel ports, and serial data communication by using the alternate pin
assignments. Those locations weve just added are called ports. There are several types of
ports: input, output or bi-directional ports. When working with ports, first of all it is necessary to
choose which port we need to work with, and then to send data to, or take it from the port.
When working with it the port acts like a memory location. Something is simply being
written into or read from it, and it could be noticed on the pins of the micro-controller.
There are 4 8-bit ports P0, P1, P2, P3.
PORT P1(pins 1 to 8): the port P1 is general purpose input/output port which can be used
for a variety of interfacing tasks. The ports P0, P2 and P3 have duel roles or additional functions
associated with them based upon the context of their usage.
PORT P3(pins 7 to 17): PORT P3 acts a normal IO port, but port P3 has additional
functions such as, serial transmit and receive pins, 2 external interrupt pins, 2 external counter
inputs, read and write pins for memory access.
PORT P2(pins 21 to 28): PORT P2 can also be used as a general purpose 8 bit port when
no external memory is present, but if external memory access is required then PORT P2 will act
as an address bus in conjunction with PORT P0 to access external memory. PORT P2 acts as A8-
A15.
PORT0(pins 32 to 39): PORT P0 can be used as a general purpose 8 bit port when no
external memory is present, but if external memory access is required then PORT P0 acts as a
multiplexed address and data bus that can be used to access external memory is conjunction with
PORT P2. P0 acts as AD0-AD7.
RTC REAL TIME CLOCK:
A real time clock is basically just like a watch - it runs on a battery and keeps time
for you even when there is a power outage. Using an RTC, you can keep track of long timelines,
even if you reprogram your microcontroller or disconnect it from USB or a power plug. A RTC
is a computer clock that keeps the track of current time. RTCs are present in almost any
electronic device which needs to keep accurate time. RTCs often have an alternate source of
power, so they can continue to keep time while the primary source of power is off or
unavailable.
Most RTCs use a crystal oscillator but some use the power line frequency. In many
cases the oscillators frequency is 32.768 kHz. This is the same frequency used in quartz clocks
and watches, and for the same reasons ,namely that frequency is exactly 2
15
cycles per second,
which is convenient rate to use with simple binary counter circuits.
RS232:
In telecommunications, RS-232 (Recommended Standard 232) is the traditional name
for a series of standards for serial binary single-ended data and control signals connecting
between a DTE (Data Terminal Equipment) and a DCE (Data Circuit-terminating Equipment). It
is commonly used in computer serial ports. The standard defines the electrical characteristics and
timing of signals, the meaning of signals, and the physical size and pinout of connectors. The
current version of the standard is TIA-232-F Interface Between Data Terminal Equipment and
Data Circuit-Terminating Equipment Employing Serial Binary Data Interchange, issued in 1997.
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.
RS-232 devices may be classified as Data Terminal Equipment (DTE) or Data
Communication Equipment (DCE); this defines at each device which wires will be sending and
receiving each signal. In general and according to the standard, terminals and computers have
male connectors with DTE pin functions, and modems have female connectors with DCE pin
functions. Other devices may have any combination of connector gender and pin definitions.
Many terminals were manufactured with female terminals but were sold with a cable with male
connectors at each end; the terminal with its cable satisfied the recommendations in the standard.
PIN DIAGRAM OF RS232




SERIAL COMMUNICATION:
Serial communication is often used either to control or to receive data from an embedded
microprocessor. Serial communication is a form of I/O in which the bits of a byte begin
transferred appear one after the other in a timed sequence on a single wire. Serial communication
has become the standard for intercomputer communication. In this project, we'll try to build a
serial link between 8051 and PC using RS232.
8051 provides a transmit channel and a receive channel of serial communication. The transmit
data pin (TXD) is specified at P3.1, and the receive data pin (RXD) is at P3.0. The serial signals
provided on these pins are TTL signal levels.All modes are controlled through SCON, the Serial
CONtrol register. The SCON bits are defined as SM0, SM1, SM2, REN, TB8, RB8, TI, RI from
MSB to LSB. The timers are controlled using TMOD, the Timer MODe register, and TCON, the
Timer CONtrol register.

TEMPERATURE SENSOR(LM35):
The LM35 sensor series(shown in figure) are precision integrated-circuit temperature
sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature.

The LM35 sensor 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 sensor does not require any external calibration or
trimming to provide typical accuracies of C at room temperature and C over a full -55 to
+150C temperature range. The LM35's low output impedance, linear output, 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. As it draws only 60 mA from
its supply, it has very low self-heating, less than 0.1C in still air. The LM35 is rated to operate
over a b55 to a150C temperature range, while the LM35C is rated for a b40 to a110Crange
(b10 with improved accuracy).


ADC: ANALOG TO DIGITAL CONVERTER:
Analog-to-Digital converters are among the most widely used devices for data
acquisition. An analog-to-digital converter (abbreviated ADC, A/D or A to D) is a device that
converts a continuous quantity to a discrete digital number. The reverse operation is performed
by a digital-to-analog converter (DAC).
Typically, an ADC is an electronic device that converts an input analog voltage (or
current) to a digital number proportional to the magnitude of the voltage or current. However,
some non-electronic or only partially electronic devices, such as rotary encoders, can also be
considered ADCs.

The digital output may use different coding schemes. Typically the digital output will be a
two's complement binary number that is proportional to the input, but there are other
possibilities. An encoder, for example, might output a Gray code.
An ADC might be used to make an isolated measurement. ADCs are also used to
quantize time-varying signals by turning them into a sequence of digital samples. The result is
quantized in both time and value.






SIMULATION CIRCUIT:







PCB DESIGN:



APPLICATIONS:
Environmental study center.

SOURCE CODE:
#include<reg51.h>
#include<stdio.h>
#include<ds1307.h>
sbit WRITE=P2^5;
sbit READ=P2^6;
sbit INTR=P2^7;
sfr ldata=0x90;
void delay(int);

char RTC_ARR[7]; // Buffer for second,minute,.....,year
void main()
{
char value1,value2,var;
INTR=1;
WRITE=1;
READ=1;
while(1)
{ ReadRTC(&RTC_ARR[0]);
RTC_ARR[0] =RTC_ARR[0] & 0x7F; // enable oscillator (bit 7=0)
RTC_ARR[1] =0x50; // minute =59
RTC_ARR[2] =0x12; // hour =05 ,24-hour mode(bit 6=0)
RTC_ARR[3] =0x03; // Day =1 or sunday
RTC_ARR[4] =0x10; // Date =30
RTC_ARR[5] =0x08; // month =August
RTC_ARR[6] =0x10; // year =05 or 2005
WriteRTC(&RTC_ARR[0]); // Set RTC
WRITE=0;
delay(10);
WRITE=1;
while(INTR==1);
READ=0;
delay(10);
TMOD=0x20;
TH1=0xfd;
SCON=0x52;
TR1=1;
ReadRTC(&RTC_ARR[0]);
//putchar(0x0C);
printf("\n Data Logging \n");
printf(" ____________ \n\n");
printf("Time : %02bX:%02bX:%02bX",RTC_ARR[2],RTC_ARR[1],RTC_ARR[0]);
printf(" %s\r",Int2Day(RTC_ARR[3]));
delay(10);
printf("\n Temperature =");
delay(10);
var=ldata;
//var=ldata*10/7.66;
if(ldata>=10)
{
value1=(var/10)+0x30;
SBUF=value1;
delay(10);
value2=(var%10)+0x30;
SBUF=value2;
delay(10);
}
else
{
value2=(var%10)+0x30;
SBUF=value2;
delay(10);
}
printf(" deg");
while(TI==0);
TI=0;
delay(10);
READ=1;
delay(1000);
}}
void delay(int time)
{
int i,j;
for(i=0;i<time;i++);
for(j=0;j<5000;j++);}
HEADER FILE:
#include<reg51.h>
#include<intrins.h>

#define ACK 1
#define NO_ACK 0
#define SLAVE 0xD0
#define WRITE 0x00
#define READ 0x01
#define ERR_ACK 0x01

unsigned char i;

const unsigned char * DayStr[7] = {{"Sun"},
{"Mon"},
{"Tue"},
{"Wen"},
{"The"},
{"Fri"},
{"Sat"}};


const unsigned char * MonthStr[12] ={{"J an"},
{"Feb"},
{"Mar"},
{"Apr"},
{"May"},
{"J un"},
{"J ul"},
{"Aug"},
{"Sep"},
{"Oct"},
{"Nov"},
{"Dec"}};


sbit SDA = P2^1; // connect to SDA pin (Data)
sbit SCL = P2^0; // connect to SCL pin (Clock)



//-------------------------------
// Convert BCD 1 byte to HEX 1 byte
//-------------------------------
/*unsigned char BCD2HEX(unsigned int bcd)
{
unsigned char temp;
temp=((bcd>>8)*100)|((bcd>>4)*10)|(bcd&0x0f);
return temp;

} */

//-------------------------------
// start I2C
//-------------------------------
void Start(void)
{
SDA =1;
SCL =1;
_nop_();_nop_();
SDA =0;
_nop_();_nop_();
SCL =0;
_nop_();_nop_();
}

//-------------------------------
// stop I2C
//-------------------------------
void Stop(void)
{
SDA =0;
_nop_();_nop_();
SCL =1;
_nop_();_nop_();
SDA =1;
}

//-------------------------------
// Write I2C
//-------------------------------
void WriteI2C(unsigned char Data)
{

for (i=0;i<8;i++)
{
SDA =(Data & 0x80) ? 1:0;
SCL=1;SCL=0;
Data<<=1;
}

SCL =1;
_nop_();_nop_();
SCL =0;

}

//-------------------------------
// Read I2C
//-------------------------------
unsigned char ReadI2C(bit ACK_Bit)
{

unsigned char Data=0;

SDA =1;
for (i=0;i<8;i++)
{
SCL =1;
Data<<=1;
Data =(Data | SDA);
SCL =0;
_nop_();
}

if (ACK_Bit ==1)
SDA =0; // Send ACK
else
SDA =1; // Send NO ACK

_nop_();_nop_();
SCL =1;
_nop_();_nop_();
SCL =0;

return Data;
}

// Read RTC (all real time)
//-------------------------------
void ReadRTC(unsigned char * buff)
{


Start();
WriteI2C(0xD0);
WriteI2C(0x00);

Start();
WriteI2C(0xD1);
*(buff+0)=ReadI2C(ACK); // Second
*(buff+1)=ReadI2C(ACK); // Minute
*(buff+2)=ReadI2C(ACK); // hour
*(buff+3)=ReadI2C(ACK); // Day
*(buff+4)=ReadI2C(ACK); // date
*(buff+5)=ReadI2C(ACK); // month
*(buff+6)=ReadI2C(NO_ACK); // year
Stop();
}

//-------------------------------
// Write RTC
//-------------------------------
void WriteRTC(unsigned char *buff)
{

Start();
WriteI2C(0xD0);
WriteI2C(0x00);
WriteI2C(*(buff+0));
WriteI2C(*(buff+1));
WriteI2C(*(buff+2));
WriteI2C(*(buff+3));
WriteI2C(*(buff+4));
WriteI2C(*(buff+5));
WriteI2C(*(buff+6));
Stop();
}
//-------------------------------
// Convert date (BCD) to string of Day
// 1=Sanday
// 2=Monday
// And so on
//-------------------------------
char * Int2Day(unsigned char day)
{
return DayStr[day-1];}
#include<reg51.h>
#include<stdio.h>
#include<ds1307.h>
sbit WRITE=P2^5;
sbit READ=P2^6;
sbit INTR=P2^7;
sfr ldata=0x90;
void delay(int);

char RTC_ARR[7]; // Buffer for second,minute,.....,year
void main()
{
char value1,value2,var;
INTR=1;
WRITE=1;
READ=1;
while(1)
{ ReadRTC(&RTC_ARR[0]);
RTC_ARR[0] =RTC_ARR[0] & 0x7F; // enable oscillator (bit 7=0)
RTC_ARR[1] =0x50; // minute =59
RTC_ARR[2] =0x12; // hour =05 ,24-hour mode(bit 6=0)
RTC_ARR[3] =0x03; // Day =1 or sunday
RTC_ARR[4] =0x10; // Date =30
RTC_ARR[5] =0x08; // month =August
RTC_ARR[6] =0x10; // year =05 or 2005
WriteRTC(&RTC_ARR[0]); // Set RTC
WRITE=0;
delay(10);
WRITE=1;
while(INTR==1);
READ=0;
delay(10);
TMOD=0x20;
TH1=0xfd;
SCON=0x52;
TR1=1;
ReadRTC(&RTC_ARR[0]);
//putchar(0x0C);
printf("\n Data Logging \n");
printf(" ____________ \n\n");
printf("Time : %02bX:%02bX:%02bX",RTC_ARR[2],RTC_ARR[1],RTC_ARR[0]);
printf(" %s\r",Int2Day(RTC_ARR[3]));
delay(10);
printf("\n Temperature =");
delay(10);
var=ldata;
//var=ldata*10/7.66;
if(ldata>=10)
{
value1=(var/10)+0x30;
SBUF=value1;
delay(10);
value2=(var%10)+0x30;
SBUF=value2;
delay(10);
}
else
{
value2=(var%10)+0x30;
SBUF=value2;
delay(10);
}
printf(" deg");
while(TI==0);
TI=0;
delay(10);
READ=1;
delay(1000);
}}
void delay(int time)
{
int i,j;
for(i=0;i<time;i++);
for(j=0;j<5000;j++);








LIST OF HARDWARE COMPONENTS:
S.NO NAME OF THE QUANTITY
COMPONENT
1. Adapter socket 1
2. Regulator 1
3. On-off switch 1
4. CMOS battery with holder 1
5. Serial port 1
6. 8051 microcontroller 1
7. RS232 1
8. DS1307 1
9. LM35 1
10. Resistors 10k
1k
4
3
11. Capacitors 1000uF,35V
10uF,50V
33pF
1uF tantalum

1
3
3
4
12. Pull up resistors 1k 1
13. Pot 10K 1
14. Crystal 11.0592MHz 1
15. LED 1
16. Push button 1
17. Bergsticks 40
18. Diodes 4
19. Reed 1
20. LDR 1

You might also like