TwinActivate ConditionalSelect 'Copy first input if' choice.

If
u2 == true
is selected, does
true
contain negative values? Or is there any block of code that can detect the presence of a signal and then output the corresponding value?
Answers
-
Hi @HengJiaYe,
The u2==true condition will only copy the first input if it is equal to the switch threshold. Threshold values can be negative.
In this simple model, my threshold is -10. As you can see, u2==true, and thus the value of 1 is passed through the ConditionalSelect block:
Hope this helps!
Adam Reid
1 -
Hello @HengJiaYe ,
when you are using the u2==true condition then for any input u2 value except 0 you'll get u1 as output. If you want to actually use the threshold value a then you should use one of the other conditions. In the model below I have an input starting from -15 and increasing till 15. I added a 5s window where the value is zero. The threshold a value is set to -10 but it's not considered in this case. The output value equals u3 only when u2 equals 0 (FALSE)
Math expression block offers more flexibility when your comparative expression becomes more complex.
Here is an example where 3 inputs are used (u1, u2 and u3). u2 is used as the condition select and the output is the sum of the expression.The above expression works like this.
IF u2>0 & u2<10:
y = u1
ELSEIF u2=<0
y = u3
ELSE
y = 0
END
Hope this helps!
Best regards,
Orestes1 -
Thanks for your reply—it helped me realize that negative numbers are also treated as true.
Have a nice day!
0 -
Thanks for sharing both examples! They really clarified the full-range check—especially the one that used a math trick I completely forgot about (haha).
Have a nice day!
1