EEET2506-Control System-Stabilizing-control-Design-Report
EEET2506-Control System-Stabilizing-control-Design-Report
Table of Contents
1. Mechanical and Electrical Assembly (10 pts) .............................................................................. 4
Page 2 of 42
RMIT Classification: Trusted
References .......................................................................................................................................... 33
Page 3 of 42
RMIT Classification: Trusted
The kit also contains the following acrylic pieces and pendulum rod according to Figure 2:
1. Acrylic pendulum tower sidewall 1
2. Acrylic pendulum tower sidewall 2
Page 4 of 42
RMIT Classification: Trusted
Figure 2 UM2717 Assembly Manual STEVAL-EDUKIT01 evaluation kit acrylic and pendulum rod
Aside from the kit, the user needs the following tools listed in the UM2717 user manual to assemble
the system:
1. Medium sized Phillip screwdriver
2. Electrician scissors
3. Wire cutter
4. Soldering iron with solder
5. Small flathead screwdriver
6. Thread lock compound (optional)
After gathering the tools and components needed for the assembly process, The STEVAL-
EDUKIT01 will have the following assembly steps to follow:
Starting with the first step, the four M3x8 mm screws and M3 nuts will be situated into the motor
shaft flange and the encoder L-bracket. Afterwards, the rotary encoder will be attached with its cable
on the side, onto the flange with washer, spring tensioner and M3x8 mm precision screws. Prior to
the next steps, all film layers should be peeled off from all acrylic pieces. Then, place the acrylic
motor mount onto the stepper motor with four m3x8 mm machine screws which should not be
Page 5 of 42
RMIT Classification: Trusted
overtightened. Using the Acrylic pendulum base, attach the four adhesive rubber pads into the 5mm
holes to create a firm base grip on any surface placed.
Once the base is established, the tower of the system will be assembled on top. Using 4 pieces of the
acrylic pendulum tower sidewalls, attach 4 pieces together and secure the pieces using screws and
nuts. Within the pocket holes, eight screws will be attached into the pocket hole with retaining nuts.
The motor and encoder system can be attached by connecting the motor cable to the Nema17 stepper
motor. The motor mount will be situated by four M3x16 mm screws and nuts on top of the tower
where the M3x8 mm screw is used to secure the motor shaft to the motor flange. The whole tower
assembly should then be fixed onto the base using four M3x16 mm screws and nuts in which only
the encoder and motor cable should be placed away from the side of the board.
For the development board attachments, use four M3 nuts, M3x20 mm screws and plastic standoffs
to secure the NUCLEO-F401RE development board to the base of the system. It is also important to
file the side of the head of the screw to prevent any interference to the Arduino connector. Lastly,
connect the pendulum rod to the encoder shaft using a M3x8 mm screw which should not be
overtightened. To provide counterweight, a paper clip is placed onto the pendulum rod.
Figure 3: Circuit diagram for the hardware, final step is to put the black driver on top of X-NUCLEO-IHM01A1 (all pins must be
connected)
For the electrical assembly, the X-NUCLEO-IHM01A1 will be connected on top of the NUCLEO-
F401RE board. The correct connection configuration of the X-NUCLEO-IHM01A1 will be in the
Page 6 of 42
RMIT Classification: Trusted
formation that the board’s green Molex connector must face opposite side to the USB connector and
ST-LINK of the NUCLEO-F401RE. Once the boards are mounted, the wiring for the rotary encoder
cable, stepper motor cables and the power supply cables will be explained according to the wiring
diagram shown according to Figure 3.
For the rotary encoder cables, there are 4 wires to connect: power wire (red), ground wire (black),
phase 1 wire (white) and phase 2 (green). The power wire will be connected to E1, which is the 5V
pin of the X-NUCLEO-IHM01A1. The ground wire will be connected to E2 or the GND pin. Then,
the phase 1 wire will be connected to E3 or DIR3 of the board. Finally, phase 2 wire will be connected
to E4 or DIR2 of the board.
For the stepper motor cables, there are 4 wires to attach to the X-NUCLEO-IHM01A1: phase A1 wire
(red), phase A2 (blue), phase B1 (yellow), phase B2 (orange). The phase A1 wire will be attached to
M1A or D4 gate (A negative) pin. M1B or D3 gate (A positive) will have phase A2 wire connected
to it. Phase B1 will be linked to M2A or D6 gate (B negative) pin. Finally, the phase B2 wire will be
connected to M2B or D5 gate (B positive) pin.
The power supply cables will consist of a positive 12 V wire (black with white stripe) and a ground
wire (black). The positive wire will be linked to PS+ or Vin pin of the board and the ground wire will
be linked to PS- or GND pin.
Page 7 of 42
RMIT Classification: Trusted
From here, the rotational displacement will be transferred into electrical signals to be processed by
the rotary encoder [4]. This can then be used to determine the system’s pendulum angle. With the
encoder data obtained, the STSW-EDUKIT01 firmware can then process the pendulum’s motion to
counter the movement received. This counter movement can be established by controlled through the
stepper motor to keep the pendulum vertically upright [4]. Additionally, to provide the rotary inverted
pendulum with a more stabilized system PID (proportional, integral, and derivative) control will be
used to balance the pendulum while preventing potential oscillations [5]. Within the kit, it is also
possible to interact with MATLAB viewer to observe how the system response in real time in its
Default or Modified mood. The rotary inverted pendulum consists of many operations: start, stop,
and stopping by displacing the pendulum. In addition, there will be a guide to identify potential
problems to solve in case the operation of the pendulum could not be activated.
Page 8 of 42
RMIT Classification: Trusted
Initially, all electronic devices need a power supply to work. Therefore, it needs a power supply
equipped with transformer to convert the 220V and the current intensity is 12A so that the system can
operate stably according to Figure 5. X-NUCLEO-IHM01A1 which is stepper motor driver expansion
board, it is used to control the step of the motor, it also can control the current and protect the system.
The power is supplied through a wiring consisting of an anode and a cathode connected through the
PS+ and PS- ports respectively as shown in the figure above. The stepper motor includes 2 coils so
that there are 2 phases needed to connect with the board. One coil needs 2 inputs to be connected to
the circuit board as shown in the figure. As is known, 1 coil controls the rotation of the rotary encoder
motor. According to the Figure 5, E1 is symbolized for 5V output, installed connected to the rotary
encoder to provide power and the ground port (GND) on the board is connected to the negative pole
of the encoder and denoted E2. E3 and E4 represent the connection between ports DIR 2 and DIR 3,
which are logic input. It allows receiving data from the rotary encoder and feedbacking the pendulum
angle to process the step of the motor and its movement direction to balance the pendulum.
Page 9 of 42
RMIT Classification: Trusted
First to establish the connection between PC and system, plug the cable into PC USB port and Nucleo
board port, open command prompt, enter the beginning code to complete the connection according
to Figure 6. Now that they are connected, command the pendulum through PC by telling it what
mode/feature users want, like 1 for default and g for modify mode. After inputting all parameters, the
pendulum will start swinging and transferring data like angle or noise to the computer to display in
the command window. After a while, user can press Ctrl+A+\ to stop and temporarily cut connection
between PC and pendulum, but the pendulum will still run. The connection will start again after user
opens and runs Real Time Workbench Matlab file; the pendulum will start to transfer data back to
the PC again so the workbench can plot graphs for users to assess performance. Once the user logs
data and exits the workbench, PC and pendulum will cut signal flow and stop communicating. From
here, to plot time response of the pendulum in Matlab using the logged data, we open another
MATLAB file, import the logged data and MATLAB will plot the response, the data is taken from a
saved file, this step doesn’t depend on the system anymore.
Page 10 of 42
RMIT Classification: Trusted
The pendulum operation can be stopped by switching off the power of the motor controller
supply and the USB cable charger. An alternative method can be clicking the black reset
button of the NUCLEO-F401RE board to reset the system while maintaining the power
and the pendulum system will resume after each run time interval. If the user chooses to
reset the system quickly, the user can apply a force to deviate the angle of the pendulum
from the vertical angle in which the system can detect and terminate its movement.
The operation will not start when the power is applied to the pendulum, however, the
pendulum’s motion has been encoded prior to the power installation which causes the
system to wait when the pendulum is still and in a downwards orientation. The system’s
operation will not start if the pendulum is not manually rotated after the system reset. Once
the system has been powered and operating, the following data will be provided from the
rotary inverted pendulum: time (seconds), cycle delay (milliseconds), pendulum angle
(degrees), rotor angle (degrees), current combined pendulum, rotor and auto slop
Page 11 of 42
RMIT Classification: Trusted
correction PID, rotor control output (degrees), and rotor position reference command
(degrees).
ii) Software installation guide and manual guide for Modified Parameters
After connecting the USB cable of the NUCLEO-F401RE, install the IRIP system
firmware that accompanies with the STEVAL-EDUKIT01. After the installation process,
open the firmware folder and enter the code for the usbmodem which is provided in the
system’s manual. In this case, the code entered will be 103 according to Figure 7 [6].
After entering the code, the IRIP [6], the user can then enter the mode from the list’s options
such as 1 for Inverted Pendulum Control, 2 for Suspended Pendulum Control, and remaining
modes. In this case, the General Mode: Full State Feedback and PID Controller will be chosen
by entering the letter g into the serial interface according to Figure 8. Once the mode has been
chosen, the messages will appear to which the user can enter the PID parameters for either
Default Mode or Modified parameters. Since the inverted pendulum uses a dual PID system,
the number 0 will be entered into the terminal. The Figure 8 below shows the Modified
Parameters of the Dual PID in which the Pendulum’s PID Proportional Gain will be 1800.00
Page 12 of 42
RMIT Classification: Trusted
with Integral Gain of 12960.00 and Differential Gain of 62.50. These parameters will be
entered into the terminal by entering the values next to each message. The Rotor PID
Proportional Gain will be 260.00 with Integral Gain of 2.00 and Differential Gain of 22.00.
After entering all PID parameters, select 1 to disable the platform angle calibration and select
0 to enable inverted mode while the rest of the modes will be disabled by entering 0.
When the terminal finishes processing, the pendulum will start its swing up process from
initial angle 0. Before the pendulum finishes its starting procedure and in its swing up process,
exit the terminal and open the MATLAB interface file which operates on the STM32
processor. The STM32 processor allows the PC to connect with the STEVAL EDUKIT01
through the Edukit USB cable. When the STM32 processor finishes verifying the program
from the reference firmware file “STM32F401RE-Nucleo.bin”, The installation for the
MATLAB interface workbench can be downloaded from the STM32 CubeProgrammer
software. When opening the Real Time Control System Workbench Matlab and waiting until
the pendulum can balance upwards, run the Matlab code to which a real time viewer output
will show the rotor angle, pendulum angle, rotor tracking and rotor control graph according
to Figure 9, that will be generated from the physical system performance [6].
When the system operation ends, the user can choose to view the data from the graphs
generated from MATLAB importing the data collected from the Real Time Control
System Workbench by opening the MATLAB Import Wizard according to Figure 10. This
allows data to be recorded and imported into the MATLAB workspace. Once the data has
been recorded, select Finish to save the data in a designated folder or folder created by the
user. Finally, the user can choose to open the file to which the save data has been generated
into a graph such as the pendulum angle vs Time graph according to Figure 11.
Page 13 of 42
RMIT Classification: Trusted
Figure 10: Import Wizard to generate recorded data from MATLAB Real Time Control System Workbench (Left)
Figure 11: Generated Graph from recorded data set (Right)
Figure 13 is the overall recorded data. Within Figure 13, the graph shows the steady state error of
the system, which is 1.5 degree or 0.83% and in Figure 14 shows the settling time after disturbance
is given, it’s estimated to be 2.3 seconds.
Page 14 of 42
RMIT Classification: Trusted
b) Operation Mode with Modified Parameters with entered gains (𝑲𝒑 , 𝑲𝑰). Time response
of the system and estimation of settling time and steady-state error (unit: %).
This section will be similar to section 5.3.2 in which the modified parameters had been entered with
Kp: 1800, Ki = 12960 and Kd = 62.5 for the pendulum. The Rotor parameters include: Kp = 260, Ki
= 2 and Kd = 22 which generates the graph according to Figure 15. The detailed graph for the
Modified parameters is shown in Figure 16 and Figure 17 where the steady state error is 0.56% and
settling time of 6.5 seconds.
Figure 16: Steady State error in Modified Mode Figure 17: Settling Time in Modified Mode
Page 15 of 42
RMIT Classification: Trusted
Conditions of Routh Hurwitz: Routh Hurwitz can only and only be applied if our characteristic
equation satisfies 2 conditions: No coefficient is missing, and every coefficient must be the same sign.
If it’s a fourth order equation, there must be 5 coefficients in that equation, corresponding to x 4, x3,
x2, x1, x0. Those 5 coefficients must have the same sign, either plus or minus, absolutely cannot be
mixed even with only 1 plus or minus. If one of these conditions are violated, Routh Hurwitz is invalid
as it is already known that system will have at least 1 open right hand side pole, which means unstable,
and the system needs changes. If all things go well, solving Routh Hurwitz will give us a whole range
of possible gains to ensure stability of the system, it is possible to choose any to experiment with, but
Routh Hurwitz is only for testing stability. For system requirements, Root Locus must be combined
as stable gains from Routh Hurwitz might not pass the requirements like overshoot, settling time, rise
time, etc. Pole zero cancellation, Root Locus: When plotting the Root Locus and do some
calculations, settling time, overshoot,.... will show up, then circle and narrow the region of gains that
give us the design specifications, then find the overlapped gains from both Routh Hurwitz and Root
Locus. Now stability and design requirements are satisfied. Plotting Root Locus, there are 10 total
rules, start by calculating the poles and zeros, put them all on an s-plane. If there are at least 1 pole
on the open right-hand side of the plane (not accounting the imaginary axis), our plant/system is
unstable, if there are 2 poles, all equal 0, which means double poles on the origin, then it is unstable.
If a pole overlaps a zero, it’s zero pole cancellation, and consider those 2 don’t exist anymore in the
Page 16 of 42
RMIT Classification: Trusted
Root Locus, in theory, this is handy as it can cancel unstable poles, making the system looks stable
on papers. In practice, zero pole cancellation does not work, your system will still be unstable unless
you change your system.
The basic concepts of control theory: Any system can be represented by transfer functions (G),
derived from Newton-Euler formulas (SISO) or Lagrange (MIMO), block diagrams and the PID
controller can be represented by the following formula. In most cases use the Laplace transform
𝐾𝑖
version of all the functions, this includes PID: 𝐾𝑝 + 𝑠
+ 𝐾𝑑 𝑠 .
Page 17 of 42
RMIT Classification: Trusted
Figure 19: Free body diagram of rotor looks from top down (left) and pendulum looks directly in front of us (right )
From above, distance from L/2 of inverted position to L/2 of other positions is the opposite of distance
from rotor in rotation to rotor when pendulum is inverted, this means consider 2 distances on the same
plane, then take small angle limit, then apply F=ma:
From the right free body diagram, only vertical component of mg, gravitational force is active, with
simple trigonometry the gravitational force acting on the pendulum is mgsin(theta). Use small angle
deviation and simplify to mg*theta. Here the friction force is due to motor motion of the system,
gamma multiply angular velocity. Now apply second law of Newton for rotational motion, since all
our distance, velocity and forces being considered are at L/2, and perpendicular to the pendulum,
multiply all forces to L/2 and add them all to get total tau needed for the system. According to the
second law, total torque also equals moment of inertia*angular acceleration of theta. The target,
pendulum, is why acceleration here is from theta. Also, friction is opposite to motion, so that will be
minus friction:
Irotor and Ipend are given, after rearranging and do Laplace transform, the transfer function of the
pendulum:
The best dynamic equation of the rotor after experimenting is 1/s2. This is had by applying PID and
𝑎
system identification to the known second order transfer function: 𝑠2 +𝑏𝑠+𝑐 with a = 𝜔𝑛2 , b = 2𝜁𝜔𝑛 , c
= 𝜔𝑛2 . However, this model will be changed to get the best transfer function for rotor, based on
experimentation. Stated in the document “Introduction_to_Integrated_Rotary_Inverted
_Pendulum_v3.pdf” referenced in this report, they concluded that the best rotor transfer function
Grotor is just 1/s2. Both Gpend and Grotor are unstable as they either contain right hand side poles
or double poles at the origin. Since dual PI controller or PI and PD controller will be tested, the
block diagrams for both cases are quite the same:
Page 18 of 42
RMIT Classification: Trusted
Simplify the block diagram further by making the inner loop of rotor a whole function:
The characteristic equation is in direct violation of Routh Hurwitz criterion, this means after adding
controller our rotor is unstable no matter what gains Kp Ki. Now multiply Trotor with Gpend to check
for stability of the plant before applying controller, obtain characteristic equation a(s):
Since Trotor is unstable with all gains value, it’s necessary to rely on the hardware and firmware not
allowing negative gains, so it is certain that Kirotor and Kprotor are all larger than 0. This is
conflicting with the characteristic equation of the plant above, coefficient of s0 is
–55.85Kirotor. This means to Routh Hurwitz this equation, Kirotor must be negative so the coefficient
can be positive and be eligible to check with Routh Hurwitz, this is a violation of Routh Hurwitz
already, and there will be positive poles from this uncontrolled plant no matter what. In other words,
there is no Kprotor and Kirotor to make the plant stable, unless overlapping the poles and zeros, which
Page 19 of 42
RMIT Classification: Trusted
will be talked later. To further test this, pick Kprotor and Kirotor, all larger than 0 to check for positive
poles. After testing, the pattern is quite clear, the plant poles have at least 2 positive poles, which
means unstable. Adding a PI controller to control this plant might be the solution, now with every
block considered, obtainthe close loop equation:
Figure 22: Root locus with Kirotor = Kprotor =50, Kipend = Kppend = 1
It is clear that the poles will not go into the left region by any means, the trajectory of the 2 complex
positive poles are upwards to infinity, they don’t lead into the left-hand region at all. There is also a
positive real pole, pulling this pole to the origin to get zero pole cancellation to see where the other
2 positive poles will go is necessary. The gain to do this is always very high but the step response is
still unstable. Since gain is high, the oscillation and overshoot are also high. If gains are above 1e12,
Page 20 of 42
RMIT Classification: Trusted
the design is not good as the pendulum only allows input that high, not higher. Changing Kirotor and
Kprotor to different values like Kirotor=100, Kprotor=50 and vice-versa, the pattern is clear, and are
all very similar to Kirotor = Kprotor = 50 case, the positive complex poles do not move into the
negative region at all, their trajectories are all travelling on the right hand side, one real positive pole
on the right of the zero at the origin, still requiring large gains to achieve zero pole cancellation. After
a while of tuning Ki Kp for dual PI controller design, the unstable pattern and Root Locus pattern
repeat themselves, it can be concluded that PI PI controller has poor performance, always lead to
unstable response and gains get unrealistic very fast. In the following section, PD controller for rotor
will be used, keeping PI for pendulum and assess the performance. Since PI PI has already failed the
stability test regardless of what gains input, there is no need to check for performance specification.
One thing to note is after experimenting, increasing gains to billions pulls the positive real pole to the
origin, but there are still 2 positive complex poles that will only stay outside of the right side no matter
what gains, which is unstable (figure 23). Adding a lead lag compensator then gains to the billions or
even trillions to cancel the real positive pole actually stabilized the system. These will be listed in the
appendix.
Figure 23: Root locus with Kirotor = Kprotor =50, Kipend = Kppend = 9.44e27, no lead or lag compensator
Figure 24: Block diagram of rotor only (left) and simplified (right)
Page 21 of 42
RMIT Classification: Trusted
1 𝐺𝑟𝑜𝑡𝑜𝑟
𝐾𝑟𝑜𝑡𝑜𝑟 = 𝐾𝑝 + 𝑠𝐾𝑑 (PD controller) and 𝐺𝑟𝑜𝑡𝑜𝑟 = 𝑠2 ⇔ 𝐺𝑐𝑙 𝑟𝑜𝑡𝑜𝑟 = 1+𝐺𝑟𝑜𝑡𝑜𝑟 ⋅ 𝐾𝑟𝑜𝑡𝑜𝑟
1
𝑠2 1
= 𝑇𝑟𝑜𝑡𝑜𝑟 = 1 = 𝑠2 +𝐾 𝑠 +𝐾𝑝
=> d(s) = 𝑠 2 + 𝐾𝑑 𝑠 + 𝐾𝑝
1+ 2⋅(𝐾𝑝 +𝑠𝐾𝑑 ) 𝑑
𝑠
𝑠2 1 𝐾𝑝
𝑠1 𝐾𝑑 0
𝑠0 0
𝐾𝑝 . 𝐾𝑑
𝑏1 = = 𝐾𝑝
𝐾𝑑
The system will be stable if it is satisfied the condition: 𝐾𝑑 > 0 𝑎𝑛𝑑 𝐾𝑝 > 0
Figure 25: Plotting from Simulink to prove the range above, with Kd = Kp = 1; Settling time = 9.5s; steady- state error ess = -0.0375%
Nevertheless, Routh Hurwitz method is impossible to look for the range for Kp Ki controller of
pendulum. If the value of Kp and Kd of rotor are kept as variables, or replaced with values >0, the
Kp and Ki of pendulum will be complicated equations to solve the gain of pendulum controller as
multivariable 4th order equations or higher are obtained. Therefore, in this case, the control system
designer tool is used to tool Kp and Ki of pendulum to find the range and even the specific value of
both gain to control the system stably.
After the range of Kp and Kd for rotor is found, now randomly pick the both value of Kp and Kd
equal 50. Tuning, trial and errors for all other values of Kp Kd >0 will always return 1 positive real
pole in the plant’s characteristic equation, so just pick 50. This also means instability:
Page 22 of 42
RMIT Classification: Trusted
Solve the 4th order equation in the denominator to get the poles, there is 1 positive value equal 7.288.
Therefore, this close loop is unstable, it’s mean that this system needs a controller, in our case PI.
Figure 27: System tuned to stability after adding PI controller for pendulum, moving positive poles to a far zero requires large gains
Now, the system is simulated in the control system designer tool which is added the PI controller to
find the desire of range for Ki Kp of pendulum control using Kp = Kd = 50 (rotor). To tune it to stable
response, that positive pole should be dragged to the zero = 0 at the origin. After that, all poles will
locate at open right half plane as the positive pole now overlaps on the zero, which means zero pole
cancellation. After the step response shows stability, the gains of pendulum control system are found
to be exceedingly big (Kp = Ki = 7.0124e09). Therefore, the gains were tuned continuously until the
minimum gains were found: The minimum gains for Ki and Kp are equal each other and equal 1.7e09
Page 23 of 42
RMIT Classification: Trusted
(with Kp Kd of rotor equal 50) and the range is from 1.7e09 and above to maintain stability and pass
design requirements. If the values of Kp Kd are changed then the range and values for stability of PI
for pendulum must also change, but with Kp = Kd the gains of PI will be lower than other cases.
Zooming into the step response, the overshoot is nearly 100%, the specific value is 99.997%. The
steady state error is around 0.002% and settling time is only 0.25 seconds, the full time from initial
value 0 to steady state value 1.0002 is a total of 0.4 seconds. This means stability is achieved and
passed the 2 design requirements: Settling time less than 6 seconds and 0 steady state error. Other
simulations involving lead and lag compensator were also carried out and using lead lag controller
brings better results in PI PI model than PD PI models. In general, using lead lag for PD PI model is
not good, in some cases bring even worse results than using P and I controller alone while some cases
the results are the same, there is no improvement. It is best, for PD PI model, just use PI PD controller
without compensators. These tests are listed in the appendix of this report.
Page 24 of 42
RMIT Classification: Trusted
Retrace to PD PI controller of pendulum case, when the gains are put in the pendulum, the real results
are completely different from simulation. The overshoot is much less than simulated, but settling time
was around 8 seconds and there seems to be no steady state error, visually. However, the system is
completely unstable. When the gains were input, the pendulum rose slowly, taking 9 seconds in total
from suspended to inverted position. It stayed inverted perfectly for only 4 or 5 seconds before
shaking violently, reflecting the massive gains that were made, then stopped working. This is an issue
requiring a different controller to fix or change gains, or considering other disturbance parameters
like noise or natural physical factors is needed.
Page 25 of 42
RMIT Classification: Trusted
The Ziegler-Nichols PID tuning technique involves two approaches. When the plant's response to a
unit-step input yields an S-shaped curve without any overshoot, the first method is applied. The
second technique looks for instances in which, for the given Kp, the output will oscillate
continuously. The recommended approach is to start with Ki and Kd set to zero and then gradually
increase Kp until the output response produces a continuous sine wave that is neither amplified nor
damped. The output sine wave will be damped at values below Kp critical and amplified at values
above Kp critical. Kp will be regarded as the critical value. Once Kp critical has been determined, the
oscillation period must be measured, and it is defined as the critical period (Tc). The PID gains for
the system will be obtained by applying the critical gain (Kcr) and critical period (Tc) into Table 2
[10], to find out the gain values with respect to the desired control type.
PID controller gains for Inverted-Pendulum using the Ziegler-Nichols tuning method:
Step 1: Operating procedure will be included in section 5.2. We work on real system response to find
out the gains for the PID.
Step 2: Activating the inverted pendulum PID controller gains, keeping the rotor PID gains as default
mode. Entering the gain for the pendulum following Ziegler-Nichols tuning procedure.
Step 3: Finding out the critical value by setting the Ki and Kd to be zero and adjusting the critical
value (Kcr) until we can get the oscillation function for the pendulum response graph. After some
adjustment, we come up with the critical value Kcr= 300000 with critical value Tc = 0.27777s.
Step 4: Applying the critical value into Table 2 to get the gains for PID control type. Which Kp
=0.6Kcr =180000, Ki = 2Kp/Tc= 1296000, Kd= Kp*Tc/8= 6249.8.
Page 26 of 42
RMIT Classification: Trusted
Step 5: After simulations, based on the system’s responses, after some try and error. We finally
obtained the two set of PID gains including pendulum angle controller and pendulum, rotor angle
control.
Pendulum controller: basically, the gain of the rotor will be kept being as the default mode, so only
the pendulum angle to be zero under disturbance. After adjustments to meet the requirements for task,
the dual PID controllers will be selected as:
Pendulum and Rotor Controllers: To keep both the pendulum and the rotor angle controller at zero
position in case of disturbance, modifications will be performed to both. So, the rotor and the
pendulum remain in the zero position after that dual PID alteration.
Page 27 of 42
RMIT Classification: Trusted
With the exact same gain attained by using Zeigler Nichol’s method, the pendulum responds
aggressively, and the rotor angle control gains are too small to compensate the responds of the
pendulum controllers, which cause the system to fall quickly due to reaching max rotor angle. The
above picture shows the time respond of the system. Pendulum angle can balance and oscillate
between -2.5 and 2.5 degrees; however, the system is unable to maintain in the upright position so
data can’t be recorded in Matlab interface. Also, rotor control is noticeably higher than when the
system was still running in default mode (first 5 seconds). Therefore, the PID gains are scaled down
by 100.
Figure 30: Steady State time response in workbench Figure 31: General time response
After scaling down the gains, the oscillation greatly reduces, and the system can balance for a long
time because the rotor gain can provide more control over the pendulum gain so the rotor angle
doesn’t exceed the max value. Plotting the data in Matlab, the system is shown to have a maximum
Page 28 of 42
RMIT Classification: Trusted
0.5 degree or 0.33% steady state error. When disturbance is given, the settling time is approximately
25 seconds. However, the rotor angle damping is still not enough to compensate higher disturbance.
With detailed tuning process listed in appendix, the gain is fined tuned to:
Pendulum:
Kp=1800, Ki=12960, Kd=62.5
Rotor:
Kp=260, Ki=2, Kd=22
Figure 33: Steady State of the final gain Figure 34: System’s response with disturbance
Page 29 of 42
RMIT Classification: Trusted
As shown in the above figure, the steady state error is oscillating between 1 and -1 which is
approximately 0.56%. When disturbance is given at time = 77sec, the system settles at time = 83.5
seconds, so the settling time is calculated to be around 6.5 seconds.
Based on the real system, there is a noticeable oscillation due to high rotor kd, to reduce or eliminate
this oscillation, kd can be reduced from 22 to 20, however settling time will be the tradeoff.
Figure 32: Steady State when kd is 20 Figure 33: Time response of the system to disturbance
The above is the effect of changing the rotor kd gain to 20. The steady state error oscillates between
-0.5 to 0.5, or 0.27%, which is half of the steady state error when rotor kd is 22. However, the settling
time increased. When disturbance is given at time = 66 sec, the pendulum settles at time = 87, which
is 21 seconds in total. The team decided to finalize with rotor kd = 22, although the steady state error
is a bit higher, the settling time is much shorter.
Page 30 of 42
RMIT Classification: Trusted
The default mode has a steady state error of 1.5 degrees or 0.83%, and a settling time of about 2.3
seconds when disturbance is given. At the same time, our gain has 1 degree, or 0.56% steady state
error with the settling time of 6.5 seconds. Based on the two data, default mode has much better
performance in terms of handling the disturbances, although our gain can also handle serval
disturbances, the settling time is still longer than the default mode.
Looking directly at the physical system, the default gain doesn’t have any noticeable oscillation
compared to the designed gain because the default rotor gain is much lower. With that lower rotor
gain, the default system’s rotor is drifting a lot while balancing the pendulum, so every disturbance
can cause the rotor to drift. If rotor settling time is a design constraint, our design gain will be superior,
however, if the design specification mostly focuses on settling time, the default gain will be a better
option.
Page 31 of 42
RMIT Classification: Trusted
For task 5, This task is a chance for our team to illustrate and gain deeper understanding about the
effects of the PID gains on the system response. With single PID control (pendulum control) obtained
from the Ziegler-Nichols tuning method. The pendulum will only be inverted for a short amount of
time, then it starts to shake and suspend. We have tried with multiple pendulum’s gain sets, but the
results seem to be the same. With dual PID control (pendulum and rotor control), after some
adjustment, we obtained the two sets of PID as shown above. The system operates better and satisfy
the requirement for the task. Comparing to the default mode, our steady state error is larger, but the
settling time is shorter. The application will perform even better with rotor gains modification
included, then we can control both pendulum and rotor angle. With that specification, we can utilize
it in further applications that requires the exact positions of pendulum as well as rotor. It is
recommended to develop a better control program so that the swing up and operation time can be
improved.
Page 32 of 42
RMIT Classification: Trusted
References
[1] STMicroelectronics. “Motor Control and Control Systems.” (accessed January 13, 2024).
[Online] ST life augmented. Available:
https://www.st.com/content/st_com/en/campaigns/educationalplatforms/motorcontrol-edu.html
[2] STMicroelectronics. “Firmware for STEVAL-EDUKIT01 evaluation kit for education on motor
control and control systems.” (accessed January 13, 2024). [Online] ST life augmented. Available:
https://www.st.com/en/embedded-software/stsw-edukit01.html?rt=db&id=DB4164
[3] MPS. “Stepper Motors Basics: Types, Uses, and Working Principles.” (accessed January 13,
2024). [Online] MPS. Available: https://www.monolithicpower.com/en/stepper-motors-basics-
types-
uses#:~:text=Due%20to%20their%20internal%20structure,motor%20control%20is%20pretty%20si
mple.
[4] Encoder Products Company. “What is an encoder?” (accessed January 13, 2024). [Online]
Encoder Products Company. Available: https://www.encoder.com/article-what-is-an-
encoder#:~:text=Encoders%20convert%20motion%20to%20an,count%2C%20speed%2C%20or%2
0direction.
[5] University of Michigan. “Inverted Pendulum: PID Controller Design.” (accessed January 13,
2024). [Online] Control Tutorials for MATLAB & SIMULINK. Available:
https://ctms.engin.umich.edu/CTMS/index.php?example=InvertedPendulum§ion=ControlPID
[6] STMicroelectronics. “The Integrated Rotary Inverted Pendulum.” (accessed January 13, 2024).
[Online] ST life augmented. Available:
https://www.st.com/content/dam/AME/2019/Educational%20Curriculums/motor-
control/Introduction_to_Integrated_Rotary_Inverted_Pendulum_v2.pdf
[7] RMIT University. “Mini-Project: Stabilizing Control Design”. (accessed January 13, 2024).
[Online] rmit.instructure.com. Available:
https://rmit.instructure.com/courses/132214/assignments/885731
Page 33 of 42
RMIT Classification: Trusted
[8] University of Michigan. “Introduction: PID Controller Design”. (accessed January 13, 2024).
[Online] Control Tutorials for MATLAB & SIMULINK. Available:
https://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlPID
[10] ResearchGate. “In: Glow Discharges and and Tokamaks ISBN: 978-1-61668-352-8 Editor:
Sean A. Murphy.” (accessed January 13, 2024). [Online] ResearchGate. Available:
https://www.researchgate.net/publication/259962135_In_Glow_Discharges_and_Tokamaks_ISBN_
978-1-61668-352-8_Editor_Sean_A_Murphy
Page 34 of 42
RMIT Classification: Trusted
Appendix:
Page 35 of 42
RMIT Classification: Trusted
Figure 35: PI PI controller with lead-lag compensator, the pole of lead must be increased to 100 to be stable, below it will be marginally stable
Page 36 of 42
RMIT Classification: Trusted
Figure 36: PI PI controller with lead compensator, the higher the real pole of lead, the faster the response
Figure 37: PI for rotor, and a single lead compensator for pendulum
Page 37 of 42
RMIT Classification: Trusted
Figure 38: PI for rotor, and a single lag compensator for pendulum
Figure 39: PI for rotor, lead-lag compensator for pendulum, the settling time is above 30 seconds
Page 38 of 42
RMIT Classification: Trusted
Figure 40: PD for rotor, single lead compensator for pendulum, can only be marginally stable and unstable
Figure 41: PD for rotor, lag compensator for pendulum, can only be marginally stable and unstable, behaves almost exactly like the case of
PD rotor and single lead compensator above
Page 39 of 42
RMIT Classification: Trusted
Figure 42: PD for rotor, lead-lag compensator as controller, has a very poor performance like single lead or single lag controller, can only be
marginally stable or unstable
Figure 43: PD for rotor, PI and lead-lag compensator as pendulum controller, performance is like without lead-lag compensator, but the gains
P I for pendulum are even bigger to achieve stability
Page 40 of 42
RMIT Classification: Trusted
Figure 44: PD for rotor, PI and lead compensator as pendulum controller, performance isn’t an improvement from any above
Figure 45: PD for rotor, PI and lag compensator as pendulum controller, performance is similar to PI and lead-lag controller, nothing new
Page 41 of 42
RMIT Classification: Trusted
P 200, I 10, D 20 - improve a bit but not noticeable so we try to increase kp again
P 260, I 10, D 20 - the steady state error is difficult to remove if we want the settling time to be
short, so we will compensate the steady state error for short settling time by increase kd while
changing ki back to 2.
P 260, I 2, D 20 - the settling time improve a bit but still not acceptable so kd will be increase
P260, I 2, D 25 - it is shaking more aggressively at steady state so we will decrease it to 22
P260, I 2, D 22 - it is shaking less, but the settling time increase, we will keep this one because the
shaking seems less aggressive.
Page 42 of 42