ME 305
|
This page details the implementation of closed loop speed control of a permanent magnet DC motor. This is accomplished using the task diagrams seen below and using a STM32 Nucleo microcontroller. See Lab4 in file list for more details. See the link below for the code respository to this lab. Code repository for this lab: https://bitbucket.org/rdeanr/me305/src/master/Lab4/
Implemented as a finite state machine, this file handles all user inputs and sets flags or shares variables that can interact with all other tasks. The state transition diagram can be seen below.
This task directly interacts with the encoder and then alters flags and shared variable values to be sent back the user task and interpretted. It can compute such quantities as position, change in position, change in time, and zeroing the encoder. The state transition diagram can be seen below.
This task directly interacts with the motors and then alters flag values to be sent back to the user task and interpretted. Receiving input from the user task, it directly controls the duty cycle of each motor. The state transition diagram can be seen below.
This diagram shows the interaction between the task files and which variables are shared between them.
This class can be modeled with the block diagram seen below. It is instrumental in setting the motor duty cycle for this lab. See the section below for plots using this class.
Plots demonstrating the motors angular velocity and duty cycle input can be seen below. The proportional gain was increased while the set point was kept at a constant 100 rad/s. As the proportional gain is increased, the accuracy of the output velocity to the reference velocity improves. However, there is a point where the output starts to have more extreme oscillatory behaviors and the settling time is no longer negligible relative to the other gain inputs. This demonstrates how closed loop control under the current programming can only approach the desired velocity within a certain margin before becoming too unstable. See the plots below for the output from the motor for closed loop control