Yes, you are but I think it needs more explanation for those who are unfamiliar with Schmitt trigger oscillators.
Souper man said:
I still dont get it (sorry!), how is a comparator going to run this? the link doesnt even clear up my question. Could i use a H-bridge to run my motors?
An h-bridge is only required when you need to change the direction of the motor.
Look at the schematic that I orignionally posted.
The comparator on the left froms an oscillator.
**broken link removed**
The website that I linked you to doesn't explain how the oscillator works but it explains the comparator Schmitt trigger and hysteresis.
I'll give a brief explaination but you really need to understand Schmitt triggers before you'll get it. The comparator is configured as a Schmitt trigger, it has an resistor and capacitor on its output. The inverting input is connected inbetween the resistor and capacitor to provide feed back and the non inferting input is connected to a potential divider to bias it at half the supply voltage.
When the oscillator is first started the voltage on the capacitor will be zero and the output of the Schmitt trigger will be high. The capacitor will charge through the resistor until it reaches the Schmitt trigger's upper threshold. The output of the Schmitt trigger will then go low and the capacitor will discharge back though the resistor until it gets to a low enough level to turn the Schmitt trigger back on again causing it to recharge. This cycle repeats until the power supply is interrupted; it is an example of a relaxation oscillator.
The frequency is controlled by the RC time constant Schmitt trigger hysteresis and the voltage on the non-inverting pin. If you want you can calculate all of this from first principles but I didn't bother, the website says the LED will flash at 2Hz, all I did was divided the capacitor and resistor values by 10 so it will oscillate at about 200Hz.
So what we've built a relaxation oscillator how do we get pulse width modulation from it?
Easy, the answer is that the waveform on the capacitor is a sawtooth waveform. All we do is add a comparator on the output and compare it will a variable reference. If the reference is set to half the supply we'll get 50% duty cycle as the sawtooth wave is higher than the reference for half the time and below the reference for hlaf the time. If the reference is set at a higher voltage then the duty cycle will be lower as the sawtooth wave is higher than the reference for only a short period of time. If the reference is set to a lower voltage then the output will be a higher duty cycle becase the sawtooth wave form is above the reference for longer periods. You can easllly set it to be fully on or fully off be setting the reference below or above the peak or troffs in the sawtooth waveform respectively. You can invert this behaviour so a higher reference gives a higher duty cycle and a lower reference gives a lower duty cycle by swapping round the comparator's inverting and non-inverting inputs.
The clever thing is (within reason) you can connect as many comparators as you like to the capcitor in the relaxation oscillator. Look at the first schematic in this post, I have connected two comparators to the capacitor to give you two channels.
The schematic below demonstrates how you can connect a transistor to the output of a comparator so it can drive a motor. The comparator is the outpur comparator on the PWM oscillator illustrated in the first schematic.
To give you a good understanding it's a good idea to simulate the circuits above using a simulator like LT SPICE.