I'm using the L298 Dual H-Bridge to control a pair of 6V @ 1600mA DC motors for a line follower robot. I'm connecting "Enable A" and "Input 1" to Vcc and "Input 2" to uC with PWM.
Which frequency do I have to use on the PWM?
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI'm using the L298 Dual H-Bridge to control a pair of 6V @ 1600mA DC motors for a line follower robot. I'm connecting "Enable A" and "Input 1" to Vcc and "Input 2" to uC with PWM.
Which frequency do I have to use on the PWM?
It's not obvious in the ST L298N datasheet. What it does tell you on this is (a) the delay between the PWM input edge and a driver output starting to respond and (b) the rise/fall time of the driver output. These are listed for both edges of both control signals and for the high-side and low-side transistors, so there's quite a pile of data to extract figures from.
What is shows is that (a) is in the range 0.7..3 us and (b) in the range 0.1..0.7 us.
To make most efficient use of the power available to the motor, as little as possible should be wasted during PWM edges. It follows that edges should be as small a percentage of the motor PWM waveform period as possible. This must be traded off against having a high-enough PWM frequency to get good averaging of the waveform from the DC motor.
When I designed in a lot of brushed DC motors on a system, then motor manufacturer recommended a PWM frequency of 2 kHz. This was echoed across the other information we had on it in those pre-internet days. There's the common argument that it should be driven above 20 kHz "so you couldn't hear it" but some basic experiments showed that we simply heard the sub-harmonics. All in all, we found no worth in the 20 kHz argument.
So if you have brushed DC motors then I would recommend a PWM frequency of 2 kHz. This gives you a 500 us PWM waveform period and your worst-case switching duration is 1.4/500 = 0.28 % of the period, which is good.
If you want bidirectional motor control using PWM then you need to supply the PWM to the inputs as shown in the ST application note.
Using the EnA and EnB signal you can turn off all current to the motor. The motor is freewheeling, though if it's speed is sufficient then one set of diodes will conduct and slow it because of the back emf. If you used this as your PWM input, then the motor would simply creep/drive in the direct set by your input signals, it would not be stationary at 50% duty cycle.
Using the In1/In2 and In3/In4 signals you can apply the PWM to the motor. You use two pins in opposition on your MCU to drive each channel and if you set the PWM outputs to just 1 or 0 then you brake the motor.
From the application note:
As a good example to follow, here is the Arduino L298 driver shield. They provide the schematic and there is driver code available to copy if you are using another MCU type.
In terms of PWM frequency, anything above about 50 Hz should work well. As the frequency rises, then switching losses do increase and you will see most applications using 100 - 1000 Hz. In rare applications you see frequencies above 20 kHz.