Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: spskeyes on Jan 16, 2013, 02:32 am

Title: getting rid of PWM hum when controlling RGB LEDs without affecting millis()
Post by: spskeyes on Jan 16, 2013, 02:32 am
Hi All,

I'm using a Fio board and controlling 2 RGB LEDs with pwm on pins 3,5,6 and 9,10,11.  I'm also using the Stepper library for a small stepper motor.  The pwm for the LEDs is producing an audible hum in my project that I want to get rid of.  Can I change the pwm frequency without affecting millis(), which the Stepper library uses for timing?

I was reading here http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM
under "Varying the timer top limit: fast PWM" but I'm not sure if it will work for both LEDs, etc.

Thanks,
Paul  
Title: Re: getting rid of PWM hum when controlling RGB LEDs without affecting millis()
Post by: 3dprinter on Jan 17, 2013, 06:25 pm
I do not know either. On the other hand, no damage will happen to your stepper if the adjusted PWM ruins the timing and the stepper goes too fast. It might just jitter.

In other words, I think there is no reason just to try it.

(Why do you think the stepper hum is due to the LED PWM? Steppers make noise anyhow - usually the current limit circuit in the driver chips is a chopper ie a PWM)
Title: Re: getting rid of PWM hum when controlling RGB LEDs without affecting millis()
Post by: CrossRoads on Jan 17, 2013, 06:46 pm
If you download Visual Analyzer from here,
http://www.sillanumsoft.org/
and connect a microphone to your PC sound card, you can use the Spectrum Analyzer to see what frequency the hum is at.
If it's ~490 Hz, that is likely the PWM. If it's something else, find the culprit.
Title: Re: getting rid of PWM hum when controlling RGB LEDs without affecting millis()
Post by: spskeyes on Jan 18, 2013, 03:15 am
Thanks for the input.  When I turn the LEDs off, with AnalogWrite(0) on all LED pins, the noise goes away.  So I'm pretty sure I'm hearing hum from the PWM.  However, I don't hear it all the time.  It changes with the colour changes.  I've tuned some specific behaviour from the motors which I know will change if I alter the timers.  I wanted to avoid retuning the motors but it sounds like I have no other option....
Title: Re: getting rid of PWM hum when controlling RGB LEDs without affecting millis()
Post by: dc42 on Jan 19, 2013, 11:02 am
It's unusual to hear hum from LED controlled with PWM. I suspect that the PWM is affecting the supply voltage and that you are hearing the resulting hum from the stepper motor or some other component. How are the LEDs connected to the Arduino, in particular, do you have the right value series resistors?