Electronic – How to keep PWM from “contaminating” analog read values on the pcb

analogbypass-capacitormidinoisepcb-design

So I'm designing a PCB for a MIDI controller with a lot of slide potentiometers and push buttons. I'm also backlighting the pushbuttons with LEDs running on PWM and I'm worried that the PWM for the LEDs is going to create a lot of noise in the analog values from the potentiometers. There is also USB on the PCB wich also is the power source.

How do I make sure that the analog values from the potentiometers are as clean as possible?

I guess PCB layout is critical and the use of bypas capacitors is a good idea?

Any help is appreciated 🙂

Best Answer

This is a MIDI controller, so I guess no analog audio processing will take place inside, which means the internal circuits should be rather noise tolerant. You should of course take care not to radiate noise which could affect other devices.

Using PWM for your LEDs means traces carrying pulsed currents. I assume your LEDs, buttons and pots will be on a PCB, which could be quite large, since you mention "a lot of slide pots".

First thing to worry about is common impedance coupling. If pulsed LED currents run through the same traces as voltages used to read the pots, then the bits of trace in common will result in extra noise in your analog readings. The solution is quite simple: don't run pulsed LED currents through traces that also carry analog signals. So, if your pots have one end at GND and the other end at VCC, simply avoid sharing GND/VCC traces between the pots and the LED driver chips.

An alternate solution is to sync your microcontroller's ADC with the PWM timer, and acquire when the LEDs are all off.

Consider adding a RC filter before your ADC, make sure the cutoff is high enough so the pots don't feel "slow". This will also reduce noise picked up by the pots themselves (via capacitive coupling with the user's finger, nearby cellphones, etc).

Then, AC currents in traces mean loop antennas, which emit electromagnetic waves. You need to reduce the area of loops carrying pulsed currents. This simply means being aware of where your LED current flows, and routing both traces close to each other. For example if your current loop is:

GND - Decoupling cap at LED driver - VCC - trace - LED - trace - resistor - driver chip - GND

Then, if you route both traces between the LED driver and the LED close together, it will radiate much less.

If you multiplex your LEDs, the first layout that comes to mind would be a grid, but that's also the one with the largest loop area.

A ground plane would work if your LEDs are grounded, but most drivers put LEDs between VCC and the driver, so a ground plane won't carry the return current. It would only act as a shield.

Also make sure that whatever drives your LEDs does not output very high slew rate current. Don't use a superfast logic gate. Slow edges are much nicer.