Go Down

Topic: PCA9685 16-channel board: Best frequency for servos and/or LEDs? [SOLVED] (Read 565 times) previous topic - next topic

donatcape

SOLVED: See post from Wawa below.  Thanks, Wawa!

Some of the documentation for the subject board states the following:
"All channels must have the same PWM frequency.  For LEDs you probably want 1.0 KHz but servos need 60 Hz."

However, the Arduino Uno documentation says some of the PWM pins use 490 Hz, while the others use 980 Hz.

What am I missing here?
Thanks in advance.

Wawa

The PCA9685 has nothing to do with Arduino PWM frequencies.
It generates it's own independent PWM frequency, that can be set between ~40Hz and 1.5kHz.

Default is 200Hz, and is ok for LEDs.
To reduce possible strobing effects when moving, you could increase this frequency,
but if the chip drives a LED driver, make sure it can handle the higher frequency.
LED drivers have a max PWM frequency to be able to dim down low enough.
Leo..

slipstick

Modern servos can also handle a range of frequencies. 50Hz (not 60Hz) is the default for servos but quite a few servos can handle 150Hz or so. But they are never driven from the hardware PWM pins.

Steve

Paul__B

But they are never driven from the hardware PWM pins.
Well, they may be and they may not be.  The point is that you are not compelled to use a PWM pin.  :smiley-roll:

Grumpy_Mike

Quote
Some of the documentation for the subject board states the following:
"All channels must have the same PWM frequency.  For LEDs you probably want 1.0 KHz but servos need 60 Hz."
Where is this crap documentation?
Why would anyone want 1KHz PWM for LEDs, that is just silly, as is running servos from PWM, because you have so little control if you do that.

donatcape

Here's the "crap documentation" that I quoted from: https://learn.adafruit.com/16-channel-pwm-servo-driver/pinouts



Wawa

Well, I don't see anything wrong with that article.
Servos need a pulse with variable width, with a frequency of about 50 or 60Hz.
The PCA generates that with x/4096 PWM.

Servos controlled directly from an Arduino pin don't need PWM pins.
The Arduino servo library can use any pin, including analogue pins for that.

LEDs can be PWM-ed with almost any frequency (within reason),
but flickering/strobing becomes a problem when the frequency is too low.
As said, the PCA's default 200Hz is usually fine, and 1kHz is not much different visually.
I currently use 800Hz, which is working fine with my PT4115 CC LED drivers.

I wouldn't use the Adafruit library for LEDs though.
It does not have an equal brightness lookup table, so smooth dimming is not easy.
I mainly use the "Brunnels" library for LEDs.

Question is: what do YOU want to do.
LEDs or servos.
Leo..

Grumpy_Mike

Here's the "crap documentation" that I quoted from: https://learn.adafruit.com/16-channel-pwm-servo-driver/pinouts
So that was a product description no a statement of fact. They are saying that for their board all LEDs must have the same PWM frequency. They are not saying that in real life all LEDs must have the same PWM frequency, just for that specific problem. So you misrepresent that quote.

Quote
Question is: what do YOU want to do.
LEDs or servos.
Guess we might never know.

There is a problem with using that board with LEDs and servos together at the same time that they don't tell you about. The solution is to invert the signals to one of the devices, normally the one you have fewest of.

Quote
Question is: what do YOU want to do.
LEDs or servos.
Guess we might never know.

There is a problem with using that board with LEDs and servos together at the same time that they don't tell you about. The solution is to invert the signals to one of the devices, normally the one you have fewest of.

Go Up