This class implements proportional position control into the ME 405 board. More...
Public Member Functions | |
def | __init__ (self, motor_name, enc_name) |
Defines controller class. More... | |
def | update (self, setpoint, rec_pos) |
This method calculates an error signal based on the users desired input and current motor position. More... | |
Public Attributes | |
Kp | |
Kp stores the proportional gain constant that either attenuates or amplifies the error signal into the actuation signal. More... | |
setpoint | |
Setpoint stores the desired motor position value that the user wants. More... | |
error | |
Error stores the difference between current motor position and desired motor position. More... | |
act_signal | |
Act_signal (actuation signal) is simply the result of multiplying error by the proportional gain constant. More... | |
This class implements proportional position control into the ME 405 board.
This is accomplished by taking user input for a desired setpoint position along with a proportional gain value and calculating an actuation signal to send to the motor driver. Details on how this is done can be found in the update method of this class.
def controller.P_controller.__init__ | ( | self, | |
motor_name, | |||
enc_name | |||
) |
Defines controller class.
Creates controller object by initializing the controller to work with a motor and encoder pair
motor_name | The general name of the motor as specified by the user |
enc_name | The general name of the encoder as specified by the use |
def controller.P_controller.update | ( | self, | |
setpoint, | |||
rec_pos | |||
) |
This method calculates an error signal based on the users desired input and current motor position.
setpoint | The value that corresponds to the users desired motor position |
rec_pos | The last known recorded position of the moto |
controller.P_controller.act_signal |
Act_signal (actuation signal) is simply the result of multiplying error by the proportional gain constant.
Act_signal is the value that gets sent to the motor to set the duty cycle. One key point is that the actuation signal can either be attenuated or amplified depending on what Kp value is used. Step response tuning shows what effect different Kp values had on the system. Moreover, actuation signal can saturate the duty cycle range of the motor, but this is okay since the set_duty method of the motor driver handles these values fine.
controller.P_controller.error |
Error stores the difference between current motor position and desired motor position.
Error can be very large, well beyond the full duty cycle of the motor, since the motors range of position is technically infinite. The program runs the controller until error is within a reasonable margin. For purposes of this system, that range is approximately 1%.
controller.P_controller.Kp |
Kp stores the proportional gain constant that either attenuates or amplifies the error signal into the actuation signal.
Kp takes on very particular units depending on the system it is controlling. For purposes of our system, the stable operating range for Kp lies between 0.1-10. Anything less than 0.1 and the system takes too long to respond and the program will eventually crash after the system runs out of RAM because a desirable steady state will never be reached and the program will run indefinitely. Anything greater than 10 and the system becomes unstable because the actuation signal fluctuates too greatly for the system to ever reach steady state. Instead excessive oscillatory behavior is observed.
controller.P_controller.setpoint |
Setpoint stores the desired motor position value that the user wants.
Setpoint is a value that tells the controller what position to move the motor to. It can contain any positive or negative whole number integer, however it's worth noting that values greater than 75000 or less than -75000 will take the program so long to reach steady-state that it may crash the program. The motor just can't move quick enough to arrive at setpoints that large before the PC runs out of RAM. Setpoint is used in the calculation of error since error is the difference between current position and desired position.