Projects

Frequency-Stable PWM Driver

DIYODE Magazine

Issue 57, April 2022

A development of the NE555-based servo driver circuit to provide stable PWM control of larger motors. - by Daniel Koch.

BUILD TIME: AN AFTERNOON
DIFFICULTY RATING: Intermediate

Way back at the beginning of DIYODE, we made Choppy, a PWM 5A motor driver based on an NE555 with a MOSFET output stage. It was very simple, and did many jobs perfectly well. However, it did have one fundamental problem that was only an issue in certain circumstances. Varying the duty cycle of an astable NE555 circuit by changing only one resistor unfortunately alters its total time period and frequency. Choppy varied from around 120Hz to 160Hz across its duty cycle.

While developing the servo driver presented elsewhere this month, we realised the potential for a modified version of that circuit to become a frequency-stable PWM circuit. We covered some of the situations where PWM frequency variation could be a problem in Classroom Issue 49. The servo driver development has created the opportunity to present a driver that works in these situations.

In converting the servo driver to be a general-purpose NE555 driver, we wanted to consider several factors. Frequency should be user-selectable, between nominal targets of around 1kHz and at least 16kHz. 16kHz is the often-accepted value for a super-sonic motor controller. Unless a person is younger than about twelve years old or has exceptional hearing, this frequency is inaudible. The NE555 has some internal limitations which mean that there needs to be a 10µs interval between the end of a monostable high period, and the next trigger. The minimum monostable pulse width (high time) is also 10µs.

The minimum value of the resistor between supply and pin 7 should be no less than 3kΩ, although we have found this from application notes and not the datasheet. The datasheet for the NE555, like many others, is notorious for having important details buried in it rather than in plain sight. The timing capacitor value can be as little as 100pF but should be no lower. However, the Phillips application note for the NE555 states that ceramic capacitors should not be used as they are unstable. Of the commonly available types that are considered stable enough, MKT is the only match. Therefore, the retail range of MKT capacitors dictates our minimum value of 1nF.

Combined with those factors are that the monostable stage no longer has a time requirement like it does to drive a servo. Therefore, we can eliminate the upper and lower limit system, unless there is a need to drive a motor between upper and lower speed limits. For the monostable section, the same 3kΩ minimum rule applies, as this limits current to the discharge transistor which carries this current and the capacitor discharge current. However, it is possible to get away with 1kΩ at lower voltages. Therefore, component values have to be chosen to give ideally at least a 5% to 95%, but preferably better, PWM control while still functioning from a range of frequencies.

On top of that, we want a transistor output stage. The transistor transition times are in the order of nanoseconds to tens of nanoseconds anyway, so as long as any intended output transistor is verified first, the design should be suitable for any common MOSFET. Our build will use a logic-level MOSFET so the driver can operate 5V motors, but these usually need to be ordered online. For devices available over the retail counter, a 12V driver circuit is recommended. See Classroom 43 for more on why.

CHOOSING VALUES

With all of that going through our heads, it was time to choose values. Our idea of having a wide range of frequencies available from one set of components quickly turned out to be a dream. Instead, a set of components would be needed for each of a selection of frequency options. The monstable section has to function so that, at its minimum, the pulse width is as short as can be. At the other end of the scale, the pulse width needs to be almost the same length as the period determined by the frequency. This presented a problem, because the full travel of the potentiometer used to give speed control on the monostable needs to be used. If it is not, and the resistance value exceeds the calculated maximum, the monostable will revert to its low state. This can be seen on an oscilloscope when the resistance value for a given capacitor was exceeded during prototyping.

What we eventually settled on was a process of choosing an approximate frequency, then calculating what resistance and capacitance would get us there. However, we then had to recalculate to find the frequency that would use the full travel of the potentiometer chosen in each case. The results are some very strange frequencies listed in the table!

In addition, the frequency of the astable section needs to be adjustable not only to find this off-the-decade frequency, but to cope with component tolerance as well. Therefore, the circuit ends up looking quite a lot like the servo driver, with the difference being in the fixed resistor rather than the variable R2 at the astable, and the single variable resistor in series with a fixed one, rather than two variable in series with a fixed, for the resistors feeding the monostable charging capacitor.

OUTPUT CIRCUITS

Tacked onto the end, we have a driver circuit. We were originally going to directly drive the motor with a MOSFET. The NE555 has enough source current, unlike many ICs, to directly drive a MOSFET's gate capacitance without undue time in the saturation zone (which has a different meaning in a MOSFET than a bipolar transistor). This option is suitable for situations where the load voltage and circuit voltage are the same. Given that the driver can operate from 5V to 15V, this will cover many maker situations. The design would amply suit a 12V motor. A logic MOSFET has been used, the IRLZ44N, because the threshold voltage at 5V will not turn on the MOSFET gate fully. See Classroom 43 for details on gate capacitance and driving MOSFETs efficiently. Using P-Channel MOSFETs is a little more involved and there are far fewer on the retail market than N-Channel devices. The usual 10kΩ Resistor between gate and ground is unnecessary, because the output of the NE555 sinks current when low, it never floats.

FREQUENCY AND RESISTOR VALUES

Target Frequency

Actual Frequency

Astable R1

Astable R2

Astable CT

Monostable R4

Monostable R5

Monostable CT

500Hz

505.05Hz

10kΩ

20kΩ

47nF

2kΩ

10kΩ

150nF

1kHz

1008Hz

10kΩ

20kΩ

22nF

1kΩ

10kΩ

82nF

5kHz

5009Hz

1kΩ

50kΩ

3.3nF

5kΩ

50kΩ

3.3nF

10kHz

9000.9 Hz

100kΩ

50kΩ

1nF

1kΩ

100kΩ

1nF

16kHz *

16,529Hz

2kΩ

50kΩ

1nF

5kΩ

50kΩ

1nF

20kHz *

20,202Hz

2kΩ

50kΩ

1nF

5kΩ

25kΩ

1.5nF

Note: R2 and R5 are variable. The maximum value of R5 is used for calculations, R2 is set based on this result. The table also does not take into account the 10µs issues discussed in text. * Theoretical Values. We had trouble with the 10µs transition time, making these frequencies work in real life.

While this will suit some people, we wanted a flexible and adaptable design. Therefore, other layouts have been devised. The most basic are the two transistor output options. Because the NE555 can sink current, it could directly drive a PNP transistor.

However, this would have the effect of inverting the duty cycle. Accordingly, the PNP power transistor is still controlled by an NPN signal transistor.

An optocoupler can, with the NE555's source or sink capability, be connected to drive on the source or the sink output, making it capable of functioning in multiple modes. This means that you could use one to control a P-Channel MOSFET by simply trying the gate to the source via a resistor, and using the optocoupler's transistor to ground the current and allow the gate voltage to ground as well. However, the gate capacitance means a resistor is needed to prevent the discharge current damaging the optocoupler's rather small internal transistor. This current limit means the MOSFET loses its fast switching time, as the gate capacitance cannot discharge quickly. More importantly, the MOSFET spends more time in the transition zone, creating heat.

A far easier option is to use the optocoupler to drive an N-Channel MOSFET. This option is for makers who wish to use a higher load voltage than the circuit will handle, or who are experiencing reliability issues from motor noise affecting the circuit supply and hence want to use a separate motor supply. The circuit here uses the output current of the NE555 when high to drive the LED in the 4N25 optocoupler. The value of R1 needs to be calculated for your specific driver circuit voltage to meet the requirements of the internal LED. On the output, a 2N7000 FET is used as a gate driver, so that the IRF1405N's gate capacitance can be rapidly discharged to ground. It also functions as an inverter: Its gate is normally held high by the resistor R2, whose value needs to be calculated to give enough gate current at your specific load voltage, while not overloading the optocoupler's output transistor.

The optocoupler's LED is driven by the driver circuit voltage, and grounded through the NE555's output when it is sinking current while low. This is necessary because of the need to tie the Q1 MOSFET gate high to the load supply voltage in order to achieve voltage conversion. Q1 can then directly ground Q2's gate, and drive the load with the correct duty cycle.

Also worth mentioning is the need to have protection on the motor output. Because the driver only works in a single direction, a diode and capacitor can be fitted straight across the terminals of the motor. The capacitor helps absorb noise, while the diode handles back-EMF.

THE BUILD

Parts Required:IDJaycar
1 x Solder Breadboard-HP9570
1 x Packet of Wire Links-PB8850
1 x 120Ω ResistorOutputRR0550
1 x 1kΩ ResistorR4RR0572
1 x 18kΩ ResistorR3RR0602
1 x 100k ResistorR1RR0620
1 x 50kΩ 25-Turn TrimpotR2RT4354
1 x 100kΩ PotentiometerR5RP7518
2 x 1nF MKT CapacitorC3, C6RM7010
1 x 10nF Ceramic CapacitorMotorRC5348
2 x 100nF MKT CapacitorC2, C5RM7125
2 x 100 µF 16V Aluminium Electrolytic CapacitorC1, C4RE6130
2 x NE555 Timer ICIC1, IC2ZL3555
1 x IRLZ44N MOSFETOutputElement14: 8651418
1 x 1N4004 DiodeMotorZR1004
2 x 8-pin IC Sockets-PI6500
2 x 2-Way Screw Terminals-HM3172
2 x PCB Pins-HP1250

We chose the basic Logic-level MOSFET circuit as our output option, and set about building the circuit onto a solderable base. Having conducted all of our prototyping on the standard breadboard, using the solder equivalent was logical. The low-profile components such as resistors and wire links went in first.

Following this, the sockets for the ICs, followed by the MKT capacitors went in. Before fitting the trimpots, we added PCB pins where the potentiometer would be wired in, as well as terminal blocks for power and the motor connection. At the last minute, we decided to add the diode and capacitor for the motor, straight onto the PCB near the motor screw terminal header.

Finally, the electrolytic capacitors across the supply rails, the MOSFET, and the trimpot can be installed. The electrolytic capacitors are fitted as close to the ICs as possible, as recommended by the NE555 datasheets and application notes. This involves bending the legs with two 90° angles in each leg.

The only external component is the potentiometer. The value of this will depend on your chosen frequency, but ours was 100kΩ. One wire joins one end of the taper with the wiper, while the other goes to the other end of the taper. Having wires and PCB pins for this component means that it can be panel mounted, and also means that the wires can be swapped around on the pins to give either clockwise or anticlockwise response from the potentiometer.

You can see extra PCB pins in the photos. These were placed for attaching the oscilloscope probes, and are not needed in normal circuit operation.

SET UP, TESTING, AND ASSESSMENT

While an interesting exploration, the device is far from perfect. It does, however, do its job. Initial setup and testing involved fitting an LED with a suitable resistor to the output terminals. We tested our circuit at 5V, so our resistor was 150Ω. Then, the oscilloscope probe was attached and the output of the astable section, and the trimpot adjusted so the frequency was at its minimum.

The probe was swapped to the monostable section, and the potentiometer turned until the duty cycle went as high as it would go.

With the probe still attached to the monostable section, the trimpot on the astable was adjusted until the duty cycle approached 100%. When it was very close, but not quite there, we stopped. This prevents the issue discussed earlier where the trigger pulse is faster than the monostable timing period.

Just to make sure, the potentiometer was turned back as far as it would go. The lower limit of the duty cycle is still quite high. This is unlikely to matter to most motors, but the LED still showed a reasonable brightness. Most modern LEDs will show a lot of light for a small amount of current, so the brightness of the LED was never going to be a good indicator.

Now all that remained was to try the circuit with a motor. Accordingly, the LED was disconnected, and a small 12V motor connected in its place. The power supply was turned up to 12V, and the output of the bench supply was turned on. Sure enough, while there is still movement from the motor at the minimum available PWM duty cycle, the motor is starting to struggle. The load of even a paper fan blade stuck on with a lump of blue tac caused a stall.

There is definite room for improvement. The significant spikes visible in the oscilloscope screenshots at the beginning of each monostable pulse come from an as-yet unknown source. They also appear on the astable output. We have some ideas but have not ruled anything in or out yet. That requires more thinking.

We would also like a design that can vary its duty cycle further down towards 0%. The ability to operate at higher frequencies would also be great, but the 10µs transition time of the NE555 is going to make this challenging. Until we either find a way around that, or devise another circuit completely which can vary the duty cycle without altering the frequency, we're sticking with this.

Additionally, the circuit is only worth the effort when a fixed or a higher frequency, or both, are needed. For many common situations, Choppy is still perfectly adequate, and it's available as a kit with a PCB! That said, even if the circuit isn't as good as we wanted it to be, the process was still informative and we feel it was a garden path worth walking down.