DC Motor - non linear response for linear ramp signal


I have a 12 Volts DC gear motor driven by a L298N driver. I noticed, that when I increase the voltage linearly with a ramp signal at the analog output of my arduino up to 12 Volts (1023), the actual applied voltage from the L298N is nonlinear. And accordingly the shaft speed also does not change linearly, although my load torque stays constant.

The attached screenshot shows the ramp input signal with (orange in Volts) and the shaft rotation (blue in rad/s). The applied voltage of my L298N was only measured with a multimeter therefore I don´t have it graphically. But its behaviour looked a lot like the shaft rotation.

Am I wrong to assume a linear behaviour? I know that this is obviously not the case when I apply different torque to the motor shaft. But in my measurement the applied torque stayed the same. Also I could accept a non linear behaviour at the very top end around 11-12 Volts but this is non linear over the whole spectrum...

Can somebody enlighten me, why this could be the case?

PS: In the graph I removed the offset at the beginning, so obviously the motor actually starts spinning at a certain voltage > 0 Volts.



Am I wrong to assume a linear behaviour?

Yes, especially if your motor draws more current than the ancient, inefficient L298 can provide.

A modern motor driver, like this one, used in brake mode, will have a fairly linear relationship between shaft speed and PWM. Coast mode will not be linear.

But the shaft speed will still depend on the motor load. If you want the shaft speed to be constant, you need an encoder and feedback (PID) control.

All right, thats interesting... But according to the datasheet the L298n can provide 2 A and the one you suggested only 1.2 A. Are you sure this driver could provide a more linear relationship?

And yes I´m aware that torque plays a role as well, but for my purpose the torque would stay constant for the most part.

But according to the datasheet the L298n can provide 2 A

Yes, for a few milliseconds, then it starts to overheat and shut down. The L298N has long been falsely advertised, and this forum is littered with posts from disappointed users.

You should choose a motor driver than can easily handle the peak (start/stall) current of your motor, which you can get from the motor data sheet. Pololu has by far the best selection of motor drivers.

If the motor shaft load will be constant, fine, but you will need to recalibrate the PWM value every time the load changes.

All right I see... In that case I´ll check out the data sheet and buy an approriate driver. Thanks for your help!

A modern motor driver, like this one, used in brake mode, will have a fairly linear relationship between shaft speed and PWM. Coast mode will not be linear.

Actually there´s one more questions. What exactly do you mean with brake mode? The tutorials that I found just set the two pins for direction to HIGH and LOW depending on the rotation direction and set a PWM output. Is there anything else to consider?

Explained in the provided link. In brake mode, the motor terminals are shorted together, which provides braking action.

Oh you are right. I skipped that part apparently. Thanks, I get it now!

If you read up on motor drivers you'll find there are various modes mentioned,
fast decay mode, slow decay mode, mixed decay mode, synchronous rectification mode.

Only synchronous rectification mode is anything like linear at all... This is because all the
other modes spend some time applying a known voltage to the motor terminals, and some
time letting them float (with zero current flowing). The amount of time in each state
is a complex function of the motor characteristics and the mechanical load, and is not linear.

Synchronous rectification always applies a voltage to the motor terminals (often alternating
in polarity), and there is always current flowing. This means the motor effectively sees an
average applied voltage that is controlled by the circuit and independent of the motor's motion.

This means it acts like there's a controlled DC voltage on the motor terminals, assuming the
PWM frequency isn't too low.

Industrial DC servo motors will always use this mode I believe since maximum control is needed, and
linearity is essential to good control-loop behaviour. However its less power efficient than
other modes, and is rarely used when not needed.