Last time we saw the the 555 PWM circuit wasn't so good. But I did recall a technique a professor mentioned as an anecdote. Generate a saw or ramp wave of your necessary frequency, and compare it to a voltage representing the desired duty cycle. First let's make our oscillator.
This neat little circuit is one I modified from this YouTube video:
Saw Generator Circuit. It's worth watching for the explanation which I will repeat in less detail here. R16, R17, R18, & Q1 form a constant current source which charge C3 in a linear fashion (as opposed to the logarithmic fashion a constant voltage source would produce). R11, R19, R20, Q2, & Q3 form the discharge circuit. When the voltage on C3 is about a diode drop above the base voltage of Q2 (which is set by the R19 & R20 voltage divider, so VCC*10/11), Q2 will turn on, consequently turning on Q3. At this point the base voltage on Q2 is predominantly set by the voltage divider of R11 & R19, which is VCC*1/11. C3 will continue to discharge until that threshold is met and Q2 turns off, resetting the cycle. Q5 and the 10k pot form a voltage follower output buffer that can scale the resulting waveform and minimizes any parasitic effects on the generator itself. "Saw" represents the signal that would feed a comparator.
I can't really vouch for the values I show in the rest of the circuit, they were tweaked as needed to get the frequency I needed.
Now you may notice that my fan driver differs from our previous discussion. This is what I drew at the time and I don't entirely recall why. Maybe so as not to invert the PWM signal? So I'm just using the Op Amp as a comparater between "Saw" and "TEMP_SET", which is some voltage reference. Below shows how the duty cycle changes relative to temperature changes. You can see how the output wave changes wherever the saw wave and the temperature level intersect (blue = temperature, red = saw).
 |
| Blue = TEMP_SET, Red = Saw, Green = PWM Fan Drive |
So I ended up building this up and trying it out. I believe I started off around 18--20KHz before figuring out that a 100Hz was more appropriate. And it did work.... Ish. I could blast the diode with ;heat and the fan would speed up and slow down, however it had a loud and distracting kicking sound related to the PWM frequency. Awful in fact.
Time for another approach.