Part II: Algorithm FormulationPreviously in Part I: Discretization and Simulation, we discuss the process of obtaining a discrete-time transfer function that represents our HDM plant. At the end, we want an algorithm that can be executed on an embedded computer. Before that, some intermediate step is essential; i.e., the discrete-time transfer function must be put into some structure ready to be formulated to an algorithm. Using digital signal processing terminology, it is called a direct form, abbreviated DF.
Direct Form ConversionLong time ago, we used to discuss in our dated article Linear Controllers: From Design to Implementation on how to manipulate between direct forms such that the embedded resources are minimized. To focus on that trick, we extract a figure from that material to Figure 1 below, which shows the process of rearranging DFI into DFII. We see that the number of delay blocks is reduced in half. One delay means one memory address. The resulting algorithm also appears somewhat simpler.
(2)Parameters and coefficients in (1) and (2) are defined as in our previous article. We need to rearrange (1),(2) in the same form as in Figure 1. Starting from (1), We multiply both numerator and denominator by and factor out the leading coefficient from the denominator. This yields
(3)with , , , , , , and , , , , , . Similarly, we can rearrange (2) to
(4)with , , ,and , , . With this rearrangement, we can construct the diagram in Figure 2 with (3),(4) in DFII as in Figure 3.
Algorithmic Difference Equation from DFII StructureFrom a discrete transfer function described ad DFII, it is straightforward to transform to a difference equation in time-domain, using the fact that represents a unit delay. So for a Z-transform representation of a sample signal , is simply , or the previous sample of that signal. Continuing in this fashion, in Z-domain corresponds to in the time-domain. The samples at inputs and outputs of unit delays in Figure 3 are referred to as the states. As an example on how to develop an algorithm for the discrete subsystem , let us define its state as as in Figure 5.
(5)and the output is computed from
(6)Do not forget that in the real-time system this algorithm must be implemented as a timer function with specified period . Each time the timer interrupt is called, this process must be executed
- update the states
- compute new state
- compute output
Scilab Script and Model FilesThe files used this document are
- hdmhil.sce : Scilab script file for parameter initialization and transfer function computation
- hdm_implement.zcos : Xcos model for DFII simulation
- dhdmsim.sce : Script for algorithm simulation
- dhdmcompare.sce : Script for response comparison. Use data from hdm_implement.zcos and dhdmsim.sce
Note :execute the script file hdmhil.sce first before running simulationDownload all as zip file: hilhdm2.zip