Oops - Seems I missed that. Thanks. So, in essence -For a schematic, see #30 above
Vref -.--------------.--- .|. | R1 |_| 1K | | Vadc | }--------. | | .|. | | 10K |_| | | | ___|___ .|. _|_/ | R2 |_| |_ _ ADC | | | \_______| | .|. | | 10K |_| | | | | 0V -^--------^-----^---
----- Expected ----- ------ Actual ------ R2 = 0.1 107363 $0001A363 392377 $0005FCB9 R2 = 330 266417144 $0FE133F8 533314220 $1FC9BAAC
The ADC values are essentially a ratio metric digital representation of a voltage. This particular project will only ever have a MAX R2 resistance of 330 ohms. Just to provide you an appreciation of this circuit/setup, theoretically a MAX decimal value of 24-bits is 16,777,215 (a far cry above PICAXE 10bit ADC - MAX 65536) which in this case would be 5.000VDC. In a ‘perfect world’ if R2 was also 1K exactly, the ADC value would be 8,388,607 and the voltage would be 2.500VDC.If I am not mistaken... the numbers that you are obtaining from the ADC - are... not ohm values... but a voltage value that then needs to be converted to a resistance value?? (Showing my ignorance here...)
You have a voltage divider circuit. +5 volts across the 1k and the 'X' resistor.
It is a 24bit value we are working with.And we can determine what the 30-bit...
As previously posted, the earlier values reported were incorrect with a number of factors not being accounted for. Since then, this circuit/setup and tolerances have been dramatically improved....When you have a 330 ohm resistor plugged in as R2, you are getting a reading of 8,333,034.
For now (and maybe forever) we can work with just the High Words, consider those 32-bit numbers split into an "integer" word and a "fractional" word (which we can ignore for now). Ignoring also the two top "Status" bits, the value for the High word for 330 ohms is 31 * 256 + 201 = 8137. The total divider resistance is 329.2 + 1000 = 1329.2 ohms, so the value corresponding to the "ADC Reference" value is 8137 * 1329.2 / 329.2 = 32854. That's quite "encouraging" as it's just 0.26% above the well-known 32767 which is the largest positive number possible in a 16-bit two's-complement (signed) number. But it is an "overflow" of 87, which would have been higher if we'd included the "fractional" part of the original number. So the main error is in the "measurement" not the calculation.R2 @ 0.1 ohms (measured 0.12 ohms)
b1=128, b2=5, b3=252, b4=185 or in binary, 10000000 00000101 11111100 10111001
R2 @ 330 ohms (measured 329.2 ohms)
b1=159, b2=201, b3=186, b4=172 or in binary, 10011111 11001001 10111010 10101100
Yes, but the ADC returns a 32-bit result. If we drop the top two bits and the bottom six it does become 24-bit. If we do that, what we should see from the ADC is ...It is a 24bit value we are working with.
'This program takes 1000 samples from the LTC2485 and then provides the average values. Startup: #com 1 #terminal 4800 pause 3000 Init: HI2cSetup I2CMASTER, $48, I2CFAST, I2CBYTE main: hi2cin (b1,b2,b3,b4) w11=w11+1 'Total Samples Count sertxd("Sample#",#w11,cr) 'Current Sample # b5=b5+1 w3=w3+b1 w4=w4+b2 w5=w5+b3 w6=w6+b4 if b5=100 then w3=w3/100 w4=w4/100 w5=w5/100 w6=w6/100 b0=b0+1 w7=w7+w3 w8=w8+w4 w9=w9+w5 w10=w10+w6 if b0=10 then gosub calc b5=0 w3=0 w4=0 w5=0 w6=0 endif pause 150 'This brief delay required for LTC2485 to be ready to provide next conversion output. goto main calc: w7=w7/10 w8=w8/10 w9=w9/10 w10=w10/10 sertxd("LTC2485 Average O/P after x1000 Samples: ",#w7," ",#w8," ",#w9," ",#w10,cr,lf) b0=0 w7=0 w8=0 w9=0 w10=0 w11=0 return
I'd agree with that. Thanks to yourself and 'marks' for pointing that out.Yes, it looks correct to me as well, although I think the terminology may be a little confusing
32-bit 24-bit 16-bit %10111111111111111111111111111111 %111111111111111111111111 %1111111111111111
%10111111111011000100111110000000 %111111111011000100111110 %1111111110110001
30-bit : 2.49699563021 V 24-bit : 2.49699577671 V 16-bit : 2.49702449073 V
30-bit : 997.599389094 R 24-bit : 997.599506018 R 16-bit : 997.622422386 R
#picaxe 08m2 #terminal 4800 SYMBOL ADCvalue1 = W1 SYMBOL X1 = W1 SYMBOL R2 = W1 SYMBOL ADCvalue2 = W2 SYMBOL inX2 = W3 SYMBOL D2 = b7 SYMBOL D1 = b6 SYMBOL Temp = W4 SYMBOL D4 = b9 SYMBOL D3 = b8 SYMBOL D5 = b11 SYMBOL rr = b11 SYMBOL R = b10 SYMBOL index = b12 Init: HI2cSetup I2CMASTER, $48, I2CFAST, I2CBYTE Main: hi2cin (b5,b4,b3,b2) CalibrationValues: b5=%10000000 b4=%00000101 b3=%11111100 b2=%10111001 ' R2 @ 0.1 ohms (measured 0.12 ohms) ' b5=%10011111 b4=%11001001 b3=%10111010 b2=%10101100 ' R2 @ 330 ohms (measured 329.2 ohms) sertxd("LTC2485: ",#b5," ",#b4," ",#b3," ",#b2) pause 200 'This brief delay is required between conversion requests from LTC2485. Convert: ADCvalue2 = ADCvalue2 *8 : ADCvalue2 = X1 **8 +ADCvalue2 ' extract equivalent 18bit value ADCvalue1 = $FFFF -ADCvalue2 +8 /10 +19660 ' calculate ADCvalue across R1(1000ohms)divide by 10 inX2 = $FFFF /X1 : Temp = $FFFF //X1+1 rr = X1 //10 : X1 = X1 /10 FOR index = 1 TO 4 inX2 = inX2 *10 : inX2 = Temp /X1 +inX2 r = inX2 //10 *rr Temp = Temp //X1 *10 -r NEXT index R2=ADCvalue2 ** inx2 Uncalibrated: ' Max (333.33) ohmns BinTOASCII R2 ,D5,D4,D3,D2,D1 sertxd(" R2 = ",D5,D4,D3,".",D2,D1) 'resolution 01 (000.17)(330.39) calibrated: R2 = R2 Min 4 -4 **65309 BinTOASCII R2 ,D5,D4,D3,D2,D1 sertxd(" calibrated = ",D5,D4,D3,".",D2,D1,cr,lf) 'resolution 01 (000.12)(329.20) end
cant you tell by the way I throw the code together I,m self taught too lol
its really a case of the data sheet being not quite right or helpfull
luckily with the testing you did it eventually got sorted out.
It will be interesting if you improve on those initial results ,I hope the test gear is uptoit!
yourve tempted me to try one of those adc but I think I'll start with something that seems
easier like the mcp4321.
Here's some code for you to tryout after penciling abit I thought I'd post it before its lost.