Criteria behind selecting pwm frequency for speed control of a dc motor?
There are several issues effected by the PWM frequency when driving a motor:
- The pulses need to come fast enough so that the mechanical system of the motor averages them out. Usually a few 10s of Hz to a few 100 Hz is good enough for this. This is rarely the limiting factor.
- In some cases, it is important that whining can't be heard at the PWM frequency. Even if the mechanical system as a whole doesn't react to single pulses, individual windings of a coil can. A electric motor works on magnetic forces, with every loop of wire in a coil arranged to create these forces. That means every bit of wire in a winding has a sideways force on it proportional to current, at least part of the time. The wire in the windings can't move far, but it can still vibrate enough for the result to be audible. 1 kHz PWM frequency may be fine in all other respects, but if this is going into a end user device the whining at that frequency could be unacceptable. For this reason, PWM for end consumer motor control is often done at 25 kHz, being just a bit beyond what most people can hear.
- Average coil current. This can be a tricky issue. Individual coils of the motor will look mostly inductive to the driving circuit. You want the current through the coils to be mostly what you'd expect from the average applied by the PWM and not go up and down substantially each pulse.
Each coil will have some finite resistance, which causes lost power proportional to the square of the current through it. The losses will be higher at the same average current when there is a large change in current over a pulse. Consider the extreme example of the coil reacting to the pulsed voltage almost instantly and you are driving it with a 50% square wave. The resistive dissipation will be 1/2 of driving the coil full on all the time, with the average current (therefore resulting motor torque) also being 1/2 of full on. However, if the coil were driven with a steady 1/2 current instead of pulses, the resistive dissipation would be 1/4 of full on but with the same 1/2 of full scale current and therefore torque.
Another way to think about this is that you don't want significant AC current on top of the average DC level. The AC current does nothing to move the motor, only the average does that. The AC component therefore only causes resistive losses in the coils and other places.
- Switching losses. The ideal switch is either fully on or fully off, which means it never dissipates any power. Real switches don't switch instantaneously and therefore spend some finite time in a transition region where they dissipate substantial power. Part of the job of the drive electronics is to minimize this transition time. However, no matter what you do there will be some time per edge where the switch is not ideal. This time is usually fixed per edge, so its fraction of the total PWM period goes up with frequency. For example, if the switch spends a total of 1 µs in transition each pulse, then at 25 kHz PWM frequency, which is 40 µs period, the transition time is 1/40 of the total. That may be acceptable. However, if the switching frequency were increased to 100 kHz, which means 10 µs period, then the transition time would be 10%. That will likely cause problems.
As for your circuit, my biggest concern is how slowly Q1 will be driven. Opto-isolators are notoriously slow (relative to most other components like individual transistors), especially when turning off. You only have R2 (although I can read its value) pulling down on the FET gate to turn it off. That's going to be slow. That may be OK if you can tolerate a slow PWM frequency, considering all the other trade-offs I mentioned above.
You might consider putting a PIC on the motor side of the opto. You can communicate digitally with that PIC via a UART interface or something that doesn't have to run at the PWM frequency. That PIC then generates the appropriate PWM locally and drives Q1 hard on and off with extra circuitry for that purpose. That way the high speed signals and fast edges don't go across a opto isolator.