Convert range of signal values to constant by Simulink
12 次查看(过去 30 天)
显示 更早的评论
Hi,
I need a block system which outs a constant when signal varies between 2 values and only for a finite time range.
for example if signal varies between 3 and 4 for 7 seconds, output must be a constant. But if signal varies between 3 and 4 for 2 seconds, output must be 0.
How can i get it ?
thanks
0 个评论
回答(3 个)
Fangjun Jiang
2011-5-25
I don't think there is a readily available block that can do the task for you. But I think you can construct a system to do that.
Construct a logic to compare your signal value. If it is between 3 and 4, the output is true (1). Otherwise, it is false (0). Feed this output to an Integrator block. The trick is to enable the "External reset" for the Integrator block. If the logic output is true (1), it keeps integrating. If the logic output is false(0), you can use this signal to reset the Integrator block so the output of the Integrator block will be reset to zero.
Now compare the output value of the Integrator block. If it is equal to or greater than 7, it means that your signal value has been continuously between 3 and 4 for at least 7 seconds, you can output the constant that you want. Otherwise, your output is zero.
All these numbers, 3, 4 or 7 can be made to be variables so you can tune them.
4 个评论
Fangjun Jiang
2011-5-25
The first input to the Integrator block is the logical output of comparing your signal value with 3 and 4. The second input (External reset) of the Integrator block could be the opposite (use NOT logical operator) of that logical output. If everything is default, the Integrator should take the signal. But if not, you can specify the logical output as double, or use a data type conversion block.
Mohamed Mahmoud
2023-4-20
One way to achieve this is by using a comparator circuit and a timer circuit. Here's an example circuit that could work:
- Use a comparator circuit to compare the input signal with the upper and lower threshold values (in this case, 3 and 4). When the input signal is between these two values, the output of the comparator will be high.
- Connect the output of the comparator to a timer circuit (e.g. a 555 timer). When the output of the comparator goes high, the timer will start counting.
- Set the timer to output a high signal only when it has counted for the desired time range (e.g. 7 seconds). When the timer output goes high, the output of the overall circuit will be high, indicating that the input signal was within the desired range for the required time period.
- If the input signal goes outside the desired range before the timer has finished counting, the output of the timer will go low and the overall circuit output will also go low.
Note that the exact circuit components and values will depend on your specific requirements and the characteristics of your input signal. Additionally, you may need to add some additional signal conditioning or filtering to ensure that the comparator circuit works correctly.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!