Chapter 4.4: Modeling Continuous-Time Systems In Discrete Time
Chapter 4.4: Modeling Continuous-Time Systems In Discrete Time
Overview of Modeling Continuous-Time Transfer Functions
Continuous-time transfer functions are mathematical representations that describe the input-output relationships in systems that operate over continuous time.
This chapter aims to convert continuous-time transfer functions (defined in the Laplace domain, or s-domain) into discrete-time transfer functions (defined in the z-domain).
Learning Objectives
List Four Methods for Approximation: Identify the four methods used for approximating the variable s in terms of z for conversion purposes.
Utilization of Approximation Methods: Apply the learned methods to convert continuous-time transfer functions to discrete-time transfer functions manually.
Implementation Using Python: Write Python code to perform the conversions from continuous-time transfer functions in the s-domain to discrete-time transfer functions in the z-domain.
4.4.1: Converting H(s) to H(z) Using Exponential Relationship
Conversion Explanation: The conversion from s to z involves writing the exponential form as follows:
Example Function Derived: Given a function:
The resulting nonlinear function is not usable directly in the discrete-time domain.
4.4.2: Approximating Methods for Continuous-Time Functions
Linear Approximation Requirement: Since the direct relationship creates nonlinear functions, approximations must be employed to ensure linear characteristics.
Example of Sampling Frequency: Assume a uniform sampling frequency of 20 samples per second, defined as:
4.4.2.1: Forward Euler or Forward Difference Approximation
Approximation Basis: Uses the Maclaurin series expansion of the exponential function for linear approximation.
Taylor Series Formula: The series representation:
First-Order Approximation: Taking only the first two terms results in:
Discrete-Time Transfer Function: Substitute into the transfer function to write it in polynomial form:
For the assumed sampling period:
4.4.2.2: Backward Euler or Backward Difference Approximation
Conceptual Foundation: Similar to the forward method but uses a different series expansion.
Formula Derivation: Forwarding the difference gives:
Resulting Transfer Function in z-domain: Incorporates similar steps as in the forward method but yields:
4.4.2.3: Bilinear Approximation or Tustin’s Method
Purpose: Aims to encapsulate the qualities of both the forward and backward approximations for a more balanced result.
Approximation Expression: Represents the relationship using:
Normalized Resulting Function: Upon substitution:
H(z) = \frac{10zT}{z-1} + . . .$ leading to a balanced function representation.
4.4.3: Creating Discrete-Time Transfer Functions with Scipy
Scipy Utility: In Python, using the Scipy library for rapid solutions is ideal.
Sample Python Code: To define the transfer functions as shown in Code Block 4.4-1:
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal as sig
num = [10]
den = [1, 10]
H_s = sig.lti(num, den)
dt = 0.05
H_z_fe = H_s.to_discrete(dt=dt, method='euler')
print('Forward Euler\n', H_z_fe)
H_z_be = H_s.to_discrete(dt=dt, method='backward_diff')
print('Backward Euler\n', H_z_be)
H_z_b = H_s.to_discrete(dt=dt, method='bilinear')
print('Bilinear\n', H_z_b)
4.4.4: Finding a Discrete-Time Output Signal by Hand
Output Calculation: To generate an output signal from the discrete transfer function, find the z-transform of the input signal.
Input Signal Example: Use a step function with a magnitude of 5.
Transforming Input: This gives us:
x(z) = \frac{5z}{z - 1}y(z) = H(z)x(z) y(z) = H(z) x(z) = \frac{(0.2z + 0.2)(5z)}{z-0.6}
4.4.5: Finding an Output Signal with Scipy
Scipy Application for Residues: Finding residues and poles using Scipy:
num = [1, 1]
den = [1, -1.6, 0.6]
r, p, k = sig.residue(num, den)
print('residues =', r)
print('poles =', p)
print('k=', k)
Effective Output Representation: Utilize the residue method for transformation back to the indexed domain utilizing:
y[k] = -4(0.6)^k + 5u[k]y[t] = 5 - 4 e^{-10.2 t} ext{ for } t \geq 0 $$
Plotting Results
Comparative Visualization: Code to generate outputs for comparison between continuous and discrete systems:
# create plots for visual comparison plt.plot(t2, y_t) plt.scatter(t1, y_kT) plt.xlabel('time, t [s]') plt.ylabel('output') plt.ylim([-1, 6]) plt.legend(['continuous', 'bilinear'], loc='lower right') plt.title('A magnitude of 5 step response bilinear approximation') plt.grid()Figure 4.4-1: Showcases the comparison of discrete-time filter outputs against their continuous-time counterparts, highlighting approximation accuracy based on sampling rates.
Conclusion
Three approximations exist for converting continuous-time to discrete-time transfer functions.
Each method provides a legitimate yet distinct approximation of the transfer function, allowing selection based on requirements in the context of practical applications and implementation in computational systems.