Pages: [1]   Go Down
Author Topic: getting rid of PWM hum when controlling RGB LEDs without affecting millis()  (Read 884 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  
Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 32
Posts: 1214
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27114
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6619
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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.

Pages: [1]   Go Up
Jump to: