Opening the book…
After completing this section, you will be able to:
- Describe the architecture of the MATLAB and Simulink simulation setup for model-based, state-feedback stabilizing control, with linearized model.
- Set up the simulation environment in MATLAB and Simulink for model-based tracking control, utilizing linearized model.
- Develop a simulation environment for model-based tracking control, using the nonlinear mini-Segway system model.
This section conducts three simulation studies. They are a model-based, state-feedback regulation with a linearized model; a model-based, cart speed tracking control (LQTI) with a linearized model; and a model-based, state-feedback cart speed tracking (LQTI) simulation with the nonlinear mini-Segway model.
First, we will study case of a model-based, state-feedback regulation with a linearized model, as shown in equations \ref{8.47}, \ref{8.48}, and \ref{8.51}. The simulation study is conducted in MATLAB/Simulink with the Simulink model shown in Figure 8.23. All the components in the Simulink model were introduced in the last section. The state feedback gain \(K_p=K_{cp}\) was provided in equation \ref{8.56}.
Figure 8.24 shows the simulation results with the state feedback gain designed in Section 8.3 and initial conditions of pendulum angle \(θ_p(0)=0.2\ rad/s\) and cart speed \({\dot{x}}_{cart}\left(0\right)=0\). We can see that the mini-Segway responses are much faster than these with the dual-PID control, with a response time about \(0.2\) second. Recall that the dual-PID case is about \(0.8\) second (see Figure 8.19). This is mainly because the model-based control utilizes all four-state information with consideration of the coupled pendulum and cart speed dynamics. Meanwhile, the dual-PID control uses only the cart speed and pendulum position feedback signal (two states) without considering the mini-Segway coupling dynamics. In Figure 8.19, negative derivative gain is used for the cart speed PID controller to improve coupling compensation. However, the dual-PID control strategy is still much slower than the model-based one due to coordinated control of model-based one.
Next, we will conduct the study with nonzero initial pendulum position \(θ_p(0)=0.2\ rad/s\) and cart speed \({\dot{x}}_{cart}\left(0\right)=0.2\ m/s\), where the turning command Turning_CMD is also set from zero to 0.2 volt at the second second with model-based state-feedback regulation. The simulation study is conducted with the Simulink model shown in Figure 8.23; all the model components were introduced in the last section.
We can see the simulation results shown in Figure 8.25; it has state feedback gain from equation \ref{8.56} in Section 8.3 and initial conditions of pendulum angle \(θ_p=\mathrm{0.2\ (rad)}\) and cart speed \({\dot{x}}_{cart}\mathrm{=0.2\ (m/s)}\). The mini-Segway responses in this case are much slower than the case with only one nonzero initial condition of pendulum angle \(θ_p\mathrm{=0.2\ }\left(\mathrm{rad}\right)\), which takes about \(1\) second for all states to go to zero. The responses in Figure 8.24 take only about \(0.2\) second to converge. This is mainly due to the coupled pendulum and cart speed dynamics, which slows down convergent speed.
Now we will use simulation to investigate a model-based, cart speed tracking controller with a linearized model. We will use the controller from equation \ref{8.63} designed in Section 8.3. The state feedback regulation controller from equation \ref{8.56} only stabilizes the mini-Segway, but it cannot be used to drive it. However, the controller designed in equation \ref{8.63} with cart speed error integration can. In fact, controller \ref{8.63}, which utilizes the control system architecture in Figure 8.13, has the same functionalities as these of dual-PID one. Figure 8.26 shows the Simulink model that implements the integral tracking control architecture from Figure 8.13. Here, the digital error integration is assumed to be calculated within the target microcontroller as a virtual state with coefficient \(K=0\). Control gain \(K_{cpi}\) in equation \ref{8.63} is used in Figure 8.26 as \(K_{pi}\).
We conduct our first simulation for this controller with a cart reference speed of \(\mathrm{0.2\ (m/s)}\), initial pendulum position of \(θ_p\mathrm{=0.2\ (rad)}\) and cart speed of \({\dot{x}}_{cart}=\mathrm{0.2\ (m/s)}\). Figure 8.27 shows the simulation results.
Compare the responses in Figure 8.27 with those in Figure 8.25. We can see that with a nonzero cart speed and pendulum position references (Cart_Spd_Ref \(=0.2\ m/s\)), system responses of the mini-Segway cart speed and pendulum position converged to zero with a little bit over one second from its initial condition of cart speed \({\dot{x}}_{cart}(0)=0.2\ (m/s)\) and pendulum position \(θ_p(0)=0.2\ (rad)\). This is very close to the regulation controller response shown in Figure 8.25. This response can be attributed to the same weight coefficients for cart position and speed, and pendulum position and speed used for designing the LQR controller. The only difference between the LQR and LQTI controller designs is the added cart speed error integration state, \(x_{ce}\), with the corresponding design weighting \(q_{55}={10}^4\). As a result, we can conclude that the LQTI design did not change the response convergence performance with additional tracking capability. At the second second, the turning command becomes 0.2 volt, leading to mini-Segway turning at a speed close to \(0.3\ (rad/s)\). From Figure 8.27, we can observe that the mini-Segway turning dynamics are independent of its pendulum and cart motion dynamics with the linearized evaluation model. As a result, state feedback uses only these pendulum and cart motion states for feedback control.
Now, we are ready to conduct a composite simulation with nonzero state initial conditions (\(θ_p(0)=0.2\ \left(rad\right)\ \mathrm{and}\) \({\dot{x}}_{cart}(0)=0.2\ (m/s)\)), zero reference signal for pendulum angle.
During the simulation, the mini-Segway cart speed reference Cart_Spd_Ref was changed from zero to \(0.1\ (m/s)\) at the second second, and then back to zero at the fourth second, where it stayed for the rest of the simulation. The turning command Turning_CMD was changed from zero to \(0.4\) volt at the third second and remained at \(0.4\) volt until to the end of simulation. From the simulation results shown in Figure 8.28, we can see that with zero mini-Segway cart reference speed, it takes about one second for both the pendulum angle and cart speed to converge back to zero, where control voltage is used initially to get cart speed to close to zero while the pendulum position has a large negative oscillation before converging to zero.
With the step cart-speed reference at the second second, it takes about \(0.8\) second for the pendulum position to converge to zero and for the cart speed to track its reference one at 0.1\(\ (m/s)\). Last, at the third second, the turning command of 0.4 volt was applied; the mini-Segway started turning and converged to a turning speed of about \(0.6\ (rad/s)\) with a response time of about 0.1 second. We can see that the turning motion does not affect the pendulum and cart speed motion. This is the main reason that both LQR and LQTI control designs in Section 8.4 can use the reduced-order model with the turning motion dynamics deleted. It simplifies the control design and results in a reduced dimension state feedback controller.
Next, use simulation to investigate the nonlinear Simulink plant model developed in Section 8.1 (see Figure 8.9). Here, we will use the cart speed tracking (LQTI) controller from equation \ref{8.63}, designed in Section 8.3. We will conduct two simulation studies. One studies the difference between the simulation results of linear and nonlinear models without the effect of Coulomb friction on both wheels. The other investigates the effect of the Coulomb friction with a nonlinear friction model (see Figure 8.8).
We can see in Figure 8.29 that the simulation environment with a nonlinear Simulink mini-Segway model is similar to the one with the linear Simulink model shown in Figure 8.26. The only difference is that the linearized model was replaced by the nonlinear Simulink model shown in Figure 8.8. As a result, no further discussion on the simulation environment will be provided. For the first simulation, we can compare the nonlinear simulation results (see Figure 8.30) with the linear results (see Figure 8.28). The simulation was conducted with the initial mini-Segway position of \(θ_p(0)=0.2\ \left(rad\right)\) and cart speed of \({\dot{x}}_{cart}(0)=0.2\ (m/s)\); reference cart speed varying from zero to \(0.1\ (m/s)\) at the second second and from \(0.1\ (m/s)\) back to zero at the fourth second; and cart turning changing from zero to \(0.1\ (volt)\) at the third second and from \(0.1\ (m/s)\) back to zero at the sixth second. The simulation environment is exactly the same as the results shown in Figure 8.28, but with the linear model replaced by the nonlinear one.
The nonlinear mini-Segway simulation results are shown in Figure 8.30 with cart speed, pendulum position, turning speed, and control inputs. Comparing these nonlinear results with the linear results from Figure 8.28, we can see that, with the same initial condition, the results are similar, with both pendulum angle and cart speed converging to zero within one second. At the second second, the cart reference speed changed from zero to \(0.1\ (m/s)\) and the cart speed converged to the reference value in about 0.6 second, similar to the linear case. However, the cart speed response of the nonlinear simulation is not as smooth. The main difference between linear and nonlinear simulation results occurs when the turning command of \(0.1\ (volt)\) is applied at the third second; the convergence rate is much slower than the linear case, but with larger turning speed.
Figure 8.31 shows the nonlinear simulation results, with the Coulomb friction block activated [32] (see Figure 8.8). In this simulation study the cart speed reference and turning command are the same as those in the previous study, along with the initial condition. With initial condition of the mini-Segway position of \(θ_p(0)=0.2\ \left(rad\right)\) and cart speed of \({\dot{x}}_{cart}(0)=0.2\ (m/s)\), both the cart speed and pendulum position converge to zero in one second. This is similar to both linear and previous nonlinear cases.
When the cart reference speed changed to \(0.1\ (m/s)\) from zero at the second second, the cart speed converged to the reference value in about 0.6 second smoothly. This is similar to the linear and nonlinear without Coulomb friction cases. However, the cart speed response of the nonlinear simulation with Coulomb friction is much smoother than the previous case without Coulomb friction. When the turning command of 0.1 (volt) is applied at the third second, we can see that the convergence rate of the turning speed is similar to the previous case without Coulomb friction. However, the coupling effect of cart speed and turning at the fourth second occurred with a slight dip of turning speed when the reference cart speed is set to zero from \(0.1\ (m/s)\). This is caused mainly by the added Coulomb friction. In fact, this effect can also be seen in the experiments.
Figure 8.32 compares the raw left wheel driving force with and without Coulomb frication modification. There is a certain difference between the unmodified and modified (with Coulomb friction activated) forces. Because the left and right wheel driving forces could be modified in slightly different ways due to the turning action, the mini-Segway turning motion could be affected by the cart speed variation.
Section Summary
This section conducts model-based simulations utilizing the model-based controller designed in Section 8.3. First, it investigates the LQR control strategy for state-feedback stabilization, utilizing mini-Segway cart position and speed, and pendulum position and speed. Then it studies state-feedback with integral cart speed tracking control, incorporating feedback of mini-Segway cart position and speed, pendulum position and speed states, and the tracking error state calculated internally in the LQTI controller. Last, the section investigates the model-based state-feedback LQTI controller designed in Section 8.3 in simulation with the nonlinear mini-Segway model developed in Section 8.1, with the added Coulomb friction model. For all the simulations, the state feedback controller is sampled at \(100\) Hz.
Section Keywords
Practice Problems
- Select one correct statement from the following list given the simulation initial condition of pendulum position of \(θ_p(0)=0.2\ \left(rad\right)\) and cart speed of \({\dot{x}}_{cart}=0.2\ (m/s)\).
- The model-based simulation results in Figure 8.28 indicated that the cart speed and pendulum position states converge to zero in about one second for both dual-PID and model-based LQTI controllers.
- The dual-PID control simulation results in Figure 8.21 indicated that the cart speed and pendulum position states converge to zero in about one second for both dual-PID and model-based LQTI controllers.
- Discuss why two reference signals (cart speed and pendulum position) are needed for the dual-PID control while only one reference signal (cart speed) is required for the model-based LQTI control.
- Compare the simulation results in Figure 8.28 and Figure 8.31 by utilizing the LQTI controller in equation \ref{8.63} for linear and nonlinear mini-Segway models, respectively. Select one correct statement from the following list.
- The linear simulation results in Figure 8.28 indicated that the mini-Segway turning motion can be affected by its driving motion.
- The nonlinear simulation results in Figure 8.31 indicated that the mini-Segway turning motion can be affected by its driving motion.
- The nonlinear simulation results in Figure 8.31 indicated that the mini-Segway turning motion cannot be affected by its driving motion.
- Design an LQTI controller with \(Q_{cpi}=diag\ \left[0.1,\ 10,\ 100,\ 0.1,\ {10}^4\right]\) and \(R_{cpi}=1\) utilizing the system model matrices defined in \ref{8.60}. Conduct a closed-loop simulation using the Simulink diagram in Figure 8.29. Then compare the simulation results with that from the LQTI controller designed using \(Q_{cpi}=diag\ \left[1,\ 1000,\ 100,\ 0.1,\ {10}^4\right]\) and \(R_{cpi}=1.\)
This page titled 8.6: Mini-Segway SiL Simulation Validation of Model-Based Controllers was last modified on Mon, 24 Aug 2026 21:09:21 GMT and is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Guoming Zhu (Co-DREAM OER) .
The book could not be loaded just now.