how to set initial signal out from relay simulink

13 views (last 30 days)
Hello all, Paul @Stephen23 @ Adam Danz
I have simulink model with relay bock.
this relay block switch on when the value reach 100 and the output signal is 1 and switch off when reach 20 and the output signal is 0.
my problem is that the relay initial output is always off, this means when the initial value is for example 44 the out out is 0.
but in some cases I want to be my initial output is on (1)
How can i change the initial output signal?
best regards, Ahmad
  4 Comments
Ahmad Al-Issa
Ahmad Al-Issa on 24 Aug 2024
Thank you @Umar your answer is correct.
it just simply add IC block or Memory block before relay block.
thank you.
Umar
Umar on 25 Aug 2024
Hi @ Ahmad Al-Issa,
Thankyou for accepting my answer.

Sign in to comment.

Accepted Answer

Akshat Dalal
Akshat Dalal on 24 Aug 2024
Hi Ahmad,
To set the initial output of a Relay block in Simulink to be ON (1) under certain conditions, you can use a workaround since the Relay block itself does not have a built-in feature to set an initial output state directly. This is also captured as a note in the 'relay' block documentation: https://www.mathworks.com/help/releases/R2021b/simulink/slref/relay.html
One effective approach is to incorporate a Memory block along with some logical operations to achieve the desired initial state. You can follow the given steps to implement this:
  1. First, add a Memory block to your model to hold the initial state of the relay output. This block will store whether the relay should start in the ON state.
  2. Next, create a logic condition using a combination of blocks such as Constant, Compare To Constant, and Logical Operator blocks. These blocks will help determine if the initial condition should set the relay to ON based on the input value.
  3. Incorporate a Switch block to toggle between the initial ON state and the normal relay operation. This block will select the output based on the initial condition logic.
  4. The output from the Switch block should then be fed back into the Memory block to create a feedback loop. This loop ensures that once the initial condition is set, the relay will operate normally according to its switching thresholds.
I hope this helps!

More Answers (1)

Umar
Umar on 25 Aug 2024

To set the initial output of a relay block in Simulink to be on (1), you can utilize a combination of a Memory block and a Switch block. Please see steps below to achieve your desired goal.

Place a Memory block before the relay block. This block will hold the initial state of the signal.

For more information on memory block, please refer to

https://www.mathworks.com/help/simulink/slref/memory.html

Then, connect a Switch block to determine the initial condition. The Switch block can take two inputs: one for the initial state (1) and another for the relay output. For more information on switch block, please refer to

https://www.mathworks.com/help/simulink/slref/switch.html?searchHighlight=Switch%20block&s_tid=srchtitle_support_results_2_Switch%20block

Afterwards, configure the Switch block to output 1 when your specific condition is met (e.g., a certain input signal or a constant value). Otherwise, it will pass the output from the relay block. Make sure that the output of the relay block is connected to the second input of the Switch block. By implementing this method, you can control the initial output state of the relay block effectively. Let me know if this resolves your issue.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!