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

Split Float to 2 INT
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
djsb



Joined: 29 Jan 2011
Posts: 49

View user's profile Send private message

PostPosted: Sat Mar 22, 2025 2:52 am     Reply with quote

Thanks. A very clear explanation and something I will try over the next few weeks.
I'm passing these explanations/solutions onto the students I help in an embedded systems class.
I'll also start looking for other temperature sensors with better accuracy at some point. But I also need to have a better understanding of the PIC's ADC limitations, as well as the limitations of the fixed voltage reference.
Lots to keep me occupied.
temtronic



Joined: 01 Jul 2010
Posts: 9445
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Mar 22, 2025 5:33 am     Reply with quote

FWIW...
I've used 1,000 of the LM35C over the past 3 decades, in remote industrial temperature control systems. Cost is more but..far better specs ! Accurate analog sensor.
After I got into using PICs, started using the DS18B20 digital temp sensor. It's a 'One wire' device,so has unique ID in it, a few other nice features like 'parasite' power ( one wire does both power and data )

I found using analog sensors to take several readings, then average those. Relying on just ONE reading can be fatal in any control application.Say an EMI spike hits the sensor's lead to the ADC... hmm PIC says it's 500* now !
Olympic averaging is nice. Take 10 readings, toss high and low, average the remaining 8.vert fast for PIC to divide by 8 !! You can (should) add a small cap to the analog line as a 'hardware' filter, helps smooth the readings as temperature is slow response.
The DS18B20 devices are nice,only need 2 wire ( I/O pin and gnd) and several can be put in parallel, though I often dedicate one I/O pin per devices,that way any problems in wiring doesn't take out all of the sensors. There is a 'trick' to find faults when using 2 or more on one wire though.
Ttelmah



Joined: 11 Mar 2010
Posts: 19765

View user's profile Send private message

PostPosted: Sat Mar 22, 2025 7:27 am     Reply with quote

Have to agree wholeheartedly. We use these in a lot of locations, and
with a proper external 2.048V reference, it becomes worth having fractional
degrees. For +ve only, gives the same 10mV/degree, but without the
500mV offset. You can sense -ve temperatures but then have to add an
external -ve source, and add an offset to the voltage fed to the ADC.
With this reference you get 5 counts per degree. Really simple. Very Happy
djsb



Joined: 29 Jan 2011
Posts: 49

View user's profile Send private message

PostPosted: Sat Mar 22, 2025 11:27 am     Reply with quote

Thanks. I'll do further research into these options and pass on your recommendations.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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