--- id: wiki-2026-0508-control-systems-engineering title: Control Systems Engineering category: 10_Wiki/Topics status: verified canonical_id: self aliases: [control-systems, feedback-control, PID-control] duplicate_of: none source_trust_level: A confidence_score: 0.9 verification_status: applied tags: [control-systems, pid, mpc, feedback] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: python framework: do-mpc/control --- # Control Systems Engineering ## 매 한 줄 > **"매 control 의 매 measure → compare → actuate 의 closed loop"**. 매 PID (1922 Minorsky) 가 매 95% industrial loops, 매 MPC (Model Predictive Control) 가 매 multivariable + constrained problems 의 dominant. 2026 의 매 RL-augmented control + neural ODEs 가 매 emerging — 매 Boston Dynamics, Tesla Autopilot, NVIDIA GR00T 가 hybrid. ## 매 핵심 ### 매 building blocks - **Plant** — 매 controlled system (motor, reactor, drone). - **Sensor** — 매 measurement (encoder, IMU, thermocouple). - **Controller** — 매 algorithm (PID, MPC, LQR). - **Actuator** — 매 output (PWM, valve, voltage). - **Reference / setpoint** — 매 desired state. ### 매 stability - **Open-loop**: 매 simple, 매 no feedback — 매 disturbance 에 fragile. - **Closed-loop**: 매 feedback — 매 disturbance reject + setpoint track. - **Stability criteria**: Routh-Hurwitz, Nyquist, Bode (gain margin > 6 dB, phase margin > 45°). ### 매 controller spectrum 1. **Bang-bang** — 매 thermostat. 2. **PID** — 매 95% loops. 3. **State-space (LQR / pole placement)** — MIMO linear. 4. **MPC** — 매 constrained, predictive. 5. **Adaptive / gain scheduling** — 매 nonlinear plants. 6. **RL / learned policy** — 매 high-dim, 매 simulation 의 train. 7. **Robust H∞** — 매 worst-case guarantees. ## 💻 패턴 ### Discrete PID with anti-windup ```python class PID: def __init__(self, kp, ki, kd, dt, u_min, u_max): self.kp, self.ki, self.kd, self.dt = kp, ki, kd, dt self.u_min, self.u_max = u_min, u_max self.i, self.prev_e = 0.0, 0.0 def step(self, setpoint, measurement): e = setpoint - measurement self.i += e * self.dt d = (e - self.prev_e) / self.dt u = self.kp*e + self.ki*self.i + self.kd*d u_clamped = max(self.u_min, min(self.u_max, u)) # 매 anti-windup: 매 saturate 시 integrator 의 back-calc if u != u_clamped: self.i -= (u - u_clamped) / self.ki if self.ki else 0 self.prev_e = e return u_clamped ``` ### Ziegler-Nichols 의 tune ```python def ziegler_nichols(Ku, Tu, kind='PID'): if kind == 'PID': return dict(kp=0.6*Ku, ki=1.2*Ku/Tu, kd=0.075*Ku*Tu) if kind == 'PI': return dict(kp=0.45*Ku, ki=0.54*Ku/Tu, kd=0) ``` ### State-space LQR (CartPole) ```python import numpy as np from scipy.linalg import solve_continuous_are A = np.array([[0,1,0,0],[0,0,-mp*g/M,0],[0,0,0,1],[0,0,(M+mp)*g/(M*l),0]]) B = np.array([[0],[1/M],[0],[-1/(M*l)]]) Q = np.diag([1, 1, 10, 10]); R = np.array([[0.1]]) P = solve_continuous_are(A, B, Q, R) K = np.linalg.inv(R) @ B.T @ P u = -K @ x # state feedback ``` ### MPC with do-mpc ```python import do_mpc model = do_mpc.model.Model('continuous') x = model.set_variable('_x', 'x', shape=(2,1)) u = model.set_variable('_u', 'u') model.set_rhs('x', np.array([[x[1]],[u - 0.1*x[1]]])) model.setup() mpc = do_mpc.controller.MPC(model) mpc.set_param(n_horizon=20, t_step=0.1) mpc.set_objective(mterm=x[0]**2, lterm=x[0]**2 + 0.01*u**2) mpc.bounds['lower','_u','u'] = -5; mpc.bounds['upper','_u','u'] = 5 mpc.setup() ``` ### Kalman filter (state estimation) ```python def kalman_step(x, P, u, z, A, B, H, Q, R): x_pred = A @ x + B @ u P_pred = A @ P @ A.T + Q K = P_pred @ H.T @ np.linalg.inv(H @ P_pred @ H.T + R) x = x_pred + K @ (z - H @ x_pred) P = (np.eye(len(x)) - K @ H) @ P_pred return x, P ``` ### RL policy (PPO via stable-baselines3) ```python from stable_baselines3 import PPO import gymnasium as gym env = gym.make("Pendulum-v1") model = PPO("MlpPolicy", env, verbose=1) model.learn(total_timesteps=200_000) ``` ### Real-time loop (Linux PREEMPT_RT) ```python import time, os os.sched_setscheduler(0, os.SCHED_FIFO, os.sched_param(80)) T = 0.001 # 1 kHz while True: t0 = time.perf_counter() u = pid.step(setpoint, sensor.read()) actuator.write(u) while time.perf_counter() - t0 < T: pass ``` ## 매 결정 기준 | 상황 | Approach | |---|---| | 매 SISO + linear | PID | | 매 MIMO + linear | LQR / state-space | | Constrained + slow plant | MPC | | Nonlinear + simulator 가능 | RL (PPO, SAC) | | Safety-critical + uncertain | Robust H∞ / sliding mode | | 매 very fast (>10 kHz) | Hardware PID (FPGA) | **기본값**: PID with proper tuning + anti-windup; escalate to MPC if multivariable or constrained. ## 🔗 Graph - 부모: [[Cyber-Physical-Systems]] · [[Robotics]] - 변형: [[PID]] · [[MPC]] - 응용: [[Digital Twin]] - Adjacent: [[Kalman-Filter-and-State-Tracking|Kalman-Filter]] · [[Reinforcement-Learning]] ## 🤖 LLM 활용 **언제**: 매 controller derivation explanation, 매 transfer function manipulation, 매 tuning suggestion based on step response, 매 simulation script generation. **언제 X**: 매 actual real-time loop (deterministic 코드 / FPGA). 매 safety certification (formal verification 필요). ## ❌ 안티패턴 - **No anti-windup**: 매 actuator saturate 시 integral runaway → overshoot. - **Derivative on error (vs measurement)**: 매 setpoint step 시 derivative kick — derivative-on-PV 사용. - **Tune via trial-and-error only**: 매 system identification 의 사용 (Ziegler-Nichols, FOPDT fit). - **MPC without warm-start**: 매 solve time 의 explode — previous solution 의 reuse. - **No filter on derivative**: 매 measurement noise 가 D term 의 amplify. - **RL on real hardware first**: 매 sim-to-real 의 가야 — safe exploration. ## 🧪 검증 / 중복 - Verified (Åström & Murray "Feedback Systems", Skogestad MIMO control, do-mpc docs, IEEE control textbooks). - 신뢰도 A. ## 🕓 Changelog | 날짜 | 변경 | |---|---| | 2026-05-08 | Phase 1 | | 2026-05-10 | Manual cleanup — control engineering: PID, LQR, MPC, RL, Kalman |