Discussion forum for the BasicX family of microcontroller chips.
|
Hi guys, From the BX documentation, GetADC(pinnumber) has an integer range of (0 - 1023). Let say if the input analog voltage is 1.8V, then , if the mathematical conversion in the BX chip goes like this ( correct me if I m wrong).... GetADC(pinnumber) = (1.8/5.0)*1023 = 0.36*1023 = 368.28 Is the final integer value = 368 ?? If the floatin pt number is 368.5, will it be rounded off to 369 instead ??? Hope that U guys out there can help me clear my doubt. PS - Any methods for me to reduce the inaccuracy occurs in the analog-to-digital conversion process ??? |
|
|
|
Alvin, GetADC float version is not an Integer value with a decimal point. The floating version of getadc returns a value of 0.0 - 1.0. Using a 0-5v scale, 1.8v on an analog pin getadc (Float Version) would return 0.36. Then to find a floating point voltage: ADCReading * Voltage Scale = Voltage 0.36 * 5.0 = 1.8volts Chris ---------- From: [SMTP:] Sent: Monday, May 07, 2001 8:06 AM To: Subject: [BasicX] Accuracy of GetADC function ?? Hi guys, From the BX documentation, GetADC(pinnumber) has an integer range of (0 - 1023). Let say if the input analog voltage is 1.8V, then , if the mathematical conversion in the BX chip goes like this ( correct me if I m wrong).... GetADC(pinnumber) = (1.8/5.0)*1023 = 0.36*1023 = 368.28 Is the final integer value = 368 ?? If the floatin pt number is 368.5, will it be rounded off to 369 instead ??? Hope that U guys out there can help me clear my doubt. PS - Any methods for me to reduce the inaccuracy occurs in the analog-to-digital conversion process ??? |
|
asked: > ... [for 1.8V in,] GetADC(pinnumber) = (1.8/5.0)*1023 = 368.28 > Is the final integer value = 368? Yes; there is no rounding in the integer GetADC function. There are two GetADC functions; the integer version yields the raw 10-bit conversion (0-1023, a long, representing 0-4.995V (5.0V/1024) while the float version yields a scaled value (0-1.0, a single). As discussed here some time ago, the latter version divides the raw conversion value by 1023, not 1024, to yield the scaled result so the float version will produce a larger result than will the integer version for the same input. > ... Any methods for me to reduce the inaccuracy [that] occurs in the analog-to-digital conversion process? First, have clean inputs, clean power and a stiff ground; condition the signal if necessary. If you have the time, you can average successive samples to reduce noise and improve resolution. A true moving-window average requires storing windowed samples in RAM and rotating pointers or shifting the data itself as new data is sampled; that was too RAM-expensive for me but, for a slowly-changing value, I've found a simple approximation works well to close on the value (although it requires no additional sample storage and it is not an average): sVin=csng(GetADC(bPin))/1024.0 'instead of: call GetADC(sVin,bPin) sVapp= sVapp+(sVin-sVapp)/sN , where N is at least 10.0 to improve resolution by one decimal digit, although it can be any non-zero positive value; for ambient temperature from an LM34, for example, I've used a divisor of 1000. Tom Becker --... ...-- The RighTime Clock Company, Inc., Cape Coral, Florida USA www.RighTime.com |
|
|
|
Make that: "... 0-1023, an integer, representing 0-4.995V...".
Tom Becker --... ...-- The RighTime Clock Company, Inc., Cape Coral, Florida USA www.RighTime.com |
|
HI Tom Becker, Sorry.. there is something I don't understand. Is "sVapp" an estimation of error value ??? LIke ... Voltage = sVin +/- sVapp ??? Is my code below good enough to process the relevant data ?? sVapp = 0.0 sVin=csng(GetADC(bPin))/1024.0 For i = 1 to 10 Step 1 sVapp= sVapp+(sVin-sVapp)/10.0 Can you help me to add in and improve the code above. I am on the learning curve of Basix programming now.Thank You. :) Alvin >I've found a simple approximation works well to close on > the value (although it requires no additional sample storage and it >is not an > average): > > sVin=csng(GetADC(bPin))/1024.0 'instead of: call GetADC (sVin,bPin) > sVapp= sVapp+(sVin-sVapp)/sN > , where N is at least 10.0 to improve resolution by one decimal digit, although > it can be any non-zero positive value; for ambient temperature from an LM34, > for example, I've used a divisor of 1000. > Tom Becker > --... ...-- > GTBecker@R... GTBecker@O... > The RighTime Clock Company, Inc., Cape Coral, Florida USA > www.RighTime.com |