Mark Bellamy wrote : > I want to display the temperature on an LCD. I'm using a LM34CZ. It > outputs 10mv per degree F. If you use an external ADC reference of 1.024 V (there are a lot of those available) you will get an ADC reading with a resolution of 0.1 F directly. No need to mul or div, just convert the 10-bit ADC value to BCD and display. You can more or less forget about the rest of your post... 1.024 V / 1024 ADC-steps = 1mV per ADC-step = 0.1 F. B.t.w, have you thought about some of the temp sensors that directly outputs a binary (digital) value ? Then you don't need the ADC at all. Best Regards, Jan-Erik. > On the LCD, I only expect one place after > the decimal. (I am probably lucky if I get accuracy to the nearest > degree, but it's still nice to have that decimal place to see which > way the temperature is trending.) To make it simple for now, I decide > to place limits of 0-100 degrees F. > > Will this design work?: > > Vcc is 5v. > The PIC ADC is configured to use Vcc as the upper ref voltage. > Take the 10bit ADC value, multiply it by .00488 (5/1024). > That will result in the actual voltage. > Multiply that value by 100 to get degrees. (or instead of of using > .00488 in the previous step, just use .488) > > How do I determine what fixed point format will work? The ADC result > is 10 bits so I will need at least two bytes. How do you determine > how many bits are required for the fractional part after the decimal? > > On figuring out how many bits I need before the decimal point: > Assuming a max temperature of 100 deg F, that results in 1V into the > ADC (100 x 10mv). 1V in the ADC would correspond to 204 ( 1/.00488). > That 204, I believe will be the largest number, so 8 bits should work. > Is this correct logic? > > Since I need to represent .488, I will need enough bits to hold 488. > That ends up requiring 9 bits (2^9=512). Is this the correct way to > tell how many bits you need for the fractional part? Maybe for > simplicity I should use the 16x16 fixed point format? Or maybe it can > be determined that .49 will be accurate enough? Although I don't know > how to calculate how accurate that will be. .488 itself is a rounded > result of 5/1024*100. Maybe .5 would be accurate enough? > > On a slightly different topic, since I'm going to hard code the > voltage per bit of the ADC, I need a stable and accurate voltage > reference. For simplicity's sake, I was going to use Vcc which is 5v. > What are some strategies to help guarantee a stable and accurate > reference voltage for an ADC? > > Thanks for all of your input. > - > > Mark Bellamy > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist