3.5 DiscreteTime Models of ContinuousTime Systems
If an analog system is to be analyzed in the discretetime domain, the problem arises of finding a discretetime representation of the system such that the output variables sampled at times suitably approximate the ones of the original system. A possible way to make such a conversion is to apply the function ToDiscreteTime to a continuoustime system. ToDiscreteTime operates on all control objects. Note that the builtin functions LaplaceTransform and ZTransform can, in principle, perform similar task. However, the procedures in Control System Professional use the statespace approach and so the conversion is, as a rule, more efficient.
Finding discretetime equivalents of continuoustime systems.
Consider a simple continuoustime system.
In[45]:=
Out[45]=
This is a possible discretetime approximation. As noted previously, the formal internal variable (in this case s) does not indicate the domain, but the Sampled option does.
In[46]:=
Out[46]=
Should the need arise, it is easy to rename the formal variable.
In[47]:=
Out[47]=
Consider a statespace continuoustime system.
In[48]:=
Out[48]//TraditionalForm=
This is its discretetime approximation. The result is still a StateSpace object that is in the discretetime domain as indicated by the option Sampled.
In[49]:=
Out[49]=
Here is the same system in TraditionalForm.
In[50]:=
Out[50]//TraditionalForm=
The default value for the option Sampled in ToDiscreteTime is the global variable $SamplingPeriod. This variable also provides a fallback where some functions retreat in situations when the sampling period does not evaluate to a number, but the numeric value is needed to perform the task (for example, to simulate the transient behavior of a system). Thus, $SamplingPeriod must never be set to anything that has no numeric value. If it is desirable for ToDiscreteTime to use a symbolic sampling period T by default, this can be easily achieved by using the standard Mathematica mechanism, say with a command .
It is worth emphasizing that the "conversion" from an analog to a sampled system is merely an approximation, the quality of which depends on the method used and the sampling period. The timedomain response functions described later in Chapter 4 can make the difference between the original and approximated system readily apparent.
This is the analog output response of the original system to the sinusoidal input signal.
In[51]:=
Out[51]=
Here is a piece of that curve on the time interval from 0 to 10 seconds.
In[52]:=
This plots the simulated response of the discretetime system for the sampling period of 0.5 seconds over the same time interval. For reference, we include the analog response from the previous plot (structurally, the line is the first element of the Graphics object returned by the previous command and is extracted with First).
In[53]:=
We can see that the sampled values systematically lag behind corresponding points on the analog curve, which is typical for the default ZeroOrderHold method. Choosing smaller values for can make the lag less noticeable.
3.5.1 The Conversion Methods
The conversion from the continuoustime domain to the discretetime domain can be performed using the following methods (see Franklin et al. (1990), Section 4). The method can be selected with the Method option.
Hold equivalence methods—zero and firstorder (triangle) hold, implemented with ZeroOrderHold and FirstOrderHold, respectively
Numerical integration methods—forward and backward rectangular rules, implemented with ForwardRectangularRule and BackwardRectangularRule, respectively, and bilinear (Tustin) transformation with and without prewarping, implemented with BilinearTransform
Zeropole mapping, implemented with ZeroPoleMapping
Options related to continuous to discretetime conversion.
This is the result of conversion with the forward rule of the transfer function system tf defined earlier in this chapter.
In[54]:=
Out[54]=
This is the conversion of the same transfer function using the backward rule.
In[55]:=
Out[55]=
This conversion uses the bilinear transformation.
In[56]:=
Out[56]=
This uses the zeropole mapping.
In[57]:=
Out[57]=
This is the firstorderhold equivalent of the transfer function .
In[58]:=
Out[58]=
Yet another example, which uses a lag network, illustrates the effect of the option CriticalFrequency on accuracy of the conversion.
In[59]:=
Out[59]=
Here is the Bode plot for the network for some set of parameters.
In[60]:=
This is the network after the bilinear transformation.
In[61]:=
Out[61]=
This computes the Bode plots for continuous and sampled lag networks—and displays them together using a utility function DisplayTogetherGraphicsArray (see Section 12.5). The responses coincide for the low frequencies but differ somewhat near the Nyquist frequency.
In[62]:=
We again use BilinearTransform, this time with frequency prewarping at some critical frequency .
In[63]:=
Out[63]=
We have achieved a perfect match at that frequency at the expense of less accurate behavior at other frequencies.
In[64]:=
Except for zeropole mapping, which naturally operates on ZeroPoleGain objects, the conversion from the continuous to the discretetime domain is implemented with statespace algorithms. Therefore, the transformation to and from StateSpace objects can be avoided if the system is represented in StateSpace in the first place.
This is our lag system as a StateSpace object.
In[65]:=
Out[65]//TraditionalForm=
This converts the system to discrete time using the bilinear transformation.
In[66]:=
Out[66]//TraditionalForm=
