Author Topic: Microcontrollers and digital noise  (Read 4854 times)

0 Members and 1 Guest are viewing this topic.

soggybag

Microcontrollers and digital noise
« 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?

Gurner

Re: Microcontrollers and digital noise
« Reply #1 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

slotbot

Re: Microcontrollers and digital noise
« Reply #2 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.
« Last Edit: August 26, 2010, 05:49:10 PM by slotbot »

cloudscapes

Re: Microcontrollers and digital noise
« Reply #3 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
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

Gurner

Re: Microcontrollers and digital noise
« Reply #4 on: August 27, 2010, 04:07:20 AM »
Post self deleted (found what I was looking for!)
« Last Edit: August 27, 2010, 04:08:51 AM by Gurner »

soggybag

Re: Microcontrollers and digital noise
« Reply #5 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.

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

slotbot

Re: Microcontrollers and digital noise
« Reply #6 on: August 27, 2010, 02:16:57 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.

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.


Code: [Select]
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

Re: Microcontrollers and digital noise
« Reply #7 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.

soggybag

Re: Microcontrollers and digital noise
« Reply #8 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.

ElectricDruid

Re: Microcontrollers and digital noise
« Reply #9 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.

MoltenVoltage

Re: Microcontrollers and digital noise
« Reply #10 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.

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