RC oscillator question
parts-man73
Posts: 830
When an Resistor and Capacitor are used to drive the oscillator input of a microcontroller in place of a crystal. Is there a way to calculate the approximate frequency that the RC oscillator will produce with various different combinations of resistors and capaciators?
I realize this type of oscillator is very inaccurate and probably fluctuates with voltage, temperature, etc. But I'm just looking for a general idea of the clock speed.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Brian
uController.com - home of SpinStudio
PropNIC - Add ethernet ability to your Propeller!
SD card Adapter
I realize this type of oscillator is very inaccurate and probably fluctuates with voltage, temperature, etc. But I'm just looking for a general idea of the clock speed.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Brian
uController.com - home of SpinStudio
PropNIC - Add ethernet ability to your Propeller!
SD card Adapter
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······· "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
Technologically challenged individual, Please have pity.
·
The frequency is basically going to be ....·
·
F = 1 / (·Dt * R * C )
·
Where:
·
Dt·is a derating factor (<=1) (<2 )·that depends largely on Voltage, Input Threshold, Temperature, Propagation delay, etc
R is the resistor value (Ohms)
C is the Capacitor value (Farads)
·
·
For Example the·Dt for·a 74HC14 configured as an oscillator is 0.8 , where the same configuration for a 74HCT14,·Dt is 0.67 ...·The only substantial difference
between the HC and the HCT is where the input threshold is.
·
If I couldn't find the·Dt value for a processor, I would create a simple test to measure it.· With known R and C values, and measuring the Frequency, the formula
can be rewritten as...
·
Dt·=· 1 / ( F * R * C )
·
...to solve for Dt
·
Dt·could also be looked at, as·how many "time constants" into the charge/discharge cycle·you are, before you have reached a switching threshold of the processor.
If you look on a scope at the voltage levels where the capacitor switches from charge to discharge and compare that to the Dt value, the relationship should be·intuitive.
·
Reference:
http://www.electronics-tutorials.ws/rc/rc_2.html
http://www.datasheetcatalog.com/datasheets_pdf/7/4/H/C/74HC14.shtml
······
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 1/27/2008 2:12:53 PM GMT
Thank you for the quick and informative reply.
I looked at the datasheet for the microcontroller that I was specifically looking at now, they did not list a Dt value, but there was a chart that I pulled some values from to try to solve for Dt.
I came up with a value of .0166 - does that sound reasonable?
The chart on the datasheet graphed VDD vs R at a constant C.
At 5V, R=10K ohm C=100pF (0.00000001 F if I'm calculating right) - F = 600 khz
so Dt = 1 / (600_000 * 10_000 * 0.00000001) = .0166
is my math solid there?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Brian
uController.com - home of SpinStudio
PropNIC - Add ethernet ability to your Propeller!
SD card Adapter
·
pF is 10^-12, so 100pF would be 100 x·10^-12 or 1 x 10^-10· = ·0.0000000001
·
Dt = 1 / (600_000 * 10_000 * 0.0000000001) = 1.67
·
I know that I said Dt should be less than or equal to 1...·· it should actually be less than 2
·
The Dt value will also depend on how the internal portion of the microprocessor handles the RC connection.· i.e. The processor·may
not cycle the external RC circuit·with a 50% duty cycle.
·
It might be·easier to·measure the capacitor charge/discharge·and obtain·empirical data that way, and then try to work it into the equation.
If you use a Dt value of 1.67 you should get reasonably close
F = 1 / ( Dt *·R *·C ) = 1 / ( 1.67 * 10k * 100pF ) = 598.802kHz
·
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 1/25/2008 11:52:14 PM GMT
I see my error in calculation. Actually, error in conversion of one of the Factors. I do appreciate your help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Brian
uController.com - home of SpinStudio
PropNIC - Add ethernet ability to your Propeller!
SD card Adapter
·
"It'd be interesting to see the difference between theoretical and actual values." - Yes, let us know....·
Does 1.67 "fit" with some of the other data·from the chart·presented in the microcontroller datasheet?
·
You might need to take multiple points to determine a Gaussian fit for Dt.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I calculated Dt for a few different values on the chart, and came up with Dt values from 0.89 and up. I didn't have any of the exact capacitor values they listed on hand. I substituted a very close value (20 pf vs 22 pf) for my test circuit.
I measured the frequency with a Propeller running code from this thread - http://forums.parallax.com/showthread.php?p=574524 by Dave Scanlan.
First I tested with a 4 mhz crystal. My test code toggled an output pin, the main loop had 7 instruction cycles. One instruction cycle consists of 4 oscillator periods. So I expected the output pin to toggle at 142_857hz. The observed value was very close to this value.
Then when I tested my RC oscillator running the same code, the observed values were extremely different than my expected values. by a factor of 4-5x. This coming week I will stop by my local electronics store and pick up some of the exact capacitors from the chart in the datasheet and see if using the exact values from thier chart will provide the same frequencies as the datasheet suggests.
The Propeller definately proved itself as a valuable tool in the toolbox! just being able to drop a bit of code into it, hook up an LCD and you have an instant frequency counter!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Brian
uController.com - home of SpinStudio
PropNIC - Add ethernet ability to your Propeller!
SD card Adapter
I'm a little surprised that the datasheet does not offer some sort of formula to calculate frequency. Can you post some of the values in the chart that they do provide?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
100 pf Capacitor is a constant on this chart. 10K Resistor and 5 volts are the variables. The graph gives me a value of approximately 600 khz.
Figure 10-7 is the graph I am using for my physical experiment to compare calculated vs actual values.
At 5 volts, with a 22 pF cap and a 10K resistor, I am approximating the freq at 5.5 mhz
Dt = 1 / (5_500_000 * 10_000 * 0.000000000022) = 0.826
I didn't have a 22 pF cap, I substituted a 20 pF cap, all other values are the same.
F = 1 / ( Dt * R * C )
F = 1 / (0.826 * 10_000 * 0.000000000020)
F = 1 / 0.0000001652
F = 6_053_268 hz
Now my test toggled an output pin, the main loop had 7 instruction cycles. One instruction cycle consists of 4 oscillator periods. So at 6.053 mhz I expected the output pin to be toggling at 216_178 hz.
Instead, I am reading a value of 84_627 hz on my actual test. Which would indicate a oscillator speed of 2_369_556, A long way off from the 6_053_268 that I calculated.
Would the change from a 22 pF to 20 pF account for such a drastic change? Or perhaps a misprint in the datasheet?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Brian
uController.com - home of SpinStudio
PropNIC - Add ethernet ability to your Propeller!
SD card Adapter
The frequency drifts some as expected with a RC type oscillator.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Brian
uController.com - home of SpinStudio
PropNIC - Add ethernet ability to your Propeller!
SD card Adapter
Ahhh...·Solderless Bread Board·(SBB) parasitic capacitance can be as high as 35pF.... so instead of placeing a 20pF cap on your circuit, you could actually be placing a 50pF cap on your circuit.
F = 1 / (0.826 * 10_000 * 0.00000000005)
F = 1 / 0.000000413
F = 2.421MHz
Note: You should also take into acount temperature, and component tolerances.· The chart specifies 25 Deg C, which is pretty standard.· Component·tolerance is usually an ideal value.
No, in fact, the difference of 5.5 mhz with 22pF vs. 6.053MHz with a 20pF is absolutely acceptable.· Both capacitance and frequency are within 10% of one another.
Remember·Dt is nothing more than a de-rating value from the ideal formula·of·1/RC ... It's a way to quantify any environmental affects on the circuit.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 1/28/2008 2:19:57 AM GMT
I have a pretty good understanding of the RC oscillator now (and hopefully all others watching our conversation learned something as well)
Thanks again for the lesson!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Brian
uController.com - home of SpinStudio
PropNIC - Add ethernet ability to your Propeller!
SD card Adapter