/Triple-loop-PID-Controller

Motor speed and position Controller using triple-loop PID algorithm cascaded over angular displacement, angular velocity, and driver current

Primary LanguageC++

Triple-loop-PID-Controller

This project is a real-life implementation of the research paper Motor control application based on STM32 and PID control theory by Zhao Zhetuo, HKUST on an Arduino UNO.

The objective of the project is to precisely control the rotation angle and rotational speed of a DC brush motor, which is provided by a potentiometer. The developed board should be able to toggle between speed controller configuration and angle controller configuration.

Control Algorithm

The control law is based on 3 cascaded PID (Proportional Integral Derivative) control loops, regulating individually over the driver current, angular speed (rpm) of the motor, and the rotation angle of the motor.

The innermost PID loop controlling the motor current, and the outermost loop controlling the theta.

alt text1

TVP

Trapezoidal velocity profile (TVP) generation has been used for getting the setpoint angular speed (rpm). The TVP is generated by the following equations2:

alt text2

$$ t_{acc,∆} = \sqrt{θ_{m}^{*}/a} $$

$$ t_{acc,traz} = ω_{max}/a $$

$$ T = t_{const} + t_{acc,traz} $$

where,

$a$ is the maximum constant acceleration, $ω_{max}$ is the maximum angular velocity during the profile, $θ_{m}^{*}$ is the desired endpoint angle, $t_{acc,∆}$ and $t_{acc,traz}$ are the time of constant acceleration for triangular and trapezoidal profils respectively, and $t_{const}$ is the time of constant velocity.

Results

The following angular speed response is observed from the system. The blue plot indicates the desired values and the red plot indicate the physical values. The two horizontal extreme lines reprent the maximum possible values of the angular velocity. The ripples produced are within a 5% error margin.

alt text

The angle response was quite unsatisfactory. Since the system is highly jittery and the encoder cpr (counts per revolution) very low (4x4 = 16), the control response only makes the system more unstable.

alt text

References:

Footnotes

  1. Zhao, Z.T., 2013. Motor Control Application Based on STM32 and PID Control Theory. AMM 385–386, 867–871. https://doi.org/10.4028/www.scientific.net/amm.385-386.867

  2. Heo, Hong-Jun, Yungdeug Son, and Jang-Mok Kim. 2019. "A Trapezoidal Velocity Profile Generator for Position Control Using a Feedback Strategy" Energies 12, no. 7: 1222. https://doi.org/10.3390/en12071222 2