Motor will go forward and then backward, is it right?

I use Bricktronics Motor Driver to control EV3 motor. When I use the goToPositionWaitForArrivalOrTimeout(720) function, I find the motor will go forward to 802(postion) and then go backward to 715.
I’m not sure it’s correct. Why the motor not reach 715 directly?
---------------------------The follow is the information on serial port --------------------
Using goToPositionWaitForArrivalOrTimeout(720)…_pidOutput: 255.00, pos: 0.00
_pidOutput: 255.00, pos: 4.00
_pidOutput: 255.00, pos: 18.00
_pidOutput: 255.00, pos: 41.00
_pidOutput: 255.00, pos: 69.00
_pidOutput: 255.00, pos: 101.00
_pidOutput: 255.00, pos: 137.00
_pidOutput: 255.00, pos: 173.00
_pidOutput: 255.00, pos: 210.00
_pidOutput: 255.00, pos: 248.00
_pidOutput: 255.00, pos: 286.00
_pidOutput: 255.00, pos: 325.00
_pidOutput: 255.00, pos: 363.00
_pidOutput: 255.00, pos: 402.00
_pidOutput: 255.00, pos: 441.00
_pidOutput: 255.00, pos: 481.00
_pidOutput: 255.00, pos: 520.00
_pidOutput: 255.00, pos: 558.00
_pidOutput: 255.00, pos: 597.00
_pidOutput: 255.00, pos: 637.00
_pidOutput: 175.35, pos: 677.00
_pidOutput: 175.35, pos: 714.00
_pidOutput: -16.34, pos: 749.00
_pidOutput: -16.34, pos: 778.00
_pidOutput: -140.67, pos: 797.00
_pidOutput: -140.67, pos: 805.00
_pidOutput: -109.21, pos: 802.00
_pidOutput: -109.21, pos: 793.00
_pidOutput: -35.01, pos: 781.00
_pidOutput: -35.01, pos: 769.00
_pidOutput: 8.89, pos: 757.00
_pidOutput: 8.89, pos: 747.00
_pidOutput: 33.99, pos: 738.00
_pidOutput: 33.99, pos: 732.00
_pidOutput: 27.11, pos: 729.00
_pidOutput: 27.11, pos: 727.00
_pidOutput: 4.66, pos: 728.00
_pidOutput: 4.66, pos: 728.00
_pidOutput: -3.53, pos: 728.00
_pidOutput: -3.53, pos: 727.00
_pidOutput: -3.52, pos: 727.00
_pidOutput: -3.52, pos: 727.00
_pidOutput: -10.99, pos: 727.00
_pidOutput: -10.99, pos: 727.00
_pidOutput: -16.04, pos: 727.00
_pidOutput: -16.04, pos: 727.00
_pidOutput: -21.09, pos: 727.00
_pidOutput: -21.09, pos: 727.00
_pidOutput: -26.14, pos: 727.00
_pidOutput: -26.14, pos: 727.00
_pidOutput: -31.19, pos: 727.00
_pidOutput: -31.19, pos: 727.00
_pidOutput: -36.24, pos: 727.00
_pidOutput: -36.24, pos: 727.00
_pidOutput: -41.30, pos: 727.00
_pidOutput: -41.30, pos: 727.00
_pidOutput: -46.35, pos: 727.00
_pidOutput: -46.35, pos: 727.00
_pidOutput: -45.62, pos: 726.00
_pidOutput: -45.62, pos: 725.00
_pidOutput: -35.04, pos: 723.00
_pidOutput: -35.04, pos: 721.00
_pidOutput: -9.79, pos: 717.00
_pidOutput: -9.79, pos: 713.00
_pidOutput: 6.77, pos: 712.00
_pidOutput: 6.77, pos: 710.00
_pidOutput: 17.80, pos: 709.00
_pidOutput: 17.80, pos: 709.00
_pidOutput: 12.71, pos: 710.00
_pidOutput: 12.71, pos: 710.00
_pidOutput: 22.35, pos: 710.00
_pidOutput: 22.35, pos: 710.00
_pidOutput: 29.56, pos: 710.00
_pidOutput: 29.56, pos: 710.00
_pidOutput: 36.78, pos: 710.00
_pidOutput: 36.78, pos: 711.00
_pidOutput: 26.66, pos: 713.00
_pidOutput: 26.66, pos: 715.00
reached position

Hello, thanks for the message. This is a good question. The answer is that the motor is using a PID control algorithm to drive the motor to the desired position (here, 720), which may overshoot the setpoint in order to reach it quicker. This can be avoided by tweaking the underlying P, I, and D control parameters.

More details about PID algorithm here: https://en.wikipedia.org/wiki/PID_controller

Here’s a graph showing the different kinds of overshoot that you may see for different values of the three terms:

To avoid overshoot, try reducing the D term. Also try reducing the P term. Dampening the control system to eliminate overshoot will likely result in it going slower and taking more time to reach the desired setpoint.

You can use the pidSetTunings(Kp, Ki, Kd) function of BricktronicsMotor to change the tunings. The default values are 2.64, 14.432, and 0.1207 for Kp, Ki, and Kd, respectively.

Thanks for your quick response!
When I read the book “LEGO and Arduino Projects”, I notice the PID but not understand. Your detailed description and graph help me understand the concept. I will try to adjust these parameters.

Thank you very much!
Bob Gao