I'm trying to make a 60Hz frequency, this is How I do it :

    freq_hz = 60
    pca9685_frequency = 25000000.0 #pca9685 clock : 25Mhz
    pca9685_resolution = 4096.0 #12 bits resolution
    freq_in_step = pca9685_resolution*float(freq_hz)
    prescaleval = pca9685_frequency/freq_in_step
    print "prescaler value = {}".format(prescaleval)
    prescale = int(math.floor(prescaleval + 0.5))
    print "however only round values can be set so we wil use {} as a prescaler value".format(prescale)
    print "which makes a frequency of {}".format(pca9685_frequency/(prescale*pca9685_resolution))
    oldmode = self.pca9685_device.readU8(self.MODE1);
    newmode = (oldmode & 0x7F) | 0x10    # sleep
    self.pca9685_device.write8(self.MODE1, newmode)  # go to sleep
    self.pca9685_device.write8(self.PRESCALE, prescale)
    self.pca9685_device.write8(self.MODE1, oldmode)
    self.pca9685_device.write8(self.MODE1, oldmode | 0x80)

On the screen the result is :

prescaler value = 101.725260417

however only round values can be set so we will use 102 as a prescaler value which makes a frequency of 59.8383884804

But with my oscilloscope, a Tektronix TDS210 I get a 64.1Hz frequency, not 59.84Hz

Did I make a mistake somewhere?


  • \$\begingroup\$ I had the same issue, this chip is not designed to create an accurate PWM frequency. The original intent was for driving LEDs where a 10% frequency error does not matter. \$\endgroup\$
    – MadHatter
    Commented Oct 22, 2017 at 20:23
  • \$\begingroup\$ Also, you have an arduino already. Unless you're running low on pins, you should probably just use its built-in PWM units – generating 60 Hz with those isn't really immensely complex \$\endgroup\$ Commented Oct 22, 2017 at 20:37
  • \$\begingroup\$ @MadHatter did you find a good one (with i2c communication) \$\endgroup\$ Commented Oct 22, 2017 at 22:30
  • \$\begingroup\$ Nope, I spent a long time looking for I2C devices... surprisingly there are not really any. I ended up using 2 atmega 328s with the same firmware and a resistor to set the I2C address... The only downside is then I had another code base to manage. \$\endgroup\$
    – MadHatter
    Commented Oct 23, 2017 at 0:01

1 Answer 1


From old awnser of the adafruit forum, the PCA9685 is not very precise. So you have to manually check and adapt the prescaler value.

My math are correct according to page 25 of the datasheet and 102 should indeed generates a frequency of 59.84Hz.

However my oscilloscope measurement gives me this :

110 = 60.24Hz
111 = 59.52Hz

TL:DR ; due to the low precision of this component the prescaler computation only gives you a close estimate, you will have to measure the real thing with an oscilloscope.

see second post : https://forums.adafruit.com/viewtopic.php?f=19&t=72554

Blue = real, measured with my oscilloscope

Red = from the datasheet formula

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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