. .
.
Control of Inverted Pendulum System (Real Time)
.
.

 1. ROTPENT: Gantry Crane

 

 

This experiment illustrates some control tasks for gantry cranes. The gantry is a moving platform or trolley that transports the crane about the factory floor or harbour. The load hangs from the crane using wires and is moved by the gantry crane. Typically the problem is to move the load quickly and move it to the correct position. The fast motion necessary for production makes it more difficult to move the load to the correct location given the swinging motions of the crane. This problem can be mimicked using the rotary pendulum system by viewing the tip of the L-shaped arm as the moving trolley and the pendulum tip as the load being carried.

 

In this experiment we will begin by modeling the system and determine strategies to dampen the oscillations of the system.

 

 

 

Fig 4.Free-body diagram of pendulum assembly.

 

Figure 4. shows the free-body diagram of the pendulum assembly that is composed of two rigid bodies: the pendulum link with mass Mp1 and length Lp1, and the pendulum weight with mass Mp2 and a length Lp2. The center of mass of the the pendulum link and the pendulum weight are calculated separately using the general expression

 

 

 

where x is the linear distance from the pivot axis and p is the density of the body. The circle in the top-left corner of  Figure 4. represents the axis of rotation or the pivot axis that goes into the page.

 

 

The pendulum system is then expressed as one rigid body with a single center of mass, as shown in Figure 5 below.

 

 

Fig 5.Free-body diagram of composite pendulum.

 

 

The center of mass of a composite object that contains n bodies can be calculated using 

 

 

 

 

where xcm,i is the known center of mass of body i and mi is the mass of body i .

 

From the free-body diagram in Figure 5, the resulting nonlinear equation of motion of the pendulum is

 

....................[1.1]

 

 

 

where Jp is the moment of inertia of the pendulum at the pivot axis z0, Mp is the total mass of the pendulum assembly, u is the linear acceleration of the pivot axis, and lp is the center of mass position as depicted in Figure5 . Thus as the pivot accelerates towards the left, the inertia of the pendulum causes it to swing upwards while the gravitation force Mpg and the applied force Mpu (the left-hand terms in Equation[1.1] ) pull the pendulum downwards.

 

The moment of inertia of the pendulum can be found experimentally. Assuming the pendulum is unactuated, linearizin  Equation[1.1] and solving for the differential equation gives the expression

 

 

 

where f is the measured frequency of the pendulum as the arm remains rigid. The frequency is calculated using

 

 

 

where ncyc is the number of cycles and Dt is the duration of these cycles. Alternatively, Jp can be calculated analytically using the moment of inertia expression

 

 

 

 

where r is the perpendicular distance between the element mass, dm , and the axis of rotation.

 

In addition to finding the moment of inertia, this laboratory investigates the stiction that is present in the system. The rotor of the DC motor that moves the ROTPEN system requires a certain amount of current to begin moving. In addition, the mass from the pendulum system requires even more current to actually begin moving the system. The friction is particularly severe for velocities around zero because friction changes sign with the direction of rotation.

 

The virtual instrument for studying the physics of the pendulum when in the gantry configuration is shown in Figure 6 below.

 

 

Fig.6 LabVIEW virtual instrument for ROTPENT simple modeling

 

 

The procedure to run the gantry crane experiment  can be accessed here .

 

 

 

 

 

2. QNET-ROTPENT: Balancing 

 

 

Balancing is a common control task. In this experiment we will find control strategies that balance the pendulum in the upright position while maintaining a desired position of the arm. When balancing the system the pendulum angle, alpha , is small and balancing can be accomplished simply with a PD controller. Since we are also interested in keeping the arm in a fixed position, a feedback from the arm position will also be introduced. The control law can then be expressed as

 

  .................[2.1]

 

where kp,theta is the arm angle proportional gain, kp,alpha is the pendulum angle proportional gain, kd,theta is the arm angle derivative gain, and kd,alpha is the pendulum angle derivative gain. The desired angle of the arm is denoted by thetar and there is no reference for the pendulum angle because the desired position is zero.

 

When balancing the pendulum over a fixed point, the arm tends to oscillate about that reference because of the friction present in the motor. Due to friction, the motor will not move until the control signal is sufficiently large and the generated torque is larger than the stiction.This means that the pendulum has to fall a certain angle before the motor moves and the net result is an oscillating motion.

 

Friction can be compensated by introducing a Dither signal at the input voltage of the DC motor. The Dither signal used has the form

 

......................[2.2]

 

 

where Ad is the voltage amplitude, fd is the sinusoid frequency, and Vd0 is the offset voltage of the signal.

 

 

3. ROTPENT: Energy Control

 

 

 

If the arm angle is kept constant and the pendulum is given an initial position it would swing with constant amplitude. Because of friction there will be damping in the oscillation. The purpose of energy control is to control the pendulum in such a way that the friction is constant. The potential energy of the pendulum is

 

.......................[3.1]

 

and the kinetic energy is

 

 

.........................................[3.2]

 

 

The potential energy is zero when the pendulum is at rest at alpha = 0 in Equation [3.1], and equals 2Mpglp when the pendulum is upright at alpha = ±pi . The sum of the potential and kinetic energy of the pendulum is

 

 

                                           .......................[3.3]

  

 

Differentiating Expression [3.3] results in the differential equation

 

 

                            .....................[3.4]

 

Substituting Equation [3.1] for pendulum acceleration into Equation [3.4] gives

 

 

                                                                  ....................[3.5]

       

 

 

Since the acceleration of the pivot is proportional to current driving the arm motor and thus also proportional to the drive voltage we find that it is easy to control the energy of the pendulum. The proportional control law

 

 

                                                                 .........................[3.6]

 

 

drives the energy towards the reference energy Er. Notice that the control law is nonlinear because the proportional gain depends on the pendulum angle, alpha, also notice that the control changes sign when dalpha /dt changes sign and when the angle is ±90°. 

 

However, for energy to change quickly the magnitude of the control signal must be large

 

 

                            ...................[3.7]

 

 

where mu is a tunable control gain and the satumax function saturates the control signal at the maximum acceleration of the pendulum pivot, umax .

 

 

4.ROTPENT: Hybrid Swing-Up Control

 

 

 The energy swing-up control in Equation[3.5] can be combined with the balancing control law in Equation[2.1] to obtain a control law which performs the dual tasks of swinging up the pendulum and balancing it. As illustrated in Figure 7, this can be accomplished by switching between the two control systems.

 

 

 

 

Fig  7. Swing-up hybrid contro1.

 

 

 

This system can be modeled as a hybrid system. Hybrid systems are systems with both continuous and discrete parts. There are two continuous parts: the closed-loop system using the swing-up energy controller and the closed-loop system using the PD balance controller. The switching strategy is the discrete element that chooses which controller, or system, to run. The switching logic can be obtained by determining a region in state space where the balancing works well. Balancing control is then used inside this region and energy control is used outside the region. Figure 8 is a called a hybrid automaton and, for this specific task, can be used to describe the system model and the switching logic.

 

 

Fig 8.Hybrid swing-up controller automaton.

 

 

 

The circles in Figure 8 are called locations and represent the two different continuous system. The arrows are called edges and represent the discrete jumps taken when certain condition are satisfied. The angle used in the switching logic in Figure 8  is called the upright angle. It is defined as zero when the pendulum is about its upright vertical position and is expressed mathematically with the expression

 

 

 

 

The various switching parameters can then be set as :

 

    and

 

 

 

Given that the pendulum starts in the downward vertical position, it is in the swing-up location of the hybrid automaton. The swing-up controller pumps energy into the pendulum until it swings within ±2° of its upright vertical position. Once the pendulum is within that that range and does not exceed 720 °/s in either direction, the edge is taken to engage the balance controller. It remain in the Balance PD control location until the pendulum goes beyond the ±30° position range or beyond ±720 °/s.

 

 

The virtual instrument used to run the balance and swing-up controllers on the QNET rotary pendulum system is shown in Figure 9 below

 

 

 

  Fig 9. LabVIEW virtual instrument for ROTPENT swing-up control.

 

 

 The procedure to run this experiment can be accessed here.

 

 

 

 

 

 

 ROTPENT Simple Modeling VI Description

 

 

Table1.  lists and describes the main elements of the QNET-ROTPENT Simple Modeling virtual instrument user interface. Every element is uniquely identified through an ID number and located in Figure 10 below.

 

 

 

Fig 10 ROTPENT Simple Modeling virtual instrument.

 

 

ID Label Parameter Description Unit
1 Theta  θ Arm angle measured by encoder on motor. deg
2 Alpha  α

Pendulum angle measured by encoder on pendulum pivot.

deg
3 Current Im Motor armature current numeric display A
4 Voltage Vm Motor input voltage numeric display V
5 Signal Type   Type of signal generated for the input voltage.  
6 Amplitude Generated signal amplitude input box. V
7 Frequency Generated signal frequency input box. Hz
8 Offset Generated signal offset input box. V
9  Disturbance  Vsd  Apply simulated disturbance voltage.  V
10  h  h  Sampling time interval of virtual instrument input box.  s
11  Mp1  Mp1  Mass of pendulum link.  kg
12  Mp2  Mp2  Mass of pendulum weight.  kg
13  Lp1  Lp1  Length from pendulum axis of rotation to start of pendulum weight.  m
14  Lp2  Lp2  Length of pendulum weight.  m
15  Calculate    Triggers the x_cm1, x_cm2, lp, and Jp calculation.  
16  x_cm1 xcm,1  Pendulum link center of mass calculated from Lp1.  m
17  x_cm2  xcm,2  Pendulum weight center of mass calculated from Lp1 and Lp2.  m
18  lp  lp  Center of mass of pendulum assembly (link+weight) output box calculated from Lp1 and Lp2.  m
19  Jp  Jp  Pendulum moment of inertia calculated from Mp1, Mp2, Lp1, and Lp2.  kg.m2
20  cycle  
 
 
 Number of pendulum cycles to take into account when performing auto-model procedure.  
21  Modeling OFF  Click on this button to begin auto-model procedure.  
22  Status  Output box that reports the current result of the auto-modeling procedure.  
23   Δ t   Δ t  Total time duration of cyles used for auto-modeling.  
24  Frequency  
 
 Frequency of pendulum.  
25 Jp  Experimentally derived pendulum moment of inertia.  
26  Angle  θ,α  Scope with measured arm angle (in red) and pendulum angle (in blue).  deg
27  Voltage  Vm  Scope with applied motor voltage (red).  V
28  Pause Plots  
 
 
 
 Pauses the Angle and Voltage scopes.  
29  Start Generator  When not pressed, the generator output is ignored and a voltage of zero is applied to the motor.  
30  EXIT  Stops the LabView virtual instrument from running.  
31  Real-Time?  The green light indicates that the sampling rate is being maintained.  

 

Table 1 Nomenclature of ROTPENT Simple Modeling VI.

 

 

  

 

  

 

ROTPENT Swing-Up Control VI Description

 

 

As a quick module description,Table2. lists and describes the main elements composing the ROTPENT Swing-Up Control virtual instrument user interface. Every element is uniquely identified through an ID number and located in Figure 11.

 

 

 

 

Figure 11. ROTPENT Swing-Up Control virtual instrument.

 

 

 

ID Label Parameter          Description   Unit
1  Theta  θ  Arm angle measured by encoder on motor.   deg
2  Alpha  α Pendulum angle measured by encoder on pendulum pivot.                                                                                                                                       
3  Current  Im  Motor armature current numeric display  A
4  Voltage  Vm  Motor input voltage numeric display.  V
5  Signal Type  
 
 
 
 Type of signal generated for the input voltage.  
6  Amplitude  Generated signal amplitude input box. V
7  Frequency  Generated signal amplitude input box.  Hz
8  Offset  Generated signal offset input box.  V
9  Disturbance  Vsd  Apply simulated disturbance voltage.  V
10  kp_theta  kp,θ  Arm angle proportional gain input box  V/rad
11  kp_alpha  kp,α  Pendulum angle proportional gain input box.   V/rad
12  kd_theta  kd,θ  Arm angle derivative gain input box.  V.s/rad
13  kd_alpha  kd,α  Pendulum angle derivative gain input box  V.s/rad
14  mu  μ  Proportional gain for energy controller.  m/(s2.J)
15  Er  Er  Reference energy for energy controller  mJ
16  Activate Swing Up                          
 
 When pressed down the energy controller that swings-up the pendulum is engaged  
 
17  Update Control  Applies the control gains kp_theta, kp_alpha, kd_theta, and kd_alpha in the Control Parameters to the running controller (note: mu and Er are updated automatically).
18  h  h  Sampling time interval of virtual instrument input box.  s
19  Mp  Mp  Mass of pendulum assembly (link + weight).  kg
20  lp  lp  Center of mass of pendulum assembly (link+weight) input box.  m
21  Marm  Marm  Mass of rotary arm.  kg
22  r  r  Length from motor shaft to pendulum pivot.  m
23  Jp  Jp  Pendulum moment of inertia relative to pivot.  kg.m2
24  Jeq  Jeq  Equivalent moment of inertia acting on the DC motor shaft.  kg.m2
25  Kt  Kt  Current-torque or back-emf constant: they are equivalent in SI units.  N.m/A
26        
27  Update Model/Design    Updates the ROTPEN model that is used in the energy calculation and simulations in the Open-loop Analysis and Control Design tabs.  
28  Amplitude  Ad  Dither signal amplitude input box.  V
29 Frequency  fd  Dither signal frequency input box  Hz
30  Offset  Vd0  Dither signal offset input box.  V
31  In Range?  
 
 
 Balance controller is engaged when this LED is turns bright green.  
32  Energy  Numeric display of the pendulum energy  mj
33  Swing-Up Control Tab  Tab control that contains the scopes and simulations for the open-loop and closed-loop ROTPEN system.  
34  Angle / Energy    Scope with measured arm angle (in red), measured pendulum angle (in blue), and pendulum energy (in green).  deg/mJ
35  Voltage  Vm  Scope with applied motor voltage (red).  V
36  Pause Plots    Pauses the Angle and Voltage scopes.  
37  Start Control    When not pressed, both the energy and balance control output are ignored and a voltage of zero is applied to the motor.  
38  EXIT    Stops the LabView virtual instrument from running.  
39  Real-Time?    The green light indicates that the sampling rate is being maintained.  

 

Table 2.  Nomenclature of  ROTPENT Swing-Up Control VI.

 

 

 

Remark:

 

  • The energy control proportional control gain, mu, and the reference energy, Er, are automatically applied to the implemented controller as they are changed. The Update Control button does not have to be pressed to update the running controller with new values of mu and Er.

 

The tab control in the front panel of the ROTPENT Swing-Up Control VI, shown in Figure 11 with identification number 34, is depicted in Figure 11.1, 11.2  and  11.3.  The identification labels for the Open-loop Analysis , Control Design - Frequency Analysis, and  Control Design - Time Analysistabs are described in the Table 2.1 ,2.2 and 2.3

 

 

 

 

 Fig 11.1 ROTPENT Swing-Up Control VI: Open-loop Analysis tab.

 

 

 

 

ID Label Parameter Description Unit
1 A A Linear state-space matrix A.  
2 B B Linear state-space matrix B
3 C C Linear state-space matrix C
4 D D Linear state-space matrix D
5 Open-loop Pole-Zero Map Plot   Phase plot showing poles and zeros of the open-loop ROTPEN system.
6 Poles Open-loop poles of ROTPEN system numeric display.
7 Zeros Open-loop zeros of ROTPEN system numeric display.

 Table 2.1 Nomenclature of ROTPENT Swing-Up Control VI: Open-loop Analysis tab.

 

 

 

 

 

 

Fig 11.2 ROTPENT Swing Up Control VI: Control Design - Frequency Analysis tab.

 

 

 

ID Label Parameter Description Unit
1  Q  R  Linear-quadratic weighting matrix that defines a penalty on the state.  
2  Q  R  Linear-quadratic weighting matrix that defines a penalty on the control action.  
3  kp_theta  
 
 
 
 
                     

 
 
 Arm angle proportional gain calculated using LQR.  V/rad
4  kp_alpha  Pendulum angle proportional gain calculated using LQR.  V/rad
5  kd_theta Arm angle derivative gain calculated using LQR.  V.s/rad
6  kd_alpha  Pendulum angle derivative gain calculated using LQR.  V.s/rad
7  Set Desired  Copies the control gains calculated to the implementable gains in the Control Parameters section of the VI.  
8  Closed-loop Pole-Zero Map Plot                                   Phase plot showing poles and zeros of the closed-loop ROTPEN system.  
9  Poles  Closed-loop poles of ROTPEN system numeric display.  
10  Zeros  Closed-loop poles of ROTPEN system numeric display.  

 

Table 2.2 Nomenclature of -ROTPENT Swing-Up Control VI: Control Design - Frequency Analysis tab.

 

 

 

 

 

 Fig 11.3 ROTPENT Swing-Up Control VI: Control Design - Time Analysis tab.

 

 

 

ID Label Parameter
Description Unit
1 Q Q Linear-quadratic weighting matrix that defines a penalty on the state.  
2 R R Linear-quadratic weighting matrix that defines a penalty on the control action.  
3 kp_theta   Arm angle proportional gain calculated using LQR. V/rad
4 kp_alpha Pendulum angle proportional gain calculated using LQR. V/rad
5 kd_theta Arm angle derivative gain calculated using LQR. V.s/rad
6 kd_alpha Pendulum angle derivative gain calculated using LQR. V.s/rad
7 Set Desired Copies the control gains calculated to the implementable gains in the Control Parameters section of the VI.  
8 Step Reference Amplitude Amplitude of the position reference step given to the closed-loop ROTPEN simulation. deg
9 Step Response Plot showing the simulated arm and pendulum step response.  

Table 2.3 Nomenclature of ROTPENT Swing-Up Control VI: Control Design - Time Analysis tab.

 

 

 

Cite this Simulator:

.....
..... .....

Copyright @ 2024 Under the NME ICT initiative of MHRD

 Powered by AmritaVirtual Lab Collaborative Platform [ Ver 00.13. ]