TopFinishKits.com

Motor Speed Control

I have received a few questions about the robot’s movements not always moving correctly like jumping or not rotating at the same speed. To help understand a possible cause, I created a few images below to help explain the motor issues.

Some issues are caused by the robot’s program just setting the motor speed for a period of time. For the example below, the motor speed is set to 75% of the motor’s full speed for a couple of seconds. In the graph below, the blue line shows the motor commanded speed at 75% for a period of time. The red line shows what motor’s speed is more likely to be. This is because the robot as mass and physics is in play.

The robot’s movements should follow the standard acceleration and deceleration curve show below. The motor speed should be increased following a defined acceleration. Hold constant speed then start to decelerate the motor at a defined rate.

While the goal is for the motor speed to follow the ideal curve shown above, it is very unlikely to follow the curve perfectly. Again physics are involved. The graph below shows the more likely motor speed. The motor speed (red line) is much closer to the ideal curve. The closer the motor speed is to this blue line, then the more likely the left and right motors will move together and in a straight line.

A common question is: How does one see exactly how the motor is moving? I recommend graphing your motor’s movements to answer this question. The Arduino IDE has a tool for graphing output from the Arduino boards. The Serial Plotter is good tool that can create this graph. Below is an example of a robot’s movement using the Serial Plotter tool. The grey line (speedProfile) is the ideal accel / decel curve. The blue line shows the actual motor movements. This graph can be used to improve your robot’s movements.

The above graph is from the TopFinishKits sample program V2.1. This new version was improved for the Serial Plotter tool and was just uploaded to the website.

Other items to consider:

  • Longer acceleration or deceleration times will improve the accuracy of the movement, but take longer to execute the moves.
  • Shorter acceleration or deceleration times make faster movements, but are more difficult to follow the ideal curve.
  • Driving in a straight line depends on all motors rotating at the same speed throughout the movement.
  • Remember the goal is for both motors to rotate at the same speed. If both motors actual speed match throughout movement, then following the ideal curve closely is not needed.
  • The accel / decel curve shown are basic movement curves. More advanced curves will use a “S-Curve”. Which is outside the scope of this topic.
To top