第二次作业 Homework 2

主动磁链到观测器型运动控制 From Active Flux to Observer-Based Motion Control

从统一电机模型到观测器速度控制——总扰动、观测器、前馈与三方权衡 From the unified machine model to observer-based speed control: total disturbance, observer, feedforward, and three-way tradeoffs.

相关内容:Lecture 2 + Lecture 3 Related: Lecture 2 + Lecture 3 截止时间:待定 Due: TBD

作业目标 / Objective

Lecture 2 中我们已经得到了统一 AC 电机模型:电磁转矩由 active flux 和 $q$ 轴电流产生,机械方程决定转速演化。Lecture 3 在此基础上继续向上走一层:把电机看成一个可控转矩源,研究如何用观测器 + 前馈提升速度控制性能。

$$T_e = \frac{3}{2}n_{\mathrm{pp}}\psi_{\mathrm{AF}}i_Q, \qquad J\dot{\Omega} = T_e - B\Omega - T_L$$

本次作业要求你从 Lecture 2 的转矩方程出发,推导出 Lecture 3 的观测器型速度控制框架,并解释跟踪、扰动抑制、噪声抑制之间的三方权衡。

为什么要做这一层抽象?
在电流内环足够快时,速度控制器不必直接关心每个绕组的微分方程,而是可以把电机等效成“转矩输入、速度输出”的对象。这样我们就能把负载变化、摩擦、参数失配全部打包成 total disturbance,再用观测器去估计并补偿它。

从统一电机模型到机械速度子系统 / From the Unified Machine Model to the Mechanical Speed Plant

1.1 从 Lecture 2 回到机械方程 / Back to the Mechanical Equation

回忆 Lecture 2 的两个核心关系:

$$T_e = \frac{3}{2}n_{\mathrm{pp}}\psi_{\mathrm{AF}}i_Q, \qquad J_s\frac{d\omega_{\mathrm{mech}}}{dt}=T_e-T_{\mathrm{load}}$$
Task 1.1
解释为什么在电流内环足够快时,速度控制器可以把电机近似看成“转矩输入、速度输出”的对象,而不必直接处理 $i_D,i_Q,\psi_{\mathrm{AF}}$ 的全部电磁动态。
在 Lecture 2 的机械方程基础上引入粘性摩擦 $B\Omega$,写出 PMSM 机械速度方程:$J\dot{\Omega}=T_e-B\Omega-T_L$。
定义 $\theta_m$ 为机械角度,$\Omega=\dot{\theta}_m$ 为机械角速度。将系统改写成一个以 $T_e$ 为输入、以 $(\theta_m,\Omega)$ 为状态的二阶机械子系统。

1.2 定义总扰动 / Defining the Total Disturbance

Lecture 3 不再把所有不确定性单独处理,而是把它们合并成一个标量扰动项。

Task 1.2
令 $b=1/J$,把 Task 1.1(b) 写成 $\dot{\Omega}=bT_e+d_n$ 的形式,给出 $d_n$ 的表达式,并说明它包含了哪些物理量。
若控制器实际输出的是转矩参考 $T_e^*$ 而不是精确的 $T_e$,并且控制器内部使用标称惯量 $J_n$,定义 $b_n=1/J_n$。推导 $$\dot{\Omega}=b_nT_e^*+d_{to}$$ 并写出 $d_{to}$ 的具体表达式。
定义 $k_b=b_n/b=J/J_n$。分别解释 $k_b=1,\;k_b>1,\;k_b<1$ 时的物理含义,并说明这三种情况对应什么样的惯量失配。
Key idea / 关键思想: 在控制器视角中,负载转矩、摩擦、惯量失配、转矩建模误差都可以被“打包”为一个总扰动 $d_{to}$。后续观测器要做的事,就是估计这个量。

观测器型速度控制律 / Observer-Based Speed Control Law

2.1 理想控制律与实际控制律 / Ideal vs Practical Control Law

定义速度跟踪误差为 $e_s=\Omega^*-\Omega$,并希望它满足一阶指数收敛规律:

$$\dot e_s=-k_{ps}e_s, \qquad k_{ps}>0$$
Task 2.1
利用 $\dot e_s=\dot{\Omega}^*-\dot{\Omega}$ 和 Part 1 的速度方程,推导理想转矩控制律 $$T_e^*=\frac{\dot{\Omega}^*+k_{ps}(\Omega^*-\Omega)-d_{to}}{b_n}.$$
说明为什么上式不能直接实现。进一步用估计值 $\hat{\Omega}$ 和 $\hat d_{to}$ 替代真实量,写出实际控制律。
利用 Lecture 2 的统一转矩方程 $$T_e=\frac{3}{2}n_{\mathrm{pp}}\psi_{\mathrm{AF}}i_Q,$$ 将转矩参考 $T_e^*$ 转换成 $q$ 轴电流参考 $i_Q^*$。指出在这一变换中为什么需要 active flux $\psi_{\mathrm{AF}}$(代码中记作 KA)。

2.2 三阶与四阶观测器 / 3rd- and 4th-Order Observers

编码器能直接测量的是位置,而不是速度和扰动。因此我们从 $\theta_m^{\mathrm{meas}}$ 出发构造观测器。

Task 2.2
写出三阶观测器的状态方程,状态取为 $[\hat{\theta}_m,\hat{\Omega},\hat d_{to}]$。说明每个状态的物理意义,以及位置误差 $e_\theta=\theta_m^{\mathrm{meas}}-\hat{\theta}_m$ 在观测器中扮演的角色。
写出四阶观测器的状态方程,状态取为 $[\hat{\theta}_m,\hat{\Omega},\hat d_{to},\hat p_{to}]$。说明新增状态 $\hat p_{to}$ 的含义,以及它为何能帮助跟踪“斜坡型”扰动。
若将三阶观测器的极点统一配置在 $s=-\omega_{ob}$,由 $(s+\omega_{ob})^3$ 推导 $\ell_1,\ell_2,\ell_3$;若为四阶观测器,由 $(s+\omega_{ob})^4$ 推导 $\ell_1,\ell_2,\ell_3,\ell_4$。
设计提示 / Hint: $\omega_{ob}$ 是观测器带宽。它越大,估计越快;但对测量噪声越敏感。Lecture 3 给出的经验规则是:$\omega_{ob}$ 通常取速度环带宽的 3 到 10 倍。

三条闭环通道与系统型别 / The Three Closed-Loop Channels and System Type

3.1 跟踪、扰动、噪声三条通道 / Tracking, Disturbance, and Noise

Lecture 3 的核心观点是:闭环输出不是由“一个性能指标”决定,而是由三条传递路径叠加得到。

Task 3.1
写出三通道分解公式 $$\Omega(s)=\Phi_r(s)\Omega^*(s)+\Phi_d(s)d_n(s)+\Phi_n(s)\big(-s\delta_p(s)\big).$$ 说明 $\Phi_r,\Phi_d,\Phi_n$ 分别代表什么物理意义。
解释为什么位置测量噪声 $\delta_p$ 在速度闭环中会以 $-s\delta_p$ 的形式出现。它与“从位置求导得到速度”之间有什么关系?
写出 Lecture 3 给出的统一表达式: $$\Phi_r(s),\quad \Phi_d(s),\quad \Phi_n(s)=1-s\Phi_d(s),$$ 并说明辅助传递函数 $G_3(s)$ 在分析中起什么作用。

3.2 扰动通道中的系统型别 / System Type in the Disturbance Channel

当 $k_b=1$ 时,扰动通道可以写成更简单的形式:

$$\Phi_d(s)\big|_{k_b=1}=\frac{G_3(s)}{\Delta_n(s+k_{ps})}$$
Task 3.2
解释为什么“观测器每多扩展一阶扰动状态,就相当于在扰动抑制通道中多引入一个积分器”。
对于三阶观测器,若 $G_3(s)\sim c_1 s$(当 $s\to 0$),说明为什么该系统是扰动通道上的 Type I,并指出它能无稳态误差抑制哪一类负载扰动。
对于四阶观测器,若 $G_3(s)\sim c_2 s^2$(当 $s\to 0$),说明为什么它对应 Type II,并指出它相对于三阶观测器额外能消除哪一类负载扰动的稳态误差。
Lecture 3 提出一个思考题:如果不用高阶观测器,而是在速度 PI 控制器中再串联一个积分器(PII),能否也获得更高的扰动型别?请从“三条通道同时受影响”这个角度讨论其代价。
提示 / Hint: 不要只写“Type I / Type II”的名称。你需要明确说明:什么是输入、什么是输出、终值定理分析的对象是什么、哪类扰动可以实现零稳态误差。

三方权衡、鲁棒性与实现映射 / Tradeoff, Robustness, and Implementation Mapping

4.1 噪声与抗扰的互补关系 / Complementarity of Noise and Disturbance

Lecture 3 给出了一个非常重要的互补约束:

$$\Phi_n(s)+s\Phi_d(s)=1$$
Task 4.1
解释上式为什么意味着“改善低频扰动抑制,必然在某些频率上恶化噪声抑制”。这里的“不可兼得”具体是指什么?
定性讨论观测器带宽 $\omega_{ob}$ 增大时,扰动估计速度、噪声放大、高频衰减之间会发生什么变化。
结合 Lecture 3 中对 $k_b$ 的分析,比较 $k_b>1$ 与 $k_b<1$ 时的典型表现:谁更容易出现超调和振荡?谁更容易暴露噪声?谁对低频抗扰更不利?

4.2 从数学到代码 / From Math to Code

Lecture 2 和 Lecture 3 的最终目标都是为了指导仿真实现与控制器编程。

Task 4.2
画出一个从 $\theta_m^{\mathrm{meas}}$ 到 $i_Q^*$ 的信号流程图,至少包含:位置测量、观测器、速度误差反馈、扰动前馈、转矩到电流换算这 5 个模块。
解释为什么 $$i_q^*= \underbrace{\text{PI feedback}}_{\text{tracking}} + \underbrace{\text{disturbance feedforward}}_{\text{rejection}}$$ 属于二自由度(2DOF)控制,而不是单一 PI 控制。
若让你在实际系统中二选一:采用三阶观测器还是四阶观测器?请给出一个工程化选择标准,说明你会如何综合考虑负载变化类型、编码器噪声水平和参数失配风险。
完成本次作业后,你应该能回答:
从 Lecture 2 到 Lecture 3,电机控制从“写出统一电机 ODE”走到了“如何围绕这些 ODE 构造一个更强的速度控制器”。如果说 Lecture 2 解决的是“对象是什么”,那么 Lecture 3 解决的是“如何利用对象模型去抗扰、去估计、去折中”。

Homework 2 in English

In Lecture 2, we already obtained the unified AC motor model: electromagnetic torque is generated by active flux and the $q$-axis current, while the mechanical equation determines the evolution of rotor speed. Lecture 3 moves one layer higher on that basis: it treats the motor as a controllable torque source and studies how observer + feedforward can improve speed-control performance.

$$T_e = \frac{3}{2}n_{\mathrm{pp}}\psi_{\mathrm{AF}}i_Q, \qquad J\dot{\Omega} = T_e - B\Omega - T_L$$

This homework asks you to start from the torque equation in Lecture 2, derive the observer-based speed-control framework in Lecture 3, and explain the three-way tradeoff among tracking, disturbance rejection, and noise suppression.

Why introduce this abstraction layer?
When the current inner loop is sufficiently fast, the speed controller no longer needs to care about the differential equation of each winding directly. Instead, the motor can be approximated as a plant with torque input and speed output. Then load variation, friction, and parameter mismatch can all be packed into a single total disturbance, which is estimated and compensated by an observer.

Part 1. From the Unified Machine Model to the Mechanical Speed Subsystem

1.1 Back to the Mechanical Equation from Lecture 2

Recall the two core relations in Lecture 2:

$$T_e = \frac{3}{2}n_{\mathrm{pp}}\psi_{\mathrm{AF}}i_Q, \qquad J_s\frac{d\omega_{\mathrm{mech}}}{dt}=T_e-T_{\mathrm{load}}$$
Task 1.1
Explain why, when the current inner loop is sufficiently fast, the speed controller can approximate the motor as a plant with torque input and speed output, instead of directly handling the full electromagnetic dynamics of $i_D$, $i_Q$, and $\psi_{\mathrm{AF}}$.
Starting from the mechanical equation in Lecture 2, add viscous friction $B\Omega$ and write the PMSM mechanical-speed equation: $J\dot{\Omega}=T_e-B\Omega-T_L$.
Define $\theta_m$ as the mechanical angle and $\Omega=\dot{\theta}_m$ as the mechanical angular speed. Rewrite the system as a second-order mechanical subsystem with input $T_e$ and states $(\theta_m,\Omega)$.

1.2 Defining the Total Disturbance

Lecture 3 no longer treats every uncertainty separately. Instead, it combines them into one scalar disturbance term.

Task 1.2
Let $b=1/J$. Rewrite Task 1.1(b) into the form $\dot{\Omega}=bT_e+d_n$, give the expression of $d_n$, and explain what physical quantities it contains.
If the controller outputs a torque reference $T_e^*$ rather than the exact actual torque $T_e$, and if the controller internally uses the nominal inertia $J_n$, define $b_n=1/J_n$. Derive $$\dot{\Omega}=b_nT_e^*+d_{to}$$ and write the explicit expression of $d_{to}$.
Define $k_b=b_n/b=J/J_n$. Explain the physical meaning of $k_b=1,\;k_b>1,\;k_b<1$, and state what kind of inertia mismatch each case corresponds to.
Key idea: From the controller's perspective, load torque, friction, inertia mismatch, and torque-modeling error can all be packaged into one total disturbance $d_{to}$. The observer that follows is meant to estimate exactly this quantity.

Part 2. Observer-Based Speed Control Law

2.1 Ideal Control Law and Practical Control Law

Define the speed-tracking error as $e_s=\Omega^*-\Omega$ and require it to satisfy a first-order exponential convergence law:

$$\dot e_s=-k_{ps}e_s, \qquad k_{ps}>0$$
Task 2.1
Using $\dot e_s=\dot{\Omega}^*-\dot{\Omega}$ together with the speed equation from Part 1, derive the ideal torque control law $$T_e^*=\frac{\dot{\Omega}^*+k_{ps}(\Omega^*-\Omega)-d_{to}}{b_n}.$$
Explain why this expression cannot be implemented directly. Then replace the unavailable true quantities with the estimates $\hat{\Omega}$ and $\hat d_{to}$, and write the practical control law.
Use the unified torque equation from Lecture 2, $$T_e=\frac{3}{2}n_{\mathrm{pp}}\psi_{\mathrm{AF}}i_Q,$$ to convert the torque reference $T_e^*$ into the $q$-axis current reference $i_Q^*$. Explain why active flux $\psi_{\mathrm{AF}}$, denoted as KA in the code, is required in this conversion.

2.2 Third-Order and Fourth-Order Observers

The encoder can measure position directly, but not speed or disturbance. Therefore we build the observer starting from $\theta_m^{\mathrm{meas}}$.

Task 2.2
Write the state equations of the third-order observer with states $[\hat{\theta}_m,\hat{\Omega},\hat d_{to}]$. Explain the physical meaning of each state and the role played by the position error $e_\theta=\theta_m^{\mathrm{meas}}-\hat{\theta}_m$.
Write the state equations of the fourth-order observer with states $[\hat{\theta}_m,\hat{\Omega},\hat d_{to},\hat p_{to}]$. Explain the meaning of the additional state $\hat p_{to}$ and why it helps track ramp-type disturbances.
If the poles of the third-order observer are all placed at $s=-\omega_{ob}$, derive $\ell_1,\ell_2,\ell_3$ from $(s+\omega_{ob})^3$. For the fourth-order observer, derive $\ell_1,\ell_2,\ell_3,\ell_4$ from $(s+\omega_{ob})^4$.
Design hint: $\omega_{ob}$ is the observer bandwidth. A larger value gives faster estimation, but also makes the observer more sensitive to measurement noise. The empirical rule given in Lecture 3 is that $\omega_{ob}$ is usually chosen to be 3 to 10 times the bandwidth of the speed loop.

Part 3. The Three Closed-Loop Channels and System Type

3.1 Tracking, Disturbance, and Noise as Three Channels

The key point of Lecture 3 is that the closed-loop output is not determined by one single performance index. Instead, it is the superposition of three transfer paths.

Task 3.1
Write the three-channel decomposition $$\Omega(s)=\Phi_r(s)\Omega^*(s)+\Phi_d(s)d_n(s)+\Phi_n(s)\big(-s\delta_p(s)\big).$$ Explain the physical meaning of $\Phi_r$, $\Phi_d$, and $\Phi_n$.
Explain why position-measurement noise $\delta_p$ appears in the speed loop as $-s\delta_p$. What is the relation between this and differentiating position in order to obtain speed?
Write the unified expressions given in Lecture 3, $$\Phi_r(s),\quad \Phi_d(s),\quad \Phi_n(s)=1-s\Phi_d(s),$$ and explain what role the auxiliary transfer function $G_3(s)$ plays in the analysis.

3.2 System Type in the Disturbance Channel

When $k_b=1$, the disturbance channel can be written in a simpler form:

$$\Phi_d(s)\big|_{k_b=1}=\frac{G_3(s)}{\Delta_n(s+k_{ps})}$$
Task 3.2
Explain why every extra disturbance state added in the observer is equivalent to introducing one more integrator into the disturbance-rejection channel.
For the third-order observer, if $G_3(s)\sim c_1 s$ as $s\to 0$, explain why the system is Type I in the disturbance channel, and identify what class of load disturbance can be rejected with zero steady-state error.
For the fourth-order observer, if $G_3(s)\sim c_2 s^2$ as $s\to 0$, explain why it becomes Type II, and state what additional class of load disturbance can be eliminated in steady state compared with the third-order observer.
Lecture 3 raises a discussion question: instead of using a higher-order observer, if we add another integrator after the speed PI controller to form a PII controller, can we also obtain a higher disturbance type? Discuss the price from the perspective that all three channels are affected at the same time.
Hint: Do not only write the labels "Type I" or "Type II". You need to state clearly what the input is, what the output is, what quantity the final-value-theorem analysis is applied to, and what kind of disturbance can achieve zero steady-state error.

Part 4. Tradeoff, Robustness, and Mapping to Implementation

4.1 Complementarity of Noise and Disturbance Rejection

Lecture 3 gives a very important complementary constraint:

$$\Phi_n(s)+s\Phi_d(s)=1$$
Task 4.1
Explain why this relation means that improving low-frequency disturbance rejection must necessarily worsen noise rejection over some frequency range. What exactly does this "you cannot get both" mean here?
Discuss qualitatively what happens as the observer bandwidth $\omega_{ob}$ increases: how do disturbance-estimation speed, noise amplification, and high-frequency attenuation change?
Using the analysis of $k_b$ in Lecture 3, compare the typical behavior of $k_b>1$ and $k_b<1$: which one is more likely to exhibit overshoot and oscillation, which one is more likely to expose noise, and which one is less favorable for low-frequency disturbance rejection?

4.2 From Mathematics to Code

The final goal of both Lecture 2 and Lecture 3 is to guide simulation implementation and controller programming.

Task 4.2
Draw a signal-flow diagram from $\theta_m^{\mathrm{meas}}$ to $i_Q^*$, including at least the following five modules: position measurement, observer, speed-error feedback, disturbance feedforward, and torque-to-current conversion.
Explain why $$i_q^*= \underbrace{\text{PI feedback}}_{\text{tracking}} + \underbrace{\text{disturbance feedforward}}_{\text{rejection}}$$ is a two-degree-of-freedom (2DOF) control structure rather than a plain PI controller.
If you had to choose only one for a practical system, a third-order observer or a fourth-order observer, give an engineering criterion for the choice. Explain how you would balance load-change type, encoder-noise level, and parameter-mismatch risk.
After finishing this homework, you should be able to answer the following:
From Lecture 2 to Lecture 3, motor control moves from "writing down the unified motor ODEs" to "how to build a stronger speed controller around those ODEs". If Lecture 2 answers the question "what is the plant?", then Lecture 3 answers the question "how do we use the plant model to reject disturbances, estimate hidden quantities, and manage tradeoffs?"

提交方式 How to Submit

请按课程通知提交 Markdown。 Please submit your work as a Markdown document according to the course announcement.
本页面不提供在线上传。 This page does not provide online upload.