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

sigma Delta ADC

realolman1realolman1 Posts: 55
edited 2017-01-19 20:56 in Propeller 1
The sigma delta ADC result is stored in a long, but it only seems to go from 0- 500 as an integer.
That doesn't seem to be enough resolution for a long, or much resolution at all


Edit:
I guess more to the point: How many different voltage levels should I be able to read between 3 and 0 volts using the sigmaDelta ADC?
I am using a TMP36 temperature sensor that is supposed to output 10mV / deg C from -40 to +125 C ...what is the smallest increment of a Degree that I should be able to read? Should I be able to read 0.1 deg C?



thank you

Comments

  • ErNaErNa Posts: 1,752
    The adc in principle is a charge balancer. The capacitor at the sense input is charged via a resistor from the analog input. To keep the voltage of the cap constant, the charge of the capacitor must be kept constant. That means, the charge flow over the input resistor must be compensated by charge flowing to the digital compensation signal output. This output is toggled with the clock speed to high or low, depending on the input current. What you read from the adc register is the number of low compensation pulses over two consecutive reads. The highest value is given, when the analog input reaches upper limit and all compensation pulses are low. That means, if you read the register ones per second, the counter will show 80,000,000. If you read every ms, the difference between two reads can reach 80,000. So you could say: the ADC creates 80,000,000 bits per second.
  • A dedicated ADC IC such as the MCP3204 or MCP3208 might be worth a try. I use the MCP3208 in some of my projects because it has 8 A/D channels and 12-bit resolution. The default range is from 0 to 4,095. It is easy to reduce resolution by shifting bits right.
    For example:
    temp1 := adc.in(0) >> 5
    
    In this example I shifted right 5-bits so that my resolution goes from 0 to 127 which is very stable in my application.
  • jmgjmg Posts: 15,173
    realolman1 wrote: »
    The sigma delta ADC result is stored in a long, but it only seems to go from 0- 500 as an integer.
    That doesn't seem to be enough resolution for a long, or much resolution at all


    Edit:
    I guess more to the point: How many different voltage levels should I be able to read between 3 and 0 volts using the sigmaDelta ADC?
    I am using a TMP36 temperature sensor that is supposed to output 10mV / deg C from -40 to +125 C ...what is the smallest increment of a Degree that I should be able to read? Should I be able to read 0.1 deg C?

    The apparent resolution of a Sigma Delta is set by the integrate time, but the practical resolution is set by the real world.
    See other posts for measurements of Prop ADC noise floor/effective bits, but IIRC in the order of 10-12bits is practical.
    0.1'C is one part in 1650, or about one part in 3000 if you use no amplifier. That's pushing to ~12b.

    The Prop use a simple CMOS inverter, so has poor absolute Zero tolerance - affected both by Vcc and the process.
    You could run a second channel to give an 'auto-zero' ~50% value, and/or you could calibrate at some known temperature.
    Selecting the integrate time to be a whole-mains cycle or multiple, can null the mains-pickup noise.
    Or, you could look at a Digital Sensor like TMP05, if you want longer lead tolerance, and no degrade of the as-shipped calibrate.



  • kwinnkwinn Posts: 8,697
    A temperature range of -40 to +125 has a span of 165 degrees. Being able to measure that over a range of 0 to 500 gives you a resolution of approximately 0.33 degrees. Do you really need more than that?
  • realolman1realolman1 Posts: 55
    edited 2017-01-20 15:35
    I think it should be able to do at least 0.1 degree. Most any digital thermometer will do that.

    and I'm not sure its doing as well as .33 degrees... I'm in the process of checking it out

    I originally had a pot hooked up to 5 vdc... now I have a TMP 36 connected to 3vdc.

    My main concern with this thread is: what is the potential resolution of the SigmaDelta ADC ? ...

    ErNa and jmg seem to be quite knowledgeable, but I still don't know what it is

    thank you all for your help
  • ErNaErNa Posts: 1,752
    The resolution is quite high, the ADC should be more precise then the temperature sensor. (2° accuracy, .5 linearity.) The response time of the sensor is several seconds, so you can low pass filter the ADC reading and generate at least 16 Bits of resolution. I sometimes run a loop, and call a "measure" subroutine, where I read the cnt to get the run time of the loop and read the freg to get the number of compensation pulses, then I divide 1000* delta freg by delta cnt to get a number in the range from 0 to 1000. Substracting the offset of the ADC (you can measure slightly negative voltages) leads to a clean readout after low pass
  • Cluso99Cluso99 Posts: 18,069
    The ADC is done in software so you can extend the number of bits by counting longer. Obviously at some point additional bits become useless, but they serve to average the result. The number of useful bits is quite dependant on the tolerances and drift of the resistors and capacitors you use in the circuit.

    I presume you have read the Sigma Delta Analog Application Note. If not then look for it on the parallax propeller documents section of the parallax website.
  • Hi realolman,
    The ap note they are referring to is AN008 which gives you the necessary details for connecting and operating the sigma/delta ADC.
    Jim
  • PublisonPublison Posts: 12,366
    edited 2017-01-21 14:55
    AN008 is located here:

    https://www.parallax.com/downloads/an008-sigma-delta-analog-digital-conversion


    You can find all the Application Notes from the store website by going to Support>Download, and typing in "AN0" in the Download Title box:

    https://www.parallax.com/downloads
  • thank you all.

    Attached is the file I modified slightly ( not the machine language) to Get the A-D conversions.

    I have read the Sigma Delta Application note. But how do I modify this to read 0.1 degree, using a TMP36 sensor, which is supposed to be 10mV/ degree and 0.75 mV at 25 deg C?

    I suppose , in other words, how do I make the ADC read 1 mV increments?
  • add an op-amp, with gain and offset configured for your TMP36's range.

    Google op-amp circuits for a zillion examples
  • AribaAriba Posts: 2,690
    Just increase the ADC_INTERVAL constant to 4096 for example. Then you have a resolution of 12 bits instead of 9 bits.
    The ADC measuring will take longer (8 times) but for your application it's still more than fast enough.
    It will not be exactly 1mV resolution but in that range. If you really want exact 1mV you need to adjust the ADC_INTERVAL value until it fits.

    Andy
  • I read the section that discussed Fahrenheit since it requires more resolution. I read this on page 20 of the datasheet:
    "This particular approach
    does not lend itself to the TMP36 because of its inherent 0.5 V
    output offset."

    I don't know what that means 'but' if the TMP36 has 10_bit analog resolution you should be able to get temperature in 0.1° increments but I would still recommend a dedicated ADC chip like the MCP3204 for that level of precision.
  • realolman1realolman1 Posts: 55
    edited 2017-01-26 13:30
    Just increase the ADC_INTERVAL constant to 4096 for example. Then you have a resolution of 12 bits instead of 9 bits.
    The ADC measuring will take longer (8 times) but for your application it's still more than fast enough.
    It will not be exactly 1mV resolution but in that range. If you really want exact 1mV you need to adjust the ADC_INTERVAL value until it fits.
    I tried this and I still get three digit numbers... they just jump around more. I think what I need to improve the resolution are FOUR digit numbers ( or a decimal point or something) . That doesn't seem to be happening with the SigmaDelta ADC ... what am I missing?

    And lardom, I am not ignoring your advice, I am just trying to find out what resolution is possible, and why I am unable to get better resolution, using only the SigmaDelta ADC and the propeller without additional hardware.

    I guess simply put...will the Sigma delta ADC and the propeller read 1 mV or not?

    thank you
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2017-01-26 13:47
    Why oh why in this digital day and age are you using an old analog temperature sensor? How about the MCP9808 which has a 0.0625'C resolution and 0.25'C accuracy in a small 8-pin msop pack and interfaces to the Prop on the same two lines as the EEPROM, that is, any I2C bus. I'm using these chips in product and they are very good and very easy to use. I am even upgrading a really old design from a customer with this chip but they have expressed misgivings because they make money out of "calibrating" the old design every year :)
  • realolman1realolman1 Posts: 55
    edited 2017-01-26 14:06
    Why oh why in this digital day and age are you using an old analog temperature sensor? How about the MCP9808 which has a 0.0625'C resolution and 0.25'C accuracy in a small 8-pin msop pack and interfaces to the Prop on the same two lines as the EEPROM, that is, any I2C bus. I'm using these chips in product and they are very good and very easy to use. I am even upgrading a really old design from a customer with this chip but they have expressed misgivings because they make money out of "calibrating" the old design every year :)
    I dunno... I am old... I'm retired... I've had this propeller setup for a number of years and haven't had time to learn it, and I thought I'd try now... the sensors were cheap. My wife doesn't like me spending anything. I didn't know anything about the chips you are suggesting. I'm not ready to spend my time cutting out those stupid plywood silhouettes you see old retired guys do because they don't have any money.

    I have spent any patience I may have had over the years. I just want to know what the capabilities of the propeller are... I am disappointed that they don't have any "real" analog inputs, but instead rely on some circuit made out of discreet components

    After all of this I still don't have the answer to my question... will the SigmaDelta ADC software and capacitor/resistor arrangement read in 1mV or less increments? If so, how?
    thank you
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2017-01-26 14:17
    Cheap? After you add all those other bits, I think not. The MCP9808s are around a buck each and more than worth every penny of that. They have their own 16-bit A/D, reference, filters etc and simple 2 wire I2C bus interface.

    Many on this forum aren't as young as they used to be, and there are many that are retired or close to it, so don't feel these things are too much for you, just give it a go and there are plenty of chaps standing around to give you a hand. You are not alone.

    BTW, remember that the Propeller chip was not made by a team of design engineers in some international section of a big corporation so it's a credit to Parallax and Chip himself. Things like A/D and even perhaps Flash etc, things we take for granted these days are easy to implement if you can afford to pay the setup costs and take your chances. The P2 does have A/D and D/A galore, or more correctly will have, once it goes into production.

  • realolman1 wrote: »
    I have spent any patience I may have had over the years. I just want to know what the capabilities of the propeller are... I am disappointed that they don't have any "real" analog inputs, but instead rely on some circuit made out of discreet components

    This is a somewhat common view of the Propeller when people start working with it, particularly if you are used to other MCUs that have analog I/O capabilities. The current Propeller is an all-digitial interface. The methods being used to connect analog inputs is the same as you would do on a digital I/O pin of almost any other MCU. Of course, the Propeller has counter modules that facilitates the processing (and/or generation) of these signals, but they're still just dealing with digital I/O.

    And, yes, baked-in analog I/O would be nice. For that, we have the upcoming Propeller 2. For the new chip, every pin has an asynchronous "smart" cell that's capable of a number of modes, both digital and analog. Until the Propeller 2 is released, however, we must do what we can with the current Propeller. For that, we either use a digital peripheral (as Peter recommended) or practice the fine craft of analog-to-digital interfacing!

    If this is just a learning experience for you, I think you'll get more mileage out of the experience if you go Peter's route. Learning the analog part is certainly valuable, but I suspect it would be much easier and more enjoyable if you already have a good feel for the rest of the chip first.

  • Is it possible to measure 1mV or less increments using the propeller and the Sigma Delta ADC software and hardware?
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2017-01-26 14:55
    realolman1 wrote: »
    Is it possible to measure 1mV or less increments using the propeller and the Sigma Delta ADC software and hardware?

    No no no no, there is no voltage reference and comparator input on the P1 that can trigger precisely and accurately regardless of voltage or temperature etc. The sigma/delta A/D is ok for capacitively coupled analog signals but I wouldn't try to use it for measuring DC with any kind of accuracy or precision. Rough battery volts it may do, millivolt? No way Jose.


    BTW, even MCUs with 12-bit A/D will have trouble there too, as I find you lose a couple of bits of precision due to noise etc anyway.


    You know what? Wouldn't it be great if they could integrate the temperature sensor, a 16-bit A/D, a voltage reference, and a serial interface, all into one tiny little chip, and sell it for a buck!
    Wait a minute....
  • realolman1 wrote: »
    I dunno... I am old... I'm retired...
    So that's what your username means! :smile: I'm old and retired too but I love programming. Last year I built a small wireless mobile robotic arm with pan/tilt for a camera. I think I paid around $150 for everything. I think that was cheap because the Propeller saved me from having to buy extra hardware.
    'Cheap' is a good thing. Good luck!
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2017-01-27 18:03
    @realolman1
    You might find the followiing thread informative,
    troubles-with-sigma-delta-adc
    ...from 2007, when we all were trying to probe the limits of operation. It may be more informative than you want, from a simple question it evolves into a fairly deep discussion of the math involved. Later on Rayman proposes to measure a thermocouple and demonstrated breadboarded success with a 27% change in reading when moving from ice water to boiling water, about a 4mV change in thermocouple output. Caution, it would tend to drift over time due to drift in the propeller thresholds and components. Another thread that gets into it, with schemes for improving the precision, some by chopping the signal...
    same-threshold-voltage-for-all-pins-on-a-given-propeller-chip
  • AribaAriba Posts: 2,690
    edited 2017-01-26 20:50
    Somethink like that may work:
    TMP36_AD.png
    The 100k/39k resistors lift the TMP36 output voltage to about 1.42V which is the threshold voltage of a Prop-pin. With that the FB resistor has a chance to do its work.

    Andy
    357 x 235 - 4K
  • Hi
    Sometimes its just fun to try something thats new to you out, and probe its limits. I did this with the sig/delt atod and was impressed with what was possible - even using it to measure resistors and capacitors for fun.
    When it comes to wanting to produce reliable repeatable results with minimum fuss, a nice ready made solution in the form of a chip of some kind, with simple interface, appeals to me. For temperature I have found the DS18B20 a great resource. Three pins in a transistor type package, fractional degree results and on ebay for £1 in UK money and available in probe format for not much more. A whole string of these can use the same three wires- each having unique addresses, accessable with a simple serial protocol.
    Worth playing with just for the fun of it- I have two sharing one flex using only two wires- (possible over short distances of 10 metres and limiting the higher temperatures when three wires perform better), to measure outside / inside temperatures 24/7, results plotted on vga screen using Propbasic. At this moment its zero degrees outside and 20 inside.

    Dave
  • Thank you all for your input. I apologize if I insulted anyone, but all I wanted to know was if I could measure 1 mV increments with the propeller and the Sigma Delta thing... apparently the answer is no way Jose. I wish I had known that when I started

    Peter Jakacki wanted to know why oh why I was trying to use an analog sensor. I did not post that I was old and didn't have much money to get sympathy or anything else... it was just a statement of fact answer to the why oh why question....

    lotta places want to charge you a buck for a chip and 15-20 bucks shipping... I found 5 of these for $15 including shipping... the best deal I saw at the time.

    I did not know about the MCP9808, and frankly it sounds like it would probably be a whole 'nother can of worms trying to communicate with that

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2017-01-27 13:51
    realolman1 wrote: »
    Thank you all for your input. I apologize if I insulted anyone, but all I wanted to know was if I could measure 1 mV increments with the propeller and the Sigma Delta thing... apparently the answer is no way Jose. I wish I had known that when I started

    Peter Jakacki wanted to know why oh why I was trying to use an analog sensor. I did not post that I was old and didn't have much money to get sympathy or anything else... it was just a statement of fact answer to the why oh why question....

    lotta places want to charge you a buck for a chip and 15-20 bucks shipping... I found 5 of these for $15 including shipping... the best deal I saw at the time.

    I did not know about the MCP9808, and frankly it sounds like it would probably be a whole 'nother can of worms trying to communicate with that

    Hey realolman, I'm just trying to make your job easier or at least give you a choice. You could just use those 1-wire sensor stainless steel probes from ebay, they are only $1.40 with free shipping. I use these ones also and don't worry about trying to communicate with these or the I2C devices as it really is quite simple plus the OBEX has plenty of code for these too. Once you've used I2C you can then realise that there is not much more to it then reading and writing bytes plus simple start and stop condition states. The main thing is to have fun doing it and not paint yourself into a very frustrating corner because you thought you'd do it the "simple" way.

Sign In or Register to comment.