CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

16F877 ADC with LM35 ( temp sensor ) - overheating!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Rollo
Guest







16F877 ADC with LM35 ( temp sensor ) - overheating!
PostPosted: Tue Mar 18, 2003 11:13 am     Reply with quote

As a one-week CCS C and PIC newbie, I was very pleased to finally get some ADC going with a POT, arranged with byte output from 0 to 255, on a 16F877. Nice, smooth and accurate.

But now, I'm trying to get a reading from a temp sensor, the LM35 ( the Celsius version of the LM34 ), but something must be shorting, because it immediately overheats when I connect. I keep double checking my wiring, as soon as I remove the LM35 and replace with the POT, all is well.

I've re-read the datasheet for 16F877 and LM35 a few times. Though I can see there's a warning in there regarding pins that can consume current out of spec, as an PIC and electronics newbie migrating from BS2, I don't have a clear picture what to do about it, and I'm stuck.

I've seen a couple of references on the Web where people seem to be connecting 16F877 pin A0 directly to the output of the LM35 ( or LM34 ), with the two other pins going to +5 and Ground. I even tried a POT to configure A3 as a Vref set to voltage +2.55V, but There's something I'm not getting...

Since the guidande on this board, thus far has been great, I thought I would ask. Any guidance would be appreciated.

Rol

Here's the code:


#INCLUDE <16F877.h>
#DEVICE ADC=8
#INCLUDE <stdlib.h>
#USE delay (clock = 4000000)
#FUSES HS,NOWDT,NOPROTECT,NOLVP,PUT, NOBROWNOUT


// bits on and off on 7-seg-LED
byte CONST segs[12] = { 0b10000001, 0b10110111, 0b11000100, 0b10010100, 0b10110010, 0b10011000, 0b10001000, 0b10110101, 0b10000000, 0b10010000, 0b01111111, 0b11111111 };

void poz()
{
delay_ms(200);
}

set_tris_A(1);

void main()
{
char numstring[5]="";
byte count=0;
byte number = 0;

setup_port_a( RA0_RA1_ANALOG_RA3_REF );
setup_adc( ADC_CLOCK_DIV_8 );
set_adc_channel( 0 );
delay_ms(500);

do{
number= Read_ADC();
delay_ms(500);

sprintf( numstring, "\%03u", number );
// turn number to string.

for( count=0;count<=2; count++) // output 7-seg led
{
output_B(segs[(numstring[count]) - '0']);
poz();
output_b(segs[11]);
poz();

}

output_b(segs[10]);
poz();
poz();

} while(true);

}
___________________________
This message was ported from CCS's old forum
Original Post ID: 12794
Sherpa Doug
Guest







Re: 16F877 ADC with LM35 ( temp sensor ) - overheating!
PostPosted: Tue Mar 18, 2003 11:39 am     Reply with quote

Is it the PIC or the LM35 that is overheating? Try running both chips with no connection between them. Can you check the output of the LM35 with a meter? Try putting a 1k resistor between the LM35 and the PIC pin as a diagnostic aid.

Also if the LM35 is on a long wire (a meter or more) it may break into high frequency oscillation. Its spec sheet should mention this and say how to fix it.

___________________________
This message was ported from CCS's old forum
Original Post ID: 12796
Rollo
Guest







Re: 16F877 ADC with LM35 ( temp sensor ) - overheating!
PostPosted: Tue Mar 18, 2003 11:55 am     Reply with quote

Thanks, for your reply. I tried all your suggestions, but they don't seem to be the problem.

Here are the results...


>Is it the PIC or the LM35 that is overheating?

It is the LM35, and also the 7805A voltage regulator, but only when the LM35 is connected. Otherwise, all is cool, for example, doing ADC with a POT.

>Try running both chips with no connection between them.

Yes. Both chips are fine when not connected.


>Can you check the output of the LM35 with a meter?

Did so just now with a 9V battery as + and - input, reading the center pin for voltage. It gave .195 which is right for room temperature of 19.5C

> Try putting a 1k resistor between the LM35 and the PIC pin as > a diagnostic aid?

I tried this and it still overheats the LM35 and voltage regulator so quickly that I have to disconnect.


> Also if the LM35 is on a long wire (a meter or more) it may
> break into high frequency oscillation. Its spec sheet should > mention this and say how to fix it.

The wire is only 4 inches long, so probably not the problem.


Thanks for your reply!
Still not working, unfortunately.

Rol



___________________________
This message was ported from CCS's old forum
Original Post ID: 12797
Sherpa Doug
Guest







Re: 16F877 ADC with LM35 ( temp sensor ) - overheating!
PostPosted: Tue Mar 18, 2003 1:37 pm     Reply with quote

Something is very odd here. I don't see how each chip could work fine seperately, yet overheat drastically when you put a 1k resistor between them. 1k should allow enough signal through to give a reading (though maybe not an accurate one) but it is hard for 1k to pass enough current to cause drastic heating. Try a 100k resistor, that can't possibly cause heating unless you have very high voltages.

I suspect you have an odd hidden problem such as a defective PCB, a cracked ground lead, a shorted bypass cap, or a mismarked resistor or such. Start with what you know works and add one tiny bit at a time till odd things happen. Take nothing for granted.

Good luck!
Sherpa Doug

:=Thanks, for your reply. I tried all your suggestions, but they don't seem to be the problem.
:=
:=Here are the results...
:=
:=
:=>Is it the PIC or the LM35 that is overheating?
:=
:=It is the LM35, and also the 7805A voltage regulator, but only when the LM35 is connected. Otherwise, all is cool, for example, doing ADC with a POT.
:=
:=>Try running both chips with no connection between them.
:=
:=Yes. Both chips are fine when not connected.
:=
:=
:=>Can you check the output of the LM35 with a meter?
:=
:=Did so just now with a 9V battery as + and - input, reading the center pin for voltage. It gave .195 which is right for room temperature of 19.5C
:=
:=> Try putting a 1k resistor between the LM35 and the PIC pin as > a diagnostic aid?
:=
:=I tried this and it still overheats the LM35 and voltage regulator so quickly that I have to disconnect.
:=
:=
:=> Also if the LM35 is on a long wire (a meter or more) it may
:=> break into high frequency oscillation. Its spec sheet should > mention this and say how to fix it.
:=
:=The wire is only 4 inches long, so probably not the problem.
:=
:=
:=Thanks for your reply!
:=Still not working, unfortunately.
:=
:=Rol
:=
:=
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 12801
Rollo
Guest







Re: 16F877 ADC with LM35 ( temp sensor ) - overheating!
PostPosted: Tue Mar 18, 2003 3:22 pm     Reply with quote

>Something is very odd here. I don't see how each chip could >work fine seperately, yet overheat drastically when you put a >1k resistor between them.

You are correct! I just purchased another LM35 and tried it in, and it works fine with the 1K resistor to the PIC. I am using a POT to get a decent Vref, but it's working.

>1k should allow enough signal through to give a reading >though maybe not an accurate one) but it is hard for 1k to >pass enough current to cause drastic heating.

I had misunderstood your meaning about where to place the resistor. I was following the spec sheet for the LM35 which seemed to be placing a resistor to ground as well as to the pin, as per first page diagram on right, in the pdf.

<a href="http://hippo.feld.cvut.cz/katalog/pdf/LM35.PDF" TARGET="_blank">http://hippo.feld.cvut.cz/katalog/pdf/LM35.PDF</a>

However, with your second response, I see you meant instead to connect PIC and LM35 through the 1K resistor. This works!

Your second response was instrumental in making me purchase a second LM35 to try it out.

Works well.

Thanks very much, Sherpa Doug!

Rol

Her's my present code again, to help other newbies like me...

#INCLUDE <16F877.h>
#DEVICE ADC=8
#INCLUDE <stdlib.h>
#USE delay (clock = 4000000)
#FUSES HS,NOWDT,NOPROTECT,NOLVP,PUT, NOBROWNOUT // NOLVP for port B?


// definition of each digit in terms of bits on and off on 7-seg-LED
byte CONST segs[12] = { 0b10000001, 0b10110111, 0b11000100, 0b10010100, 0b10110010, 0b10011000,0b10001000,0b10110101,0b10000000, 0b10010000, 0b01111111, 0b11111111 };

void poz(){

delay_ms(200);
}


set_tris_A(1);

void main()
{

char numstring[5]="";

byte count=0;
byte number = 0;



setup_port_a( RA0_RA1_ANALOG_RA3_REF );
setup_adc( ADC_CLOCK_DIV_8 );
set_adc_channel( 0 );
delay_ms(500);

do{
number= Read_ADC();
delay_ms(500);

sprintf( numstring, "\%03u", number );// turn number to string.
for( count=0;count<=2; count++) // output number to 7-seg led
{
output_B(segs[(numstring[count]) - '0']);
poz();
output_b(segs[11]);
poz();

}
output_b(segs[10]);
poz();
poz();

} while(true);

}
___________________________
This message was ported from CCS's old forum
Original Post ID: 12807
Sherpa Doug
Guest







Glad to be of help.
PostPosted: Tue Mar 18, 2003 3:32 pm     Reply with quote


___________________________
This message was ported from CCS's old forum
Original Post ID: 12808
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group