Sliding Mode Control Simulator Back
Control Engineering Simulator

Sliding Mode Control — VSC and Robustness

Apply SMC to a 2nd-order plant under disturbance. Adjust the sliding surface coefficient c, switching gain k, boundary layer width phi and disturbance amplitude d to feel robust convergence to the origin and chattering suppression.

Parameters
Sliding surface coefficient c
Switching gain k
Boundary layer width φ
Disturbance amplitude d

Plant: ẍ = -a·ẋ - b·x + u + d(t), a=1, b=2, x(0)=2, ẋ(0)=0, disturbance d(t)=d·sin(5t), dt=0.01, T=5s.

Results
Reach time t_reach
Settling time (2% band)
Chattering metric
Max |s| after reach
Phase plane and time response

Top: phase-plane (x₁, x₂) trajectory (blue) and sliding surface s=c·x₁+x₂=0 (green line). Bottom: time response x₁(t), x₂(t) and control input u(t).

Theory & Key Formulas

For the 2nd-order plant $\ddot x = -a\dot x - b x + u + d(t)$, define the states $x_1=x,\ x_2=\dot x$ and design a sliding surface.

Sliding surface $s$; $c$ is the positive coefficient that sets the surface slope:

$$s = c\,x_1 + x_2$$

Control law combining feedback linearization with a switching term; $k$ is the switching gain:

$$u = -k\,\mathrm{sign}(s) - c\,x_2 + a\,x_2 + b\,x_1$$

Chattering suppression via a boundary layer $\varphi$ (smoothing):

$$\mathrm{sign}(s)\;\longrightarrow\;\tanh(s/\varphi)$$

Sliding condition and on-surface dynamics:

$$s\,\dot s < 0,\qquad s=0\ \Rightarrow\ \dot x_1 = -c\,x_1$$

If $k$ exceeds the disturbance amplitude, the reaching condition is satisfied. Once on the surface, convergence is exponential with rate $c$.

What is the Sliding Mode Control simulator?

🙋
I keep hearing about sliding mode control — but what is actually "sliding"?
🎓
Roughly speaking, you carve a "slide" into state space ahead of time, and we call that slide the sliding surface. Look at the phase plane in the top half. The green dashed line is $s=c\,x_1+x_2=0$ — that's our slide. The blue trajectory starts at (2, 0), races straight toward the green line first ("reaching"), and then slides along it toward the origin ("sliding"). See it?
🙋
Yeah, I see it! But there's a disturbance acting on the system, and the trajectory still stops at the origin. Is this what people mean by "robust"?
🎓
Exactly. If the switching gain $k$ in $u=-k\,\mathrm{sign}(s)\,\cdots$ is larger than the disturbance, you reach the surface in finite time. Once you're on it, the dynamics become $\dot x_1=-c\,x_1$, so no matter what frequency or amplitude the disturbance has, you converge exponentially to the origin. That's why motor drives and power converters love SMC. Try cranking the "Disturbance amplitude d" slider up to 5 — the trajectory still nails the origin.
🙋
Cool! But the red line in the bottom plot (the control input u) is jagged. Is that chattering?
🎓
Right. $\mathrm{sign}(s)$ is discontinuous at zero, so the moment $s$ crosses zero the control snaps back and forth. Set the "Boundary layer width φ" to 0 — the chattering metric blows up. Then raise φ to about 0.1, and $\mathrm{sign}$ is replaced by $\tanh(s/\varphi)$, making the input smooth. The price is a tiny residual error at the origin, but on real hardware that trade is essential to prevent wear.
🙋
How do you pick the surface slope c? Bigger seems faster, right?
🎓
Good question. $c$ sets the on-surface time constant $1/c$, so larger does mean faster. But push $c$ too high and the reaching phase needs huge control effort, saturating the actuator. Try $c=10$ in the simulator and watch the u amplitude explode. The usual practice is to pick $c$ a bit below the mechanical bandwidth, and $k$ as your disturbance estimate plus margin.

Frequently Asked Questions

PID linearly combines the error, its integral and its derivative — intuitive to design and easy to tune. SMC instead carries a nonlinear "sign" switching term, and as long as the disturbance bound is known, robustness can be guaranteed theoretically. The downside is chattering that can wear out mechanical parts or power devices, which is why a boundary layer or higher-order SMC is used in practice. Think of PID for mild disturbances and SMC for parameter variation or strong disturbances.
To satisfy the reaching condition $V'=s\,\dot s<0$, $k$ is designed to exceed the upper bound of disturbance and model error: $k>|d|_\max+\eta$, where $\eta>0$ corresponds to the reaching rate margin. Pushing $k$ too high inflates the switching input and worsens chattering, so keep the margin minimal. If the disturbance bound is hard to estimate, an adaptive sliding mode that tunes the gain online is another option.
Inside $|s|<\varphi$, $\mathrm{sign}(s)\approx s/\varphi$ — the controller switches to a high-gain proportional law on the surface. Proportional control cannot fully cancel steady-state error, so an integrated or DC component of the disturbance leaves $s$ at a small offset. The error bound is proportional to $\varphi$, so you back-solve from your tolerance. Chattering vs. residual error is the classic trade-off. To wipe it out completely, use integral sliding mode (ISM) or super-twisting.
For 2nd-order systems the linear surface $s=c\,x_1+x_2$ is the most basic, but not mandatory. Higher-order systems often use $s=(\frac{d}{dt}+c)^{n-1}x$, and to target finite-time convergence you can pick nonlinear surfaces like $s=x_2+\beta|x_1|^{\alpha}\mathrm{sign}(x_1)$ (terminal SMC). Because the surface directly determines on-surface behavior, response time, overshoot and input constraints all matter.

Real-world applications

Robot arm trajectory tracking: Multi-joint robots have strong inertial coupling between joints and large payload variation, so model error is always present. Because SMC drives tracking error to zero given only an error bound, it is widely used in industrial robot trajectory control and in force-control modes. A boundary layer is typically added to spare the reducers from shock loads.

Power converters (DC-DC converters and inverters): The switching elements themselves embody "switching", so SMC and power electronics pair naturally. Fast voltage response and strong rejection of sudden load changes have made SMC standard in PV inverters and EV motor drives. A boundary layer is usually used to cap the switching frequency.

Aerospace attitude and missile control: Aerodynamic coefficients vary strongly with speed and altitude, so gain-scheduled PID can struggle. SMC is insensitive to parameter variation, and is researched and deployed in terminal missile guidance and reentry vehicle attitude control.

Automotive ABS, ESC and electric power steering: Automotive control suffers from large uncertainty in road friction, making it a great match for SMC. Wheel slip ratio tracking in ABS, yaw rate SMC in ESC and assist torque SMC in EPS have all been studied and put into production, where robustness directly translates into safety.

Common misconceptions and pitfalls

The most common misconception is to think "the bigger k, the better." In theory the reaching condition is satisfied as long as $k$ exceeds the disturbance, but oversized $k$ inflates input amplitude, aggravates chattering and wears out or destroys the actuator. Try setting $k=20$ and $\varphi=0$ in the simulator — the chattering metric goes astronomical. Practice is to keep $k$ at roughly 1.5–2× the estimated disturbance bound and absorb the rest of the robustness budget with a boundary layer or adaptive law.

The next pitfall is to assume that once you add a boundary layer φ you have "near-ideal SMC." The instant you introduce φ, strict invariance is lost, and you are left with a finite residual error and low-frequency oscillation. Raise φ to 0.5 in the simulator and a small wobble appears around the origin. Whether that error is acceptable depends on the application: for precision positioning, the practical answer is to layer integral sliding mode (ISM) or super-twisting on top. Treat "boundary layer = trade-off knob," not "boundary layer = chattering cure."

Finally, note that this tool shows the ideal SMC with perfectly known model. In real implementations the cancellation terms $a\,x_2 + b\,x_1$ carry model error, which adds to the effective disturbance. Real-system practice is to design $k$ including model error, or to derive an error bound from a system-ID nominal model. On top of that, discrete-time implementation caps the switching frequency at the sampling rate, which is itself a chattering source. A continuous-time simulation that looks great can behave very differently at a 1 kHz sample rate.