Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB

Sponsor

controlSUITE™ software
Comprehensive.
Intuitive.
Optimized.

Real-world software for real-time control. Details Here!

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | BasicX | Accuracy of GetADC function ??

Discussion forum for the BasicX family of microcontroller chips.

Accuracy of GetADC function ?? - Author Unknown - May 7 10:05:00 2001

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 ???





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


RE: Accuracy of GetADC function ?? - Chris Harriman - May 7 12:21:00 2001

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 ???


______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Accuracy of GetADC function ?? - Author Unknown - May 7 14:24:00 2001

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





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Accuracy of GetADC function ?? - Author Unknown - May 7 14:34:00 2001

Make that: "... 0-1023, an integer, representing 0-4.995V...". Tom Becker
--... ...--

The RighTime Clock Company, Inc., Cape Coral, Florida USA
www.RighTime.com




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

sVapp ?? - Author Unknown - May 8 11:17:00 2001

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




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )