Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

PWM based speed controlling is not possible of VNH5019 with Arduino MEGA


Dear all,

I am trying to control the speed of a dc motor with VNH5019 and Arduino using open loop controller just to see the open loop characteristics. I’m changing the pwm signal to vary the speed of the motor, but it does not. I changed the duty form 0 to 1 (arduino pwm reference from 0 to 255), even driver gets correct pwm signal from Arduino, motor driver output voltages has reached to max quickly and get saturated.

If I am correct it should show a linear variation of speed with pwm.

I have attached the experimental result with this. Can any one give me some suggestions to get it correct.


Drive-Brake Operation for VNH5019


We expect there to be a nonlinear relationship between the duty cycle and speed when operating in drive-coast mode. If you tell me more about your setup and how you are testing, I might be able to say if the mount of nonlinearity you are seeing makes sense.

Which of our VNH5019 boards are you using, the Arduino shield or the carrier? Could you post the code you were using during testing? How did you measure the RPM of the motor? Could you post a link to the product page or datasheet for your motor? Also, could you post pictures of your testing setup?



Hi, we use Ardunio shield. speed is measured using an encoder, we tested its operation by varying the supply voltage to motor from 0 to 24v and it gave a linear relationship and proper voltage/speed ratio as in motor datasheet.

We tested the wpm signal using an oscilloscope and it shows the correct signal to driver circuit. But driver circuit outputs shows unexpected voltages.


It sounds like your test setup is fine, so the non-linearity you are seeing is probably just the normal behavior for driving your motor from the VNH5019 driver. Unfortunately, it is not practical for the VNH5019 to operate in drive-brake mode, so there is not much that can be done besides trying to compensate for the nonlinearity in software. If that is not an option for you, you probably will need to get a different driver. Our high power motor drivers can operate in drive-brake mode, so you might consider those.



Hi Claire. Im about to start arduino and planing to drive 2 12v dc motors with vnh5019 arduino compitable driver. While searching saw you conversation with TSWeerakoon and you were saying “it is not practical for the VNH5019 to operate in drive-brake mode” that i couldnt understand normally. Finaly with arduino uno and vnh5019 can i control speeds and directions of motors separately.

Simply as i can understand dual vnh5019

Yes, it is possible to control the speed and direction of two motors independently with our Dual VNH5019 Motor Driver Shield for Arduino. The driver operates in a hybrid mode that partially works like drive-coast and partially like drive-brake. This usually gives good results, but depending on the characteristics of your motor, you might see a noticeably non-linear relationship between the PWM duty cycle and the resulting speed, which is the issue that TSWeerakoon seemed to be having.



Thank you for repling nathanb.
Are you saying non-lineerity depends on motors. What if i use 2 same motors. Or can you advise me any other motor driver.



I expect the two channels of the VNH5019 to control two of the same motor very similarly. The non-linearity discussed earlier in this thread refers to the duty cycle not having a linear relationship with the motor’s speed.