Shop OBEX P1 Docs P2 Docs Learn Events
Noisy A/D performance — Parallax Forums

Noisy A/D performance

BradCBradC Posts: 2,601
edited 2009-09-12 20:10 in Propeller 1
G'day all.

I'm doing a bit of audio signal processing and trying to get optimum performance from the delta sigma A/D the prop can do.

A closeup of the configuration is attached.

I'm running 2 channels, one has 1nf caps high and low, the other has 10nf caps high and low. (don't need 2 channels, just experimenting)

In the picture the extra cap is between the vdd and vss pins. I've used pin0 as the detection pin and pin 2 as the feedback pin. Pin 1 has been tried as an input, an output high and low.

Started with 100k feedback resistors, but I've got better performance from 33k.

Now, to the problem. I'm seeing instability of the readings. The capacitor size (1 vs 10nf) makes no difference to the noise levels.

The code I'm using is identical to the code in the application note. I've also tried a modified version of the Microphone to Headphones demo. I'm pretty convinced its not a software issue.

The sound is great when there is a sufficiently large input signal although the noise is still superimposed on it (you just can't hear it relatively), but when the input signal is very slow changing or static the counter hunts anywhere +/- 5 counts per sample.

I'm running in 12 bit mode at 19.5Khz, but it makes no difference. The instability is about the same no matter how fast or slow I run it.

Now, when things are static for a while (a few seconds usually) the counter will lock onto the signal nicely and hold a reading but if I disturb things with the tip of my finger, it will hunt for a while before it finally settles down again. By feeding the A/D output directly into a duty D/A the noise is very obvious. When it settles finally the silence is deafening!

With the 33k resistor it settles a lot faster than with the 100k. I tried lowering the value further but the noise values remain about the same while the sensitivity drops considerably.

I'm just stumped as to how I can improve the noise level short of a digital low pass filter (which I don't really want to do too unless I have no other option).

Of course the other option is to use an external A/D converter, but where is the fun in that ??

Is anyone else doing audio processing using the chip as a converter?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lt's not particularly silly, is it?

Post Edited (BradC) : 9/11/2009 11:47:16 AM GMT
408 x 424 - 55K
ADC.jpg 54.7K

Comments

  • LeonLeon Posts: 7,620
    edited 2009-09-11 11:51
    Try using better quality capacitors - monolithic ceramic. I don't remember any undue noise when I tried that ADC, but it was a long time ago.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • KyeKye Posts: 2,200
    edited 2009-09-11 12:38
    This same fact is actually preventing me from releasing my dual DAC/ADC audio driver for the prop.

    I'm just not sure how to remove all the noise the ADC produces. When left alone the value from the ADC hovers around 140/255 which is about right. But when the I apply an audio signal for passthrough the ADC and out to the DAC the noise is just tremendous.

    Its like theres a 70 HZ wave out static on the line or something. I can hear the real audio source in the background but in the foreground its just all noise.

    I do not belive there is a problem with the DAC as its been able to play wave files smoothly.

    Anyone know where I could find documents related to audio processing to remove all that noise?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • Agent420Agent420 Posts: 439
    edited 2009-09-11 12:53
    I have done some meager fft processing with arms and avrs, but nothing substantial (just spectrum analyzing).· But an fft filter seems like what you would need to accomplish that in software.· Not sure if the memory and coding requirements would outweigh simply using a 'real' adc instead.

    Anyway, here is one link for consideration.· Most of what I have found in the past has been in C, but you should be able to infer it's operation.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • RaymanRayman Posts: 14,849
    edited 2009-09-11 12:55
    I think you're unlikely to get 12 or even 10 bits with that kind of circuit... I think what people normally do is take 12-bit samples and then shift right 4 bits or so to make it an 8-bit sample...

    I have noticed that nearby pins can add noise... For the dip package, I had gaurd pins set to output 0 in either side of the signal pins (it's a waste of pins, but I had extra...)...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • BradCBradC Posts: 2,601
    edited 2009-09-11 12:55
    Kye said...

    Its like theres a 70 HZ wave out static on the line or something. I can hear the real audio source in the background but in the foreground its just all noise.

    Hrm.. mine is not that bad. My audio is crystal clear, just with a light fuzz on it (not distortion, just overlaid noise). Guess I can't expect a great SNR with only 12 bits [noparse]:)[/noparse]

    Tried new caps Leon (nice 1nf monoblocks) but no improvement.
    Time to break out the CRO I guess.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lt's not particularly silly, is it?
  • BradCBradC Posts: 2,601
    edited 2009-09-11 13:35
    Rayman said...

    I have noticed that nearby pins can add noise... For the dip package, I had gaurd pins set to output 0 in either side of the signal pins (it's a waste of pins, but I had extra...)...

    I tried the guard pins to 0, and I tried them to +3.3v internally. No dice.
    *then* I put 470nF between pins 1 & 3 (feedback is on pin 2, and input is pin 0), tied pin 3 to +3.3v externally and *poof* noise gone. Noise was 14 counts, it's now 2. Massive improvement.

    As soon as I arc up the D/A converter it comes back though. I suspect it's related to the layout I'm using on the Proto board. Oh well, I'm a step closer anyway.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lt's not particularly silly, is it?
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2009-09-11 15:24
    The test that Chip did:


    Note about the circuit layout, from the Spin test object:

    ' It is very critical that the following circuit be connected within a few millimeters of the
    ' Propeller pins, since at 80 MHz there is a 12.5ns feedback loop operating. Normally, this
    ' kind of thing is done on-chip, where parasitics are minimal. This probably will not work on
    ' the breadboad, at all. I soldered 0603 SMT parts directly onto the pins to keep things
    ' short and it worked beautifully:


    http://forums.parallax.com/showthread.php?p=576575[noparse][[/noparse]url]

    Post Edited (Bob Lawrence (VE1RLL)) : 9/11/2009 4:32:10 PM GMT
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2009-09-11 19:40
    The AVRs quote 10 bit res but that is very dependant on the chip package and board layout. So even with internal nominally purpose built a/d with reference volts the 8 bit mark is probably nearer the truth. I bet most systems, outside of lab quality, do not acheive the perfect bit count.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Style and grace : Nil point
  • VIRANDVIRAND Posts: 656
    edited 2009-09-11 21:38
    That problem is typical of software based ADC.The logic gates all make impulse noise when they change states
    and having high precision at 5 volts or less (worse) is hard even with external ADC,
    which needs capacitors on the power supply pins and input to absorb all of that RF noise in the circuit,
    and averaging samples which still float after all that.

    But even an (LM386) analog audio amplifier probably has more noise, and since Reality is analog except at the
    noisy quantum level, it's probably impossible to remove all quantization noise from digital audio and
    have an input-output connection with less noise than anything analog possible. Is there any such thing as a
    digital microphone or a digital speaker? Funny idea but if there was quantum-level quantization in such
    imaginary things, there would still be loss from finite sampling rate and influence from other noise sources,
    including state changes in any logic gates in between the input and output.

    Anything that can present a noiseless model of Reality must be a Synthesizer (or a Virtual Reality).
  • BradCBradC Posts: 2,601
    edited 2009-09-12 05:11
    So I fired up the old CRO to see if I could figure out what was going on. The noise envelope on the feedback pin is ringing at about 2.3Khz (not quite sure of the significance of the frequency but it's certainly repeatable and measurable).

    The noise envelope changes depending on which cog the A/D is running on. It gets slightly cleaner as I move from cog 0 to cog 7. In addition, if I shut down all the other cogs it cleans up nicely. It *appears* that accessing the HUB is ever so slightly changing the threshold voltage on the feedback pin. A SPIN cog running hard induces more noise into the system than an assembler cog doing maths but not touching the hub.

    I can't measure accurately less than 20mV on my CRO and the hash on the 3.3v rail is up around 20mV, so I suspect the threshold point is changing due to either internal power distribution resistance in the chip itself, or insufficient bypassing on the Propeller Proto-Board.

    I thought I'd get clever and set up an identical parallel A/D circuit, just without the audio input and see what happened. As it turns out, the noise envelope is almost identical to the first unit. (The phase and envelope is identical) Logically this means the threshold on both input pins is varying precisely the same amount as the 3.3v rail fluctuates. I thought I'd get clever and try to subtract the noise from the reference converter from the audio converter, but it's just different enough to leave a significant noise signal behind.

    Time to start looking for a small external 12 bit converter I guess. I was hoping to get away with just the prop and an op-amp.. oh well.

    Oh, and the noise gets significantly worse when I start swinging other pins around, so it *has* to be something to do with the threshold point on the feedback pin. I just can't see any other reason for it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lt's not particularly silly, is it?
  • dMajodMajo Posts: 855
    edited 2009-09-12 09:11
    @BradC

    Rayman have a nice applet on his site

    diagram.png
    Perhaps you should consider Vdd/Vss AVdd and AGnd. In this way you will remove most of the other logic switching noise from the input pin. I think that C1+C2+R1 tap should be as close as possible to the prop input, but for C1/C2 Vcc/Gnd i think is better if they are well filtered. Ofcourse if you're doing audio you have a capacitor instead of R2



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · Propeller Object Exchange (last Publications / Updates)

    Post Edited (dMajo) : 9/12/2009 9:42:15 AM GMT
    643 x 206 - 14K
    CLC.jpg 14.1K
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-09-12 09:27
    Brad, what do you want to do with 12 Bits? That's 4096, you know? wink.gif
    With a 5V supply, this are 1.2 mV. See the app-notes of ADCs and their suggestions about board-layout. No, not bread-boards, but double-sided, shielding, well thought out position of caps (with low inductance), an extra power-supply with very little noise ...


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • BradCBradC Posts: 2,601
    edited 2009-09-12 09:40
    Nick Mueller said...
    Brad, what do you want to do with 12 Bits? That's 4096, you know? wink.gif

    A guitar has quite a dynamic range.

    I'll re-work the board again taking into account separate rails for the ADC portion tomorrow and see what happens.
    It's purely for academic value now as I've ordered some external 8 pin converters which will arrive on Thursday. I'll keep playing with the internal converters between now and then.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lt's not particularly silly, is it?
  • KyeKye Posts: 2,200
    edited 2009-09-12 14:38
    Well, if its a hardware problem then I'm just going to have bad audio qaulity. I'm aiming to make my device as cheap as possible. I guess I just go for small surface mount resistors and such to get everything as close as possible.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • localrogerlocalroger Posts: 3,452
    edited 2009-09-12 15:02
    BradC... Instead of going all-in on an external ADC, it seems like the problem you've identified could be fixed with just a second op-amp to function as a more reliable comparator. In a pinch you could run both the uC output and input pins through buffers which are if necessary powered from a separate regulator, possibly even at a higher voltage (which always helps with noise) ... seems like this might solve the problem and leave you with software control of the ADC bit depth.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2009-09-12 18:47
    I'm not sure if anyone linked back to this thread, Troubles with Sigma-Delta ADC. The link is direct to Chip's insights into why to choose certain pins over others to make the best ADC, (Cog0 using pins 7 and 8, and Cog7 using pins 23 and 24), and PCB layout. The thread has a lot of discussion of the theory and limits of performance.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • localrogerlocalroger Posts: 3,452
    edited 2009-09-12 19:59
    Tracy, thanks for that -- I've bookmarked it. Somehow that didn't come up in my own searches for A/D info.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2009-09-12 20:10
    The threshold point of the smpling pin is being used, this pin was intended for general in/out and the fact that it choices to switch so predictably is a bonus rather tha a design criteria. Put this together with real world muck on/in the rails, and floating in the ether, it will never be clinical.

    It's probably just one of those wonderful uses that was discovered, rather than intended

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Style and grace : Nil point
Sign In or Register to comment.