Implementing a Discrete-Time Model (Z-Domain) in Arduino

Hello,

I am trying to implement a continuous-time transfer function which has been discretized (into the z-domain) in Arduino.

For instance, lets say I have a model with the following transfer function:

H =

                    s - 1
  exp(-0.3*s) * -------------
                s^2 + 4 s + 5

Using zero-order hold with a sampling time of 0.01 seconds. The model looks like:

H_zoh =

            0.009752 z - 0.009851
  z^(-30) * ---------------------
            z^2 - 1.96 z + 0.9608

Next, I want to implement this in Arduino and simulate a step response. However I do not know how to implement a discrete-time transfer function in Arduino.

I have already set up a 100 Hz timer, however I do not know what to do from there.

I hope this was the correct forum to ask.

Daniel

https://en.wikipedia.org/wiki/Digital_filter#Filter_realization

Technically you are implementing a digital filter, the Z-transform maps between continuous and discrete domains, you are not implementing the Z-transform!

MarkT: Technically you are implementing a digital filter, the Z-transform maps between continuous and discrete domains, you are not implementing the Z-transform!

Yes you are correct - I will change the title of the thread. What I am trying to do is implement a discrete-time model (in the z-domain) into Arduino. I have a z-transform already as well as a timer and now I need to implement the model some how.

Regarding my application, the model will be used for motor control and not digital filtering, but the implementation of the discrete model is the same.

dgelman:
I have already set up a 100 Hz timer, however I do not know what to do from there.

Post what you have. Please use
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags.