The system consists of a PM brushed DC motor that acts as the system's actuator by moving the rotary arm. An encoder is attached to the motor to measure the angular position of the coupled motor arm / rotary arm. At the end of the rotary arm there is a pillow block that holds an axle that the pendulum link rotates on. Attached to the pendulum axle is another encoder that measures the encoder's angular position. The motor is controlled by a motor driver that runs in current mode. That means that the driver's controller changes the current in the motor significantly faster than the pendulum dynamics such that it can be approximated to be almost instantaneous. The current driver is controlled through a National Instruments myRIO microcontroller. The control logic is all implemented in LabVIEW.
To be able to have the system fully operational my team had to perform tasks that can be broken down into three main categories
The first task is to fully model and then characterize the system. This task began with deriving the equations of motion for the inverted pendulum. This was achieved straightforwardly using Lagrangian mechanics. With a mathematical model, we needed to identify the system parameters and so we ran multiple tests to characterize the system. Now that we have the fully characterized system, we are able to predict the behavior of the system. To do this, we developed a Simulink model from the equations of motion. To add fidelity to the simulation, the Simulink model captures various effects such as the quantization due to the encoders and discretization effects,
The controller was designed to take the pendulum in the stable configuration and stabilize in the unstable inverted position. To do this, a hybrid controller was designed. The first mode consisted of a swing up controller. This was accomplished using a simple energy based swing up method. The control effort is dictated by the difference of the current energy and the desired energy. After the pendulum reaches within 30 degrees of the inverted position, the swing up controller was deactivated. After the pendulum reaches within 25 degrees of the inverted position, an LQR controller kicks in. There exists a deadband of 5 degrees that prevents the two controllers from fighting each other. The initial LQR gains were determined using Bryson's method and then tuned from there to achieve good performance.
Before any control logic was implemented on the actual hardware, the controller design was verified to work in the Simulink model. We paid attention to current and power demands from the controller to make sure we are able to safely provide it given the hardware constraints. After the controller design was verified in simulation, we implemented it on our myRIO microcontroller using labVIEW. The labVIEW program handled the controller, angle wrapping, and switching logic. The important part of the implementation task is how the actual hardware and software deviates from our assumptions. The first is that the encoder quantizes the angular position and does not return a continuous position. This quantization effect, although modeled in Simulink, was not explicitly accounted for in the controller design phase. The next issue is that there is not an actual measurement of the angular velocity, but an approximation from the encoder position. This brings in two issues. The first is that since the encoder position is digital, taking a pure derivative of the signal would not return an accurate velocity measurement. Instead a smoothed derivative had to be taken, but that brings other inaccuracies. The second is that LQR assumes full state feedback and since we are approximating the angular velocity this is not true. A more intelligent approach would be to implement a observer-based feedback strategy that uses the LQR gains for the controller gains. For the sake of reduced complexity, we assumed the angular velocity approximation was an actual measurement.
The end result of the entire project yielded the following products:
The equations of motion of the system along with the identification of all relevant physical parameters
Simulink model of the entire system
A hybrid controller that consists of a swing up controller and an LQR controller
A labVIEW program that implements the controller, angle wrapping, and switching logic
The video demonstrates the system operating as intended. Here were also demonstrate the ability to reject disturbances.
This video shows both the ability to stabilize when the inertia properties are slightly different then determined and how smoothly the system stabilizes the pendulum that we can balance a marker on the tip.
This is a plot of one of the experiments run to characterize the system. From the experimental data we were able to extract physical parameters of the system. With the parameters, we ran a simulation of the event and overlaid it over the experimental data.
The image shows the resulting Simulink model of the inverted pendulum
The above plots shows the designed controller run on the Simulink model. We were able to verify that the designed controller meets all design requirements and hardware constraints in simulation before any implementation.
The above image is of the front panel of the Labview program that allows us to implement the controller. Here we have the controller gains as adjustable inputs from the user that allows for fast tuning.