Block with adjustable delay

24 Ansichten (letzte 30 Tage)
Tjitze de Vries
Tjitze de Vries am 3 Nov. 2024 um 20:38
Beantwortet: Tjitze de Vries am 14 Nov. 2024 um 11:40
Hi everybody,
In Matlab-Simulink I am looking for a function block or a combination of multiple blocks. That block functions as follows: If a signal on the input changes from 0 to 1, then that 1 is passed on to the output with an adjustable delay.If the signal on the input becomes 0, then the 0 is immediately passed on to the output.
Your answer would be very much appreciated!
TJan

Antworten (2)

Umar
Umar am 3 Nov. 2024 um 22:33
Bearbeitet: Umar am 3 Nov. 2024 um 22:34

Hi @Tjitze de Vries ,

You asked, “ In Matlab-Simulink I am looking for a function block or a combination of multiple blocks. That block functions as follows: If a signal on the input changes from 0 to 1, then that 1 is passed on to the output with an adjustable delay.If the signal on the input becomes 0, then the 0 is immediately passed on to the output.

For Signal Detection, use a Switch block or a Compare To Constant block to detect when the input signal changes from 0 to 1. This will allow you to define two paths based on the input value.

Switch

Compare to constant

For the case where the input transitions from 0 to 1, utilize a Unit Delay block or a Transport Delay block. The Unit Delay block will store the signal and provide it at the next time step, while the Transport Delay block allows you to specify an adjustable delay time.

Unit delay

Transport delay

Connect this delay block in series with the output path triggered by the switch condition detecting the transition from 0 to 1. For the path where the input signal is 0, connect it directly to an output port without any delay. This can be done using another Switch or by directly routing the signal. Finally, you can combine these outputs using another Switch or logical blocks that decide which output (delayed or immediate) is passed through based on the state of the input signal. Here is how you might set up your Simulink model:

Input Signal Block: Represents your incoming signal.

Compare To Constant Block: Set to compare against 0 and 1.

Switch Block (for detecting transition): First input connected to your input signal. Second input connected to a delay line (Unit Delay or Transport Delay).

Unit Delay/Transport Delay Block: Configurable delay time for when transitioning from 0 to 1.

Direct Connection for Zero Output: Ensure there’s an immediate path for when the signal is 0.

You can make the delay adjustable by linking its parameter to a variable in your workspace. Ensure your simulation time is appropriately set so that you can observe these transitions and delays effectively. After building your model, simulate it with various test signals (e.g., step functions) to validate that it behaves as expected under different scenarios.

If you encounter specific issues during implementation, consider checking MATLAB's documentation or forums for additional examples and troubleshooting tips.

https://www.mathworks.com/help/simscape/troubleshooting-and-limitations.html

Hope this helps.

  2 Kommentare
Walter Roberson
Walter Roberson am 3 Nov. 2024 um 23:59
Note that the transport delay block typically ends up doing linear interpolation of signals.
Umar
Umar am 4 Nov. 2024 um 2:56
Hi @Walter Roberson,
Your comments are duly noted. You are right! - when an output is required at a time that does not match any of the stored input times, the Transport Delay block performs linear interpolation between points. This means that if you request an output at a non-integer time (say t = 4.5) and have data points at t = 4 and t = 5, it will calculate the output value based on a straight-line estimation between these two points. Again, I always learn a lot from you.

Melden Sie sich an, um zu kommentieren.


Tjitze de Vries
Tjitze de Vries am 14 Nov. 2024 um 11:40
Hi Umar,
Thank you for your reply!
It was helpfull and I implemented it in a Simulink model.
best regards
Tjitze de Vries

Produkte


Version

R2015b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by