Please enable JavaScript to view this site.

Waijung 2 User Guide

Discrete-time

Discrete-time refers to a type of signal or system where the data is sampled or updated at specific discrete time intervals, rather than being continuous. In contrast to continuous-time systems, where signals are continuously varying with time, discrete-time systems process data in a step-by-step manner at discrete time points.

The need for discrete-time arises in various real-world applications, especially when using microcontrollers like the ESP32. Some reasons for using discrete-time systems are:

 

1.Digital Processing: Microcontrollers, including the ESP32, are inherently digital devices. They work with binary data, and processing signals in the digital domain is more straightforward and efficient. By converting continuous-time signals into discrete-time signals, the ESP32 can process and manipulate data using digital algorithms, such as filtering, control algorithms, and signal processing techniques.

2.Sampling: In many practical applications, obtaining continuous measurements or controlling continuous processes in real-time is not always feasible or cost-effective. Sampling a continuous signal at discrete intervals allows capturing and processing its essential features while reducing the data size and computational complexity.

3.Compatibility: Many real-world systems and sensors provide data in a discrete-time format, making it convenient to work directly with sampled data without the need for continuous-to-discrete conversion.

 

For applications like embedded control, sensor interfacing, data logging, and IoT (Internet of Things) projects, using discrete-time systems with microcontrollers like the ESP32 offers an effective and practical solution. It enables efficient digital signal processing, control, and communication while making the most of the resources available on these micro-controllers.

 

Reference: Convert model from continuous to discrete time - MATLAB c2d

Discretize the RC Controller

Step 1: Get Designed Controller Transfer Function (Continuous-time)

Step 2: Add Continuous-time controller transfer function in the MATLAB workspace

Use following Matlab Commands to create Continuous-time Transfer Function:

Cs_num = [5.6882 7486];

Cs_den = [1 0];

Cs = tf(Cs_num,Cs_den)

Figure 38: MATLAB Commands for Creating the Continuous-time Transfer Function of the Controller

Figure 38: MATLAB Commands for Creating the Continuous-time Transfer Function of the Controller

Step 3: Convert Continuous-time controller transfer function to Discrete-time controller transfer function

Use following Matlab Command to convert to Discrete-time Transfer Function:

Gz = c2d(Gs,0.05,'zoh')

 

0.05 - Sample time
'zoh' - Discretization method: Zero-order hold (default). Assumes the control inputs are piecewise constant over the sample time Ts.

Figure 39: MATLAB Command for Converting the Controller's Transfer Function to Discrete-time

Figure 39: MATLAB Command for Converting the Controller's Transfer Function to Discrete-time

Evaluate Discrete-time controller transfer function

Step 1: Get Designed Controller Transfer Function (Discrete-time)

Step 2: Create the Simulink model

Simulink Model: rc_controller_dis_sim.slx

Use following blocks:

For Input : Use Step block

To create controller and plant : Discrete Transfer Fcn,Transfer Fcn, Add, Rate Transition

For Output : Use Scope

Figure 40: Simulink Model Comparing Continuous-time and Discrete-time Controllers

Figure 40: Simulink Model Comparing Continuous-time and Discrete-time Controllers

Step 3: Run Simulation and Open Scope for the results

Figure 41: Comparative Results of the Simulink Model Comparing Continuous-time and Discrete-time Controllers

Figure 41: Comparative Results of the Simulink Model Comparing Continuous-time and Discrete-time Controllers

 

When analyzing the output presented in Figure 39, it's important to clarify that the focus is solely on the controller's performance without the inclusion of the plant. This discussion centers on the comparison between the discretized transfer function and the continuous-time transfer function, highlighting the variations that can arise between these two aspects. When comparing the discretized transfer function with the continuous-time transfer function, it is common to observe some differences between the two. Discretization is the process of converting a continuous-time system into its discrete-time equivalent, usually to implement the control or signal processing algorithms on digital platforms like microcontrollers. While the discrete-time system aims to approximate the continuous-time behavior, it may not exactly match the continuous-time response due to several reasons.

One of the primary reasons for the discrepancies is the sampling time used during discretization. A finite sampling time introduces quantization errors and aliasing effects, leading to discrepancies between the two systems. Additionally, the chosen discretization method and the order of the discretization can affect the accuracy of the results.

Furthermore, the discrete-time system operates in a step-by-step manner at specific intervals, which inherently introduces a time delay compared to the continuous-time system. This time delay can affect the dynamic response of the discrete-time system, leading to deviations from the continuous-time behavior.

The degree of similarity between the two transfer functions depends on factors such as the sampling time, discretization method, system complexity, and the specific behavior being analyzed. Engineers need to carefully select the appropriate discretization method and sampling time to minimize the differences between the discrete-time and continuous-time systems.

In summary, while the discretized transfer function aims to approximate the behavior of the continuous-time system, variations in sampling time, discretization method, and inherent time delays can lead to differences between the two. Understanding these discrepancies is essential for accurately implementing control algorithms and ensuring the overall system's performance meets the desired requirements.

Copyright 2024 Aimagin Co.,Ltd. Rev.1659