Skip to content

Commit df272ce

Browse files
committed
Update int.osc. notes in examples
In theory the data sheet says the internal oscillator (clock) is 25MHz but in testing the internal oscillator for the PCA9685 chip is a range between about 23-27MHz. Adafruit testing for implimenting the int.osc. showed and upper level of about 27 Mhz My own testing with 4 different Adafruit PCA9685 16-Channel Servo Drivers gave 24060000, 24090000, 24600000, and 25000000 Mhz when tuning the int.osc. frequency to get aproximatly 50Hz PWM signals. Actual pwm signals were 50.6xx to 50.1xx Hz across the four chips tested as the PCA9685 chip output is not super precise. This PR expands the notes on the PWM frequency and gives rough instructions on checking the PWM frequenty for tuning the int.osc. value.
1 parent 52c2844 commit df272ce

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

examples/pwmtest/pwmtest.ino

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,23 @@ void setup() {
3131
Serial.println("16 channel PWM test!");
3232

3333
pwm.begin();
34-
// In theory the internal oscillator is 25MHz but it really isn't
35-
// that precise. You can 'calibrate' by tweaking this number till
36-
// you get the frequency you're expecting!
37-
pwm.setOscillatorFrequency(27000000); // The int.osc. is closer to 27MHz
34+
/*
35+
* In theory the internal oscillator (clock) is 25MHz but it really isn't
36+
* that precise. You can 'calibrate' this by tweaking this number until
37+
* you get the PWM update frequency you're expecting!
38+
* The int.osc. for the PCA9685 chip is a range between about 23-27MHz and
39+
* is used for calculating things like writeMicroseconds()
40+
* Analog servos run at ~50 Hz updates, It is importaint to use an
41+
* oscilloscope in setting the int.osc frequency for the I2C PCA9685 chip.
42+
* 1) Attach the oscilloscope to one of the PWM signal pins and ground on
43+
* the I2C PCA9685 chip you are setting the value for.
44+
* 2) Adjust setOscillatorFrequency() until the PWM update frequency is the
45+
* expected value (50Hz for most ESCs)
46+
* Setting the value here is specific to each individual I2C PCA9685 chip and
47+
* affects the calculations for the PWM update frequency.
48+
* Failure to correctly set the int.osc value will cause unexpected PWM results
49+
*/
50+
pwm.setOscillatorFrequency(27000000);
3851
pwm.setPWMFreq(1600); // This is the maximum PWM frequency
3952

4053
// if you want to really speed stuff up, you can go into 'fast 400khz I2C' mode

examples/servo/servo.ino

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,23 @@ void setup() {
4545
Serial.println("8 channel Servo test!");
4646

4747
pwm.begin();
48-
// In theory the internal oscillator is 25MHz but it really isn't
49-
// that precise. You can 'calibrate' by tweaking this number till
50-
// you get the frequency you're expecting!
51-
pwm.setOscillatorFrequency(27000000); // The int.osc. is closer to 27MHz
48+
/*
49+
* In theory the internal oscillator (clock) is 25MHz but it really isn't
50+
* that precise. You can 'calibrate' this by tweaking this number until
51+
* you get the PWM update frequency you're expecting!
52+
* The int.osc. for the PCA9685 chip is a range between about 23-27MHz and
53+
* is used for calculating things like writeMicroseconds()
54+
* Analog servos run at ~50 Hz updates, It is importaint to use an
55+
* oscilloscope in setting the int.osc frequency for the I2C PCA9685 chip.
56+
* 1) Attach the oscilloscope to one of the PWM signal pins and ground on
57+
* the I2C PCA9685 chip you are setting the value for.
58+
* 2) Adjust setOscillatorFrequency() until the PWM update frequency is the
59+
* expected value (50Hz for most ESCs)
60+
* Setting the value here is specific to each individual I2C PCA9685 chip and
61+
* affects the calculations for the PWM update frequency.
62+
* Failure to correctly set the int.osc value will cause unexpected PWM results
63+
*/
64+
pwm.setOscillatorFrequency(27000000);
5265
pwm.setPWMFreq(SERVO_FREQ); // Analog servos run at ~50 Hz updates
5366

5467
delay(10);

0 commit comments

Comments
 (0)