GOAL PreLab 6 PWM Design for H-bridge Driver (due Oct 23) The overall goal of Lab6 is to demonstrate a DC motor controller that can adjust speed and direction. You will design the PWM waveform and digital logic to provide the input signals to the H-bridge IC chip that drives the DC motor. INTRODUCTION Pulse width modulation (PWM). PWM has many, many applications. Why is it so useful? Two major reasons are simple implementation and power efficiency. PWM is a digital technique to mimic analog control of a load (e.g. variable speed), so it can be easily implemented with microcontrollers. PWM is power efficient because the load is operated by transistor switches that are either fully ON or completely OFF. Why does this matter? Fig. 1: DC motor with gear head for lower RPM but higher torque. o For a BJT, power dissipation depends a lot on V CE. Recall that V CE is typically less than 1V in saturation mode (e.g. BJT switch) but can be several volts for a BJT in active mode (e.g. emitter follower). Therefore, power dissipation is much lower when a BJT is used as a switch rather than a follower. o For a MOSFET, power dissipation depends a lot on R DS,ON. Recall that R DS,ON is typically less than 1 ohm for a power MOSFET in the ohmic (linear) region. It turns out that R DS,ON is much higher for a MOSFET in the active region. Therefore, power dissipation is much lower when a MOSFET is used as a switch rather than a follower. H-bridges. A very common way to drive a DC motor with PWM is to use an H-bridge. As shown in Fig. 2, the motor is connected to four switches, where the arrangement resembles the letter H. Although Fig. 2 shows mechanical switches, H-bridges actually use high-side and low-side transistors (BJT or MOSFET). The switches are grouped into pairs that control the direction of current flowing through the motor. Each pair is called a half-bridge and resembles a totem-pole (or push-pull) configuration. A digital input determines which switch is closed and which one is open within a half-bridge. Motor speed control can be achieved by applying PWM to one half-bridge while the other half-bridge is held low. We will use the L293D quadruple half-h driver chip, which contains four half-bridges (more than we need for this lab). Fig. 2: (a) Motor moves clockwise when IN1 = LOW and IN2 = HIGH. (b) Motor moves counter-clockwise when IN1 = HIGH and IN2 = LOW. (c) Motor stops when IN1 = IN2 = LOW. 1
DESIGN REQUIREMENTS It s good to start with the constraints. o Motor: 12V DC, 120 RPM o PWM waveform: Free-running current = 80 ma, Stall current = 800 ma NOTE: This H-bridge cannot handle the motor s stall current. Fortunately, this lab will mostly deal with the motor in free-running mode. So we should be OK! Output is 0 or 5V for compatibility with digital logic. Use an LM311 voltage comparator with a single +5V supply. Use LM358 op amps with a single +5V supply for the triangle wave generator. Triangle wave has a peak-to-peak value of 2.5V PP (+/- 0.1V is OK) at 5 khz (+/- 250 Hz is OK). NOTE: A higher frequency would be better, but the LM358 has speed limitations. Use standard 5% resistors. Capacitors can either be 100 pf, 1 nf, 10 nf, or 100 nf. TRIANGLE WAVE GENERATOR DESIGN Vcc Vcc R6 Vref 5 6 Vcc 4 8 U1B 7 LM358N V R3 PR_SQ Vref 3 2 4 8 C U1A 1 LM358N V PR_TRIANGLE 5V Vref R2 R4 R5 R1 Fig. 3: Schematic of the triangle wave oscillator. Note that Pins 4 and 8 on op amp U1A do not require Vcc and Gnd (internally connected). 2
TASK 1: Compute the R 1 and R 2 necessary to achieve the desired peak-to-peak amplitude. o Remember that we are using op amps powered by a SINGLE supply. o The following formulas for the triangle wave generator might be useful: f = R 2 / (4R 1 R 3 C) V SAT(+) = V CC - 1 V SAT(-) = 0 V TH = (R 1 /R 2 ) (V SAT(+) V SAT(-) ) / 2 V REF = (V SAT(+) + V SAT(-) ) /2 o R1 is typically in the 10 kohm range. This ensures the output currents of op amp U1A and U1B are less than 1 ma. TASK 2: Compute the R 3 necessary to achieve the desired frequency. o Remember that you are limited to C = 100 pf, 1 nf, 10 nf, or 100 nf. o Typical R 3 values are between 1 kohm and 1 Mohm. A capacitor has infinite impedance at DC, since Z = 1/jωC. This has the unfortunate consequence that the op-amp integrator has infinite gain at DC. This leads to an unsteady DC output due to accumulated error from input bias and offset current! To avoid this defect, most integrators have a large resistor in parallel with the capacitor (see above figure). This resistor R 4 is typically chosen to be at least 10 times higher than R 3. TASK 3: Choose R 4 that is appropriate for your circuit. o You must choose from 51 kohm, 100 kohm, 510 kohm, 1.0 Mohm, and 1.5 Mohm. TASK 4: Choose 5% resistors for the R 5 -R 6 voltage divider that produces V REF. o Typical values are 10 kohm to ensure low power dissipation (e.g. a few mw or less). TASK 5: Simulate your circuit. o Use LM358N op amps. o Place voltage probes on the Schmitt trigger output and the integrator output. o Use a Transient Simulation Choose an end time that is long enough to show between 3 to 5 cycles. Use a Max time step of 1e-8 to ensure sufficient time resolution. o Measure the peak-to-peak voltage and frequency of the triangle waveform. 3 Fig. 4: Buma had to change his R1 and R3 to get satisfactory values for frequency and amplitude.
o Did you satisfy both design specs? If not If the peak-to-peak voltage needs improvement, change R1 a little bit. This will also affect the frequency (see below). If the frequency needs improvement, change R3. You must determine appropriate values for R1 and R3 in order to satisfy the design specs! NOTE: Buma had to tweak R1 and R3 to get satisfactory values for amplitude and frequency. PWM DESIGN A PWM waveform is obtained by comparing the triangle (also called a ramp) wave with some kind of input signal V SIG. Suppose we want the PWM duty cycle to INCREASE for HIGHER V SIG. TASK 6: Sketch how the voltage comparator should be connected to the triangle wave and V SIG. o As shown in Fig. 5, should V SIG be connected to the (+) or (-) input of the comparator? What about the triangle wave? o Explain your reasoning! Fig. 5: Which comparator input is connected to Vsig? TASK 7: Sketch how you would use a 10 kohm potentiometer to produce V SIG. o Also include how the 10K pot is connected to the comparator. TASK 8: Simulate your entire PWM circuit (triangle wave, potentiometer, and comparator). o Use the LM311N comparator. Pins 1 and 4 are both connected to GND. Pin 5 is connected to V CC = +5V. Use a 1 kohm pull-up resistor to +5V. o If you want the potentiometer wiper to be on the right side, use flip horizontal rather than rotate! Fig. 6(top) shows the correct orientation using flip horizontal. Fig. 6 (bottom) shows the incorrect orientation using rotate. o Place voltage probes on both comparator inputs and the comparator output. o Produce three waveforms of the PWM output: Pot = 20%, 40%, and 60%. Fig. 6: (Top) Correct potentiometer orientation (Bottom) Incorrect potentiometer orientation. 4
Fig. 7: Simulated PWM waveform when the potentiometer is at 20% (left) and 60% (right). CONTROL LOGIC OK, now we need to think about how to hook up the H-bridge. The L293D H-bridge has four half-bridges, but we will only use two of them. Fig. 8 shows a typical connection diagram and truth table for using the L293D as a full-bridge for one DC motor. The chip has two power connections: V CC1 = +5V for the TTL logic and V CC2 = +12V for logic level shifting and motor power. We will keep the enable (EN) input HIGH (+5V) for this lab. The IN1 and IN2 inputs are the digital inputs that determine if a half-bridge output connects the motor terminal to POWER or GND. This may look intimidating, but it is actually not that bad. There are only TWO scenarios. 1. Motor direction = counter-clockwise: IN1 = PWM signal, IN2 = LOW (0V). 2. Motor direction = clockwise: IN1 = LOW (0V), IN2 = PWM signal. This means we need a way to properly route the PWM signal and LOW to the IN1 and IN2 inputs! Fig. 8: Connection diagram and truth table for using the L293D chip as a full-bridge for one DC motor. Clockwise (turn right) speed control requires IN1 = LOW while IN2 = PWM. Conversely, counter-clockwise (turn left) speed control requires IN1 = PWM while IN2 = LOW. We will always keep the EN (enable) input HIGH for this lab. In other applications, you can enable (EN = HIGH) or disable (EN = LOW) the motor. 5
How to do this? The user wants to control direction and speed. Direction is either clockwise or counter-clockwise, so that is a binary quantity. We can use a toggle switch to produce a digital signal DIR that is either 0V (counter-clockwise) or 5V (clockwise). Speed is the PWM signal with a duty cycle determined by V SIG from the 10K potentiometer. What to do with the DIR and PWM signals? There many ways, but Fig. 9 shows a reasonable approach. It may look intimidating, but it really isn t as long as you clearly understand the necessary inputs to the H-bridge. As mentioned before, the H-bridge s IN1 is either PWM or LOW, depending on the desired direction. This sounds like a scenario to use a 2-to-1 multiplexer! Likewise, the H-bridge s IN2 is either LOW or PWM, depending on the desired direction. Another 2:1 mux can be used here! Mux s are awesome TASK 9: Complete the wiring for the inputs and outputs of the two 2:1 mux s in Fig. 9. o Recall from ECE 118 that a 2:1 mux has a single select bit S to decide whether input0 or input1 is sent through to the output. o Provide a sketch of the final result. +5V 2:1 MUX Toggle Switch DIR A0 OUT A1 S IN1 H-BRIDGE M 10K Pot +5V V SIG PWM B0 OUT B1 S IN2 Fig. 9: Simplified schematic of the digital logic for the DC motor controller. Direction (DIR) is produced from a toggle switch. The PWM duty cycle is determined by the 10K potentiometer. The two 2:1 mux's determine the values of the H-bridge's IN1 and IN2. Please submit the following: Answers to all TASKS. Multisim schematic showing triangle wave generator, potentiometer, and comparator (e.g. for TASK 8). Four waveforms (from TASK 5 and TASK 8) (End of PreLab6) 6