Shop OBEX P1 Docs P2 Docs Learn Events
Analog to Digital ? — Parallax Forums

Analog to Digital ?

PaulPaul Posts: 263
edited 2007-01-18 19:35 in Propeller 1
I'm looking for examples for sigma-delta ADC written in assembly or SPIN.
I need to monitor some 60-400 hz signals. Thanks.

Paul

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-07 16:22
    There are two examples (microphone to headphone and microphone to vga) that I believe are included with the Propeller Tool that demonstrate ADC done in assembly. The microphone to headphone example also does DAC and is quite short. They're designed to work with the Demo Board's circuit.
  • PaulPaul Posts: 263
    edited 2006-12-07 17:27
    Are these available for download somewhere? I've checked for ADC in "Propeller Objects Exchange" and "Propeller downloads"
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-12-07 17:36
    www.sxlist.com has samples for the SXes with schematics. Since the wiring and the principles are the same, you might consider reading their material to fully understand how simple it is. Also, Senix Ubicom published a paper on how these work that might be helpful.

    There are two wiring versions. The best uses 3 pins to draw a higher degree of accuracy, but in many cases the two pin configuration is quite adequate. As I recall, one has 12 bit resolution while the other has 8 bit resolution. Since 7bits will provide over 1000 steps of resolution, many tasks have Analog to Digital converters that are overkill.

    Propellor's 160mhz also offers sampling more frequently than a lot of ADC chips.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • PaulPaul Posts: 263
    edited 2006-12-07 18:29
    Thank you Kramer. I agree the propeller should be able to scream, even at 80Mhz. There's a paper/book coming out that explains the CNT/PHS/FRQ to us mere mortals needing ADC and DAC stuff. I'll probably wait for it to come out. Hopefully soon!
  • BergamotBergamot Posts: 185
    edited 2006-12-07 18:37
    Can the ADC/DAC stuff be run from Spin?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-12-07 19:56
    Here is the program I use to test ADC functionality. I have two modes in which it displays: serial back through the USB connection and to a VGA monitor, you dont have to do either I used these as a visual indication of the readings made.

    Bergamot, DAC is possible in straight Spin, I have posted the code to the forums, use http://search.parallax.com·to find it. ADC must use assembly because the timing in which the values are read is critical.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • PaulPaul Posts: 263
    edited 2006-12-07 20:26
    Thanks Paul! This looks like what I was looking for. I can see the similarities between this and the Microphone to Headphone program. (but now I don't have to use headphones... lol)
  • yerpa58yerpa58 Posts: 25
    edited 2006-12-08 02:51
    Kramer said...
    <snip> ...one has 12 bit resolution while the other has 8 bit resolution. Since 7bits will provide over 1000 steps of resolution, many tasks have Analog to Digital converters that are overkill. <snip></quote>

    7 bits provide 128 steps, 12 bits provide 4096 steps. I'd be interested in knowing the actual sample rate and effective number of bits that the propellor's A/D conversion method can provide.
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2006-12-08 03:55
    ' At 80MHz the ADC/DAC sample resolutions and rates are as follows:
    '
    ' sample   sample               
    ' bits       rate               
    ' ----------------              
    ' 5       2.5 MHz               
    ' 6      1.25 MHz               
    ' 7       625 KHz               
    ' 8       313 KHz               
    ' 9       156 KHz               
    ' 10       78 KHz               
    ' 11       39 KHz               
    ' 12     19.5 KHz               
    ' 13     9.77 KHz               
    ' 14     4.88 KHz
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-12-08 04:14
    Please forgive the typo. 7 bits provides over 100 steps of resolution.
    In many cases, greater factors of ten really just look good on paper.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "If you want more fiber, eat the package.· Not enough?· Eat the manual."········
    ···················· Tropical regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • Christof Eb.Christof Eb. Posts: 1,161
    edited 2006-12-08 13:01
    Hello,
    I tried adc with my selfmade propeller circuit setup, but it did not work (due to too long wire connections?).
    Therefore I tried it as pure spin to slow it down. And now it works - really slow but surprisingly accurate.
    Christof
  • Christof Eb.Christof Eb. Posts: 1,161
    edited 2006-12-08 13:04
    Sorry that was the old file, added some comments....
    Christof
  • PaulPaul Posts: 263
    edited 2006-12-08 20:25
    Christof, Your resistor values are different than the Demo Board. Can you elaborate on which to use?
  • Christof Eb.Christof Eb. Posts: 1,161
    edited 2006-12-09 16:28
    Paul,
    the voltage at the capacitor and input pin 8 is held near 3.3Volts/2 by the method. The current into the capacitor is I_Input=(U_Input-3.3/2)/R_Input and is to be compensated by the same current through R_feedback. I_feedback=3.3/2/R_Feedback, when the pin is switched to low. So, if the voltage to be measured is greater than 3.3V, R_Input has to be greater than R_Feedback and this gives the relation of the resistors.
    Normally the input resistor is wanted to be as high as possible to give no influence to the voltage measured. I don't know the input current into the input pin, which gives an error in the method, because this current is assumed to be zero. This input current would therefore be a limit for the values of the resistors.
    I used a normal 1kOhm cheap resistor and had the opportunity to measure 962Ohms as actual value.
  • Bill HenningBill Henning Posts: 6,445
    edited 2006-12-10 23:54
    Very interesting. I had a chance to try it out today, and it does work - however as presented, it appears to be less than ideal for reading relatively low resistence potentiometers.

    Using a 10kohm linear pot, to get a reasonable range of readings, I had to use the 14 bit mode, throw away the lowest five bits, and subtract 141;

    that is

    value/32-141

    and then I got a range between 1/2 and 351/352 - which is more than good enough for my application; I just needed a proportional input based on a knob I turn.

    I'll have to pick up a 10megohm pot, that should give me better range and control with this a/d method and 150k input resistor.

    Hmmm...

    I can't see any reason why I can't put a 4051 8:1 analog mux in front of it... [noparse]:)[/noparse] then 5 pins will give me 8 analog inputs (or put two muxes on, 4 bits to select channel and get 16 analog channels in)
  • Bill HenningBill Henning Posts: 6,445
    edited 2006-12-12 08:47
    After considerable thought, I wonder if the problem I am experiencing (lowest five bits being useless) is due to noise issues. The proto board I am using has half inch (5 .1" holes) strips for each pin of the propeller... which could act like antenae for high frequency signals.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-12-12 17:04
    Bill, spacing is critical especially for the two caps and the feedback resistor should be located very cose to the propeller. And doing it suface-mount 0603 size is preferable. The first revision of the Propeller Demo Board had the exact problem you are describing (which is why we went to the second revision). The second we didn't include the ADC components but made sure the spacing from any IO pin to it's connecting hole is <1". I have tested the concept by soldering through hole parts directly into the I/O, the result was +/- 10 counts on a 12 bit sample. A dedicated surface mount very very close to the Propeller could achieve even better results.

    Try·isolating·those excess holes for your ADC circuit and populate only those which are closest. Also try to double up by placing two leads through 1 hole, using a pair of needlenose to crimp the leads a bit ussually works.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Bill HenningBill Henning Posts: 6,445
    edited 2006-12-13 05:51
    Hi Paul,

    The resistor is right at the pins, and the capacitors are soldered right to the bridging resistor, and out of the junction comes the 150k resistor...

    The problem I think is really due to the .5" long tinned strip for every pin of the prop on the proto board.

    Hmm... +-10 counts is (roughly) 4 bits off, still, thats two bits better than my result.

    I'm actually considering making a PCB, and dedicating a couple of pins to an A/D circuit. I will however be dissapointed if I end up with four unusable bits. I'm used to the LSB being unreliable, but above that is less than desirable.

    On the other hand, its pretty amazing to do such a/d without dedicated a/d hardware [noparse]:)[/noparse]

    Now if Chip would only incorporate my upgrade suggestions to the shift registers, we could talk to off-board SPI A/D's at 640MBPS with the next prop.
    Paul Baker (Parallax) said...
    Bill, spacing is critical especially for the two caps and the feedback resistor should be located very cose to the propeller. And doing it suface-mount 0603 size is preferable. The first revision of the Propeller Demo Board had the exact problem you are describing (which is why we went to the second revision). The second we didn't include the ADC components but made sure the spacing from any IO pin to it's connecting hole is <1". I have tested the concept by soldering through hole parts directly into the I/O, the result was +/- 10 counts on a 12 bit sample. A dedicated surface mount very very close to the Propeller could achieve even better results.

    Try·isolating·those excess holes for your ADC circuit and populate only those which are closest. Also try to double up by placing two leads through 1 hole, using a pair of needlenose to crimp the leads a bit ussually works.

  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-12-13 07:09
    The thing is the chip wasn't originally designed to do ADC, it was a serendipitous discovery it was adequate to do it with any precision. The feedback path goes from the pin through the bus into the cog through the counter circuitry back out the bus and out the feedback pin. This is quite a long path and creates a relatively high noise floor compared to dedicated ADC chips, but it is sufficient to get fast and dirty measurements of analog signals. While the idea isn't set in stone, Chip is heavily leaning to keeping the feedback path local to the I/O block in the next Propeller by having pin pairs when a feedback mode is specified, this alone should help with the noise floor.

    If you do design a board, avoid curvatures of the traces in the critical region and keep the unresistored side of the feedback pin away from the feed-in (ideally by not using adjacent I/O pins) to minimize cross-talk.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 12/13/2006 7:14:02 AM GMT
  • Bill HenningBill Henning Posts: 6,445
    edited 2006-12-13 08:52
    Thanks, I'll keep that in mind... I guess I was just drooling at the prospect of (essentially free) reasonably accurate high speed A/D [noparse]:)[/noparse]

    The fact is, what I've got on the proto board is "good enough" for my current need - a pots that can be read to provide proportional positioning information; and by giving up some unneeded sampling speed, and filtering the signal (either in software or with a capacitor - or both) I can get as much precision as I need... I just have to give up on high sample speeds.

    What I'm thinking of doing is using an 4051 analog mux to "front end" to two pins, so I get 8 channels of input at the cost of five pins. (or sixteen channels for six pins). I think I can get a nice reliable 8 bits of data and still get about 1000 samples per sec on each channel, which is still plenty for my current needs.

    If I do lay out a board, I was thinking of using P23 and P27 for A/D, as P23 is nice and close to both Vss and Vcc for the 1nF caps; and P27 is on the other side of the TV d/a network (hmm maybe not a good idea... could be a source of high frequency crosstalk)

    Or maybe P20,21,22 for the address lines for a MUX, with P19 and P23 for the A/D.

    The only problem with the propeller is that I don't have as much time to work with it as I'd like! I can only sneak in an hour or so a day, and maybe four on the weekend :-(

    (By Px I meant PortAx...)
  • PropeleroPropelero Posts: 5
    edited 2006-12-19 11:06
    Hello!!!

    I'm a new user of the propeller and interested about the ADC capabilities of the chip. I think chip's capabilities are impressive, and I'm very interested in knowing some things about the design you've done. Now I'm thinking about a project i've in mind, and have some questions:

    In ADC:
    Which are the adquisition, numerical conversion and temporization methods you use?


    Thanks a lot, and excuse me for my poor english smile.gif
  • GadgetmanGadgetman Posts: 2,436
    edited 2007-01-18 12:09
    Paul Baker (Parallax) said...
    Here is the program I use to test ADC functionality. I have two modes in which it displays: serial back through the USB connection and to a VGA monitor, you dont have to do either I used these as a visual indication of the readings made.
    I was wondering...

    It's not recommended to use adjacent pins for this procedure.
    If I use pins P0/P2 for one ADC, can I then use P1/P3 for another ADC-conversion at the same time?



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-18 14:26
    The reason to suggest using non-adjacent pins is noise coupling from one pin to another. By doing a second ADC on interleaved pins at the same time, you will still get the noise, it'll just be different noise from the other ADC process. If you need to do two ADCs, use say pins P0 and P2 for one and P4 and P6 for the other, then use P1, P3, P5, and P7 for signals that don't change often or don't change while you're doing the ADC.
  • GadgetmanGadgetman Posts: 2,436
    edited 2007-01-18 18:22
    I was thinking of running the ADC operations pretty continuously...

    Well, since I'm considering using 4-to-1 analog multiplexers/switches to reduce the number of Propeller I/O-pins tied up with ADC circuitry, I suppose I could use the other pins for control signals.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't visit my new website...
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-01-18 19:35
    The issue is the high switching rate of the feedback path is a source of crosstalk when the two paths are adjacent, but this goes beyond paired ADC lines and is applicable to the Feedin path being adjacent to any high speed switching line. Ideally you would group all feedback paths and all feedin paths and surround the feedin paths by moat paths (signal lines which dont switch or switch infrequently). But in this situation you have to be careful on how you layout the traces because the cross talk can occur external to the chip as well, ideally paths contain no right angles and cross a right angles on opposite sides of the board. The first prototype of the Propeller Proto Board, routing these grouped external lines were not done properly and the ADC performed poorly (about 1/2 of the digits were garbage).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.