0
\$\begingroup\$

I have developed an embedded electronics system centered around the Arduino Due. In my application, I am controlling the force of the end effector of a rigid object using a DC motor. The feedback force sensor has a lot of dead-time and I am unable to get the performance I expect with a standard PID. I am now looking into model predictive control, however at first I will try to use a Smith predictor. To do this, we need to develop an internal model describing the system we have. I have never done this and I need some guidance on formulating a discrete model and implementing it in C++/Arduino.

So far, I developed a continuous-time model based off of input-output data using System Identification Toolbox in MATLAB. Then I performed appropriate discretization (zero-order hold) to get a discrete model, \$H(z)\$, in the z-domain. To implement this in C++/Arduino I believe I am supposed to perform the inverse z-transform to get \$h[n]\$. \$h[n]\$ is then written in a interrupt service routine (ISR) to get the model output.

For instance, my continuous model is:

$$H = \frac{1}{5s+10}$$

Using zero-order hold at 100 Hz, the discrete model is:

$$H_{zoh} = \frac{0.00198}{z-0.9802}$$

Sample time: 0.01 seconds

Using the z-transform table, the inverse \$h[n]\$ is:

$$h[n] = 0.00198 \cdot \mathcal{H}(n-1) \cdot 0.9802^{(n-1)}$$

So far, is what I have been doing on the right track? If so, how would I implement this in an ISR?

\$\endgroup\$
3
  • \$\begingroup\$ The problem is you have three fairly different types of questions here: is your control system proposal sound, how one implements a discrete time controller on a small MCU, and specifically what that looks like in Arduino-style code. \$\endgroup\$ Commented Jun 6, 2016 at 17:37
  • \$\begingroup\$ @ChrisStratton Out of the three problems you interpreted, "How one implements a discrete time model* on a small MCU" is the most appropriate. I understand how to implement in Arduino-style code as well as verifying if the control system is viable. \$\endgroup\$ Commented Jun 6, 2016 at 18:06
  • \$\begingroup\$ I don't get it, why inverse? If you want implement the function you just have to use recursive formula tha you'll find for FIR filter, you have 1st order. \$\endgroup\$ Commented Jun 6, 2016 at 18:07

1 Answer 1

1
\$\begingroup\$

You can write your system as \$H(z)=\dfrac{B(z)}{A(z)}\$ the use a recursive formula for IIR filter where you have A and B coefficients. Before you have to change the form to have denominator like \$ A(z) = 1+a1\cdot z^{-1}+ a2\cdot z^{-2}+..\$ by multiplying your form

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ Thank you very much Marko. I will try to do this however I found it much easier to transform the transfer function into a state-space representation using MATLAB and implementing the state-space model into Arduino. MatrixMath is a great library for this! \$\endgroup\$ Commented Jun 9, 2016 at 13:52
  • \$\begingroup\$ Above formula is the simplest form y=b0*input-a1*y; b0=-0.00198/0.9802, a1=-1/0.9802. \$\endgroup\$ Commented Jun 9, 2016 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.