Need help LM34 & TLC2543 ADC combo
I've successfully done the experiment #4 in parallax's industrial
controls. Hooked up an LM34 and ADC0831. Supplied 0.3v to the Vin(-)
and 0.6v to the Ref+ (temperature range of 30F to 90F) then used the
formula
tspan=6000
DegF=tspan/255*result/10+300
This gave me a nice 3 digit temp.
Then I switched over to the TLC2543 and got it working over the full
range (5.1v to Ref+ and Ref- grounded) using this formula (stolen
from Tracy Allan as usual).
Adv=1
result = 64*ADv+256*/result
Gives me a nice 4 digit temperature.
After that the trouble starts
I hooked up the TLC2543, put 0.3v to Ref- and 0.6v to Ref+ and used
this formula
tspan=6000
DegF=tspan/4095*result/10+300
Well, I can't even see if my formula is correct or not. Just kept
getting 4095 as the raw result. I tried varying Ref+ and it turns
out I can't go down to 0.6v, anything under about 0.7v just gives me
the maximum of 4095 in the raw result. I'm obviously missing
something here.
Can anyone steer me in the right direction?
controls. Hooked up an LM34 and ADC0831. Supplied 0.3v to the Vin(-)
and 0.6v to the Ref+ (temperature range of 30F to 90F) then used the
formula
tspan=6000
DegF=tspan/255*result/10+300
This gave me a nice 3 digit temp.
Then I switched over to the TLC2543 and got it working over the full
range (5.1v to Ref+ and Ref- grounded) using this formula (stolen
from Tracy Allan as usual).
Adv=1
result = 64*ADv+256*/result
Gives me a nice 4 digit temperature.
After that the trouble starts
I hooked up the TLC2543, put 0.3v to Ref- and 0.6v to Ref+ and used
this formula
tspan=6000
DegF=tspan/4095*result/10+300
Well, I can't even see if my formula is correct or not. Just kept
getting 4095 as the raw result. I tried varying Ref+ and it turns
out I can't go down to 0.6v, anything under about 0.7v just gives me
the maximum of 4095 in the raw result. I'm obviously missing
something here.
Can anyone steer me in the right direction?
Comments
>controls. Hooked up an LM34 and ADC0831. Supplied 0.3v to the Vin(-)
>and 0.6v to the Ref+ (temperature range of 30F to 90F) then used the
>formula
>
>tspan=6000
>DegF=tspan/255*result/10+300
Did you mean 0.9 volts to Ref+?
since tspan is a constant, it can be rolled in with the /255 and the /10:
DegF= result */ 600 + 300
The */ operator implies division by 256. (There are 256 intervals, not 255)
That gives temperature from 300 to 900 (meaning 30.0 to 90.0)
>
>This gave me a nice 3 digit temp.
>
>Then I switched over to the TLC2543 and got it working over the full
>range (5.1v to Ref+ and Ref- grounded) using this formula (stolen
>from Tracy Allan as usual).
>
>Adv=1
>result = 64*ADv+256*/result
Simplify to
degF = result */ 320
In the program that you took that from, the bit variable ADv is a
"flag". When ADv=1,the subroutine returns millivolts, and you have
64+258, which equals 320. The order of things in */ does not matter,
x */ y = y */ x.
>
>Gives me a nice 4 digit temperature.
3 digits I think, 300 to 900 again.
>
>After that the trouble starts
>
>I hooked up the TLC2543, put 0.3v to Ref- and 0.6v to Ref+ and used
>this formula
0.9 volts to ref+, or 0.6?
>
>tspan=6000
>DegF=tspan/4095*result/10+300
Try
degF= result*/375+3000
That should give 6000 to 9000 to represent temperatures from 30.00 to
90.00 degrees F.
That is pushing the full 12 bit (4096 count) resolution of the converter.
Why 375? Because 6000/4096 is the conversion ratio you want, and for
use with the */ operator you multiply that times 256. 6000/4096 *
256 = 375.
>
>Well, I can't even see if my formula is correct or not. Just kept
>getting 4095 as the raw result. I tried varying Ref+ and it turns
>out I can't go down to 0.6v, anything under about 0.7v just gives me
>the maximum of 4095 in the raw result. I'm obviously missing
>something here.
>
>Can anyone steer me in the right direction?
I hope that helps!
-- Tracy
and made the assumption that Ref+ voltage added on to Ref- like on
the ADC0831. The datasheet doesn't mention that though, it just says
ref+ is the upper limit. So, I changed the voltages to 0.30v on ref-
and 1.0v on ref+. Then I figured out the ratio of
Result=AIN0-Ref(-)/(Ref(+) - Ref(-))*4095 or for 72.1 degrees thats
421/700*4095 = 2463
I got pretty well the exact raw value printing out on my screen. I
assume I have the ref+- figured out.
So the rest *should* be easy:
degF=result/4095*700
But of course, you can't have decimals so the division always
equates to 1. I tried multiplying result by 10, that helps but, the
value I get back is lower than it should be - 350 instead of 421. I
assume I'm losing a pile of accuracy to rounding. THe whole point of
narrowing the temperature range it to get more decimal places onto
the temperature. I find I always have some bouncing in the last
digit and, if that digit is hundredths of degrees instead of tenths,
I'll have less bouncing between displayed whole numbers.
Anyone know how to do this properly?
> Try
>
> degF= result*/375+3000
>
> That should give 6000 to 9000 to represent temperatures from 30.00
to
> 90.00 degrees F.
> I hope that helps!
>
> -- Tracy
You are a GOD! [noparse]:D[/noparse] I'm going to have to sit down with a pencil and
paper and see if I can figure out how the hell that works. I do
pretty good at good ol' staightforward math most of the time, but
all this indirect stuff has me baffled. This works perfect though.
Oh and yes I just realized I changed from 30-90 to 30-100 between my
two posts - thats a no-no sorry [noparse]:([/noparse]