### ASW – Switch with automatic selection of input

Function Description
The ASW block copies one of the inputs u1, …, u4 or one of the parameters p1, …, p4 to the output y. The appropriate input signal is copied to the output as long as the input signal iSW belongs to the set $\left\{1,2,3,4\right\}$ and the parameters are copied when iSW belongs to the set $\left\{-1,-2,-3,-4\right\}$ (i.e. $\mathtt{\text{y}}=\mathtt{\text{p1}}$ for $\mathtt{\text{iSW}}=-1$, $\mathtt{\text{y}}=\mathtt{\text{u3}}$ for $\mathtt{\text{iSW}}=3$ etc.). If the iSW input signal differs from any of these values (i.e. $\mathtt{\text{iSW}}=0$ or $\mathtt{\text{iSW}}<-4$ or $\mathtt{\text{iSW}}>4$), the output is set to the value of input or parameter which has changed the most recently. The signal or parameter is considered changed when it differs by more than delta from its value at the moment of its last change (i.e. the changes are measured integrally, not as a difference from the last sample). The following priority order is used when changes occur simultaneously in more than one signal: p4, p3, p2, p1, u4, u3, u2, u1. The identifier of input signal or parameter which is copied to the output y is always available at the oSW output.

The ASW block has one special feature. The updated value of y is copied to all the parameters p1, …, p4. This results in all external tools reading the same value y. This is particularly useful in higher-level systems which use the set&follow method (e.g. a slider in Iconics Genesis). This feature is not implemented in Simulink as there are no ways to read the values of inputs by external programs.

ATTENTION! One of the inputs u1, …, u4 can be delayed by one step when the block is contained in a loop. This might result in an illusion, that the priority is broken (the oSW output then shows that the most recently changed signal is the delayed one). In such a situation the LPBRK block(s) must be used in appropriate positions.

Inputs

 u1..u4 Analog input signals to be selected from double iSW Active signal or parameter selector long

Outputs

 y The selected analog signal or parameter double oSW Identifier of the selected signal or parameter long

Parameters

 delta Threshold for detecting a change  $\odot$0.000001 double p1..p4 Parameters to be selected from double

2019 © REX Controls s.r.o., www.rexygen.com