0% found this document useful (0 votes)
37 views21 pages

Digital Thermometer with PIC 16F877A

This document outlines the design and development of a digital thermometer using the PIC 16f877A microcontroller and LM35DZ temperature sensor. It details the components, including an analog-to-digital converter, and explains the programming and implementation process necessary for accurate temperature measurement. The project aims to apply theoretical knowledge in a practical setting while addressing the challenges of temperature measurement accuracy.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views21 pages

Digital Thermometer with PIC 16F877A

This document outlines the design and development of a digital thermometer using the PIC 16f877A microcontroller and LM35DZ temperature sensor. It details the components, including an analog-to-digital converter, and explains the programming and implementation process necessary for accurate temperature measurement. The project aims to apply theoretical knowledge in a practical setting while addressing the challenges of temperature measurement accuracy.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

NATIONAL UNIVERSITY

SANTIAGO ANTÚNEZ DE MAYOLO

FACULTY OF SCIENCES

Professional School of Engineering of


Systems and Information Technology

MICROPROCESSORS
AND PERIPHERALS

TEACHER: ENG. ALVARADO CACERES LUIS

THEME: DIGITAL THERMOMETER WITH PIC 16f877A

STUDENTS:

Blas Cerda Elmer

Chauca Guzmán John Harold


Calderón Lenin War
Maldonado Inti Nelson Vitaliano
Pohl Cáceres Paul
Silverio Torres Edison
Tahua Quijano Edwin
HUARAZ ± 2011
INTRODUCTION

This paper explains the design and development to implement a


"digital thermometer" based on the PIC 16f877A microcontroller, manufactured by
Microchip, which will be programmed in the assembly language of the microcontroller for
the functioning of the project.

Temperature is a misleading measure due to its simplicity. A


We often think of her as just a number, but in reality, she is a structure.
statistics whose accuracy and repeatability may be affected by thermal mass, the
measurement time, electrical noise, and measurement algorithms.

The temperature is difficult to measure accurately even under optimal circumstances, and in
the testing conditions in real environments is even more difficult. Understanding the advantages
and the disadvantages of the various approaches that exist to measure temperature,
it will be easier to avoid problems and achieve better results.
1. GENERAL DESCRIPTIONS

The present project aims to build a digital thermometer that


using an LM35DZ temperature sensor, display the temperature of
environment in an LCD display.

To carry out this project, the use of the


PIC 16f877A microcontroller which has a built-in converter
analog digital that acts as an interpreter between the sensor and the PIC, this PIC
it will be programmed in assembly language to perform the methods
necessary.

With this project we aim to put into practice the


concepts learned so far in the course and also develop
our capabilities in formulation, development, and implementation of
system projects.

[Link] FRAMEWORK

SensorLM35DZ

The sensor that will be used is the LM35DZ transistor model TO-92,
which is a temperature sensor with good accuracy in Celsius scale.
This device converts ambient temperature into voltage.
order of mV.

The LM35DZ provides an output resolution of 10mV for each


Celsius degree.

Using it only without any special configuration, the


the device has a measurement range of 2 to 150°C, as shown at
continuation:

This setup is ideal for the project as it only


we will use it to measure temperatures up to 99°C.
This sensor is manufactured by Fairchild and National Semiconductor.

Analog-to-digital converter

The conversion stage will be carried out using a converter.


analog-to-digital, which is an A/D of 8 bits with parallel output, because it is
one of the most popular devices in systems applications, in addition to
being well documented, as there is a large amount of information in books and in
Internet to be used in applications with microprocessors,
microcontrollers and PLDs.

This converter uses the method of successive approximations for the


conversion, which is briefly described below:

Successive approximation converters contain a fixed value in


its conversion time that does not depend on the value of the analog input, the
the basic arrangement is similar to that of a digital ramp ADC, however, the
successive approximation converter does not use any counter to provide the
input in the DAC converter block, but instead uses a register with
control logic that modifies the content of the register bit by bit until the data
The record is the digital equivalent of the analog entry.

The conversion time of successive approximation converters


n bits require n clock cycles to perform their conversion regardless of the
magnitude of the voltage that is present at its input, this is due to the
control circuits need to test a logic 1 in each bit position to
see if it is needed or not, it's for stock the approximation converters
successive ones have very fast conversion times, their use in applications of
data acquisition systems will allow for the acquisition of more values from
data over a given time interval.

This can be very important when the analog data changes its
value quickly.
An example of an A/D converter is the ADC0804.

The function of each of its pins is:

Pin Name Function Logic

1 CS- Chip Select Enable the chip I/0


2 RD - Authorized exit Read the information I/0
3 WR- Start conversion Start conversion I/0
4 CLKIN Clock entry
5 INTR End conversion indicator I/0
6 Vlts + Analog positive signal -0.3/16V
7 Vlts - Analog negative signal 0
8 A GND Analog Earth 0
9 Vref/2 1/2 maximum of Pin 6
10 D GND Digital land
11/18 DB7 to DB0 Digital outputs I/0
19 CLK R Internal clock outputs
20 Vcc Food up to 6.5V

This converter is manufactured by National Semiconductor.

This converter will be used because the LM35DZ sensor provides us with the
temperature as voltage and since voltage is an analog quantity, we need to
convert it to its equivalent in digital value to be able to handle it, as the values
digital is discrete quantities and therefore it is easier to work with them than with
analog quantities.

The converter presents the following diagram according to the placement of


the pines described above:

Its most important characteristics are:

y It has two analog inputs: VIN(+) and VIN(-), which allow to have
differential inputs. That is, the actual input voltage VINit is the difference
between the voltages applied at those terminals. In measurements taken in
a single point, the analog input is applied in VIN(+) while VIN(-) it
connects to the analog ground. During normal operation, the converter
use VCC+5 V as the reference voltage and the analog input can
vary from 0 to 5 V, which is the full scale value.
y Convert the analog input voltage into an eight-bit digital output.
The output is three-state, allowing the converter to connect with
ease in data channels. With eight bits the resolution is 5V / 255 =
19.6 mV.
y It has an internal clock circuit that produces a frequency equal to
f=1/(1.1RC), where R and C are the values of the external components
connected to the converter. A typical clock frequency is 606 kHz and is
obtains with R = 10k; y C = 150 pf. If desired, it can also be connected to a
external clock; this connects to the CLKIN terminal of the IC.
y When using a frequency of 606 kHz, the conversion time is,
approximately equal to 100Qs.
y It has separate ground connections for the analog voltages and
digital. Terminal eight corresponds to the analog earth and connects to
common point as a reference in the analog circuit that generates the voltage
analog. Terminal ten is the digital ground, which is used by everyone.
the digital devices that integrate into the system.

Microcontroller PIC 16f877A

The interpretation of the data obtained from the A/D converter is


it is carried out within the PIC 16f877A microcontroller, manufactured by Microchip.
The PIC 16f877A converts the values from the A/D converter into values.
equivalents for visualization.
As this device is the one that will carry out the most work.
important to our project, because it is useless to have the best sensor
not the most accurate analog-to-digital converter for temperature
we have a device that interprets the values correctly, we
The PIC 16f877A will be briefly described below:
For the most common applications (almost 90%), the choice of a
the appropriate version of PIC is the best solution; however, given its nature
general, other families of microcontrollers are more effective in applications
specific, especially if they have a particular characteristic that predominates
it may be very developed in another family.

The most important details of the excellent reception that the PICs have are the
following:

y Ease of handling: They have a reduced set of instructions; 35 in the range.


media.
y Good information, easy to obtain and affordable.
y Precio: Su coste es comparativamente inferior al de sus competidores.
y They have a high operating speed. Good average of parameters:
speed, consumption, size, power supply, compact code, etc.
y Easy and cheap development tools.
y There is a wide variety of hardware tools that allow recording, debugging,
erase and check the behavior of the PICs.
y Fast design.
y The wide variety of PIC models allows you to choose the one that best meets the
application requirements.
One of the reasons for the success of the PICs is based on their use. When learning
to handle one of them, knowing their architecture and their repertoire of
instructions, it is very easy to use another model.
Relevant characteristics.

Description of the most representative features of the PICs:

Architecture.

The processor architecture follows the Harvard model. In this


architecture, the CPU connects independently and with different buses with
the instruction memory and the data memory.

The Harvard architecture allows the CPU to access the


two memories. Furthermore, it promotes numerous advantages to the functioning of
system as they will be described.

Segmentation.

The segmentation technique ('pipe-line') is applied in the execution of the


instructions.

Segmentation allows the processor to perform simultaneously the


execution of an instruction and the search for the code of the next one. From this
each instruction can be executed in a loop (a loop of instructions
equivalent to four clock cycles.

Jump instructions take two cycles when the address of the


next instruction until the branching one is completed.

Format of the instructions.

The format of all the instructions is the same length.

All instructions of the low-range microcontrollers have


a length of 12 bits. The mid-range ones have 14 bits and more than the high range ones.
high. This feature is very advantageous in memory optimization
instructions and greatly facilitates the construction of assemblers and
compilers.

Game of instructions.

RISC Processor (Reduced Instruction Set Computer).

The low-end models come with a repertoire of 33.


Instructions, 35 for the mid-range and almost 60 for the high-end.

All instructions are orthogonal


Any instruction can handle any element of the architecture.
as a source or as a destination.

Architecture based on a 'register bank'


This means that all the system objects (I/O ports,
timers, memory positions, etc.) are physically implemented
like records.
Diversity of microcontroller models with features and
different resources
The wide variety of PIC microcontroller models allows for the
user can select the most suitable for their project.

Powerful and economical support tools


The company Microchip and others that use the PIC make available to
users numerous tools to develop hardware and software. They are
muy abundantes los programadores, los simuladores software, los emuladores en
real time, Assemblers, C Compilers, BASIC Interpreters and Compilers,
etc.

The Harvard architecture and the segmentation technique are the


main resources on which high performance relies
characterize these programmable devices, improving two characteristics
essentials:
y Execution speed.
y Efficiency in code compacting.

Features of the PIC 16f877A

y 1K program RAM memory with 14-bit Flash type word.


y Data EEPROM memory with 68 general-purpose registers.
y 8-bit ALU.
y 2 communication ports, port A with 5 bits and port B with 8 bits.
y Timer with prescaler.
y 8-level stack.
y 13-bit program counter.
Dipl d cry to the liquid (LCD) 2 liters a by 16 characters r
(k 0066u)

For visualizing temperatures, use a display of


liquid crystal (L of 2 lines for 16 characters (ks66uel whatever
connected to the output of port B of the PI16F to send him the
data is visualized as it is equivalent to decimal numbers of the
Word of Italian obtained from the ADC and through port A they will send the signals.
to control the device.

3. The A

The thermometer was developed according to the following diagram.


blocks

220 ohm

The block diagram shows the general scheme of the


project that starts from a sensor that in this case is the L the which
transforms the ambient temperature into voltage, on the order of mV, this
The device outputs a resolution of 10mV per degree.
Celsius.

Using them without any special configuration, the device


a measurement range of 2 to 150°C, this configuration is ideal for
The project will only be used to measure temperatures up to 99°C.

Once the output from the analog sensor is obtained, it is sent to the ...
analog-to-digital converter (A/D), which is an 8-bit A/D converter with
parallel output, which has the great task of transforming the analog signal from the
L 5 digital signals of 8 bits are sent to the interpretation phase.
The interpretation of the data obtained from the A/D converter it
It will be carried out in the PIC 16f877A microcontroller, which will convert the values.
equivalents for visualization.

This device needs to be properly programmed to


obtain the desired operation which is of great importance
this stage as it will define the success or failure of the project. This programming
It is done in Assembly language for subsequent burning.

A display will be used for the temperature visualization.


cristal líquido (LCD) de 2 líneas por 16 caracteres el cual será conectado a
the output of port B of the PIC 16f877A to send data to it
visualize, these being the equivalents to decimal numbers of the word
digital obtained from the ADC and through port A the signals will be sent to
control the device.

So that the PIC 16f877A can carry out the interpretation of the
datos es necesario que este sea programado con la funcionalidad deseada
To do this, we will use the following block diagram of the operation.
of the program that will be burned into the PIC 16f877A.
4. IMPLEMENTATION DIGITAL THERMOMETER

MATERIAL AND EQUIPMENT TO USE:

y 1PROTOBOARD
y PIC16f877A
y SENSORLM35DZ
y ADC0804
y 4MHzCRYSTAL
y 2x16LIQUIDCRYSTALDISPLAY
y 2ceramiccapacitorsof27pf
y 150pfCERAMICCAPACITOR
y 210Kpressurepotentiometers;
y 10K RESISTOR; A¼DEWATT
y 5VPOWERSUPPLY
y TELEPHONECABLE
y POINTEDANDCUTPLIERS
y DIGITALMULTIMETER
y REGULATEDPOWERSUPPLYOF5V

DEVELOPMENT OF THE DIGITAL THERMOMETER

Initially, one must consider how the sensor works.


LM35, which as previously mentioned, gives us 10mV at the output.
each degree Celsius.

Since the sensor output is in mV, this output will be converted into a
digital quantity to facilitate its handling. For this, the ADC0804 will be used.

For the analog-to-digital conversion, the ADC0804 will be manipulated as follows


way

1. The CAD is enabled by applying a low pulse to the CS terminal,


to initiate the conversion.
2. The terminal (low pulse) called WR is enabled to start the
conversion process, for this you must wait 100Qs
approximately for the conversion to take place.
3. The terminal (low pulse) named RD is enabled so that at the output it
tenga el resultado de la conversión.
4. Finally, the converter is disabled.

The above can be seen in the following diagram:


The reference voltage that will be handled in the converter is calculated.
in the following way:
Since the LM35 provides an output of 10mV/°C and the maximum
the temperature that can be detected is 150 °C, it has to be 10mV x 150 =
1.5V, which is the maximum voltage it can deliver, then, based on
At this voltage, since it is the maximum, it will be the reference voltage.
But as the ADC handles V at its inputREF/2 the voltage of
the reference will be 0.75 V.
The current that will be handled at that reference voltage will be
1mA and the voltage will be obtained from VCC= 5V through a voltage divider:

The total resistance of the divider is calculated:


Rt = VCC/ Idesired
Rt = 5V / 1mA = 2.5 k;

The factor that will be used to calculate R1 and R2 of the divider


tension is calculated:

Vdesired/ Vtotal= 0.75V / 5V = 0.15

Once the factor is obtained, the value of the ...


resistors:
R1 = 0.15 * 2.5k; = 375;

R2 = 2.5k; - 375; = 2125;

Now it will be checked if the values are correct:

Vref= (375;/375;+2125;0.75 V = 5V

What is the voltage needed to adjust the steps of the


full-scale converter.

Regarding the PIC 16f877A, to interpret the value of the


conversion and its visualization, the program was developed to
according to the following block diagram:

From the information presented in the block diagram, the following is developed
code in MikroC language.
unsigned ;
unsigned int dc_rd;
char*text,*text2,*text;
lng tl ng;
int i,j;
id ain(){
I = 0;
cd_Config(&P B, 4, 5, , 3, 2, , 0);
CD_Cmd(LCD_CURSR_OFF);
LCD_Cmd(LCD_CLEAR);
for(i=0;i<5;i++){
LCD_Cmd(LCD_CLEAR);
I . SIS E AS
LCD_Out(1,i,text);
Delay_ms(1000);
I AND ELECTRONIC IERIA
LCD_Out(2,i,text2);
Delay_ms(1000);
}
text1= "INGENIERIA ELECTRONICA";
LCD_Out(2,1,text1);
ADCON1= 0x82;
TRISA = 0xFF;
Delay_ms(10000);
LCD_Cmd(LCD_CLEAR);

Temperature:
for (j = 16; j > 0; j--) {
LCD_Cmd(LCD_CLEAR);
LCD_Out(1,j,text);
Delay_ms(500);
}

while (1){
adc_rd= ADC_read(2);

tlong = (long)adc_rd * 5000;


tlong = tlong / 1023 - 40;
ch= tlong /1000;

if(ch==0)
LCD_Chr(2,6,' ');
else
LCD_Chr(2,6,48+ch);

ch=(tlong /100)%10;

LCD_Chr_CP(48+ch);
ch=(tlong /10)%10;
LCD_Chr_CP(48+ch);
LCD_Chr_CP('.');

ch= tlong %10;


LCD_Chr_CP(48+ch);
LCD_Chr_CP('C');
Delay_ms(200);
}
}

And in assembly language, the code is as follows:


;#############################################################

LIST p= PIC 16f877A Direction to define micro.


#include<[Link]> Standard header file.

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

#################### DEFINITIONS ###########################

Lcd_var E U 0X10
ACCOUNT1 E U 0X08
CONTA2 E U 0X09
ASCI E U 0X12
ACCOUNT3 E U 0X20
CONTA4 E U 0X21
THE TEMPERATUREE U 0X24
UNIT E U 0X25
DECT E U 0X26
TEN E U 0X27
UNO E U 0X28
UNI E U 0X29
################BEGINNING OF THE PROGRAM#####################

ORG0X00
GOTOHOME

MAIN PROGRAM
ORG 0X05
#include<[Link]> LCD routines file.

*********TABLE OF TEMPERATURE VALUES.*******************


;************************************************************
Routine: TABLE
Function: Table with the temperature values to display on the LCD.
Entries: W.
Outputs: W.
Variables used: None.
;************************************************************

TABLE ADDWFPCL,F ;SUMAWA PCL


RETLWB'10000011' ;- 3°CPOS.0
RETLWB'10000010' ;- 2°CPOS.1
RETLWB'10000001' ;- 1°CPOS.2
RETLWB'00000000' ; 0°C POS.3
RETLWB'00000001' ;+ 1°C POS.4
RETLWB'00000010' ;+ 2°CPOS.5
RETLWB'00000011' ;+ 3°CPOS.6
RETLWB'00000100' ;+ 4°CPOS.7
RETLWB'00000101' ;+ 5°CPOS.8
RETLWB'00000110' ;+ 6°CPOS.9
RETLWB'00000111' ;+ 7°CPOS.10
RETLWB'00001000' ;+ 8°CPOS.11
RETLWB'00001001'; + 9°CPOS.12
RETLWB'00001010';+10°C POS.13
RETLWB'00001011' ;+11°C POS.14
RETLWB'00001100' ;+12°C POS.15
RETLWB'00001101' ;+13°C POS.16
RETLWB'00001110' ;+14°C POS.17
RETLWB'00001111' ;+15°C POS.18
RETLWB'00010000'; +16°C POSITION.19
RETLWB'00010001' ;+17°C POS.20
RETLWB'00010010' ;+18°C POSITION.21
RETLWB'00010011' ;+19°C POS.22
RETLWB'00010100' ;+20°C POS.23
RETLWB'00010101' ;+21°C POS.24
RETLWB'00010110' ;+22°C POS.25
RETLWB'00010111'; +23°C POS.26
RETLWB'00011000'; +24°C POS.27
RETLWB'00011001' ;+25°C POSITION.28
RETLWB'00011010' ;+26°C POS.29
RETLWB'00011011' ;+27°C POSITION.30
RETLWB'00011100'; +28°C POS.31
RETLWB'00011101' ;+29°C POSITION.32
RETLWB'00011110'; +30°C POS.33
RETLWB'00011111' ;+31°C POS.34
RETLWB'00100000' ;+32°C POSITION.35
RETLWB'00100001' ;+33°C POS.36
RETLWB'00100010' ;+34°CPOS.37
RETLWB'00100011'; +35°C POS.38
RETLWB'00100100' ;+36°CPOS.39
RETLWB'00100101' ;+37°CPOS.40
RETLWB'00100110' ;+38°C POSITION.41
RETLWB'00100111'; +39°CPOS.43
RETLWB'00101000' ;+40°C POS.44
RETLWB'00101000' ;+40°C POS.45
RETLWB'00101000' ;+40°C POS.46
RETLWB'00101000' ;+40°CPOS.47
RETLWB'00101000' ;+40°C POS.48
RETLWB'00101000' ;+40°C POS.49
RETLWB'00101000'; +40°C POS.50

RETURN RETURN TO THE SUBROUTINE.

;*************** INICIALIZACION DELPROGRAMA.*****************


START BSFSTATUS,RP0 WE SET PORTS A AND B AS OUTPUTS,
CLRF TRISB
CLRF TRISA
BCFSTATUS,RP0
MOVLWB'00110000'; WE INTRODUCE THE NUMBER '00110000' INTO THE REGISTER
MOVWFASCI ;ASCI.
CALL LCD_INI INITIALIZE THE LCD DISPLAY.

MOVLWB'00001100' DISPLAY LCD IN BLINK AND WITHOUT CURSOR.


CALL LCD_REG

MOVLW 0x80 VISUALIZATION OF THE PHRASE "THE TEMPERATURE"


CALL LCD_REG ON THE FIRST LINE OF THE LCD DISPLAY
BY MEANS OF
MOVLW'L' LCD_ORDER_REGY_LCD_DATA OF THE FILE
CALL LCD_DATA ;[Link].
MOVLW 'A'
CALL LCD_DATA
MOVLW ' '
CALL LCD_DATA
MOVLW'T'
CALL LCD_DATA
MOVLW 'E'
CALL LCD_DATA
MOVLW'M'
CALL LCD_DATA
MOVLW 'P'
CALL LCD_DATA
MOVLW 'E'
CALL LCD_DATA
MOVLW 'R'
CALL LCD_DATA
MOVLW 'A'
CALL LCD_DATA
MOVLW'T'
CALL LCD_DATA
MOVLW'U'
CALL LCD_DATO
MOVLW 'R'
CALL LCD_DATA
MOVLW 'A'
CALL LCD_DATO

MOVLW 0xC0 VISUALIZATION OF THE PHRASE "ISDE:+00°C"


CALL LCD_REG ON THE SECOND LINE OF THE LCD DISPLAY
BY MEANS OF
MOVLW 'E' THE ORDERS LCD REGY LCD DATA OF THE FILE
CALL LCD_DATA ;LCD_CXX.INC.
MOVLW'S'
CALL LCD_DATA
MOVLW ' '
CALL LCD_DATA
Load W with 'D'
CALL LCD_DATA
MOVLW 'E'
CALL LCD_DATA
MOVLW
CALL LCD_DATA
MOVLW ' '
CALL LCD_DATA
MOVLW '+'
CALL LCD_DATA
Move Literal to W Register '0'
CALL LCD_DATA
Move literal '0' to W register
CALL LCD_DATA
MOVLWB'11011111'
CALL LCD_DATA
MOVLW 'C'
CALL LCD_DATA

***************BEGINNING OF THE MAIN PROGRAM.*************

PRINCIPAL MOVLWB'00011000' DISABLE DISPLAY AND ADC.


Move W to PORTA
CALL TEMPO1 TIMINGS FOR THE GOOD
OPERATION
CALL TEMPO1 ;DELADC.
CALL TEMPO1
CALL TIME1
CALL TIME1

BSFSTATUS, RP0 PORT AS INPUTS TO RECEIVE DATA,


MOVLWB'11111111' ENABLE ADC AS READING.
Move W to TRISB
BCFSTATUS,RP0
MOVLWB'00010000'
MOVWFPORTA

CALL TEMPO1 TIMING TO FINISH EXECUTING


CALL TEMPO1 ;LALECTURA ELADC.
CALL TIME1
CALL TEMPO1
CALL TEMPO1

MOVLWB'00000000' ENABLING THE LETTER OF THE D.C.


MOVWF PORTA

CALL TIME1 TIMING TO FINISH REALIZING


CALL TEMPO1 THE WRITING OF THE DC.
CALL TEMPO1
CALL TEMPO1
CALL TIME1

MOVF PORTB,W DATA COLLECTION OF THE ADC, CALL TO


TABLE
CALL TABLE Data paralysis conversion and storage
MOVWF TEMPERATURE ;THIS DATA IN TEMPERATURE REGISTER.

BSFSTATUS,RP0 ;PORTBCOMOSALIDAS, DISABLEMENT OF


ADC
CLRF TRISB ENABLING THE LCD DISPLAY.
BCF STATUS,RP0
MOVLWB'00011100'
Move W to PORTA

BTFS TEMPERATURE, 7; ASK IF THE DATA IS POSITIVE OR


GOTO POSITIVE NEGATIVE CONELBIT 7 OF THE REGISTER
TEMPERATURE.
GOTO NEGATIVE

POSITIVE MOVLW 0xC7 SEND THE SIGN TO POSITION 0XC7


CALL LCD_REG DEL DISPLAYLCDY JUMP TO THE POSITION
MOVLW '+'' FIN.
CALL LCD_DATA
GOTO FINT

NEGATIVE BCF TEMPERATURE,7; PUT STEELBIT 7 OF THE RECORD


TEMPERATURE
MOVLW 0xC7 SIGNAL TO POSITION 0XC7
CALL LCD_REG; DELETE DISPLAYLCD.
MOVLW'-'
CALL LCD_DATA

FINT CALL BCDT CALL THE BCD CONVERSION SUBROUTINE.

MOVLW 0xC9 WRITE THE UNITEN REGISTRATION DATA


CALL LCD_REG POSITION 0XC9 OF LCD DISPLAY.
MOVF UNIT,W
CALL LCD_DATA

MOVLW 0xC8 WRITE THE DATA OF THE DETECTED RECORD


CALL LCD_REG POSITION0XC8 OF THE LCD DISPLAY.
MOVF DECT,W
CALL LCD_DATA

GOTO PRINCIPAL JUMP TO THE MAIN POSITION.

;******************** SUBRUTINE TIME 1.**********************


;*************************************************************
Routine: TEMPO1
Function: Delay for the correct reading of the ADC with 2 counters in decimal
; de255y40 respectively.
;Entradas: Ninguna.
Outputs: None.
Variables used: CONTA3, CONTA4
;*************************************************** **********
TEMPO1 MOVLW 255 SUBROUTINE OF TIMING THROUGH
MOVWFCONTA3 ;COUNTERSLOADEDWITHTHENUMBERS
MOVLW.40 ; IN DECIMAL 255 AND 40 RESPECTIVELY.
MOVWFCONTA4

LOOP3 DECFSZCONTA3,1
GOTOBUCLE3

LOOP4 DECFSZCONTA4,1
GOTO LOOP3
RETURN

************BCD CONVERSION OF TEMPERATURE.*************


;************************************************************
;Routine:BCDT
Function: Convert the analog temperature values to digital for
; separate the tens from the units and convert it to ASCII value.
;Entradas: TEMPERATURA, ASCI.
Outputs: UNIT, DECT.
Variables used: None.
;********************************* ***************************

BCDT CLRF UNIT SUBROUTINE CONVERTS THE VALUE IN


CLRF DECT BINARY OF A BCD RECORD.
MOVLWB'00001010';VARIABLEDIEZ=10.
MOVWFDIEZ
MOVLWB'00000001' ;VARIABLEUNO=1.
MOVWFUNO
GOTO DOS
PRINCIPAL INCF DECT,F INCREASE BY 1 FOR EACH
TWO MOVE TEMPERATURE, W; TENS OF TEMPERATURE.
THREE MOVE WORK FUNCTION OF THE UNIT
MOVF TEN, W
SUBWF TEMPERATURE, F; WE SUBTRACT 10 FROM THE TEMPERATURE FOR
BTFSCSTATUS,C SEPARATE THE TENS FROM THE UNITS.
GOTOPRINCI
GO TO FOUR
FIVE INCF UNIT, F INCREMENT UNITEN 1 FOR EACH
FOUR MOVF ONE,W UNIT OF TEMPERATURE.
SUBWFUNI,F WE SUBTRACT 1 FROM THE UNITS TO KNOW
BTFSCSTATUS,C THE UNITS.
GO TO FIVE
MOVFASCI,W WE CONVERTED THE VALUE OF UNIT ASCII.
XORWFUNIT
MOVFASCI,W We convert the value of the DEDCTA ASCI.
XORWFDECT
RETURN
;################END MAIN PROGRAM#####################
END;End of program

After compiling the code and generating its hexadecimal code, it will be simulated.
its operation in the Proteus Software according to the following graph
Thermometer diagram in Proteus
5. SYNTHESIS

As we have explained the project carry out the measurement of the


ambient temperature using an LM35 sensor which gives us the measurement
in an analog signal, which will be converted to digital by the converter
analog digital that will provide an 8-bit digital signal as output that
they will be interpreted by the PIC 16f877A and the visualization of the
data on the LCD.

With this device, we can measure the temperature of an environment.


the device in question such as a motor, refrigerator, etc.

BIBLIOGRAPHY

y PIC Microcontrollers, Practical Design of Applications


José Ma. Ángulo Usategui, Ignacio Ángulo Martínez
2nd edition
McGraw Hill Publishing
Pages 29, 30
1999

y [Link]
y [Link]
y [Link]
y [Link]

You might also like