Shop OBEX P1 Docs P2 Docs Learn Events
ADC.SPIN inconsistent readings — Parallax Forums

ADC.SPIN inconsistent readings

william chanwilliam chan Posts: 1,326
edited 2012-06-26 01:46 in General Discussion
Hi All,

I have been getting reading inaccuracies with ADC.SPIN on a commercial double sided PCB and have been wondering why nobody else has complained so far.

First I use a 12k and 5k voltage divider to get a sample voltage of a 2 cell Li-Ion battery down to Propeller's 3.3v range.
Then I use 100k for the detecting resistor and also 100k for the feedback resistor.
All parts are placed very close to the Propeller pins.
The Propeller chip is running at 40Mhz and the ADC is set for 8 bit sampling.

The thing is, when I use 10nF adc capacitor to ground only, I get about 7% error or inconsistency in readings.
When I change it to 1nF, the error improves to about 4%.
It seems, that the lower the capacitance value, the more consistent the readings get, so much so until I should be using about 10pF to get less than 1% error rate.
I don't mind going with 10pF capacitance but I worry because the recommended value is 10nF.

Anybody?

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-06-24 04:51
    Capacitance is related directly to frequency. With all the wifi and cell phones and bluetooth around these days, might just be having RFI. pf capacitance might be tied to filtering 2.4Ghz noise.

    Is this 12 bit ADC or are you going for higher resolution. 16bit was recently discussed as being rather unnecessary.

    I have to take a look at he ADC.SPIN object and stop guessing what you are doing.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-06-24 07:47
    A couple things come to mind:
    1. Your input resistor should be 150K, not 100K. This is to compensate for part-to-part variations in the logic threshold.
    2. At the summing junction, there should be caps to both Vss and Vdd. This is to ensure that noise on the power rail does not shift the logic threshold relative to the voltage at the summing junction.

    -Phil
  • william chanwilliam chan Posts: 1,326
    edited 2012-06-25 20:42
    I can't add another capacitor to Vdd as the current PCB has no provisions for it.

    I wish to report that changing the input resistor to 150k and capacitor value of 22pF to Vss, I managed to get about about 0.5% accuracy which is good enough for my application of detecting Li-Ion battery voltage.

    It seems like beau's ADC.SPIN code requires a much lower capacitance value than recommended. This fact has been confirmed 3 times on 3 different projects.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-06-25 21:05
    Also bear in mind that your source impedance due to the 12K/5K divider is pretty high relative to the input impedance of the ADC. There will be some interaction because of that, which will compromise accuracy.

    -Phil
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-06-26 01:46
    The resistance and the capacitance together form a filter network. Depending upon the configuration, it can be low pass or high pass.
    I'd say that 0.5% accuracy is excellent.
Sign In or Register to comment.