-
Notifications
You must be signed in to change notification settings - Fork 0
Home

These gears are driven by the PID controller and show the output position of the system. The bottom gear is attached to the output shaft of the servo and the top gear is attached to the rotary encoder which reads the output position back into the system.
These switches either enable or disable each factor independently. When in the up position the gain value is determined by the adjustment knob below the switch. When in the down position, the gain value is locked to 0.
These knobs control the gain values, Kp, Ki, and Kd. Rotate clockwise to increase the gain of the respective factor. The numerical values of the gains can be viewed by enabling the debug output in the Arduino code. TODO: write more details and link
This knob is the main input to the system. It sets the position that the controller will try to achieve with the other P I and D inputs. Note that the potentiometer used only has ~340 degrees of rotation.
This switch flips the input position by 180 degrees. The up position enables this inversion, the down position acts like normal. This switch is useful for inputting an instantaneous position change. This situation is common when setting the position to a specific location through software.
This switch allows signals to be sent to the output servo, or blocks signals. The up position enables the output servo, down disables the output servo
A PID controller takes input from a sensor in order to drive a motor or other device, which in turn changes the sensor. This creates a closed feedback loop because the output of the system influences the input of the system.
TODO: explain software loop. explain that each loop sets the speed
PID stands for the three factors used in the calculation of the output. P = proportional, I = integral, D = derivative. The function looks like this:
PID = Kp * p + Ki * i + Kd * d
Where Kp, Ki, and Kd are constant coefficients used to scale the p, i, and d values which are calculated based on the error of the system. The error is simply the difference between the desired location and the actual location. The units used for the measurements do not matter, it could be degrees, radians, rpm, inches, cm etc. However, the units do affect the values of the coefficients. The coefficients are the values we tweak to tune the controller to behave how we want. How to tune a PID controller.
These values change between each iteration of the control loop. They are calculated based on the error in the system, which is also calculated at the beginning of each iteration.
P stands for proportional, meaning the larger the error, the larger the p value. This is the base of a PID controller, the further away from the desired location, the setpoint, the faster the controller commands the motor to move. In the case of the controller on this repository, and likely others, the p value is exactly the current error. This simplifies calculations and is easy to understand.
Note that error can be both negative and positive, changing the direction of travel.
I stands for integral. All this means is after each iteration of the control logic, the error is accumulated into the i value. This has the effect of counteracting constant resistance. If the motor doesn't quite make it to the setpoint with just the proportional factor, the i value will continue to grow until the motor begins moving again and reaches the setpoint.
D stands for derivative. A derivative is simply a rate of change in a value. So the d variable is measuring the rate of change in the error. The controller on this repository does this by simply subtracting the last error measurement from the current one, giving the change between one iteration.