====== Damped Compound Pendulum (DCP) ====== **Author:** Sangsin Park Email: \\ **Date:** Last modified on <10/17/18> \\ **Keywords:** compound pendulum, pendulum control with a propeller, damped compound pendulum \\ {{ dcp:DCP.jpg?400 |}} \\ The photo above depicts the damped compound pendulum (DCP) control which allows you to understand a second order system and PID control. The big picture problem is to make a good step response. Solving this partially or completely is important because a step response is a basis to analyze control performances. This tutorial shows you how to build a DCP system, how to find a relationship with control input voltages (i.e. analog output voltages as a base voltage of a transistor to rotate a motor) and pendulum angles from an encoder, how to match a mathematical model with experimental measurements, how to make a LabVIEW program for PID control, and experiments and takes approximately 2 - 3 hours to complete. **Additionally, LEGO DCP is included.** \\ ===== Motivation and Audience ===== This tutorial's motivation is to understand a second order system. Readers of this tutorial assume the reader has the following background and interests: * Know how to control a plant \\ * Perhaps also know how to make equations of motion \\ * This tutorial may also attract readers who want to understand how to find a system ID The rest of this tutorial is presented as follows: * Parts List and Sources * Construction * Modeling * System ID * PID control * Experiments * LEGO DCP * Final Words \\ ===== Parts List and Sources ===== \\ ^PART NAME/DESCRIPTION ^VENDOR ^VENDOR Number or URL ^PRICE (USD) ^QTY ^ | H5-360-IE-S/Optical Encoder | US Digital | https://www.usdigital.com/products/encoders/incremental/rotary/shaft/H5 | 92.95 | 1 | | USB-6211/NI Multifuction I/O Device | National Instruments | http://www.ni.com/en-us/support/model.usb-6211.html | 949.00 | 1 | | 1316.12.5/Glass fiber reinforced super nylon propeller | Graupner | https://www.graupner.com/Prop-12x5cm-5x2-Zol-l-/1316.12.5/ | 2.79 EUR | 1 | | TIP31/NPN Transistor | RadioShack | https://www.radioshack.com/products/tip31-transistor | 1.50 | 1 | | DC Motor/nominal voltage of 5V | - | - | - | 1 | | Resistor/1k Ohms | - | - | - | 1 | | Resistor/10k Ohms | - | - | - | 2 | | Capacitor/10nF | - | - | - | 3 | | 1N4004/zener diode | - | - | - | 1 | | 4 pin connector | - | - | - | 2 | | 3 pin connector | - | - | - | 1 | \\ ===== Construction ===== This section gives step-by-step instructions along with photos to build circuits to drive a motor and read an encoder. There are circuits and devices what we need. Three schematics to construct a motor driver, connectors and low pass filters are shown following. \\ \\ {{ dcp:electric_devices.jpg?400 |}} \\ \\ **Step 1** \\ \\ Here are top and down pictures of a circuit of a motor driver and connectors. I use a socket which is placed between connectors for easy wire routing. {{ dcp:motor_driver.jpg?800 |}} \\ \\ The schematics of the motor driver and the connectors are presented as follows. I use an NPN transistor (TR) to drive motor. As the base voltage of TR increases, the current through the motor increases. The encoder needs 5V and I use two signals of A and B to read the pendulum rotation angle. The connector #3 is for the USB-6211's analog output (AO) connection. Wires of AO GND and AO 0 are hooked up to the USB-6211's terminal 12 and 14, respectively. \\ {{ dcp:sch_motor_driver.jpg?400 |}} {{ dcp:sch_connectors.jpg?800 |}} \\ \\ **Step 2** \\ \\ This is low-pass filters to get rid of the encoder's signal noise. The cut-off frequency is 1.59 kHz. \\ {{ dcp:lpf_for_encoder.jpg?400 |}} \\ \\ The schematic of the low-pass filter is presented as follows. A resistor of 10k ohms and a capacitor of 10 nF are used in it. Wires of PFI 0, PFI 1, and DGND are hooked up to the USB-6211's terminal 1, 2 and 5, respectively. \\ {{ dcp:sch_lpf.jpg?400 |}} \\ \\ **Step 3** \\ \\ Make sure that the USB-6211's wire connections are same as the picture. \\ {{ dcp:ni_wire_connections.jpg?400 |}} \\ ===== Modeling ===== Free body diagram of DCP is presented as follow: {{ dcp:FBD.jpg?600 |}} Equation of motion (EOM) is given by {{ dcp:eom_1.jpg?250 |}} and {{ dcp:moment_of_inertia.jpg?150 |}} Assume that the pendulum moment of inertia is a plate about its center and the thrust force is proportional to the control input voltage which is the output voltage from USB-6211 (see the following figure). Let's set the ratio as //Km//. {{ dcp:blockdiagram_voltage_to_force.jpg?300 |}} Then the EOM can be rewritten by {{ dcp:eom_2.jpg?250 |}} To find the //Km//, I use the steady-state behaviour of the DCP. At steady-state θss, angular velocity and acceleration go to zero. Therefore, the EOM is simplified by {{ dcp:ss_equation_01.jpg?200 |}} or, {{ dcp:ss_equation_02.jpg?150 |}} Try several experiments by choosing different values of AO voltage and measure the steady-state pendulum angles. The experiement results are shown in a following table. \\ ^AO Voltage (V) ^Pendulum Angle (degree) ^ | 0.8 | 0 | | 0.85 | 2.25 | | 0.9 | 4 | | 0.95 | 5.75 | | 1 | 8.5 | | 1.2 | 16.5 | | 1.4 | 26 | | 1.6 | 34 | | 1.8 | 43 | | 2.0 | 51.5 | | 2.2 | 64 | | 2.4 | 78 | \\ From the experiment data, I can plot a graph such as {{ dcp:voltage_to_ss_angle.jpg?400 |}} Then, I use the first degree polynomial equation to fit to data points. The result is shown in {{ dcp:curve_fitting.jpg?400 |}} and the fitted polynomial equation is {{ dcp:fitted_equation.jpg?300 |}} Note that DCP has a dead-zone which means that it needs greater than 5V to rotate a propeller, and the offset value of 0.7697 is used. Now, the //Km// can be determined With the fitted polynomial equation {{ dcp:Km.jpg?110 |}} To linearize the EOM, assume that the pendulum angle is small. Then the value of sinθ is similar to θ. {{ dcp:linearized_eom_1.jpg?230 |}} Taking Laplace transform, the transfer function of DCP would be {{ dcp:tf.jpg?200 |}} And, the block diagram of the above transfer function would be {{ dcp:blockdiagram_voltage_to_angle.jpg?400 |}} // // ===== System ID ===== The unknowns of the DCP which are damping coefficient ( c ) and distance from pivot to CG (d) can be determined by system identification. The DCP is the second order system and all second order system have the following characteristic equation. {{ dcp:char_equation.jpg?200 |}} Moreover, there are two relationships. {{ dcp:logarithmic.jpg?300 |}} I use 10 degrees step response because of less oscillation time and pick out first two peak points to calculate damping ratio and natural frequency. {{ dcp:sys_id_01.jpg?400 |}} By the calculation, yields the following: ζ = 0.0127 and **ωn = 1.5783**. The calculated damping ratio, however, is too small after comparing a model response with experiment response. To match two responses similarly, I add 0.085 to that value. Therefore, **ζ = 0.0977**. The comparison with experiment and model response is shown in the following figure. {{ dcp:sys_id_02.jpg?400 |}} // // ===== PID Control ===== A LabVIEW program is employed to control the DCP and PID controller is implemented on it at control frequency of 200Hz. The P, I, and D gain are 0.1, 0.28, and 0.9, respectively. {{ dcp:pid_r3_200hz_block_diagram.jpg |}} In addition, there is the front panel of that LabVIEW block diagram. {{ dcp:pid_r3_front_panel.jpg?400 |}} // // ===== Experiments ===== Before installing a propeller, make the propeller's hole bigger (see the following picture). I drill a hole of 5 mm but recommend a hole of 5.5 mm. {{ dcp:propeller_hole.jpg?300 |}} Then, there is a motor assembled with the propeller. {{ dcp:new_propeller.jpg?300 |}} === Exp. #1 === 50 degrees step commend and twice disturbances. {{ dcp:experiments_01.mp4 |}} And the experiment #1's graph is shown in {{ dcp:exp_01_graph.jpg?400 |}} === Exp. #2 === Gradually increase step commend from 40 to 65 degrees: 40, 50, 60, and 65 degrees. {{ dcp:experiments_02.mp4 |}} And the experiment #2's graph is shown in {{ dcp:exp_02_graph.jpg?400 |}} // // ===== LEGO DCP ===== You can make a LEGO version DCP with LEGO bricks, a motorized propeller, and a HiTechnic angle sensor. Even if the angle sensor's resolution is not good (1-degree accuracy), a LEGO DCP control does not matter. {{ dcp:lego_dcp.jpg?500 |}} === LabVIEW block diagram for PID control === A LabVIEW program, which is similar to the before LabVIEW code, is employed to control the LEGO DCP at a control frequency of 40Hz. The P, I, and D gain are 0.05, 0.8, and 0.05, respectively. Here is the LabVIEW file. {{dcp:lego_dcp_labview_02.zip?linkonly}} {{ dcp:lego_dcp_labview_block_diagram.jpg |}} In addition, here is the front panel of the LabVIEW program. {{ dcp:lego_dcp_labview_front_panel.jpg?400 |}} A breakdown of the LabVIEW block diagram is shown as follows. 1. Initialize an angle sensor {{ dcp:lego_dcp_init_angle.jpg |}} Before while loop, reset angle sensor and wait until its angle is within 1 degree. 2. Read angle {{ dcp:lego_dcp_read_angle.jpg |}} An angle from the angle sensor is measured in the range 0 to 359 degrees with 1-degree accuracy. To display angle in the range -180 to 180, when the angle is greater than 180, subtract 360 from that. Moreover, to avoid getting mixed up with wires, I assign a local variable for the Angle. 3. PID controller {{ dcp:lego_dcp_pid.jpg?500 |}} If a control frequency is changed, a value of dt also needs to be changed to a value of 1/frequency. 4. Convert angle to motor power {{ dcp:lego_dcp_conversion.jpg |}} A constant of 68.98519 is a proportional gain to convert from angle to motor power and another constant of 10 is bias for dead-zone. Those constants can be determined by curve-fitting (see the **Modeling** section). 5. Input motor power {{ dcp:lego_dcp_motor.jpg?300 |}} For safety and to limit motor rotation to a single direction, a motor power is constrained by in the range of 0 to 100. ** NB: If motor terminals are hooked up to an oscilloscope, a motor power range becomes strange. The motor power is in the range -100 to 100. Zero power is not zero anymore. For example, at -100, a motor doesn't rotate and at 0, it can rotate. ** 6. Save time and angle {{ dcp:lego_dcp_save_data.jpg?700 |}} To calculate experiment time, read a current time before while loop, and then subtract the time from a time updated in while loop. Lastly, two local variables, Time and Angle, are written into a file after press a STOP button. === Exp. #1 - 40 degrees step command and disturbances === {{ dcp:lego_dcp_exp_01.mp4 |}} {{ dcp:lego_dcp_40_degrees_pid.jpg?500 |}} // // ===== Final Words ===== This tutorial's objective is to understand a second order system through a compound pendulum with a motorized propeller referred to as Damped Compound Pendulum (DCP) and I share my efforts in detail regarding two different DCP realization. PID control of a DCP is successful and then a LEGO version DCP is made for control class and hands-on lab. Eventually, the LEGO DCP is also controlled well. \\ \\ For questions, clarifications, etc, Email: