0

i'm using arduino to dimmer 9 led strips with different output pins after an FFT audio analysis gives results at 60Hz = 16ms. [FFT is performed by a PC and sent to arduino using a RF24 module]

I started the project using SoftPWM on pins D2->D9 & A4 with a lower frequency update but now i'm having problems increasing the frequency update. I have already wired 6 copies of that board and i'm looking for a software solution

To diagnose the problem i performed a test sending a pwm value and zero at a certain frequency, if the frequency is high you can only see a lower emitted power

If I set the pwm once I have a stable signal (led intensity) If I set the pwm every ~10ms (10ms on @ certain pwm, 10ms at pwm=0) I have an unstable intensity, repeating the test on the pin 6 with a normal analogWrite i don't have the problem. With 10ms i clearly see it blinking at a random frequency (~20Hz=50ms), with 15ms I only see it random fluctuating

I'm using arduino Pro mini - 5V - 2kB Without signals arduino performs 16k cycles/second (most without changing anything), with a 10ms signal it runs at 14k cycles/second so it seems not a load problem.

Can someone help me regarding this problem?

  • Should I change library
  • Should I move to a lower level to rewrite a more performing library
  • Should I use only 6 std pwm, draw again the board, print them again, weld all components again, and test it again?

Thanks!

PS: I can't create the SoftPWM tag for a reputation problem, can a moderator do that?

  • there's only so much an AVR can do in software, they are limited in "horsepower". Coupled with your FFT workload, it sounds like you're pretty lucky it works as well as it does. analogWrite is "hardware accelerated" so to speak, so if you can use it instead, that should provide higher capacity. You can get external GPIO expanders or DACs, or use a 2nd pro-mini talking to the 1st over uart. – dandavis Feb 7 at 19:07
  • Sorry, I wasn't explicit. FHT is done by a PC, results are sent to arduino using an RF24 module. If not really needed i want to avoid to modify the hardware, since it's inside a printed PCB and i'm worried I must redesign it to handle a new module. I have 6 identical board that receive RF24 packets and enable/disable leds – brazoayeye Feb 7 at 19:32
0

The problem is not a SoftPWM limitation but a physical one. SoftPWM have a PWM cycle at 60Hz, that makes impossible to update output faster than 34mS and that explain why I see low frequency trying to change the state with every 10 ms.

Aliasing

Hardcoding the IRS I can reach a much faster PWM cycle, keeping the same PWM frequency I have roughly 60% less of CPU used. With a full CPU load and latest version of the code I can reach ~600Hz PWM cycle. I decided to use a ~300PWM cycle to have enough CPU to perform other tasks (mainly handle RF24 to receive packets @ 60Hz and, if needed, forward them too other bases)

Even at higher frequencies average intensity is not stable, but higher the frequency more stable the result. That can be explained because the eye "average" incoming light and that average is not very stable

avg alias

Since leds are used to produce visual effects I don't need a very accurate output, and 300Hz are enough. (I also don't have big mosfets and I don't want to stress them with higher frequencies)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.