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

Pololu Forum

Questions about the arduino library for 24v18 Arduino shield

I was wondering if anyone could explain some of the arduino library parameters in more detail.

I’ve read through the readme and I am currently using the driver to run the motor fine - As in I can start/stop/increase i to increase “speed”. However, I’d like to know more about the speed parameter and what the i = 400 in the demo refers to in terms of actual value being changed on the microcontroller.

For instance, I’m used to PWM where setting 255 would be 100% duty cycle and etc. What would be the equivalent of duty cycle control if I were to implement it with this driver?

I’m controlling a relatively high power (1HP) DC brushed motor at 24V, and would like to soft start with a lower voltage to avoid a large surge current. After that, I’d like to increase the duty cycle to around 75% to reach peak operating efficiency (as per the datasheet recommendation). If anyone can give me some pointers that would be lovely!

Edit: After reading function definitions, I notice a peculiar problem. When my speed is set to 400 (255 PWM), the motor operates extremely slowly under a full load.

However, when I increase this 400 to a much higher value, the motor responds by running much faster (even though the code sets speed to 400 if a higher value is passed in). What exactly is happening and why is the motor running faster when I pass in a value much greater than 400?


The setMxSpeed() function in our Arduino library for the Pololu Dual G2 High Power Motor Driver Shields increments the duty cycle by 0.25%, so 400 would correspond to 100% duty cycle. The setMxSpeed() function also produces a 20 kHz PWM signal (with a valid Arduino), while Arduino’s analogWrite() typically produces a 490 Hz PWM signal.

For gradually ramping up the motor, I recommend looking at the demo in our Arduino Library. You will probably want to set the maximum speed in the for loop to 300 to set the maximum duty cycle to 75%.

It is unclear why you are getting different results when setting the speed above 400. As you mentioned, our function should set the speed to 400 when a larger number is passed in. Could you tell us more about your setup? Could you post your Arduino sketch? Could you also post pictures of your setup?

– Jeremy