## Introduction

When it comes to control systems, the inverted pendulum system is something that stands out from amongst the rest. Linear control concepts such as stabilization of unstable systems can be demonstrated using the inverted pendulum. Since the system is intrinsically non linear, many non linear concepts can also be demonstrated using the inverted pendulum. This system has basically two equilibrium states, one stable and the other unstable. In the stable equilibrium state, the pendulum points downwards and in the absence of any controlling forces, it returns to its original state. In the unstable equilibrium state, the pendulum points upwards. Due to this orientation of the system, it does call for a controlling force to act on it to maintain this positioning. The fundamental objective of the inverted pendulum is to maintain the unstable equilibrium when it starts in an erect position. The results were taken using the Matlab controller.

## General Equations:

Derivation of Equations of State and Output:

Based on the parameters and the physical values of the system, the equations of state and the output equations are derived below the dimensions are omitted in the equation in order to preserve the readability. The dimensions are shown in the table.

Deriving the Transfer Function of the Open Loop System:

This complex mathematical derivation was carried out using the MATLAB software simulator.

Y(s)/U(s)= C(sI-A)-1B +D

Solving in MatLab using a symbolic operator for s and simplifying denominators:

Obtaining the Controllable, Observable and Jordan Canonical forms in (1):

This is perhaps the most complicated part of the operation and the entire derivation had been depicted in a very presentable form as shown below.

Obtaining the Impulse Response and Step Response:

In order to carry out this part of the test, we need to chose a set of boundary conditions. The boundary conditions so chosen are arbitrary.

Let y1(t0)= y2(t0)=0

The impulse response is obtained using the partial fraction solution of the last step. The impulse response in the Laplace s-domain is 1.

The unstable system can be understood by analysis of the different coefficients of t. the negative coefficients of t (-6.4309 and -18.787) are time decaying and tend to zero as time, t, approaches infinity. On the other hand, the positive coefficients of t diverge at large values of t. the combined effect resulting in an unstable equilibrium system. Since the non-decaying exponential terms have opposing signs, one will dominate the other and the e18.787t term having both a larger exponent and coefficient, will dominate.

The results obtained from the MATLAB simulator for the impulse response time along with the derivation for the step response have been shown below.

Figure 1: Unit Impulse Response

Step response derivation is also obtained using the partial fraction solution. The step response in the Laplace s-domain is 1/s.

Simplified, In this case as well, both negative and positive coefficients are encountered and the concept of unstable equilibrium can be understood from the very same principles involving the decaying and non decaying terms. Again, the e18.787t term will dominate for large values of t. The output is plotted below in Figure 2.

Figure 2: Step response output

The Bode Plot and the Root Locus Plots:

The bode.m and the rlocus.m functions in MATLAB are used to plot the graphs for both the outputs and they are shown below.

Figure 3: Bode Diagram for output 1, generated in Matlab.

Figure 4: Root-Locus Plot for output 1, generated in Matlab.

Figure 5: Bode diagram for output 2, generated in Matlab.

Figure 6: Root-Locus Plot for output 2, generated in Matlab.

Design of a Lead-Lag Controller:

There are a few steps involved in designing the lead-lag compensator. We first understand whether the system type needs to be increased in order to satisfy the steady state error specification. Kc needs to be calculated to satisfy the steady state error. Once this is done Bode plots for G(s) = KcGp(s)/s(Nreq−Nsys) are made.

The Lead portion of the lead-lag compensator is made as follows: the amount of phase shift in G(jω) is determined at the specified gain crossover frequency and the uncompensated phase margin PMuncompensated (assuming that the specified gain crossover frequency defines the

uncompensated phase margin) is calculated. The values of φmax and αd that are required to raise the phase curve to the value needed to satisfy the phase margin specification are to be calculated subsequently. Using the value of αd and the specified gain crossover frequency, compute the lead compensator’s zero zcd and pole pcd.

The Lag portion of the compensator is also designed as follows:

The magnitude of G(jω) at the specified gain crossover frequency is first determined. Then we determine the amount of shift to the magnitude curve at the specified gain crossover frequency that is caused by the lead compensator. After that we determine the amount of magnitude attenuation that is required to drop the combined (plant + lead compensator) magnitude down to 0 db, and compute the corresponding αg. Then using the value of αg and the specified gain crossover frequency, compute the lag compensator’s zero zcg and pole pcg.

These are the Bode plots for the magnitude and phase of a typical lead lag type compensator.

Gp(s) =2/s

The steady-state error specification for a unit parabolic input is ess_specif ied = 0.0125. The phase margin specification is P Mspecif ied ≥ 45◦. The gain crossover frequency specification ωx_compensated ≈ 5 r/s.

Compensator Gain:

The first step in the design procedure is to determine the number of poles that the compensator must have at s = 0 and the value of the gain Kc. Since the steady-state error specification is for a parabolic input, the required number of poles at the origin in the compensated system is Nreq = 2. The plant model described in (3) has Nsys = 1, so the compensator must have Nreq − Nsys = 2− 1 = 1 pole located at s = 0.

When Gp(s) is augmented with this compensator pole at the origin, the error constant of Gp(s)/s is Kx_plant = 2/1 = 2, so the steady-state error for a parabolic input is ess_plant = 1/2 = 0.5. The specified steady-state error ess_specif ied = 0.0125 requires an error constant of Kx_required = 1/0.0125 = 80. Therefore, the compensator requires a gain having a value of

## Making the Bode Plots

The next step is to plot the magnitude and phase as a function of frequency ω for the series combination of the compensator gain (and any compensator poles at s = 0) and the given system Gp(s). This transfer function will be the one used to determine the values of the compensator’s poles and zeros and to determine if more than one stage of either lead or lag compensation

is needed. The magnitude |G (jω)| is generally plotted in decibels (db) vs. frequency on a log scale, and the phase ∠G (jω) is plotted in degrees vs. frequency on a log scale. At this stage of the design, the system whose frequency response is being plotted is

Figure 2 shows the Bode plots for this augmented system. The dashed lines are the curves for Gp (jω). Since the compensator does have one pole at the origin, the slopes of the magnitude curves for G (jω) and Gp (jω) differ by −20 db/decade at all frequencies. At ω = 1 r/s, the gain Kc has raised the curve by 20 log10 |40| ≈ 32 db. The plant’s phase curve is shifted by −90◦ at all frequencies in producing ∠G (jω), due to the compensator’s pole at the origin.

The next phase of the design deals with determining (s/zcd + 1) / (s/pcd + 1). The values of zcd and pcd will be chosen to satisfy the phase margin specification at the required gain crossover frequency. Note that at ω = 0, the magnitude |(jω/zcd + 1) / (jω/pcd + 1)| = 1 ⇒ 0 db and the phase ∠ (jω/zcd + 1) / (jω/pcd + 1) = 0 degrees. Therefore, the low frequency parts of the curves just plotted will be unchanged, and the steady-state error specification will remain satisfied. The

Bode plots after the design of the lead part of the compensator will be the sum, at each frequency, of the plots made in this step of the procedure and the plots of (jω/zcd + 1) / (jω/pcd + 1).

Fig. 2. Bode plots after the steady-state error specification has been satisfied

Determination of φmax and αd

Given the value of the uncompensated phase margin from the previous step, we can now determine the amount of positive phase shift that the lead compensator must provide. The compensator must move the phase curve of G (jω) at ω = ωx = 5 r/s upward from its current value of −180◦ to the value needed to satisfy the phase margin specification. A safety factor of 10◦ will be included in this phase shift. Thus, the amount of phase shift that the lead compensator needs to provide at ω = ωx is

φmax = P Mspecif ied + 10◦ − P Muncompensated (8) = 45◦ + 10◦ − 0◦ = 55◦

Knowing φmax, we can compute the value of αd. From “Phase Lead Compensator Design Using Bode Plots”, the largest angle produced by the compensator is so the value of αd is computed from and the compensator’s pole–zero combination will be related by the ratio zcd/pcd = αd = 0.099.

The value of φmax = 55◦ in this example is at (or near) the upper limit for a single stage of lead compensation. Many references state that αd ≥ 0.1 should be used for the lead compensator to prevent excessively large component values and to limit the amount of undesired shift in the magnitude curve of G(s) due to the compensator. The value αd = 0.1 corresponds to a maximum phase shift φmax ≈ 55◦. We will assume in this example that αd = 0.099 is acceptable for a single stage of lead compensation.

## Determination of zcd and pcd

The next and last step in the design of the transfer function for the lead compensator is to determine the values of the pole and zero. Note that in the design of the lead part of the lag-lead compensator, we did not have to determine the new gain crossover frequency. That frequency is specified, and the lag part of the compensator will take care of the shift in the magnitude curve caused by the lead part of the compensator.

Knowing the value of αd and the specified value of ωx−compensated, there are no decisions to be made at this point in the design. Only simple calculations are needed to compute zcd and pcd.

As mentioned in Section II-A, the frequency ωmax is the geometric mean of zcd and pcd; that is, ωmax = √zcdpcd. Since ωmax = ωx−compensated by design, the compensator’s zero and pole are computed from Including that part of the compensator needed to satisfy the steady-state error, the transfer function for the compensator at this stage of the design is Determination of αg

Once the lead part of the compensator has been determined, the amount of magnitude attenuation that the lag compensator must provide at the specified gain crossover frequency can be evaluated. For all frequencies greater than about 4 * zcg, the magnitude |(jω/zcg + 1) / (jω/pcg + 1)| of the lag compensator is −20*log10 (αg) db. Therefore, high frequencies (relative to zcg) will be attenuated by −20 * log10 (αg) db. Thus, αg can be determined by evaluating the magnitude |Gc_lead(jω)Gp(jω)| at the specified ωx_compensated.

If the Bode plots of Gc_lead(jω)Gp(jω) are available, then this magnitude can be read directly from the graph at the specified gain crossover frequency. If only the plots of G(jω) defined in (6) are available, then the following relation can be used to compute |Gc_lead(jω)Gp(jω)| at ω = ωx_compensated.

This value of αg will provide the necessary attenuation at ω = 5 r/s to establish that frequency as the compensated gain crossover frequency. This value of αg is slightly above the upper limit generally used for a lag compensator. We will assume that is an acceptable value.

Bode plots after the lead portion of the lag-lead compensator has been designed.

Determination of zcg and pcg

The last step in the design of the transfer function for the lag-lead compensator is to determine the values of the pole and zero for the lag portion of the compensator. We have already determined their ratio αg , so only one of those terms is a free variable. We will choose to place the compensator zero and then compute the pole location from pcg = zcg /αg. We will use

the same approach as described in “Phase Lag Compensator Design Using Bode Plots”, namely placing the compensator zero zcg one decade lower in frequency than the compensated gain crossover frequency. This assumes that only one stage of lag compensator will be used. The general rule of thumb if nstage stages of lag compensator are being used is

In this example the lead-lag compensator’s zero and pole are located at

And the final transfer function is

Bode plots for the lead lag compensated system.

The Bode plots for the final lag-lead compensated system are shown in Fig. 4. The gain crossover frequency is 5 r/s and the phase margin is 49.9◦, so both of those specifications have been satisfied. The error constant for the compensated system is

so the steady-state error is ess = 1/80 = 0.0125, and that specification has also been satisfied. Therefore, the compensator in (18) is one that allows all the specifications to be satisfied for the given plant.

## Conclusions

The inverted pendulum and the complex mathematical derivations associated with it were run using the MATLAB software and simulator and the various graphs were plotted to understand the complex unstable equilibrium principles of the system.