What is the secret of comedy?
To the point:
The shield has printed on it Frequency 40 - 1000Hz.
-The code demo starts at 1600Hz, what is the top end?
I tested the output at various Frequency settings, with the PWM output (set to 50%) hooked to an Arduino Mega R3 acting as a frequency counter. Here are the frequencies I got:
listed as set value = measured value
pwm.setPWMFreq(40); = 38 (5% is good enough since I am using the Mega as a Frequency counter)
pwm.setPWMFreq(1000); = 922 (8%...meh close enough)
pwm.setPWMFreq(1600); = 1611 (woot!)
and now for the issues:
pwm.setPWMFreq(800); = 752
pwm.setPWMFreq(900); = 752
pwm.setPWMFreq(1100); = 922
pwm.setPWMFreq(1200); = 922
pwm.setPWMFreq(1300); = 1232
pwm.setPWMFreq(1400); = 1232
pwm.setPWMFreq(1500); = 1232
I use the same Frequency counting program for other uses so I don't feel it is an issue with that. Here is the source of that program:
https://www.pjrc.com/teensy/td_libs_FreqCount.html
So are there certain "allowed" frequencies for the setPWMFreq? Am I missing something?
Timing. The secret of comedy is timing.
1411 16-Channel 12-bit PWM Shield Frequency Questions Issues
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- megahurts
- Posts: 1
- Joined: Wed Feb 16, 2011 1:53 pm
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: 1411 16-Channel 12-bit PWM Shield Frequency Questions Is
The PCA9685 has an internal oscillator whose nominal frequency is 25MHz and a clock prescaler that accepts values from 3 to 255 in the PRE_SCALE register. The system clock ticks once every PRE_SCALE ticks of the oscillator.
The PWM counter is a 12-bit clock, so the PWM frequency has a nominal value of 25MHz/(4096*PRE_SCALE)
The datasheet provides a formula to calculate prescale values for PWM frequencies as:
round( 25MHz / ( 4096 * PWM-frequency )) - 1
The master clock isn't made for high precision, and most on-chip RC oscillators are accurate and stable to within about 5%.
The PWM counter is a 12-bit clock, so the PWM frequency has a nominal value of 25MHz/(4096*PRE_SCALE)
The datasheet provides a formula to calculate prescale values for PWM frequencies as:
round( 25MHz / ( 4096 * PWM-frequency )) - 1
The master clock isn't made for high precision, and most on-chip RC oscillators are accurate and stable to within about 5%.
Please be positive and constructive with your questions and comments.