Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

programming PIC16F877 to use LM35

Status
Not open for further replies.

AUSTStudent

New Member
Hello

I want to use temperature sensor, LM35 with PIC16F877. There are many programs to connect LM35 with PIC16F877 and then show the result on LCD. I want to display the temperature reading on the Computer through parallel port, as I would be using Serial Port to connect to a mobile.

I am programming the microcontroller in PicBasic Pro. I am using one pin, AN0 to connect the output of LM35. The A/D conversion is performed. I want to have the result of conversion on PortB (or any other port) and then connect this port to computer through parallel port. The code that I have written is shown below:

********************************************************

define ADC_BITS 8

define ADC_CLOCK 3

define ADC_SAMPLEUS 50

x var byte

TRISA=255

TRISB=0

ADCON1=%10000010

pause 500

loop:

ADCIN 0,x

x = x*100 [As for room temperature, I get 0.26V, so multiplying by 100 to
get 26°C, LM35 produces 10mV/°C]

PortB = x

output PortB

pause 500

goto loop
**********************************************************

Using this code, I dont get the data on PortB. The PortB is all zeros. Can anyone plz tell me the what modification should I do in the program???I dont want to display on the LCD.

Where is the result of A/D conversion stored in PIC16F877, so that I can connect PortB to it. Plz explain in detail and that it can work.

Plz help me. Its very urgent...

Thanx a lot...

May God bless all of us...
 
hi,
You have set the ADC to 8bit = 255

With 0.26V in this gives a count of [0.26/5] *255 =13

then you are multiplying by 100 = 1300, which exceeds the 'width' of PORTB [255]

As a test just multiply by 10.. OK
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top