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

Sigma Delta Converters

chelletengchelleteng Posts: 29
edited 2012-03-26 14:01 in General Discussion
I do not fully understand the operation of the sigma-delta converter (the one using counter registers).

When the analog input is zero/Vdd, the counter feedback would automatically pull it to high/low respectively. The one read as high will increment the count by 1. However, if the feedback pulls the analog input to the reverse of the analog input, wouldn't the output be the same? Very confused.

Could use some help, thanks!

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-19 09:24
    Maybe this will help:

    -Phil
  • chelletengchelleteng Posts: 29
    edited 2012-03-19 09:27
    Yeah, this is the one I read & still not understand. Very curious of its operation!
  • lardomlardom Posts: 1,659
    edited 2012-03-19 15:24
    In order for me to grasp how sigma delta ADC worked I had to first study op amps and voltage dividers. At least for me the details made sense once I understood the basic concepts. The link that Phil Pilgrim provided is an excellent place to start. I had to read it a few times with a calculator before I could make sense of it.
  • jmgjmg Posts: 15,184
    edited 2012-03-19 16:51
    chelleteng wrote: »
    However, if the feedback pulls the analog input to the reverse of the analog input, wouldn't the output be the same? Very confused.

    See
    http://en.wikipedia.org/wiki/Delta-sigma_modulation

    The best way to analyze a first order ADC, is as an Integrator followed by a D-FF. (see fig 1b)

    The D-FF-Q (or !Q) is wired so it gives negative feedback, and so keeps the Integrator in the linear region.

    This gives what I call a lazy Sawtooth-Sum on the Integrator output, and if you use a good quality integrator, you will correctly sum small charges over long time periods.

    The Gated-Counter then simply sums the time the FF-Q is high, and so gives a % of VCC reading.

    You can kludge an ADC with a D-FF, and a RC circuit, but that is not a true integrator, so performance is at the low end of the scale.
    (it does not 'remember' small charges, over long times )

    A purist would use a good Integrator, plus an Analog Switch to a precision reference voltage, so the Chip Vcc/Gnd noise is not part of the measurement.

    If you have a good integrator, and run the FF=HI gated counter continually, you can also get varying precision by timebase.
    eg 4095 clocks gives possible values from 0..4095, whilst 131071 clocks will give 32x the precision.
  • User NameUser Name Posts: 1,451
    edited 2012-03-19 17:05
    Dr. Steven W. Smith also has an excellent treatment of delta-sigma (as well as every other aspect of DSP!) . But it seemed to me that chelleteng's chief confusion was its specific implementation using Propeller counter registers.
  • william chanwilliam chan Posts: 1,326
    edited 2012-03-19 17:27
    chelleteng wrote: »
    However, if the feedback pulls the analog input to the reverse of the analog input, wouldn't the output be the same?

    Even though the feedback pulls in the opposite direction, the next reading need not be the same as the feedback as it depends on who is pulling more strongly and
    the remaining charge in the capacitors. So some readings will still read high, and some readings will read low.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2012-03-19 18:58
    ... A million ways to skin a cat right?

    Ok... If you think for a second that the heart of the ADC can be made using a simple inverter with a slight bit of hysteresis at the I/O switching threshold, then the output of the inverter becomes the sigma-delta feedback or drive pin. As a result the input will always remain VERY close the the I/O switching threshold of the inverter. This is another fundamental concept of the sigma-delta, the fact that the input to the sigma delta wants to be at the I/O switching threshold ... Ideally this is Vdd/2 .

    With this concept, assume for a second that there is no external influence at the input of the sigma-delta... If we looked at this pin we would expect it to be HIGH 50% of the time and LOW 50% of the time, because it's right at the threshold of the I/O. If we looked at the same pin 256 times, then the result would be something close to 127 since that's 50% of 256. This also would be representative of an 8-bit sample. Now lets say that we force the input pin LOW, then the input would read a zero 100% of the time and report a 0 after 256 samples. Likewise if the pin were held HIGH 100% of the time, we would report 255 as a result.

    Note: The resolution of the ADC is directly proportional to how many samples you take. If you read it 4096 times, then the resolution would be 12-bit ... if you only read it 16 times, then the resolution would be 4-bit.

    Something I think is neat with a sigma-delta ADC that allows you to skip a math conversion.... Suppose you want to read a voltage in milli-volts. Instead of taking a 12-bit sample and sampling 4096 times, and then doing the conversion math so that it's human readable. Just sample the ADC 3300 times (assuming your system runs at 3.3Volts) and the result will be in milli-volts without needing to convert the result later.
  • jmgjmg Posts: 15,184
    edited 2012-03-19 19:39
    Note: The resolution of the ADC is directly proportional to how many samples you take. If you read it 4096 times, then the resolution would be 12-bit ... if you only read it 16 times, then the resolution would be 4-bit.

    With some provisos :
    If you use a simple RC (quasi integrator) (as in an008), then the precision limit is not as good, as one made using a proper integrator.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-19 20:51
    Also, because the logic threshold can vary from part to part, it's necessary to reduce the gain to less than unity to make sure that both input extremes fall within the acceptance range without clipping. This results in longer integration times. That's why it's important to include calibration circuitry in one's design, so the precise integration time for the desired precision can be determined.

    -Phil
  • chelletengchelleteng Posts: 29
    edited 2012-03-22 07:45
    Alright! Thanks for the info/help! :D
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-03-22 08:21
    Analogy.

    Think of yourself as the propeller's brain and eyes. Think of the capacitors at the input as a bucket starting at half full of water. Something or somebody outside is randomly taking water out or putting water in. You, the propeller have a supply of water on a water meter. You watch the bucket and if you see it go down, you add water (opposite direction) and if you see it go up, you suck water out, always keeping it at 1/2 full. After a certain known period of time, you look at your water meter. It tells you exactly the net amount you added/subracted, and that will be exactly equal to the amount that the external entity added/subtracted. Divide amount by time and you have rate. That in essence is how it works.

    It may be that the external entity is supplying its end through a pipe that has resistance. In that case, the rate of water flow is equal to pressure divided by the resistance of the pipe. That is analogous to I = V/R. Sigma-delta can measure voltage, but its operation is best understood in terms of current.

    You as propeller are actually metering in or out using a teaspoon. Counting the number of teaspoons you add minus the teaspoons you take out.
  • chelletengchelleteng Posts: 29
    edited 2012-03-22 20:09
    Another question...
    In Beau Schwabe's ADC driver v1.0,
    A new cog was created at the beginning, but how do I call the assembly sample from the assembly codes into my own program? Thank you...
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-03-23 08:50
    chellenteng, I moved your specific question about this over to the Propeller forum. You can use a more specific title, such as Help with Beau Schwabe's ADC driver v1.0 instead of just Help with Propeller programming.

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2012-03-23 10:13
    chelleteng,

    Without looking at your exact code it's hard to tell, but the ADC driver is designed to be called by passing an address location of the variable you want the result to go into.

    For example, when you call 'SigmaDelta(sample)' Sample should be an address value in your main program.

    in the VAR section and the OBJ section of your main program you might have something that looks like this...
    VAR
       long  ADCvalue
    
    OBJ
       ADC     :     "ADC"
    

    From the main program you could launch the adc like this...
    PUB YourMainProgram
       ADC.SigmaDelta(@ADCvalue)
    

    ...You would only need to launch the ADC.SigmaDelta statement above once, where upon any time that you wanted to read the ADC value, you would just look at the variable ADCvalue
  • chelletengchelleteng Posts: 29
    edited 2012-03-24 09:00
    I'm sorry if my question/problem is quite unclear, what I meant is that how come there is no getSample method to obtain a reading from the ADC assembly codes into my program?
    I tried the method you recommended and it did not work. Thank you for the help though!
  • Mike GreenMike Green Posts: 23,101
    edited 2012-03-24 09:13
    There is no getSample method because you are expected to get the reading yourself from the variable that's shared between the ADC routine and your program (and that you furnish). Beau's example should work. If it doesn't work for you, you'll need to post your source code so we can help you figure out what's different between what you've done and what Beau suggested.
  • william chanwilliam chan Posts: 1,326
    edited 2012-03-24 17:41
    Maybe it would help future users if Beau's ADC object could have some Code Documentation which shows for example
    how to pass a variable address in and how to set the number of cycles per sample, or maybe come with a demo spin file.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-03-25 10:16
    I personally would love to see a comparison of the Propeller ADC object versus a typical ADC chip. My impression is that the Propeller ADC can actually do an as good or better job than a 12 bit or 14bit chip - but I have difficulty with being sure.

    The only other problems is that the Propeller ADC solution is best constructed with solder and in a permanent fashion as breadboards do not make good stable connections for such.

    I suspect that these two are the primary reasons that people shy away from using the Propeller's ADC instead of an ADC chip.
  • lardomlardom Posts: 1,659
    edited 2012-03-25 21:57
    The Propeller ADC was educational for me. I bought several ADC chips for further experimentation. I think AN008 explains the process well. Because the real world is analog and micro's are digital it is important to learn how ADC/DAC works.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-26 07:36
    @Beau,

    Is version 1.0 the latest version of ADC.spin?

    It seems like if hasn't been polished for general purpose use yet.

    If you change the feedback pin to any IO pin higher than P8, you'll get a compiler error (about source field being larger than 9 bits).

    This line seems to be the culprit.
    asm_entry     mov       dira,#1<<SDF                    'make SDF pin an output
    


    I also don't understand why a mov statement is used to set pin directions. Wouldn't this mess up the settings of the other pins being used by other objects?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-26 07:52
    Duane Degn wrote:
    I also don't understand why a mov statement is used to set pin directions. Wouldn't this mess up the settings of the other pins being used by other objects?
    No, it doesn't. Each PASM program occupies its own cog, and each cog has its own dira register.

    -Phil
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-26 08:05
    No, it doesn't. Each PASM program occupies its own cog, and each cog has its own dira register.

    -Phil

    Ah yes, I should have known that.

    There's still the over 9 bit source field problem with pins higher the P8.

    I thought the convention for setting pins was to have the parent object set them as part of the Start method call.

    I see ADC.spin is dated 2007 so this convention might not have been implemented yet. This seems like a good object to have updated and maybe have a demo made for it.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-26 08:09
    Duane Degn wrote:
    I thought the convention for setting pins was to have the parent object set them as part of the Start method call.
    That doesn't work, since the Start method is in a different cog from the PASM code.

    -Phil
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-26 08:41
    That doesn't work, since the Start method is in a different cog from the PASM code.

    -Phil

    I mean passing the pins to use as part of the Start method parameters as in FullDuplexSerial.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-26 08:46
    Oh. Yes, that's the way it should be done.

    -Phil
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2012-03-26 08:53
    Agreed, that's the way it should have been done (<--specifying the pin(s) that you want to use) .... when I wrote that I was just learning how to write assembly, and that piece of code was actually lifted from a piece of code that Chip had written.. I think from the microphone to VGA demo.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-26 09:27
    Agreed, that's the way it should have been done (<--specifying the pin(s) that you want to use) .... when I wrote that I was just learning how to write assembly, and that piece of code was actually lifted from a piece of code that Chip had written.. I think from the microphone to VGA demo.

    I was thinking it looked like an "Early Beau" (which looks a lot better than "Early Duane" code).

    I was trying to make a little demo of the object using either the PropBOE mic or the Demo Board mic by that first PASM line complained when I changed the pin assignments.

    It doesn't seem like a friendly enough piece of software to be in the Propeller Tool library.
  • jmgjmg Posts: 15,184
    edited 2012-03-26 14:01
    I personally would love to see a comparison of the Propeller ADC object versus a typical ADC chip. My impression is that the Propeller ADC can actually do an as good or better job than a 12 bit or 14bit chip - but I have difficulty with being sure.

    It would depend on the 'external help'. The simple quasi integrator RC, will suffer due to being a much less than ideal charge summer. - but you could add an external integrator, and maybe a reference-switch (removes Vcc/Gnd noise).

    This would be easy to self-test, as you can create high precision DACS via PWM. (again, ideally these would use a reference switch, to avoid that internal Vdd.Gnd noise )

    Even 10mV of noise drops you below 9 bits, and 1mV of noise, drops you below 12 bits.
    Your average 'better' regulator delivers around 8 bits of precision.

    On another uC we used 2 x 8 bit DACs and 256:1 summing, to give 16-bit DAC steps, with a precision around 18 bits.

    Good candidates for reference SW would be a xx3157, a classic SPCO analog, or SN74AVC1T45, (xx1T45) a Dual Supply Translator.
Sign In or Register to comment.