DIYstompboxes.com

DIY Stompboxes => Digital & DSP => Topic started by: soggybag on August 25, 2010, 11:50:18 PM

Title: Microcontrollers and digital noise
Post by: soggybag on August 25, 2010, 11:50:18 PM
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?
Title: Re: Microcontrollers and digital noise
Post by: Gurner on August 26, 2010, 04:14:48 PM
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
Title: Re: Microcontrollers and digital noise
Post by: slotbot on August 26, 2010, 05:02:07 PM
+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.
Title: Re: Microcontrollers and digital noise
Post by: 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
Title: Re: Microcontrollers and digital noise
Post by: Gurner on August 27, 2010, 04:07:20 AM
Post self deleted (found what I was looking for!)
Title: Re: Microcontrollers and digital noise
Post by: 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
Title: Re: Microcontrollers and digital noise
Post by: slotbot on August 27, 2010, 02:16:57 PM
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 (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.


Title: Re: Microcontrollers and digital noise
Post by: JKowalski on August 27, 2010, 04:16:41 PM
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.
Title: Re: Microcontrollers and digital noise
Post by: soggybag on August 27, 2010, 06:17:10 PM
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.
Title: Re: Microcontrollers and digital noise
Post by: ElectricDruid on October 26, 2010, 05:53:51 PM
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.
Title: Re: Microcontrollers and digital noise
Post by: MoltenVoltage on October 27, 2010, 06:21:35 PM
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.