Microcontrollers and digital noise

Started by soggybag, August 25, 2010, 11:50:18 PM

Previous topic - Next topic

soggybag

I'm working on a project that uses an AVR chip. It's all on the breadboard right now. I can hear some digital noise leaking through into the audio. I'm using the chip to generate a control voltage via PWM. The rest of audio is running through a Twin-T type filter.

I'm guessing I'll be able to nix this with careful layout when things get committed to a PCB. I think the chip runs at 10mhz, it's my guess that the noise is coming from the PWM.

I'm wondering if anyone has any suggestions for best practice?

Gurner

This might see m an obvious suggestion, but have you tried increasing the pwm frequency above normal hearing - I'm doing something similar & was hearing the PWM, so I upped the pwm to 20khz - PWM noise gone!

An awful lot of processor white noise on the 1/2 vcc rail though....had to have a separate rail for the analogue in the end

slotbot

#2
+1 ^^

are you using the same code as in the other thread though? i think according to that code you are alrady using max frequency for phase correct pwm mode. It should  be around 19 kHz in this case.

also if you arnent already use a regulator with some caps to power the mcu.

cloudscapes

I think I managed to up my PWM freqs to around 30khz in bascom. wish I could find the code...
it was a doubler register

star grounding also helps
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

Gurner

#4
Post self deleted (found what I was looking for!)

soggybag

I'm using this code, which I took from another example. The comment says it sets the "phase correct mode 1". There is a "Fast" mode. I'm not sure if this is a faster speed or is just processed faster. I'm still researching.

TCCR0A |= (1<<COM0A1) | (1<<WGM00); // PWM Phase correct mode 1
TCCR0B |= (1<<CS00);// --no prescale

slotbot

Quote from: cloudscapes on August 26, 2010, 10:51:42 PM
I think I managed to up my PWM freqs to around 30khz in bascom. wish I could find the code...
it was a doubler register

star grounding also helps

yes you can get i think ~36kHz with this ic.

Quote from: soggybag on August 27, 2010, 11:11:54 AM
I'm using this code, which I took from another example. The comment says it sets the "phase correct mode 1". There is a "Fast" mode. I'm not sure if this is a faster speed or is just processed faster. I'm still researching.


TCCR0A |= (1<<COM0A1) | (1<<WGM00); // PWM Phase correct mode 1
TCCR0B |= (1<<CS00);// --no prescale


yes use fast PWM it will be twice as fast. (with C, assembly, bascom or otherwise)

you can see teh differnnce in teh data sheet here

http://www.atmel.com/dyn/resources/prod_documents/doc2535.pdf


look at figures 11-6 and 11-7 respectively (pg65), you will see the difference in the "switching" pattern for phase correct pwm vs fast pwm. for fast pwm they say frequency is clk/255 as opposed to clk/510 so it should be around 36kHz with fast pwm and no prescaler.



JKowalski

Separating digital and analog grounds is a common design strategy, tying them together only at the point where the grounding wire from the power supply/enclosure to the board is.

soggybag

I had that in mind. As it is not everything is on the breadboard. I'm hoping the noise is really more of an issue on the breadboard.

ElectricDruid

Are you using any ADC channels in your design? I've done some PIC-based modulation projects and I used the ADC channels to control them with 0-5V control voltages from pots. If the pots aren't properly filtered (1K and 100n cap) then you get a lot of ADC noise going in. In one or two things I did, this caused jitter in the values of variables used internally and showed up as noise in the output.

Just a thought. Your design might be totally different.

T.

MoltenVoltage

I've been researching this lately too.

From what I have read, and what makes the most sense intuitively, is, to the extent possible, physically separate the analog and digital portions of the circuit, then go to great lengths to keep their grounds from passing near each other, and particularly avoid having the two grounds cross each other on different layers, then connect all the grounds as close as possible to the power supply.

MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!