## 4 Simulations
### Design Method  
In Section 4.2, a gain margin of 3.6 was obtained. Considering a constant stiffness \(K\), the maximum gain \(K_{pmax}\) that preserves stability is \(K_{p_{max}}\approx 3.6K_{p}\). Then, adding this maximum gain \(K_{p_{max}}\approx 3.6K_{p}\) into the design curves in Figure 6, one can obtain the gain that keeps the error within desired values while preserving stability. Figure 13 shows the design curves, including the stability margin bound \(K_{p_{max}}\approx 3.6(0.004211)\approx 0.0152\). The curves are obtained considering a value of \(M=0.00314\). The curves in Figure 13 can be used to find the control gain \(K_{p}\) that gives a desired force error. Assume the magnitude of the disturbance is provided, for example, \(4M\). Then, if one selects a control gain of \(K_{p}=0.013\), the expected steady-state error is \(e_{ss}\approx 0.96\) N (see the curve \(4M\) in Figure 13). Considering the disturbance of magnitude \(4M\) and the controller \(G_{c}=K_{p}+K_{d}s\) with \(K_{p}=0.013\), the force control system is simulated. Figure 14 presents the disturbance and the resulting force error \(e\). Note that the force error \(e\) in Figure 14, when \(K_{p}=0.013\), corresponds to the value of \(e\approx 1\) in the curves of Figure 13.  
Since \(K_{p}=0.013\) is close to \(K_{p_{max}}\), a small increase in \(K_{p}\) can cause oscillations and instability in the system. The presented technique can be combined with root-locus analysis to make an adjustment of \(K_{p}\) to have a desired damping. Figure 15 presents the root-locus of the force control system, computed from the open-loop transfer function \(L(s)\) in Equation (7) with \(G_{c}=K_{p}+K_{d}s\) and using a second-order Pade approximation of \(G_{T}(s)\), i.e., \(G_{T}(s)=\approx\frac{N_{r}(sL)}{D_{r}(sL)}\), where \(N_{r}(sL)=\sum_{k=0}^{r}\frac{(2r-K)!}{k(r-K)! }(-sT)^{k}\), \(D_{r}(sL)=\sum_{k=0}^{r}\frac{(2r-K)!}{k(r-K)! }(sT)^{k}\), \(T\) is the value of the delay, and \(r\) is the order of the approximation (see [18]). Figure 15 contains three markers showing the critical gain value 6.3 (similar to the gain margin), the gain 3.08 corresponding to \(K_{p}=0.013\), and the gain value 0.231 corresponding to a damping factor of 0.7. Figure 13: Design method: steady-state error \(e_{ss}\) in terms of control gain \(K_{p}\) and ramp value \(M\), considering gain margin. Figure 14 presents the simulation when \(K_{p}\) is adjusted by the gain value 0.231, i.e., \(K_{p}=0.231\times 0.004422=9.9\times 10^{-4}\). One can see that the force error \(e\) has a damped response when \(K_{p}=9.9\times 10^{-4}\) but the value of \(e\) is bigger than the case when \(K_{p}\) is close to the gain margin value. Therefore, one can observe the compromise between force regulation and stability. Time-Varying Disturbances  
The design curves, such as those in Figure 5, for the case of time-varying disturbance are computed as follows. Considering the disturbance \(x_{d}(t)=0.01\sin(0.628t)\) and the controller \(G_{c}=K_{p}+K_{d}s+\frac{K_{i}}{s}\) with the gains presented in Table 1, Equation (6) can be used to obtained the curves presented in Figure 16. These curves are computed for a fixed frequency of 0.628 and different sinusoidal amplitudes (from 0.005 to 0.08). The horizontal axis represents the controller magnitude, and the vertical axis represents the deviation of the force from its desired value. Figure 14: Force error \(e_{ss}\) in presence of ramp disturbance and disturbance \(x_{d}(t)\). Figure 15: Root-locus analysis computed with \(L(s)\) in Equation (7). Bottom part: zoom-in around the origin. The simulation of the force control system with disturbance \(x_{d}(t)=\sin(0.628t)\) for different amplitudes (0.01, 0.02, 0.04, and 0.08) is performed, and the results are presented in Figure 17. Note that the deviation of the force \(f\) with respect to the reference \(f_{d}=50\) N corresponds with the deviation predicted by the curves in Figure 16 for the case \(K_{GM}=1\), since the control magnitude was not changed.