<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CyberPhysicalSystem on Darrin 的部落格</title><link>http://darrin.cc/zh-tw/categories/cyberphysicalsystem/</link><description>Recent content in CyberPhysicalSystem on Darrin 的部落格</description><generator>Hugo -- gohugo.io</generator><language>zh-tw</language><copyright>Darrin Lin</copyright><lastBuildDate>Sun, 07 Jun 2026 00:00:00 +0800</lastBuildDate><atom:link href="http://darrin.cc/zh-tw/categories/cyberphysicalsystem/index.xml" rel="self" type="application/rss+xml"/><item><title>NTNU CPS Linear System</title><link>http://darrin.cc/zh-tw/p/ntnu-cps-linear-system/</link><pubDate>Sun, 07 Jun 2026 00:00:00 +0800</pubDate><guid>http://darrin.cc/zh-tw/p/ntnu-cps-linear-system/</guid><description>&lt;h2 id="linear-system-analysis">linear system analysis
&lt;/h2>&lt;p>$x_1&amp;rsquo; = 5x_1+3x_2$&lt;br>
$x_2&amp;rsquo;=-6x_1-4x_2$&lt;br>
can be solve in linear algebra
$$\begin{bmatrix} x_1&amp;rsquo; \\ x_2&amp;rsquo; \end{bmatrix} = \begin{bmatrix} 5 &amp;amp; 3 \\ 6 &amp;amp; -4 \end{bmatrix}\begin{bmatrix} x_1 \\ x_2 \end{bmatrix}$$
we can change $x_1&amp;rsquo;=ax_1$ to $x_1(t)=Ce^{at}$&lt;/p>
&lt;p>and can we do some translation for
$$\begin{cases} x_1&amp;rsquo;= a_1x_1+a_2x_2 \\ x_2&amp;rsquo;=a_3x_1+a_4x_2 \end{cases}$$
into
$$\begin{cases} y_1&amp;rsquo;= a_ay_1 \\ y_2&amp;rsquo;=a_by_2 \end{cases}$$
than use
$$\begin{cases} y_1(t) \\ y_2(t) \end{cases}$$
? is it useful?&lt;/p>
&lt;p>we can change it first change
$$\begin{bmatrix} x_1&amp;rsquo; \\ x_2&amp;rsquo; \end{bmatrix} = \begin{bmatrix} a_1 &amp;amp; a_2 \\ a_3 &amp;amp; a_4 \end{bmatrix}\begin{bmatrix} x_1 \\ x_2 \end{bmatrix}$$
into
$$\begin{bmatrix} y_1&amp;rsquo; \\ y_2&amp;rsquo; \end{bmatrix} = \begin{bmatrix} a_a &amp;amp; 0 \\ 0 &amp;amp; a_b \end{bmatrix}\begin{bmatrix} y_1 \\ y_2 \end{bmatrix}$$&lt;/p>
&lt;p>$x&amp;rsquo; = Ax$ that A is operator, x is operand&lt;/p>
&lt;p>Every vector x in $E$ (n dimension) can be uniquely express as $x=\sum_{i=1}^{n}t_ie_i$ &lt;br>
$t_i$ are coordinate of x in the basis $e_i$&lt;/p>
&lt;p>Each coordinate is a linear function $E\to R$, the coordinate system is an isomorphism(one-to-one and onto) $R\to E$&lt;/p>
&lt;p>eigenvalues of $\begin{bmatrix} a &amp;amp; b \\ c &amp;amp; d \end{bmatrix}$ (A)&lt;br>
compute $Det(A-\lambda I)=0$
$$ Det\begin{bmatrix} a -\lambda &amp;amp; b \\ c &amp;amp; d -\lambda \end{bmatrix}=0 $$
$(a-\lambda)(d-\lambda) - (bc)=0$ $\Rightarrow$ $\lambda_1=\alpha, \lambda_2 =\beta$&lt;br>
$B = \begin{bmatrix} \lambda_1 &amp;amp; 0 \\ 0 &amp;amp; \lambda_2 \end{bmatrix} = \begin{bmatrix} \alpha &amp;amp; 0 \\ 0 &amp;amp; \beta \end{bmatrix}$&lt;br>
$x&amp;rsquo; = Ax; y = Qx; x = Q^{-1}y;x&amp;rsquo;=Q^{-1}y&amp;rsquo;$&lt;br>
$y&amp;rsquo;=Qx&amp;rsquo;=QAx=QAQ^{-1}y=By$&lt;br>
$\begin{bmatrix} y_1&amp;rsquo; \\ y_2&amp;rsquo; \end{bmatrix} = \begin{bmatrix} \alpha &amp;amp; 0 \\ 0 &amp;amp; \beta \end{bmatrix}\begin{bmatrix} y_1 \\ y_2 \end{bmatrix} = \begin{bmatrix} \alpha y_1 \\ \beta y_2 \end{bmatrix}$&lt;/p>
&lt;p>if eigenvalue $\lambda$ of $A$ has i（maginary part）, the system $x=Ax$ can&amp;rsquo;t solve by $x(t)=Ce^{\lambda t}$&lt;/p>
&lt;h2 id="ebeginbmatrix-a--b--c--d-endbmatrix">$e^{\begin{bmatrix} a &amp;amp; b \\ c &amp;amp; d \end{bmatrix}}$
&lt;/h2>&lt;p>$e^T = \sum_{n=0}^\infty \frac{T^k}{k!}$ = $\frac{1}{k_0}T^{k_0} + \frac{1}{k_1}T^{k_1} + \cdots$ where $k_i$ is the smallest integer such that $T^{k_i}$ is linearly dependent on $I, T, T^2, \cdots, T^{k_i-1}$&lt;/p>
&lt;p>Proposition: Let $P$, $S$, $T$ denote generators on $R^n$.Then:&lt;/p>
&lt;ol>
&lt;li>if $Q = PTP^{-1}$, then $e^Q = Pe^TP^{-1}$&lt;/li>
&lt;li>if ST = TS, then $e^{S+T} = e^Se^T$&lt;/li>
&lt;li>if $e^{-S} = (e^S)^{-1}$&lt;/li>
&lt;li>if $n = 2$ and $T = \begin{bmatrix} a &amp;amp; -b \\ c &amp;amp; d \end{bmatrix}$, than $e^T = e^a\begin{bmatrix} \cos b &amp;amp; -\sin b \\ \sin b &amp;amp; \cos b \end{bmatrix}$&lt;/li>
&lt;/ol>
&lt;h3 id="example-eb">example $e^B$
&lt;/h3>&lt;p>$B = \begin{bmatrix} \lambda &amp;amp; 0 \\ 0 &amp;amp; \mu \end{bmatrix}$, find $e^B$&lt;br>
$\Rightarrow e^B = \sum_{k=0}^\infty \frac{B^n}{k!}
= \sum_{k=0}^\infty \frac{1}{k!}\begin{bmatrix} \lambda &amp;amp; 0 \\ 0 &amp;amp; \mu \end{bmatrix} ^k
= \begin{bmatrix} \sum_{k=0}^\infty \frac{\lambda^k}{k!} &amp;amp; 0 \\ 0 &amp;amp; \sum_{k=0}^\infty \frac{\mu^k}{k!} \end{bmatrix}
= \begin{bmatrix} e^\lambda &amp;amp; 0 \\ 0 &amp;amp; e^\mu \end{bmatrix}$&lt;/p>
&lt;h3 id="example-et">example $e^T$
&lt;/h3>&lt;p>$T = \begin{bmatrix} a &amp;amp; 0 \\ b &amp;amp; a \end{bmatrix}$, find $e^T$&lt;br>
$\Rightarrow T= aI+B$ where $B = \begin{bmatrix} 0 &amp;amp; 0 \\ b &amp;amp; 0 \end{bmatrix}$&lt;br>
$e^T = e^{aI+B} = e^{aI}e^B (\because (aI)B = B(aI))$&lt;br>
$= e^a\sum_{k=0}^\infty \frac{1}{k!}\begin{bmatrix} 0 &amp;amp; 0 \\ b &amp;amp; 0 \end{bmatrix}^k$
$= e^a e^B$ ($e^{aI} \cdot e^B$ since B is a matrix, so $e^{aI} = \sum_{n=0}^\infty \frac{(aI)^k}{k!}$
= $\frac{1}{k_0}a^{k_0}I + \frac{1}{k_1}a^{k_1}I + \cdots$ , then since it will times $e^B$ then it can don&amp;rsquo;t need $I$)&lt;br>
$e^B = \sum_{k=0}^\infty \frac{1}{k!}\begin{bmatrix} 0 &amp;amp; 0 \\ b &amp;amp; 0 \end{bmatrix}^k = \frac{B^0}{0!} + \frac{B^1}{1!}
= I + B$
$e^T = e^a(I+B) = e^a\begin{bmatrix} 1 &amp;amp; 0 \\ b &amp;amp; 1 \end{bmatrix}$&lt;/p>
&lt;h3 id="example-et-1">example $e^T$
&lt;/h3>&lt;p>$T = \begin{bmatrix} \lambda &amp;amp; 0 \\ 1 &amp;amp; \lambda \end{bmatrix}$, find $e^T$&lt;br>
$e^T = \begin{bmatrix} e^\lambda &amp;amp; 0 \\ e^\lambda &amp;amp; e^\lambda \end{bmatrix}$ (since $T = \lambda I + B$ where $B = \begin{bmatrix} 0 &amp;amp; 0 \\ 1 &amp;amp; 0 \end{bmatrix}$, then $e^T = e^{\lambda I}e^B = e^\lambda e^B$ and $e^B = I + B$) &lt;br>
$= e^\lambda\begin{bmatrix} 1 &amp;amp; 0 \\ 1 &amp;amp; 1 \end{bmatrix}$&lt;/p>
&lt;h3 id="example">EXAMPLE
&lt;/h3>&lt;p>if $x = R^n$ is an eignenvector of $T$ with eigenvalue $\alpha$, then $x$ is also an eigenvector of $e^T$ with eigenvalue $e^\alpha$\&lt;/p>
&lt;h3 id="proof">Proof
&lt;/h3>&lt;p>From $Tx = \alpha x$&lt;br>
$\Rightarrow e^Tx=\sum_{k=0}^\infty \frac{T^k}{k!}x
= \sum_{k=0}^\infty \frac{1}{k!}\alpha^kx$
$= \lim_{n\to \infty} \sum_{k=0}^n \frac{T^kx}{k!}$&lt;br>
$= \lim_{n\to \infty} \sum_{k=0}^n \frac{\alpha^kx}{k!}$ ($Tx = \alpha x$ so $T^kx = \alpha^kx$)&lt;br>
$= \sum_{k=0}^\infty \frac{\alpha^k}{k!}x = e^\alpha x$&lt;/p>
&lt;h2 id="proposition-fracddteta--aeta--etaa">Proposition $\frac{d}{dt}e^{tA} = Ae^{tA} = e^{tA}A$
&lt;/h2>&lt;h3 id="part-i-show-that-fracddteta--aeta">Part I show that $\frac{d}{dt}e^{tA} = Ae^{tA}$
&lt;/h3>&lt;p>$\frac{d}{dt}e^{tA} = \lim_{h\to 0} \frac{e^{(t+h)A} - e^{tA}}{h}$&lt;br>
$= \lim_{h\to 0} \frac{e^{tA}e^{hA} - e^{tA}}{h}$ (since $e^{(t+h)A} = e^{tA}e^{hA}$)&lt;br>
$= \lim_{h\to 0} e^{tA}\frac{e^{hA} - I}{h}$&lt;br>
$= e^{tA}\lim_{h\to 0} \frac{e^{hA} - I}{h}$&lt;br>
$= e^{tA}\lim_{h\to 0} \frac{\sum_{k=0}^\infty \frac{(hA)^k}{k!} - I}{h}$&lt;br>
$= e^{tA}\lim_{h\to 0} \frac{\sum_{k=0}^\infty \frac{h^kA^k}{k!}}{1}$ (Loppital&amp;rsquo;s rule, since $\sum_{k=0}^\infty \frac{(hA)^k}{k!} - I$ is 0 when $h=0$)&lt;br>
$= e^{tA}A$&lt;/p>
&lt;h3 id="part-ii-show-that-etaa--aeta">Part II show that $e^{tA}A = Ae^{tA}$
&lt;/h3>&lt;p>$e^{tA}A = \sum_{k=0}^\infty \frac{(tA)^k}{k!}A$&lt;br>
$\Rightarrow e^{tA}A = \sum_{k=0}^\infty \frac{t^kA^k}{k!}A$&lt;br>
$= A \sum_{k=0}^\infty \frac{t^kA^k}{k!}$ ($\frac{t^kA^k}{k!} = \beta A^k$, then $A\beta A^k = \beta A^{k+1}$, so $A$ can move to the front of the sum)&lt;br>
$= Ae^{tA}$&lt;/p>
&lt;h3 id="theorem-for-xax-ain-rn-x0--k-in-rn-the-general-solution-is-xt--etak-and-the-solution-is-unique">Theorem: For $x&amp;rsquo;=Ax$ ($A\in R^n$), $x(0) = k \in R^n$ the general solution is $x(t) = e^{tA}k$ and the solution is unique
&lt;/h3>&lt;h4 id="proof-1">Proof
&lt;/h4>&lt;p>$\frac{d}{dt}e^{tA}k = Ae^{tA}k$ (from the proposition above)\&lt;/p>
&lt;p>Let $x(t) be any solution and let $y(t) = e^{-tA}x(t)$&lt;br>
$\Rightarrow y&amp;rsquo;(t) = -Ae^{-tA}x(t) + e^{-tA}x&amp;rsquo;(t) = -Ae^{-tA}x(t) + e^{-tA}Ax(t) = 0$&lt;br>
$\Rightarrow y&amp;rsquo;(t) = \frac{d}{dt}(e^{-tA}x(t))
= \frac{d}{dt}e^{-tA}x(t) + e^{-tA}\frac{d}{dt}x(t) = (-Ae^{-tA})x(t) + e^{-tA}Ax(t) = 0$&lt;br>
$\Rightarrow y(t) = y(0) = e^{-0A}x(0) = C$&lt;br>
$\Rightarrow y(t) = e^{-tA}\cdot x(t)$
$x(t) = e^{tA}y(t) = e^{tA}C$&lt;/p>
&lt;h3 id="example-1">Example
&lt;/h3>&lt;p>Find the general solution of $x&amp;rsquo; = Ax$ where $a = \begin{bmatrix} a &amp;amp; 0 \\ b &amp;amp; a \end{bmatrix}$&lt;br>
$\Rightarrow$ The general solution is $e^{tA}k$ where $k = \begin{bmatrix} k_1 \\ k_2 \end{bmatrix}$&lt;br>
from previous example, we know&lt;br>
$e^A = e^a\begin{bmatrix} 1 &amp;amp; 0 \\ b &amp;amp; 1 \end{bmatrix}$&lt;br>
$e^{tA} = e^{ta}\begin{bmatrix} 1 &amp;amp; 0 \\ tb &amp;amp; 1 \end{bmatrix}$&lt;br>
$\Rightarrow e^{tA}k = e^{ta}\begin{bmatrix} 1 &amp;amp; 0 \\ tb &amp;amp; 1 \end{bmatrix}\begin{bmatrix} k_1 \\ k_2 \end{bmatrix} = e^{ta}\begin{bmatrix} k_1 \\ tbk_1 + k_2 \end{bmatrix}$&lt;br>
$\Rightarrow \begin{cases} x_1(t) = e^{ta}k_1 \\ x_2(t) = e^{ta}(tbk_1 + k_2) \end{cases}$&lt;/p>
&lt;h2 id="predict-the-behavior-of-the-system-x--ax-by-looking-at-the-eigenvalues-of-a">predict the behavior of the system $x&amp;rsquo; = Ax$ by looking at the eigenvalues of $A$
&lt;/h2>&lt;h3 id="y--by-where-b--beginbmatrix-lambda_1--0--0--lambda_2-endbmatrix">$y&amp;rsquo; = By$ where $B = \begin{bmatrix} \lambda_1 &amp;amp; 0 \\ 0 &amp;amp; \lambda_2 \end{bmatrix}$
&lt;/h3>&lt;p>then $y_1&amp;rsquo; = \lambda_1 y_1$ and $y_2&amp;rsquo; = \lambda_2 y_2$, the solution is for some negative $\lambda_1$ and $\lambda_2$, it will converge to $(0, 0)$ for $(y_1, y_2)$ as time $t$ goes by, for some positive $\lambda_1$ and $\lambda_2$, it will diverge to infinity for $(y_1, y_2)$, for some $\lambda_1$ and $\lambda_2$ with different sign, it will diverge to infinity for some direction and converge to (0, 0) for some direction for $(y_1, y_2)$&lt;/p>
&lt;h4 id="three-kinds-of-behavior-for-y--by">three kinds of behavior for $y&amp;rsquo; = By$:
&lt;/h4>&lt;p>$\det(\begin{bmatrix} \lambda_1-a &amp;amp; b \\ c &amp;amp; \lambda_2-a \end{bmatrix}) &amp;gt; 0$ and it will be $\alpha\lambda^2 + \beta\alpha + \gamma = 0$&lt;/p>
&lt;ul>
&lt;li>if $\beta^2 - 4\alpha\gamma &amp;gt; 0$, $B= \begin{bmatrix} \lambda_1 &amp;amp; 0 \\ 0 &amp;amp; \lambda_2 \end{bmatrix}$, it will have two different eigenvalues&lt;/li>
&lt;li>if $\beta^2 - 4\alpha\gamma &amp;lt; 0$ ($B= \begin{bmatrix} a &amp;amp; -b \\ b &amp;amp; a \end{bmatrix}$), it will be $\begin{bmatrix}y_1(t) \\ y_2(t) \end{bmatrix} = e^{a t}\begin{bmatrix} k_1\cos b t &amp;amp; -k_2\sin b t \\ k_1\sin b t &amp;amp; k_2\cos b t \end{bmatrix}\begin{bmatrix} k_1 \\ k_2 \end{bmatrix}$, it will be a spiral, if $a &amp;lt; 0$ it will be a spiral sink, if $a &amp;gt; 0$ it will be a spiral source, if $a = 0$ it will be a center&lt;/li>
&lt;li>if $\beta^2 - 4\alpha\gamma = 0$, it will have one eigenvalue, $B = \begin{bmatrix} \lambda &amp;amp; 1 \\ 0 &amp;amp; \lambda \end{bmatrix}$, the solution is $\begin{bmatrix} y_1(t) \\ y_2(t) \end{bmatrix} = e^{\lambda t}\begin{bmatrix} k_1 + k_2 t \\ k_2 \end{bmatrix}$, if $\lambda &amp;lt; 0$ it will be a degenerate node sink, if $\lambda &amp;gt; 0$ it will be a degenerate node source, if $\lambda = 0$ it will be a line of fixed points&lt;/li>
&lt;/ul>
&lt;h3 id="tune-the-system-behavior">tune the system behavior
&lt;/h3>&lt;p>We will change $A$ to $G$ and let it become any kind of converge model. Bring some diverge system to converge system.&lt;/p>
&lt;h2 id="system-stability">system stability
&lt;/h2>&lt;h3 id="definitionstability">Definition(stability)
&lt;/h3>&lt;p>Suppose $\bar{x} \in W$ is an equilibrium of the differential equation $x&amp;rsquo; = f(x)$, then $\bar{x}$ is said to be a &amp;ldquo;stable equilibrium&amp;rdquo; if for every neiborhood $U$ of $\bar{x}$ in $W$, there is a neighborhood $U_1$ of $\bar{x}$ in $U$ such that every solution $x(t)$ with $x(0)$ in $U_1$ is defined and in U fo all $t&amp;lt;0$&lt;/p>
&lt;p>if $\lim_{t\to \infty} x(t) = \bar{x}$ then $\bar{x}$ is said to be an &amp;ldquo;asymptotically stable equilibrium&amp;rdquo;&lt;/p>
&lt;h2 id="from-xax-to-system-control">from $x&amp;rsquo;=Ax$ to system control
&lt;/h2>&lt;p>$\Rightarrow x&amp;rsquo;=Mx$ where $M = A - []$ and we control matrix $[]$&lt;br>
e.g. A will make system be circle, but we want system to be converge, so we can add some control matrix to make the system be converge, so does deverge.&lt;/p>
&lt;h2 id="the-state-space-model-morden-control">the state space model (morden control)
&lt;/h2>&lt;h3 id="damper-effect">damper effect
&lt;/h3>&lt;p>in the physics, we have know the Hooke&amp;rsquo;s law $F = k\Delta x$ can apply in spring, and there is another thing called damper（阻尼）&lt;br>
damper is a device that can dissipate energy, it can be used to reduce the oscillation of a system, it can be used to make a system be more stable, it can be used to make a system be more comfortable, it can be used to make a system be more safe&lt;/p>
&lt;h3 id="example-spring-mass-damper-system">Example: spring-mass-damper system
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl"> -&amp;gt; x(t)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&amp;lt;--f_k(t)-spring--|====| f(t)-&amp;gt;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&amp;lt;--f_b(t)-damper--|====|
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>$f_k(t) = -kx(t)$(Hooke&amp;rsquo;s law) by spring&lt;br>
$f_b(t) = -b \cdot \frac{d\lambda (t)}{dt}$ ($\frac{d\lambda (t)}{dt}$ is the velocity of the mass, $b$ is the damping coefficient)&lt;br>
$F=ma = m\frac{d^2x(t)}{dt^2}$ we have $f(t) + f_k(t) + f_b(t) = m\frac{d^2x(t)}{dt^2}$&lt;br>
$\Rightarrow m\frac{d^2x(t)}{dt^2} + b\frac{dx(t)}{dt} + kx(t) = f(t)$&lt;br>
$\Rightarrow m\cdot x&amp;rsquo;&amp;rsquo;+bx&amp;rsquo;+kx = f(t)$&lt;/p>
&lt;p>define state variable $z_1(t) = x(t)$ and $z_2(t) = x&amp;rsquo;(t) = z_1&amp;rsquo;(t)$&lt;br>
Further, let $u(t)$ be system&amp;rsquo;s input $\Rightarrow u(t) = f(t)$, let $y(t)$ be system&amp;rsquo;s output $\Rightarrow y(t) = x(t)$&lt;/p>
&lt;p>$D \Rightarrow z_2&amp;rsquo;(t)=\frac{1}{m}u(t) - \frac{b}{m}z_2(t) - \frac{k}{m}z_1(t)$\&lt;/p>
&lt;p>$\begin{bmatrix} z_1&amp;rsquo;(t) \\ z_2&amp;rsquo;(t) \end{bmatrix} = \begin{bmatrix} 0 &amp;amp; 1 \\ -\frac{k}{m} &amp;amp; -\frac{b}{m} \end{bmatrix}\begin{bmatrix} z_1(t) \\ z_2(t) \end{bmatrix} + \begin{bmatrix} 0 \\ \frac{1}{m} \end{bmatrix}u(t)$&lt;br>
and y(t) = $\begin{bmatrix} 1 &amp;amp; 0 \end{bmatrix}\begin{bmatrix} z_1(t) \\ z_2(t) \end{bmatrix} + \begin{bmatrix} 0 \end{bmatrix}u(t)$&lt;/p>
&lt;p>In general, we can write the state space model as&lt;br>
$\begin{cases} z&amp;rsquo;(t) = Az(t) + Bu(t) \\ y(t) = Cz(t) + Du(t) \end{cases}$ where $z(t) = \begin{bmatrix} z_1(t) \\ z_2(t) \end{bmatrix}$&lt;br>
$A$: state matrix / system matrix (suppose $u(t) = 0 \Rightarrow z&amp;rsquo;(t) = Az(t) \Rightarrow x&amp;rsquo;=Ax$)&lt;br>
$B$: input matrix / control matrix (i.e., how the input imapcts the state variables)&lt;br>
$C$: output matrix (i.e., how the state variables affect output)&lt;br>
$D$: direct transfer matrix (i.e., how the input directly affects output)&lt;br>
$z(t)$: state variables (a vector)&lt;br>
$u(t)$: input&lt;br>
$y(t)$: output&lt;/p>
&lt;h4 id="apply-example">apply example
&lt;/h4>&lt;p>suppose $u = -Kz(t) \Rightarrow Az(t) + B(-Kz(t)) = (A-BK)z(t)$, that $A-BK$ is the $M$ we mentioned before, so we can change the system behavior by changing $K$&lt;/p>
&lt;h2 id="state-feedback-control">state feedback control
&lt;/h2>&lt;h2 id="lyapunov-stability-criteria">Lyapunov stability criteria
&lt;/h2>&lt;p>Let $\bar{x}\in W$ br an equilibrium for a dynamical system $x&amp;rsquo; = f(x)$&lt;br>
Let $V: U\to R$ be a continuous function defined on a neighborhood $U\in W$ of $x$, differentiable on $U - \bar{x}$&lt;br>
such that&lt;/p>
&lt;ol>
&lt;li>$V(\bar{x}) = 0$ and $V(x) &amp;gt; 0$ if $x \neq \bar{x}$&lt;/li>
&lt;li>$V(x)\leq 0$ in $U - \bar{x}$, if 1, 2 are true, then the system is stable at $\bar{x}$\&lt;/li>
&lt;li>$V(x) &amp;lt; 0$ in $U-\bar{x}$, if 1, 2, 3 are true, then the system is asymptotically stable&lt;/li>
&lt;/ol>
&lt;p>asymptotically stable is when give any initial state, the system will converge to the equilibrium point as time goes by, so it is more stronger than stable&lt;br>
since stable only means that the system will not diverge to infinity, but it can still oscillate around the equilibrium point&lt;/p>
&lt;h2 id="pid-control-classical-control">PID control (classical control)
&lt;/h2>&lt;p>P: portional, I: integral, D: differential&lt;br>
there are three parameters in P control, I control and D control&lt;/p>
&lt;p>For example, spring-mass-damper system, the $K$ in $u = -Kz(t)$ is PD control&lt;br>
we can use LQR(linear quadratic regulator) to find the optimal $K$ for the system&lt;/p></description></item><item><title>NTNU CPS Real-time System Model</title><link>http://darrin.cc/zh-tw/p/ntnu-cps-real-time-system-model/</link><pubDate>Sun, 07 Jun 2026 00:00:00 +0800</pubDate><guid>http://darrin.cc/zh-tw/p/ntnu-cps-real-time-system-model/</guid><description>&lt;h2 id="deadline">deadline
&lt;/h2>&lt;div class="mermaid-scroll" tabindex="0" role="region" aria-label="Scrollable diagram">
&lt;pre class="mermaid">flowchart LR
a[sensing]
b[computing]
c[actuating]
d[environment]
a--&amp;gt;b--&amp;gt;c--&amp;gt;d--&amp;gt;a
&lt;/pre>
&lt;/div>&lt;h3 id="where-are-deadline-come-from">where are deadline come from
&lt;/h3>&lt;h2 id="type-of-real-time-system">type of Real-time system
&lt;/h2>&lt;h3 id="hard-real-time-system">hard real-time system
&lt;/h3>&lt;h4 id="definition">definition
&lt;/h4>&lt;p>If producing results after deadline, then it will give seriously bad consequence. e.g. earthquake warning&lt;/p>
&lt;h3 id="soft-real-time-system">soft real-time system
&lt;/h3>&lt;h4 id="definition-1">definition
&lt;/h4>&lt;p>If producing results after deadline, then it will give lower utility. e.g. live streaming, online multiplayer game&lt;/p>
&lt;h3 id="firm-real-time-system">firm real-time system
&lt;/h3>&lt;h4 id="definition-2">definition
&lt;/h4>&lt;p>If producing results after deadline, then it will be useless.&lt;/p>
&lt;h2 id="model">model
&lt;/h2>&lt;p>$\Gamma: \text{task set: }{\tau_1 , \tau_2, \tau_3 ,&amp;hellip;}$&lt;br>
Tasks have many type, some of them are period task, some just one-time task(only one job), also have other&lt;br>
$j_i$: job in task $\tau_i$&lt;br>
R: Response time of Real time system is finish time - arrival time&lt;br>
$T_i$: time period of job in task&lt;br>
$C_i$: execution time (in the worst case)&lt;br>
$U$: CPU utilization = sum of CPU use time percentage($[ \sum_{i} \frac{C_i}{T_i}]$)&lt;/p>
&lt;h2 id="algorithm">algorithm
&lt;/h2>&lt;h3 id="optima">optima
&lt;/h3>&lt;p>if one of the algorithm is schedulable, optima algorithm is also schedulable.&lt;br>
if there is some scheduler can schedule some sub-task, the optima can also schedule those.(not mean it can schedule all task set, but for all of other schedule can)&lt;/p>
&lt;h3 id="example">example
&lt;/h3>&lt;ul>
&lt;li>priority $j_i&amp;gt;j_j for i&amp;lt;j$&lt;/li>
&lt;li>non-preemptive&lt;/li>
&lt;li>schedule according to priority order&lt;/li>
&lt;/ul>
&lt;p>$\tau_1 \rightarrow \tau_5, \tau_2 \rightarrow \tau_3 / \tau_4$&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">CPU1: j2 j2 j3 j3 j4 j4
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">CPU2: j1 j5 j5 j5 j5
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>but if $c_2 = 1$ will become:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">CPU1: j2 j4 j4
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">CPU2: j1 j3 j3 j5 j5 j5 j5
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="critical-section-handle-problempriority-inversion">critical section handle problem(priority inversion)
&lt;/h3>&lt;p>In the critical section, higher priority task may delay because before higher priority may wait before executing critical section and the lower is executing higher priority task first.&lt;/p>
&lt;p>For example(T1 &amp;gt; T2 &amp;gt; T3):&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">c: critical section, w: wait, n: normal, X: no execution
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">T1: X X X X n n w w w w w w c c c c n n F X X
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">T2: X X X X X X X n n n n F X X X X X X X X X
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">T3: n n c c w w c w w w w c w w w w w w w n F
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>middle priority task that can preempt higher priority task&lt;/p>
&lt;h1 id="rate-monotonicrm-scheduling">Rate-monotonic(RM) scheduling
&lt;/h1>&lt;h2 id="assumption">assumption
&lt;/h2>&lt;ol>
&lt;li>periodic hard-real-time tasks&lt;/li>
&lt;li>deadlines consist of run ability constraint (i.e, implicit deadline)&lt;/li>
&lt;li>tasks have no dependency&lt;/li>
&lt;li>constant execution time for each job of a task&lt;/li>
&lt;li>focus only on periodic hard-real-time jobs (same as 1.)&lt;/li>
&lt;/ol>
&lt;h2 id="fix-priority-preemptive-scheduling-fp">fix priority preemptive scheduling (FP)
&lt;/h2>&lt;p>for example, STCF isn&amp;rsquo;t FP&lt;br>
// with FP, we can have run Queue, and take first job and wait until job finish, then take first again\&lt;/p>
&lt;h2 id="worst-case-most-challenging-case-analysis">worst-case (most challenging case) analysis
&lt;/h2>&lt;p>we should consider the worst case&lt;/p>
&lt;h3 id="critical-instant">critical instant
&lt;/h3>&lt;p>there is n higher priority tasks, has job release at same time as target task $\tau_i$ did&lt;br>
and we can consider them as 1 higher priority task $\tau_0$ (impact same as n tasks)&lt;br>
we can know that shift the time of $\tau_0$&amp;rsquo;s job won&amp;rsquo;t affect response time of $\tau_i$, because it is still inside the response time of $\tau_i$&lt;br>
so the worst case is the $\tau_0$ arrival time same as $\tau_i$&lt;/p>
&lt;p>for different priority order, the execution time of longer:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">=: executing, ^: arrive -: idle
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">t1|^==---^==---^==---^
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">t2|^--=== --=== --===^
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">t1|^===-- ----- -----^
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">t2|^---==^==---^==---^
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">vvXXXXXincorrectXXXXXvv
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">t1|^===== ====- -----^
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">t2|^---XX^---X=^==---^
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>$\Rightarrow$ task has longer period should have lower priority is better&lt;/p>
&lt;h3 id="analysis-t_1-and-t_2">analysis $T_1$ and $T_2$
&lt;/h3>&lt;p>suppose $T_1&amp;gt;T_2$&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">τ₁|^----- ----- ---^--
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">τ₂|^-----^-----^-----^
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>There will be $\lceil{\frac{T_1}{T_2}}\rceil$ arrivals of jobs of $\tau_2$ within two arrivals of $\tau_1$(longer over shorter)&lt;br>
There will be $\lfloor{\frac{T_1}{T_2}}\rfloor$ arrivals of jobs of $\tau_2$ whose deadline fall within $T_1$&lt;/p>
&lt;p>If we set $\tau_1$ to be of a higher priority, than fot $\tau_1$, than for $\tau_1$ and $\tau_2$ both be schedulable, we need $c_1 + c_2 \leq T_2 \Rightarrow \lceil{\frac{T_1}{T_2}}\rceil C_1+\lceil{\frac{T_1}{T_2}}\rceil C_2\leq\lceil{\frac{T_1}{T_2}}\rceil T_2\leq T_1$&lt;br>
imply\&lt;/p>
&lt;p>If we set $\tau_1$ to be of a higher priority, than fot $\tau_1$, than for $\tau_1$ and $\tau_2$ both be schedulable, we need $\lfloor{\frac{T_1}{T_2}}\rfloor C_2+C_1\leq T_1$\&lt;/p>
&lt;p>independent with $C_1, C_2$, only consider with arrival rate&lt;/p>
&lt;h2 id="theorem">Theorem
&lt;/h2>&lt;h3 id="theorem-1">Theorem 1
&lt;/h3>&lt;p>A critical instant for any task occurs whenever the task is requested simultaneously with requests for all priority tasks.&lt;/p>
&lt;h3 id="theorem-2">Theorem 2
&lt;/h3>&lt;p>If a feasible priority assignment exists for some task set, the rate-monotonic priority assignment will be feasible for that task set tool&lt;/p>
&lt;h2 id="task-set-utilization-aka-utilization-factor-of-the-task-set">task set utilization (aka utilization factor of the task set)
&lt;/h2>&lt;p>$\sum_i \frac{C_i}{T_i}$&lt;br>
$U\leq ln2=0.693\rightarrow schedulable$&lt;br>
$U\leq n(2^{\frac{1}{n}}-1)$&lt;br>
if only two tasks than as long as $U\leq 2(\sqrt{2}-1)=0.83$ than the task set is schedulable using RM(but not mean if higher than 0.83 not schedulable)&lt;/p>
&lt;h3 id="proof-of-the-sufficient-schedulability-test-uleq-2sqrt2-1">proof of the sufficient schedulability test $U\leq 2(\sqrt{2}-1)$
&lt;/h3>&lt;p>$T_1 &amp;gt; T_2$\&lt;/p>
&lt;h4 id="case-1">Case 1
&lt;/h4>&lt;p>$\tau_2$ next job came after $\tau_1$ finish&lt;/p>
&lt;p>$C_1 \leq T_1 - T_2 \lfloor \frac{T_1}{T_2} \rfloor \Rightarrow$
The longest possible value of $C_2$ is $C_2 = T_2 - C_1 \Rightarrow U = \frac{C_1}{T_1} + \frac{C_2}{T_2} = 1 + C_1 (\frac{1}{T_1} - \frac{1}{T_2}) = f(C_1)$&lt;/p>
&lt;p>if $C_1$ decrease, $U$ increase
if $C_1$ increase, $U$ decrease&lt;/p>
&lt;h4 id="case-2">Case 2
&lt;/h4>&lt;p>$\tau_2$ next job came before $\tau_1$ finish&lt;/p>
&lt;p>$C_1 \geq T_1 - T_2 \lfloor \frac{T_1}{T_2} \rfloor \Rightarrow$
The longest possible value of $C_2$ is $C_2 = \frac{T_1 - C_1}{\lfloor \frac{T_1}{T_2} \rfloor + 1}$
$\Rightarrow U = \frac{C_1}{T_1} + \frac{C_2}{T_2} = \dots = \frac{1}{T_2} \cdot \frac{T_1}{\lfloor \frac{T_1}{T_2} \rfloor + 1} + C_1 (\frac{1}{T_1} - \frac{1}{T_2(\lfloor \frac{T_1}{T_2} \rfloor + 1)})$
$(C_1 (\frac{1}{T_1} - \frac{1}{T_2(\lfloor \frac{T_1}{T_2} \rfloor + 1)})) &amp;gt; 0$&lt;/p>
&lt;p>if $C_1$ decrease, $U$ decrease
if $C_1$ increase, $U$ increase&lt;/p>
&lt;h4 id="summarize">summarize
&lt;/h4>&lt;p>$C_1=T_2 - T_1\lfloor{\frac{T_1}{T_2}}\rfloor$
$\Rightarrow U=\frac{C_1}{T_1}+{C_2}{T_2} = &amp;hellip;&amp;hellip; \leq 2(\sqrt{2}-1)$\&lt;/p>
&lt;h2 id="edf">EDF
&lt;/h2>&lt;p>EDF is a optimal scheduler, if $U &amp;lt; 1$. But in real world, the dynamic scheduling may have some other cost&lt;/p>
&lt;h2 id="real-time-servers">real-time servers
&lt;/h2>&lt;p>a server to handle the aperiodic task, and also try to give good response time for aperiodic task, and also try to guarantee the schedulability of periodic task. that get balance between the two type of task.&lt;/p>
&lt;h3 id="aperiodic-task-and-periodic-task">aperiodic task and periodic task
&lt;/h3>&lt;p>For real-time system, we usually have two type of task, periodic task and aperiodic task.&lt;br>
The system should guarantee the schedulability of periodic task, and also try to give good response time for aperiodic task.&lt;/p>
&lt;h4 id="periodic-task">periodic task
&lt;/h4>&lt;p>task that has a job release at regular interval, and the deadline is same as the period.&lt;/p>
&lt;h4 id="aperiodic-task">aperiodic task
&lt;/h4>&lt;p>also called non-periodic task, task that has a job release at irregular interval, and the deadline is not same as the period.&lt;/p>
&lt;h3 id="shipboard-computing">shipboard computing
&lt;/h3>&lt;p>Computing on a ship (usually for military), for example, the ship has a radar system, and cannon system, the radar system is periodic task, and the cannon system is aperiodic task.&lt;/p>
&lt;p>Aperiodic task may delay the periodic task, so we need to design handle the aperiodic task that can be predictable, and also try to give minimum response time that won&amp;rsquo;t delay the periodic task to miss the deadline.&lt;/p>
&lt;h3 id="key-idea">key idea
&lt;/h3>&lt;p>create a periodic task to serve aperiodic task and control their interference to the rest of periodic tasks.&lt;/p>
&lt;h3 id="way-to-serve-aperiodic-task">way to serve aperiodic task
&lt;/h3>&lt;p>Add a periodically scheduled budget of execution time for aperiodic task, and also give a period for the budget.&lt;br>
Once the aperiodic task arrive, it can use the budget to execute, and if the budget is used up, then it need to wait until next period to get new budget.&lt;/p>
&lt;p>For the case of example in textbook, we set aperiodic task as lowest priority since we don&amp;rsquo;t want to delay the periodic task, and just make the aperiodic budget scheduled as a periodic task to make it predictable, and also try to give good response time for aperiodic task.&lt;/p>
&lt;h3 id="schedulability-test">schedulability test
&lt;/h3>&lt;p>let $U_p$ be the utilization of all periodic task, and $U_s$ be the utilization of the server where $U_s = \frac{C_s}{T_s}$, $\Rightarrow U_p + U_s \leq n(K^{\frac{1}{n}}-1)$, where $K = \frac{2}{U_s+1}$&lt;/p>
&lt;p>then we need $U_p + U_s \leq (n+1)(2^{\frac{1}{n+1}}-1)$ to guarantee the schedulability of all periodic task, and also try to give good response time for aperiodic task.&lt;/p>
&lt;h4 id="worst-task-configuration">worst task configuration
&lt;/h4>&lt;p>assumed 100% workload,
from server, $\tau_1$, $\tau_2$ to $\tau_n$s&amp;rsquo; period $T_s$, $T_1$&amp;hellip; from min to max correspond RM priority，and $C_1 = T_1 - T_s$, $C_2 = T_2 - T_1$&amp;hellip; $C_n = T_n - T_{n-1}$ reach 100% workload&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">Ts|==------|==
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">T1|--=-------|=
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">T2|---=-------|=
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>$\begin{cases} C_{n-1} = T_n -T_{n+1} \\
C_n = T_s - C_s - \sum_{i=1}^{n-1} C_i\end{cases}$&lt;br>
$C_s + \sum_{i=1}^{n-1} C_i = T_n - T_s$&lt;br>
$\Rightarrow C_n = T_s - (C_s + \sum_{i=1}^{n-1} C_i) = T_s - (T_n - T_s) = 2T_s - T_n$&lt;/p>
&lt;p>$U = \frac{C_s}{T_s} + \sum_{i=1}^{n} \frac{C_i}{T_i}
= U_s + \sum_{i=1}^{n-1} \frac{C_i}{T_i} + \frac{C_n}{T_n}
= U_s + \sum_{i=1}^{n-1} \frac{T_i - T_{i-1}}{T_i} + \frac{2T_s - T_n}{T_n}
= U_s -n + \sum_{i=1}^{n-1} \frac{T_{i+1}}{T_i} + \frac{2T_s}{T_n}$&lt;br>
$= U_s - n + \frac{T_2}{T_1}+\frac{T_3}{T_2} + &amp;hellip; + \frac{T_n}{T_{n-1}} + (\frac{2T_s}{T_1}\frac{T_1}{T_n})$&lt;br>
now let $R_i = \frac{T_{i+1}}{T_i}$ and K = $\frac{2T_s}{T_1}$, we have $U = U_s - n \sum^{n-1}{i=1}R_i + K\frac{T_1}{T_n}$&lt;br>
rate that $\frac{T_n}{T_1} = \frac{T_n}{T_{n-1}} \cdot \frac{T_{n-1}}{T_{n-2}} \cdot &amp;hellip; \cdot \frac{T_2}{T_1} = R_{n-1} \cdot R_{n-2} \cdot &amp;hellip; \cdot R_1 = \prod_{i=1}^{n-1} R_i$&lt;br>
$\Rightarrow U = U_s - n + \sum_{i=1}^{n-1} R_i + K\frac{T_1}{T_n} = U_s - n + \sum_{i=1}^{n-1} R_i + K\frac{1}{\prod_{i=1}^{n-1} R_i} = f(R_i)$&lt;/p>
&lt;p>To find the minimum of U, we can compute $\frac{df(R_i)}{dR_i} = 0$ for each $R_i$&lt;br>
$\Rightarrow \frac{df(R_i)}{dR_i} = 1 - K\frac{1}{\prod_{j=1}^{n-1} R_j} \cdot \frac{1}{R_i} = 0$&lt;br>
$\Rightarrow \frac{K}{R_i \prod_{j=1}^{n-1} R_j} = 1$ for each $R_i$&lt;br>
we choose $R_1 = R_2 = &amp;hellip; = R_{n-1} = K^{\frac{1}{n}}$ to satisfy the above equation&lt;/p>
&lt;p>$\Rightarrow U = U_s -n + \sum_{i=1}^{n-1} K^{\frac{1}{n}} + K\frac{1}{K^{\frac{n-1}{n}}}$
$=U_s -n + (n-1)K^{\frac{1}{n}} + K\frac{1\cdot K^{\frac{1}{n}}}{K^{\frac{n-1}{n}} K^{\frac{1}{n}}}$
$=U_s -n + (n-1)K^{\frac{1}{n}} + K^{\frac{1}{n}}$
$=U_s + n(K^{\frac{1}{n}} - 1)$#
The lowest upper bound for $U_p$ is $n(K^{\frac{1}{n}}-1)$&lt;/p>
&lt;p>from $K=\frac{2T_s}{T_1}$ and $U_s=\frac{C_s}{T_s} -1 \Rightarrow U_s+1=\frac{T_1}{T_s}$
$\Rightarrow K = \frac{2}{U_s+1}$&lt;/p>
&lt;h3 id="defferable-server-vs-polling-server">defferable server vs polling server
&lt;/h3>&lt;h4 id="defferable-server">defferable server
&lt;/h4>&lt;p>the server will execute the aperiodic task &lt;strong>immediately&lt;/strong> when it arrive, and if the budget is used up, then it need to wait until next period to get new budget.&lt;br>
the response time of aperiodic task is better than polling server, but it may cause more interference to periodic task&lt;/p>
&lt;h4 id="polling-server">polling server
&lt;/h4>&lt;p>only the there is aperiodic task arrive before the server&amp;rsquo;s period, then the server will execute the aperiodic task immediately when it arrive, else the server will idle until next period to check if there is aperiodic task arrive.&lt;/p>
&lt;h2 id="resource-access-protocols">resource access protocols
&lt;/h2>&lt;p>the protocols is designed to handle the critical section problem, and also try to get predictable response time.&lt;/p>
&lt;h2 id="multi-criticality-systems-with-varying-degrees-of-execution-time-assurance">Multi-criticality Systems with Varying Degrees of Execution Time Assurance
&lt;/h2>&lt;h3 id="harmonic-period">harmonic period
&lt;/h3>&lt;p>If all the task starting in critical instant, since all the task is the smallest&amp;rsquo;s period&amp;rsquo;s integer multiple, so the critical instant will come back again in the same period.&lt;/p>
&lt;h3 id="criticality">criticality
&lt;/h3>&lt;p>the criticality isn&amp;rsquo;t same as the priority&lt;br>
the criticality is about how bad the consequence if the task miss the deadline.&lt;/p>
&lt;h3 id="multi-criticality-systems">Multi-criticality Systems
&lt;/h3>&lt;p>In this case, high criticality task will take most execution time and run the complex task, the low criticality task will take less execution time and easy task.\&lt;/p>
&lt;h3 id="schedulability-analysis">schedulability analysis
&lt;/h3>&lt;p>For criticality level $L = {A, B, C, D}$&lt;br>
$C_ij$: execution time of task $\tau_i$ viewed from criticality level $j$&lt;br>
$\tau_1$: $T=D_1 = 2$, $L_1 = A$, $C_{1A} = 2$, $C_{1B} = 1$&lt;br>
$\tau_2$: $T=D_2 = 4$, $L_2 = B$, $C_{2A} = 1$, $C_{2B} = 1$&lt;/p>
&lt;h4 id="preemptive-fixed-priority-scheduling">preemptive fixed priority scheduling
&lt;/h4>&lt;p>if assign $\tau_1$ with a higher priority $\Rightarrow$ the system is deemed unschedulable.&lt;br>
if assign $\tau_2$ with a higher priority $\Rightarrow$ the system is deemed schedulable.&lt;/p>
&lt;h2 id="solution-of-priority-inversion">solution of priority inversion
&lt;/h2>&lt;p>fix the problem of &amp;ldquo;pathetic&amp;rdquo; priority inversion&lt;/p>
&lt;p>For all of them are try to reduce the response time. And we use blocking time to explain it.&lt;/p>
&lt;h3 id="non-preemptive-protocolnpp">Non-preemptive protocol(NPP)
&lt;/h3>&lt;p>put the time that &lt;strong>into&lt;/strong> the critical section into the highest priority, so that won&amp;rsquo;t cause priority inversion since the critical section will be executed immediately when it arrive.
After the critical section, the task return to the original priority, and also give the chance for other task to preempt.&lt;/p>
&lt;h3 id="highest-locker-priority-protocolhlp">Highest locker priority protocol(HLP)
&lt;/h3>&lt;p>when a task enter the critical section, it will inherit the highest priority of all the &lt;strong>task that enter the same critical section&lt;/strong>, other part is same as NPP.&lt;br>
so the task that has the highest priority and don&amp;rsquo;t enter the critical section won&amp;rsquo;t be affected.&lt;/p>
&lt;h3 id="priority-inheritance-protocolpip">Priority inheritance protocol(PIP)
&lt;/h3>&lt;p>it will &lt;strong>inherit the highest priority&lt;/strong> that is &lt;strong>blocked by the same critical section&lt;/strong> and wait for it finish critical section &lt;strong>now&lt;/strong>.
&lt;img src="http://darrin.cc/p/ntnu-cps-real-time-system-model/pri_inversion_pip.jpeg"
width="4032"
height="2268"
srcset="http://darrin.cc/p/ntnu-cps-real-time-system-model/pri_inversion_pip_hu7427612375514599136.jpeg 480w, http://darrin.cc/p/ntnu-cps-real-time-system-model/pri_inversion_pip_hu16466701478648728697.jpeg 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="177"
data-flex-basis="426px"
>&lt;/p>
&lt;p>This has some situation that make it has higher blocking time than HLP, NPP. so we have the priority ceiling protocol(PCP) to solve this problem.&lt;/p>
&lt;h3 id="priority-ceiling-protocolpcp">Priority ceiling protocol(PCP)
&lt;/h3>&lt;p>$C(x)$: the priority ceiling of resource $x$&lt;br>
We can determine before execution, we ceiling the priority of the critical section, and also ceiling the priority of the task that enter the critical section to the ceiling priority of the critical section.&lt;br>
$C(S^*)$: the ceiling of the semaphore with the highest ceiling among all the semaphores currently locked by other tasks&lt;/p>
&lt;p>&lt;img src="http://darrin.cc/p/ntnu-cps-real-time-system-model/pri_inversion_pcp.jpeg"
width="4032"
height="2268"
srcset="http://darrin.cc/p/ntnu-cps-real-time-system-model/pri_inversion_pcp_hu3653945254522191760.jpeg 480w, http://darrin.cc/p/ntnu-cps-real-time-system-model/pri_inversion_pcp_hu13184298192124380473.jpeg 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="177"
data-flex-basis="426px"
>&lt;/p>
&lt;p>Which means that when we enter the critical section, we will set the priority of the task to the highest priority of all the task that may use the same critical section. only the task that has higher priority than the ceiling priority or the task that has higher priority than origin priority and is in non-critical section(don&amp;rsquo;t has any other critical section) can preempt the task that is in critical section.\&lt;/p>
&lt;p>in pthread support PIP and PCP&lt;/p>
&lt;h3 id="blocking-time-analysis">blocking time analysis
&lt;/h3>&lt;!-- delay of the origin higher priority task that caused by the lower priority task that is executing critical section. (time that from the **end** of the critical section that executing(may be the lower priority task) to the next same critical section(may be the higher priority) **start** execute again) \ -->、
&lt;p>blocking time: the time that the higher priority task is delay by the lower priority task.&lt;/p>
&lt;!-- why not max P + 1 -->
&lt;p>$P_i$: nominal priority level of task $\tau_i$&lt;br>
$P_i(R_k)$: atomic priority level of $\tau_i$ when it enters the critical section that utilizes resource $R_k$&lt;br>
$B_i$: maximum blocking time of task $\tau_i$ due to the priority change of some other tasks&lt;/p>
&lt;p>$B_i = max_{j,k}{\delta_{j,k} | Z_{j,k} \in r_n}$ (the longest critical section of $\tau_j$ guarded by section $S_k$); ($\delta_{j,k}$ is duration of $Z_{j,k}$; $Z_{j,k}$ is the longest critical section of $\tau_j$ guarded by semaphore $S_k$ )&lt;br>
$r_i$: the set of all the longest critical sections that can block $\tau_i$&lt;br>
$r_i$: $U_{(j: P_j &amp;lt; P_i)}$ $r_{i,j}$, where $r_{i,j} = {Z_{j,k} | s_k\in \sigma_{i,j} }$, where $\sigma_{i,j}$ is the set of semaphores(used by some lower-priority tasks $\tau_j$) that can block $\tau_i$&lt;/p>
&lt;ul>
&lt;li>NPP: $P_i(R_k) = max_h{P_h}$&lt;/li>
&lt;li>HLP: $P_i(R_k) = max_h{P_h | \tau_h \text{ uses } R_k}$&lt;/li>
&lt;li>PIP: $P_i(R_k) = max { P_i, max_h{P_h | \tau_h \text{ is blocked on } R_k}}$ (priority inheritance: $max_h$&amp;hellip;.)&lt;/li>
&lt;/ul>
&lt;p>For the PIP, the blocking time is the time that the &lt;strong>waiting&lt;/strong> for other critical section to finish&lt;/p></description></item><item><title>NTNU CPS Control Systems</title><link>http://darrin.cc/zh-tw/p/ntnu-cps-control-systems/</link><pubDate>Mon, 13 Apr 2026 00:00:00 +0800</pubDate><guid>http://darrin.cc/zh-tw/p/ntnu-cps-control-systems/</guid><description>&lt;h2 id="estimating-a-system-output">Estimating a System Output
&lt;/h2>&lt;p>There are two common ways to obtain a system output $x(t)$:&lt;/p>
&lt;ol>
&lt;li>Model the system with differential equations and solve them for $x(t)$.&lt;/li>
&lt;li>Find the impulse response $h(t)$ and compute the output from an input $u(t)$ using convolution:&lt;/li>
&lt;/ol>
&lt;p>$$
x(t)=u(t)*h(t).
$$&lt;/p>
&lt;h2 id="linear-time-invariant-systems">Linear Time-Invariant Systems
&lt;/h2>&lt;p>An LTI system satisfies both linearity and time invariance.&lt;/p>
&lt;h3 id="linearity">Linearity
&lt;/h3>&lt;p>If&lt;/p>
&lt;p>$$
u_1(t)\rightarrow x_1(t), \qquad u_2(t)\rightarrow x_2(t),
$$&lt;/p>
&lt;p>then, for constants $\alpha$ and $\beta$,&lt;/p>
&lt;p>$$
\alpha u_1(t)+\beta u_2(t)
\rightarrow
\alpha x_1(t)+\beta x_2(t).
$$&lt;/p>
&lt;p>This property combines homogeneity and additivity.&lt;/p>
&lt;h3 id="time-invariance">Time invariance
&lt;/h3>&lt;p>If&lt;/p>
&lt;p>$$
u(t)\rightarrow x(t),
$$&lt;/p>
&lt;p>then shifting the input by $\tau$ produces the same shift in the output:&lt;/p>
&lt;p>$$
u(t-\tau)\rightarrow x(t-\tau).
$$&lt;/p>
&lt;h2 id="impulse-response-and-convolution">Impulse Response and Convolution
&lt;/h2>&lt;p>The impulse response $h(t)$ is the output of an LTI system when the input is a unit impulse at $t=0$.&lt;/p>
&lt;p>Over a short interval $[\tau,\tau+\Delta\tau]$, the input contributes approximately&lt;/p>
&lt;p>$$
x_\tau(t)=u(\tau)\Delta\tau,h(t-\tau).
$$&lt;/p>
&lt;p>Summing all contributions and taking the limit gives the convolution integral:&lt;/p>
&lt;p>$$
x(t)=\int_0^t u(\tau)h(t-\tau),d\tau=u(t)*h(t).
$$&lt;/p>
&lt;h2 id="laplace-transform">Laplace Transform
&lt;/h2>&lt;p>The one-sided Laplace transform is&lt;/p>
&lt;p>$$
F(s)=\mathcal{L}{f(t)}=\int_0^\infty f(t)e^{-st},dt.
$$&lt;/p>
&lt;h3 id="example">Example
&lt;/h3>&lt;p>For $f(t)=e^{-at}$,&lt;/p>
&lt;p>$$
\begin{aligned}
\mathcal{L}{e^{-at}}
&amp;amp;=\int_0^\infty e^{-(a+s)t},dt \
&amp;amp;=\frac{1}{s+a}, \qquad \operatorname{Re}(s+a)&amp;gt;0.
\end{aligned}
$$&lt;/p>
&lt;h3 id="convolution-theorem">Convolution theorem
&lt;/h3>&lt;p>Convolution in the time domain becomes multiplication in the Laplace domain:&lt;/p>
&lt;p>$$
\mathcal{L}{f(t)*g(t)}=F(s)G(s).
$$&lt;/p>
&lt;h2 id="partial-fraction-decomposition">Partial-Fraction Decomposition
&lt;/h2>&lt;p>Partial fractions make inverse Laplace transforms easier. For example,&lt;/p>
&lt;p>$$
X(s)=\frac{c}{s(a_1s+a_2)}
=\frac{c}{a_2}\left(\frac{1}{s}-\frac{1}{s+\frac{a_2}{a_1}}\right).
$$&lt;/p>
&lt;p>Each term can then be transformed back to the time domain using a standard Laplace-transform table.&lt;/p>
&lt;h2 id="control-systems">Control Systems
&lt;/h2>&lt;h3 id="open-loop-control">Open-loop control
&lt;/h3>&lt;p>An open-loop controller sends a command to the plant without measuring the output for correction.&lt;/p>
&lt;div class="mermaid-scroll" tabindex="0" role="region" aria-label="Scrollable diagram">
&lt;pre class="mermaid">flowchart LR
R[&amp;#34;R(s): reference&amp;#34;] --&amp;gt; C[&amp;#34;C(s): controller&amp;#34;]
C --&amp;gt;|&amp;#34;U(s)&amp;#34;| G[&amp;#34;G(s): plant&amp;#34;]
G --&amp;gt; X[&amp;#34;X(s): output&amp;#34;]
&lt;/pre>
&lt;/div>&lt;p>The transfer function from reference to output is&lt;/p>
&lt;p>$$
\frac{X(s)}{R(s)}=C(s)G(s).
$$&lt;/p>
&lt;h3 id="closed-loop-control">Closed-loop control
&lt;/h3>&lt;p>A closed-loop controller feeds the measured output back to the input and uses the error $E(s)$ to correct the system.&lt;/p>
&lt;div class="mermaid-scroll" tabindex="0" role="region" aria-label="Scrollable diagram">
&lt;pre class="mermaid">flowchart LR
R[&amp;#34;R(s): reference&amp;#34;] --&amp;gt; S((+))
S --&amp;gt;|&amp;#34;E(s)&amp;#34;| C[&amp;#34;C(s): controller&amp;#34;]
C --&amp;gt;|&amp;#34;U(s)&amp;#34;| G[&amp;#34;G(s): plant&amp;#34;]
G --&amp;gt; X[&amp;#34;X(s): output&amp;#34;]
X --&amp;gt;|feedback| S
&lt;/pre>
&lt;/div>&lt;p>For unity negative feedback,&lt;/p>
&lt;p>$$
E(s)=R(s)-X(s), \qquad X(s)=G(s)C(s)E(s),
$$&lt;/p>
&lt;p>so the closed-loop transfer function is&lt;/p>
&lt;p>$$
\frac{X(s)}{R(s)}=\frac{C(s)G(s)}{1+C(s)G(s)}.
$$&lt;/p></description></item><item><title>NTNU CPS Fourier Analysis</title><link>http://darrin.cc/zh-tw/p/ntnu-cps-fourier-analysis/</link><pubDate>Mon, 13 Apr 2026 00:00:00 +0800</pubDate><guid>http://darrin.cc/zh-tw/p/ntnu-cps-fourier-analysis/</guid><description>&lt;h2 id="function-decomposition">Function Decomposition
&lt;/h2>&lt;p>Fourier analysis represents a function as a weighted sum of basis functions:&lt;/p>
&lt;p>$$
f(x)=a_1f_1(x)+a_2f_2(x)+\cdots.
$$&lt;/p>
&lt;p>Two functions $f_1$ and $f_2$ are orthogonal on $[a,b]$ if their inner product is zero:&lt;/p>
&lt;p>$$
\langle f_1,f_2\rangle=\int_a^b f_1(x)f_2(x),dx=0.
$$&lt;/p>
&lt;h3 id="vector-space-analogy">Vector-space analogy
&lt;/h3>&lt;p>For an orthogonal basis ${\mathbf{i},\mathbf{j}}$,&lt;/p>
&lt;p>$$
\mathbf{y}=a_1\mathbf{i}+a_2\mathbf{j},
$$&lt;/p>
&lt;p>and each coefficient can be obtained by projection:&lt;/p>
&lt;p>$$
a_1=\frac{\langle\mathbf{y},\mathbf{i}\rangle}{\lVert\mathbf{i}\rVert^2},
\qquad
a_2=\frac{\langle\mathbf{y},\mathbf{j}\rangle}{\lVert\mathbf{j}\rVert^2}.
$$&lt;/p>
&lt;p>The same idea is used to compute Fourier coefficients.&lt;/p>
&lt;h2 id="orthogonal-trigonometric-basis">Orthogonal Trigonometric Basis
&lt;/h2>&lt;p>The function set&lt;/p>
&lt;p>$$
\left{1,\cos\frac{n\pi x}{P},\sin\frac{n\pi x}{P}\right},
\qquad n\in\mathbb{N},
$$&lt;/p>
&lt;p>is orthogonal over any interval of length $2P$, such as $[a,a+2P]$.&lt;/p>
&lt;p>The proof considers five pairings:&lt;/p>
&lt;ol>
&lt;li>$1$ and $\cos(n\pi x/P)$&lt;/li>
&lt;li>$1$ and $\sin(n\pi x/P)$&lt;/li>
&lt;li>$\cos(n\pi x/P)$ and $\sin(m\pi x/P)$&lt;/li>
&lt;li>$\cos(n\pi x/P)$ and $\cos(m\pi x/P)$ for $n\ne m$&lt;/li>
&lt;li>$\sin(n\pi x/P)$ and $\sin(m\pi x/P)$ for $n\ne m$&lt;/li>
&lt;/ol>
&lt;p>For example,&lt;/p>
&lt;p>$$
\int_a^{a+2P}\cos\frac{n\pi x}{P},dx
=\frac{P}{n\pi}
\left[\sin\frac{n\pi x}{P}\right]_a^{a+2P}=0.
$$&lt;/p>
&lt;p>The remaining cases follow from periodicity and the product-to-sum identities.&lt;/p>
&lt;h2 id="fourier-series">Fourier Series
&lt;/h2>&lt;p>For a function $f(x)$ defined on $[-P,P]$, its Fourier series is&lt;/p>
&lt;p>$$
f(x)=\frac{a_0}{2}
+\sum_{n=1}^{\infty}
\left(
a_n\cos\frac{n\pi x}{P}
+b_n\sin\frac{n\pi x}{P}
\right),
$$&lt;/p>
&lt;p>where&lt;/p>
&lt;p>$$
\begin{aligned}
a_0&amp;amp;=\frac{1}{P}\int_{-P}^{P}f(x),dx, \
a_n&amp;amp;=\frac{1}{P}\int_{-P}^{P}f(x)\cos\frac{n\pi x}{P},dx, \
b_n&amp;amp;=\frac{1}{P}\int_{-P}^{P}f(x)\sin\frac{n\pi x}{P},dx.
\end{aligned}
$$&lt;/p>
&lt;p>The coefficients are projections onto the orthogonal trigonometric basis. For example,&lt;/p>
&lt;p>$$
a_n=
\frac{\left\langle f(x),\cos\frac{n\pi x}{P}\right\rangle}
{\left\lVert\cos\frac{n\pi x}{P}\right\rVert^2}.
$$&lt;/p>
&lt;h3 id="example">Example
&lt;/h3>&lt;p>Consider&lt;/p>
&lt;p>$$
f(x)=
\begin{cases}
0, &amp;amp; -\pi&amp;lt;x&amp;lt;0, \
\pi-x, &amp;amp; 0\le x&amp;lt;\pi.
\end{cases}
$$&lt;/p>
&lt;p>With $P=\pi$,&lt;/p>
&lt;p>$$
a_0=\frac{1}{\pi}\int_0^\pi(\pi-x),dx=\frac{\pi}{2},
$$&lt;/p>
&lt;p>$$
a_n=\frac{1-(-1)^n}{n^2\pi},
\qquad
b_n=\frac{1}{n}.
$$&lt;/p>
&lt;h2 id="from-fourier-series-to-fourier-integral">From Fourier Series to Fourier Integral
&lt;/h2>&lt;p>Let&lt;/p>
&lt;p>$$
\alpha_n=\frac{n\pi}{P},
\qquad
\Delta\alpha=\frac{\pi}{P}.
$$&lt;/p>
&lt;p>As $P\to\infty$, the spacing $\Delta\alpha\to0$ and the Fourier-series sum becomes an integral:&lt;/p>
&lt;p>$$
f(x)=\frac{1}{\pi}\int_0^\infty
\left[A(\alpha)\cos(\alpha x)+B(\alpha)\sin(\alpha x)\right]d\alpha,
$$&lt;/p>
&lt;p>where&lt;/p>
&lt;p>$$
A(\alpha)=\int_{-\infty}^{\infty}f(t)\cos(\alpha t),dt,
$$&lt;/p>
&lt;p>$$
B(\alpha)=\int_{-\infty}^{\infty}f(t)\sin(\alpha t),dt.
$$&lt;/p>
&lt;h2 id="complex-fourier-series">Complex Fourier Series
&lt;/h2>&lt;p>Euler&amp;rsquo;s formula gives&lt;/p>
&lt;p>$$
e^{ix}=\cos x+i\sin x,
\qquad
e^{-ix}=\cos x-i\sin x.
$$&lt;/p>
&lt;p>Therefore,&lt;/p>
&lt;p>$$
\cos x=\frac{e^{ix}+e^{-ix}}{2},
\qquad
\sin x=\frac{e^{ix}-e^{-ix}}{2i}.
$$&lt;/p>
&lt;p>The Fourier series can be written in complex form as&lt;/p>
&lt;p>$$
f(x)=\sum_{n=-\infty}^{\infty}C_ne^{i n\pi x/P},
$$&lt;/p>
&lt;p>with&lt;/p>
&lt;p>$$
C_n=\frac{1}{2P}\int_{-P}^{P}f(x)e^{-i n\pi x/P},dx.
$$&lt;/p>
&lt;h2 id="fourier-transform">Fourier Transform
&lt;/h2>&lt;p>Using the standard angular-frequency convention, the Fourier transform is&lt;/p>
&lt;p>$$
F(\omega)=\int_{-\infty}^{\infty}f(t)e^{-i\omega t},dt,
$$&lt;/p>
&lt;p>and the inverse transform is&lt;/p>
&lt;p>$$
f(t)=\frac{1}{2\pi}\int_{-\infty}^{\infty}F(\omega)e^{i\omega t},d\omega.
$$&lt;/p>
&lt;p>The value $F(\omega)$ describes the contribution of the complex exponential $e^{i\omega t}$ at angular frequency $\omega$.&lt;/p>
&lt;h2 id="discrete-fourier-transform">Discrete Fourier Transform
&lt;/h2>&lt;p>Sampling a continuous signal every $T$ seconds gives samples&lt;/p>
&lt;p>$$
x_n=f(nT).
$$&lt;/p>
&lt;p>For $N$ samples, the discrete Fourier transform (DFT) is&lt;/p>
&lt;p>$$
X_k=\sum_{n=0}^{N-1}x_ne^{-i2\pi kn/N},
\qquad k=0,1,\ldots,N-1.
$$&lt;/p>
&lt;p>The inverse DFT is&lt;/p>
&lt;p>$$
x_n=\frac{1}{N}\sum_{k=0}^{N-1}X_ke^{i2\pi kn/N}.
$$&lt;/p>
&lt;h2 id="fast-fourier-transform">Fast Fourier Transform
&lt;/h2>&lt;p>The fast Fourier transform (FFT) is an efficient family of algorithms for computing the DFT. A direct DFT requires $O(N^2)$ operations, while an FFT reduces the complexity to $O(N\log N)$.&lt;/p></description></item><item><title>NTNU CPS Introduction</title><link>http://darrin.cc/zh-tw/p/ntnu-cps-introduction/</link><pubDate>Tue, 24 Feb 2026 00:00:00 +0800</pubDate><guid>http://darrin.cc/zh-tw/p/ntnu-cps-introduction/</guid><description>&lt;h2 id="cyber-physical-system-components">Cyber-Physical System Components
&lt;/h2>&lt;p>A cyber-physical system (CPS) combines computation, communication, and physical processes. Its main components are:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Plant&lt;/strong>
&lt;ul>
&lt;li>Sensors&lt;/li>
&lt;li>Actuators&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;strong>Controller&lt;/strong>&lt;/li>
&lt;li>&lt;strong>Wireless network&lt;/strong>
&lt;ul>
&lt;li>Connects multiple nodes and carries data and control flows&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;p>The plant sends sensed data to the controller. After computing a control decision, the controller sends a control flow back to the plant&amp;rsquo;s actuators. These components communicate through the wireless network.&lt;/p>
&lt;div class="mermaid-scroll" tabindex="0" role="region" aria-label="Scrollable diagram">
&lt;pre class="mermaid">flowchart LR
P[Plant] -- Sensed data --&amp;gt; N[Wireless network]
N --&amp;gt; C[Controller]
C -- Control command --&amp;gt; N
N --&amp;gt; A[Actuator]
A --&amp;gt; P
&lt;/pre>
&lt;/div>&lt;h2 id="inside-the-wireless-network">Inside the Wireless Network
&lt;/h2>&lt;h3 id="cyber-layer-network-manager">Cyber layer: network manager
&lt;/h3>&lt;p>The network manager monitors and reconfigures the wireless network. After a configuration change, the network acknowledges the network manager.&lt;/p>
&lt;h3 id="physical-layer-controller-and-plant">Physical layer: controller and plant
&lt;/h3>&lt;p>The controller actuates the plant, while sensors measure the plant&amp;rsquo;s state and return observations to the controller.&lt;/p>
&lt;p>When developing a CPS, the cyber and physical parts should be designed as one system. Joint design can reveal optimization opportunities that are missed when networking, computation, and control are considered independently.&lt;/p>
&lt;h2 id="timing-and-signal-processing">Timing and Signal Processing
&lt;/h2>&lt;p>Engineers usually assign conservative deadlines to sensing and control flows so that the system remains safe under worst-case conditions.&lt;/p>
&lt;p>Fourier analysis is useful for decomposing and processing sensor signals, while control theory determines how the system should respond to those signals.&lt;/p></description></item></channel></rss>