PWM Output Voltage

Hi, I'm trying to use the PWM output on an Arduino Uno to control the output voltage of an L298N motor driver to my motor. However I seem to be facing an issue where the output voltages from my motor driver do not match with the PWM values that I input and seem to vary between different motors. For example with a PWM value of 127 and an output voltage of 8V at 100% duty cycle, I can get values of 3V for one motor and as high as 6V for another motor when I measure the voltage across the motor terminals.

Could it be an issue with the motor driver? I get similar results when testing with both channels of the motor driver.
I saw some answers to in this forum saying to use a low pass filter to smoothen the PWM output voltage to get a consistent voltage output. Would this help in my case?


How are the motors powered ?

I have an external DC power supply connected to the motor driver which are then connected to the motor.

Theres your issue, your 1000V 2mA power supply is faulty.

NOW - be specific.

Well I did mention that the measured voltage across the terminals of the motor is 8V at 100% duty cycle.
But to be specific my DC power supply is a constant voltage/constant current power supply. In my case I controlled the output voltage to around 11V such that the measured voltage at the motor driver output/motor terminals are 8V since I'm using an 8V motor. Measured current draw to the motor is around 0.3 to 0.7A.

Before Mike - or others - gets to this, I will point out that measuring a PWM output with a multimeter is a nonsensical exercise as the interaction between the PWM and the ADC operation of the meter is difficult to predict.

In short, simply do not measure it. :roll_eyes: It either works to control the motor or it does not.

That actually makes little or no sense. :worried: You are applying pulses of 11 V to the motor. Nothing more, nothing less.

In general, a motor will accept this if the difference between its rated voltage and the actual voltage of the PWM is not too great. The motor will not generally perform well at low PWM duty cycles and may heat excessively.

"8V" is a recommendation only, as a compromise between power output and motor lifetime. D.C. motor voltage ratings are nominal.

I wonder where this came from. Some time ago I have tried all my cheap DMMs and all have measured the same expected DC component of the PWM signal. AFAIK the DMM in DC mode should measure only the "DC component" of the signal presented - it is low pass filtered to supress the mains frequency, much lower than typical PWM signal. In AC settings it measures the "AC component" using some high pass filter - again designed to reliably measure from the mains frequency to some upper limit of given DMM. For cheap DMM the AC range may be from 20 Hz to 1 kHz - in other words measuring AC component of fast PWM may be unreliable but shouldn't be "interaction difficult to predict." The frequency range is either directly written in the specifications or may be easily characterised and should be quite repeatable: you increase the PWM frequency and look at what frequency the reported value starts to drop.

Yup I understand that a PWM output will be sending pulses of the output voltage to the motor. The reason I set 11V on my DC power supply is so that after accounting for the voltage drop I would get 8V at the output to my motor.

I forgot to mention that each of my motors are in fact assembled to a gearbox. Could the difference in the load on the motor be the reason of this variation in output voltage? However, from what I understand of PWM, the load shouldn't be affecting the input voltage since that should be based on the duty cycle that I input into the arduino right?

If your power supply and PWM switch (the L298N) are capable of providing and switching the full voltage and current, then what load you connect should arguably have no effect.

Well, actually that is not true at all. :grin:

Your load here is a motor. A motor is actually a generator - when you turn off the power supply - as you do with the PWM - the voltage does not drop to zero, but to the voltage that the motor generates which is dependent on how fast the motor is spinning, and no doubt that depends on how heavily the particular motor is loaded.

So in short, measuring these "average" voltages when you are providing PWM to a motor, is as I suggested before, not particularly useful. :confused:

This sort of discrepancy is typically explained if you are using fast/slow/mixed decay-mode switching of the H-bridge, in which case the output voltage is not always determined by the control input, but sometimes by the inductive reaction of the motor windings.

Only the synchronous rectification mode of driving an H-bridge determines the output voltage from the control input 100% of the time, and that mode will show linear voltage relationship to the PWM duty cycle.

The problem with synchronous rectification mode (aka synchronous decay) is its less efficient for simple motor driving and is typically only used when linear response is important (such as with a servo-motor).

Here's a TI document on this: