THERMO LM35 DZ with PIC16F877

Status
Not open for further replies.

derrick826

New Member
Hi guys ,

i have a problem with interfacing the THERMO LM35 into PIC16F877. Basically i have already done a program to calculate the voltage converted in the PIC16F877 by using the internal ADC in to a temperature value. I have simulated my program in the PIC simulator IDE using the 7-segments LED ( common cathode) and it actually works. As the voltage value of the ADC changes due to the LM35 which converts the temperature to voltage value , it basically gives me the correct display on the 7-segment LEDS.

Based on the LM35 DZ data shee, + 10.0 mV/°C scale factor, i have calculated that let's say it's a temperature of 25 celcius , .....so the device itself will output about 0.25v which goes to the 10-bit ADC of the PIC that converts into a digital value of 51 in decimal. With that converted value , i have divided the 51 decimal by 2 to get back my temperature value which is approximately 25.5 celcius which will be displayed on the 3 7-segments leds.

i build the hardware as followed :
**broken link removed**


but it didn't give the expected display on the 3 7-segments LEDS. The displays didn't turn out to be numbers. Is my PIC program has something wrong or the hardware which i have build is wrong? hope you guys can give me a helping hand.. thanks
 
Your PIC program is probably wrong, you're probably not converting the numbers to the correct bit patterns for the LED's.

You might check my seven segment tutorial?, where I use a lookup table to do this.
 
Hi derrick826 can you tell me how do you get the value 51? Does it an automatically generated value from AD module (without calculated).
 
You haven't connected a voltage reference for the A to D. (Or is this not required for a pic A to D)
 
erosennin said:
You haven't connected a voltage reference for the A to D. (Or is this not required for a pic A to D)

You can set it use Vdd internally as the reference.
 
Well if VDD is 5V, and Voltage from the LM35 is going to be approximately 0.25V at all times, won't this cause issues with a 10bit resolution?

Edit: I take that back... it's fine
 
Last edited:

here you go.... but i have already double checked my bit patterns for the LED's.
 
derrick826 said:
is my connection for the LM35 correct?

hi,
That looks OK, what do you measure with a DVM on the output pin of the LM35?? at say room temp, knowing that its 10mV/deg??

Copied your code, will give a spin later on, let you know!
 
here in my country is about 26 degree celcius so referring to the data sheet it produces 10mv/1 degree celcius.... the voltage which i get is approximately 0.26v when measuring with a DVM

answer for the above question:Hi derrick826 can you tell me how do you get the value 51?

0.25v if 25 degree celcius is divided by (5/1023) which gives 51.15

I suspect is the hardware configuration part? cause i have tried so many times to improve on the program, and retest on the simulation...... i'm not that good when comes to the hardware part..
 
Last edited:
i didn't use any base resistors for Q1-Q3 will it have any effect?
what do you mean standard pinout? i'm using the basic common cathode 7-segment display which has 10 pins (something like DIP pins)
 
derrick826 said:
i didn't use any base resistors for Q1-Q3 will it have any effect?
what do you mean standard pinout? i'm using the basic common cathode 7-segment display which has 10 pins (something like DIP pins)

hi,
Resistors are recommended, say 470R/1K.

If I am reading your diagram correctly, you are using PNP transistors, so the LED will be enabled when the PIC pin is Low 0v???

If you are driving the segments High shouldnt the transistors be npn, ON when the pin is High???
 
Last edited:
I agree with you, Eric. The transistors must be npn type, BC337 for example.
1k base resistors should be fine.
 
o000 meaning that for the RC0, RC1 and RC2 pin should be connected in series to a 470R/1K ohm before connecting to the PNP transistors and the output for each of this pins must be a 0 v, low to switch on the 7-segment led (common cathode). am i right.?
 
i have changed the diagram
**broken link removed**
is this the right one now? and the program have to be changed.. instead of driving high i must drive low
 
hi eng1,

I am pro-simulators, BUT they must be used with caution as they can appear to run a program correctly.

When I used to design surveying equipment, I had to rely heavily on simulation,
so I had a number of PC's configured as different types of equipment.

My argument in favour of simulation, if it works in the simulator it dosnt necessarily mean it will work in the field,
BUT if dosn't work in simulation it will NEVER work in the field... A sort of guilty until proven innocent approach!

Regards
 
hi,
NPN transistors as you are setting the transistor drive pins high.

The 1K's are OK
 
Last edited:

Hi Eric, is your observation directed at me? I totally agree with your point of view.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…