Go Down

Topic: getting rid of PWM hum when controlling RGB LEDs without affecting millis() (Read 978 times) previous topic - next topic

spskeyes

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  

Msquare

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)

CrossRoads

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.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

spskeyes

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....

dc42

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?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Go Up