# Asymptotic Output Tracking with Estimator

Design a controller for a cardiac pacemaker to maintain a healthy ECG signal. The controller has to incorporate an estimator since not all signals are measured. »

A third-order heartbeat model.

 In[1]:= Xasys = AffineStateSpaceModel[ {{-((\!\( \*SubsuperscriptBox[\(x\), \(1\), \(3\)] + \( \*SubscriptBox[\(x\), \(1\)]\ \*SubscriptBox[\(x\), \(2\)]\) + \*SubscriptBox[\(x\), \(3\)]\))/\[Epsilon]), -2 Subscript[x, 1] - 2 Subscript[x, 2], -1 - Subscript[x, 2]}, {{ 0 }, {0 }, {1 }}, {Subscript[x, 3]}, {{ 0 }}}, {Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}, {u}, {Automatic}, Automatic , SamplingPeriod -> None] /. \[Epsilon] -> 0.2;

With completely zero stimuli, the ECG signal is zero.

 In[2]:= Xasys = AffineStateSpaceModel[ {{-((\!\( \*SubsuperscriptBox[\(x\), \(1\), \(3\)] + \( \*SubscriptBox[\(x\), \(1\)]\ \*SubscriptBox[\(x\), \(2\)]\) + \*SubscriptBox[\(x\), \(3\)]\))/\[Epsilon]), -2 Subscript[x, 1] - 2 Subscript[x, 2], -1 - Subscript[x, 2]}, {{ 0 }, {0 }, {1 }}, {Subscript[x, 3]}, {{ 0 }}}, {Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}, {u}, {Automatic}, Automatic , SamplingPeriod -> None] /. \[Epsilon] -> 0.2;; StateResponse[{asys, {0, 0, 0.5}}, 0, {t, 0, 40}]; Plot[Evaluate[%], {t, 0, 40}, PlotLegends -> {"\!\(\*SubscriptBox[\(x\), \(1\)]\) Length of muscle \ fiber", "\!\(\*SubscriptBox[\(x\), \(2\)]\) Tension in muscle fiber", "\!\(\*SubscriptBox[\(x\), \(3\)]\) ECG signal"}]
 Out[2]=

The model reveals some zero dynamics involving states and .

 In[3]:= X\[ScriptCapitalF] = FeedbackLinearize[ asys, {{Subscript[z, 1], Subscript[z, 2], Subscript[z, 3]}, v}];
 In[4]:= X{\[ScriptCapitalF]["ZeroDynamics"], Rest@\[ScriptCapitalF]["InverseStateTransformation"]}
 Out[4]=

The zero dynamics are well behaved.

 In[5]:= X{\[ScriptCapitalF]["ZeroDynamics"], Rest@\[ScriptCapitalF]["InverseStateTransformation"]}; Normal[\[ScriptCapitalF]["ZeroDynamics"]][[1, 1]] /. z_[\[FormalT]] :> z; StreamPlot[%, {Subscript[z, 2], -3, 3}, {Subscript[z, 3], -3, 3}, Epilog -> {PointSize[Medium], Point[{{0, 0}, {1, -1}}]}]
 Out[5]=

A reference data for is obtained from physionet.org.

Compute the tracking controller.

 In[7]:= X\[Kappa] = AsymptoticOutputTracker[asys, ecgRef, {-350}]
 Out[7]=

Compute a set of estimator gains.

 In[8]:= X\[ScriptL] = EstimatorGains[ StateSpaceModel[asys], {-350, -370 + 10 I, -370 - 10 I}]
 Out[8]=

The complete controller.

 In[9]:= XSimplify[\[ScriptC] = EstimatorRegulator[asys, {\[ScriptL], \[Kappa]}]]
 Out[9]=

The simulation shows that the tracking has been achieved.

 In[10]:= Xcsys = SystemsModelFeedbackConnect[asys, \[ScriptC]]; or = OutputResponse[{csys, {0, 0, 0.5, 0, 0, 0}}, 0, {t, 0, 3}];
 In[11]:= XPlot[{ecgRef, or}, {t, 0, 3}, PlotRange -> {All, {-1, 1.2}}, PlotLegends -> {"Reference", "Actual"}]
 Out[11]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »