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.
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.
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.