ME 405 Term Project: Thermal Imaging Nerf Turret 1.0
A library that contains software used to control and fire an automated Nerf turret. The turret uses a MLX90640 Thermal Imaging camera to determine opponent's position and fire.
src.controller.PIController Class Reference

The class initializes a proportional gain constant, Kp, an integral gain Ki and a desired setpoint for a system. More...

Public Member Functions

 __init__ (self, Kp, Ki, setPoint)
 This function initializes the proportional and integral gain constants and desired setpoint.
 
 run (self, actualVal)
 This function handles control by comparing the current system value to the desired set point, and then computing the error.
 
 set_setpoint (self, setPt)
 This function sets the desired setpoint.
 
 set_Kp (self, Kp)
 This function sets the proportional gain.
 
 set_Ki (self, Ki)
 This function sets the intergral gain.
 

Public Attributes

 Kp
 
 Ki
 
 setPoint
 
 totalE
 

Detailed Description

The class initializes a proportional gain constant, Kp, an integral gain Ki and a desired setpoint for a system.

When feedback is applied through the run() method, the error in the system is calculated, and the proportional and integral gain is applied. Rapidly and repeatedly calling run() enables one to create a closed loop proportional controller.

Constructor & Destructor Documentation

◆ __init__()

src.controller.PIController.__init__ ( self,
Kp,
Ki,
setPoint )

This function initializes the proportional and integral gain constants and desired setpoint.

Parameters
KpUser specified proportional gain constant.
KiUser specified integral gain constant
setPointDesired setpoint for the system to be driven to.

Member Function Documentation

◆ run()

src.controller.PIController.run ( self,
actualVal )

This function handles control by comparing the current system value to the desired set point, and then computing the error.

The error is then multiplied by the gain Kp to obtain proportional control. The total error is integrated by summing it, and then Ki is applied to obtain integral control. Together, this creates a PI controller.

Parameters
actualValThe measured current value of the system.
Returns
The output to be sent to the system driver as a float. (For a motor system, this is the PWM duty cycle percentage to be sent to the motor)

◆ set_Ki()

src.controller.PIController.set_Ki ( self,
Ki )

This function sets the intergral gain.

Parameters
KiThe new integral gain value.

◆ set_Kp()

src.controller.PIController.set_Kp ( self,
Kp )

This function sets the proportional gain.

Parameters
KpThe new proportional gain value.

◆ set_setpoint()

src.controller.PIController.set_setpoint ( self,
setPt )

This function sets the desired setpoint.

Parameters
setPtThe new desired setpoint of the system.

The documentation for this class was generated from the following file: