Shop OBEX P1 Docs P2 Docs Learn Events
Sigma-Delta ADC — Parallax Forums

Sigma-Delta ADC

W9GFOW9GFO Posts: 4,010
edited 2009-05-30 04:53 in Propeller 1
My ADC is giving me these values;

0.00v = 8191
1.31v = 7166 ???
3.28v = 10549
4.42v = 12743
5.34v = 14547
6.05v = 16030

How do I figure out a formula so that I can get accurate voltage readings? It is not linear like I thought it would be. They are better now that it is rewired.

Rich H

Edited to add yet another data point

Post Edited (W9GFO) : 5/27/2009 4:01:25 PM GMT

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-05-27 02:42
    Just out of curiousity, what are you using for an ADC?
  • W9GFOW9GFO Posts: 4,010
    edited 2009-05-27 02:47
    I am using a Sigma-Delta circuit on the Propeller chip.

    V-IN goes to Pin 16 via a 332k resistor,
    there is a 100k between Pins 16 & 17,
    102 caps going to ground and 3.3v.

    Rich H
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-05-27 02:52
    BTW, I think your reading for 0.00V is probably in error. For one thing 8191 = $1FFF, which is highly suspicious. Second, it's the reading that makes the curve non-linear.

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-05-27 02:52
    Can you post your code?
  • W9GFOW9GFO Posts: 4,010
    edited 2009-05-27 02:58
    Phil Pilgrim (PhiPi) said...
    Can you post your code?

    Sure! It's an object from the Obex with very minor changes.

    Rich H

    Edited to replace wrong copy of code...

    Post Edited (W9GFO) : 5/27/2009 3:06:51 AM GMT
  • W9GFOW9GFO Posts: 4,010
    edited 2009-05-27 04:45
    Ok, well I found two errors. The first, I am using adjacent pins. I just read that they should be separated to avoid crosstalk. Secondly, my 332k resistor is between the two caps and the input pin rather than between the V-IN and the caps. That's a leftover from when I was going to use a voltage divider...

    Rich H
  • sylvie369sylvie369 Posts: 1,622
    edited 2009-05-27 10:58
    Phil Pilgrim (PhiPi) said...
    BTW, I think your reading for 0.00V is probably in error. For one thing 8191 = $1FFF, which is highly suspicious. Second, it's the reading that makes the curve non-linear.

    -Phil
    Here's where graphing your data can be really useful. You have a nice set of linear readings, except for the first one (attached), as Phil points out.
    494 x 303 - 29K
  • W9GFOW9GFO Posts: 4,010
    edited 2009-05-27 15:38
    sylvie369 said...
    Here's where graphing your data can be really useful. You have a nice set of linear readings, except for the first one (attached), as Phil points out.

    I considered them to be non linear because I could not find a coefficient that worked for the entire range.

    Since I made the changes these are the readings I get;
    
    Floating = 9203
    Ground   = 7145
    1.31v    = 9053   - 7145 = 1908 : 1456
    3.28v    = 12081  - 7145 = 4936 : 1504
    4.97v    = 14705  - 7145 = 7560 : 1521
    6.08v    = 16373  - 7145 = 9228 : 1518 ' nearly clipped
    6.81v    = 16382  -- clipped
    
    about 1500 units per volt
    
    


    The three middle ones seem reasonable to me but I am not getting the range expected. Also, now that I have wired it up "correctly" the readings are much less steady. Before they would vary +- ~ 10, now it is +- 100. To get a useable value I am averaging 500 readings.

    According to the calculator here the 332k resistor should give me up to a 7.1v range. Is it normal that it is so far off? I checked the values of resistors before soldering them in. They were 331k and 101k - pretty close - that changes the range to 7.05 v. Still, not close to what I am seeing.

    Also, shouldn't the ground value be closer to zero? It is nearly halfway up the scale at 14 bits.

    Rich H

    attachment.php?attachmentid=61200

    Post Edited (W9GFO) : 5/27/2009 4:17:29 PM GMT
    329 x 111 - 15K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-05-27 16:37
    Rich,

    On reason that the calculations can be off is that the digital threshold is not precisely Vdd/2 and can vary from unit to unit. Also, ground won't be near zero. Think of it this way: with "Analog In" at ground potential, what voltage has to be present on fbpin to leave adcpin at Vdd/2?

    You could revert to your divider again, and add a 330K or larger resistor from the common node to ground. That may help to center your range a little better.

    -Phil
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2009-05-27 16:43
    >Also, shouldn't the ground value be closer to zero? It is nearly halfway up the scale at 14 bits.

    Remember that the response is symmetrical around the Prop threshold (nominally 1.65 volts). So 1.65+5.4 = 7.05 V and on the low end 1.65-5.4= -3.75 V. Ground should not be zero, but indeed the expectation is that it would be lower than your result.

    If you adust your analog input slowly until you find half scale (count=8192 at 14 bits), then that voltage is the effective Prop threshold, which will not be exactly 1.65 volts. Your results suggest that the effective threshold is lower, and the whole range is shifted downward.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2009-05-27 17:43
    Wonderful pragmatic information of ADC construction. I hadn't know that crosstalk might be a problem with adjacent pins.

    Thanks!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ain't gadgetry a wonderful thing?

    aka G. Herzog [noparse][[/noparse] 黃鶴 ] in Taiwan
  • W9GFOW9GFO Posts: 4,010
    edited 2009-05-30 04:53
    Phil Pilgrim (PhiPi) said...

    You could revert to your divider again, and add a 330K or larger resistor from the common node to ground. That may help to center your range a little better.

    I don't mind it not being centered, just need it to measure up to 7 volts. A larger resistor should work right? Maybe around 500k?
    Tracy Allen said...
    Your results suggest that the effective threshold is lower, and the whole range is shifted downward.

    Is it normal that it is shifted downward? I wonder why it would be like that. Using the Prop's ADC may be adding extra challenges that I don't need. I'm working on a project for Gadget Gangster where one feature is to be able to display battery voltage. With such variations in values from the ADC, and no option for the kit builder to change the code, it may not work to do it this way.

    I suppose I could create a 'setup' menu where the ADC is calibrated, saving the value to EEPROM - but I haven't done that sort of thing yet.

    When using the Prop's ADC to measure a non-changing voltage, what deviation in values is to be expected? With 14 bit resolution the numbers are varying by 100 each way, just want to know if that is common.

    Rich H

    Voltage to be measured goes through the resistor in the middle of the picture then through the red jumper and to pin 16. The 100k resistor joins pin 16 and pin 18.

    549735718_VPCtc-X2.jpg

    Post Edited (W9GFO) : 5/30/2009 4:58:54 AM GMT
Sign In or Register to comment.