# Performance Improvement of an NMP Mini Segway Using Sample and Hold Inputs
## 6 Experimental Implementation
### Outer-Loop Controller Tuning  
For each stabilizing \(G_{Rc}\) designed for the inner-loop LQR\({}_{c}\), the outer-loop LQR\({}_{d}\) controller was tuned accordingly to achieve the optimal performance. A \"baseline\" LQR\({}_{d}\) was designed first using weighting matrices \(Q_{di}=\text{diag}[100\ 0.1\ 80\ 0.1\ 10\ 0.01]\) and \(R_{di}=\text{diag}[1\ 1]\). With the feasible LQR\({}_{c}\) controllers, the dual-loop feasible regions are shown in Figure 10. The smallest feasible sampling periods are 0.1136 s, 0.1162 s, and 0.1184 s for \(G_{Rc}\), equal to 0.8, 0.9, and 1.0, respectively. Since the feasible regions of the \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \(G_{Rc}\) & **0.6** & **0.7** & **0.8** & **0.9** & **1.0** & **1.1** \\ \hline \(|x_{cart}|_{avg}\) (mm) & 19.35 & 15.32 & 18.63 & 12.17 & 16.58 & \(\infty\) \\ \(|\theta_{p}|_{avg}\) (mm) & 4.31 & 2.56 & 1.08 & 0.85 & 0.89 & \(\infty\) \\ \(|v|_{avg}\) (V) & 3.96 & 2.44 & 1.16 & 1.00 & 1.10 & \(\infty\) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Mean absolute values of cart displacement and control voltage with inner-loop LQR\({}_{c}\) only. Figure 9: LQR\({}_{c}\) tuning data plot. closed-loop systems with SPSHI in Figures 4 and 10 are barely changed, the SHI parameter selection remains unchanged at \(p=0.2\) and \(\delta=0.2\) s.  
For the purpose of tuning, \(G_{Rd}\) was introduced so that \(R_{d}=G_{Rd}R_{di}\), and \(G_{Rd}\) ranges from 0.3 to 1.1 with an increment of 0.2 while the \(Q_{di}\) matrix is fixed. Smaller \(G_{Rd}\) values, such as 0.1 and 0.2, were tested, but the corresponding LQR\({}_{d}\) gains were too large for the MS system, resulting in an unstable closed-loop MS system. From the system bandwidths of 1.3 Hz for the cart displacement and 33.9 Hz for the body pitch angle, the outer-loop controller sampled at 5 Hz can only cover the cart displacement performance. Therefore, control gain tuning is used to minimize cart oscillation magnitude, and the results for each \(G_{Rc}\) are shown in Table 3 below. It is clear that when \(G_{Rc}=0.9\), the best improvement was achieved, where the oscillation magnitude with inner-loop control only was 12.17 mm and dual-loop was 3.83 mm, a 68.4% improvement. It was 28.3% and 60.0% for \(G_{Rc}=0.8\) and 1.0, respectively). The outer-loop tuning result for \(G_{Rc}=0.9\) is shown in Figure 11.  
The experimental results in Figure 11 are divided into six segments. Segment I corresponds to the responses with inner-loop controller only from the previous section and used as the baseline controller. Between segments II and VI, \(G_{Rd}\) increases from 0.3 to 1.1 with a 0.2 increment. The dual-loop experimental results with SPSHI in Figure 11a show that the outer-loop LQR\({}_{d}\) with \(G_{Rd}=0.3\) reduces the cart displacement magnitude significantly. However, the cart body pitch angle (shown in Figure 11b) is barely affected due to the aforementioned inadequate control sample frequency. From segments II to VI, with increased \(G_{Rd}\), the cart displacement magnitude increases while the SHI control effort decreases. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline  & \multicolumn{5}{c}{\(\mathbf{G_{Rd}}\) **Value**} \\ \cline{2-7}  & **N/A** & **0.3** & **0.5** & **0.7** & **0.9** & **1.1** \\ \hline \(|x_{cart}|_{avg}\) (mm) & 18.83 & 13.50 & 15.46 & 15.64 & 16.89 & 15.51 \\ \(\mathrm{G_{Rc}}=0.8\) & & & & & & \\ \(|x_{cart}|_{avg}\) (mm) & 12.17 & 3.85 & 5.39 & 6.29 & 6.84 & 7.36 \\ \(\mathrm{G_{Rc}}=0.9\) & & & & & & \\ \(|x_{cart}|_{avg}\) (mm) & 16.58 & 6.63 & 8.00 & 10.55 & 12.07 & 13.29 \\ \(\mathrm{G_{Rc}}=1.0\) & & & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Mean absolute values of outer-loop LQR\({}_{d}\). Figure 10: The feasible region of the closed-loop MS system with SPSHI. The overall control, \(u\), and SPSHI control \(\omega\) are shown in Figure 11c,d, respectively. The SPSHI signal is 0 in segment I since only LQR\({}_{Rc}\) is active. The outer-loop is activated, starting from segment II.