Polybench® Reference
Copies input S to output Sa, if the Gate input is >= 1, or copies input S to output Sb if the Gate input is <= 0.

Switch

Overview

Use this operator to switch a channel bus to one of two output channel buses. The switch is controled by the Gate input, which must have 1 channel.
This operator is the counter part of the Switch Converge operator (link).

The Gate input expects a pseudo-boolean signal, which is either around 0 or around 1.

Operator ports

Input S: Any sample type. The connection is not limited to one type of signal.

Input Gate: Floating point values

Output Sa: Any sample type. The connection is not limited to one type of signal.

Output Sb: Any sample type. The connection is not limited to one type of signal.

Properties

Find more information about changing properties here: link

Caption
type: Word or phrase
The name of the object in the project. This name must not contain '.' or '$' characters.

Every object has the Caption property. This property is very important, because it is the name by which Polybench recognizes this object.
It is allowed to give multiple objects the same name, as long as the objects are of the same type. In that case, a reference to this caption includes all the objects with the same caption.
In Polybench, every object can be addressed by an Address specifier, which starts with the dollar sign, for example: $My Page.My Object. 'My Page' would be the Caption of a page, and 'My Object' the Caption of an object on that page.

Documentation
type: See description
Optional documentation of this object.

It is good practice to write in short notes why you have used this object, and why its properties are set the way they are set. If this object is an operator, the Documentation text is displayed below the operator symbol.

Details

The Gate input always functions as scalar. The Gate is connected to only one input channel, which switches all channels from S to either Sa or Sb at the same time.

If the signal on the Gate input is less than 0, the Gate is set to 0. If it is greater than 1, it is set to 1. If the signal value is between 0 and 1, the value is rounded to either 0 or 1.
Therefore it is important to note that the Gate input signal should be a pseudo-digital signal, because if it contains a slow rizing signal, the switch timing is difficult to predict.

Switch breaks the time line

The outputs of the Switch will be signals of which the time line can be broken. For example, if you switch the input signal 10 seconds to the second output, then the time line of the first input will show a hole of 10 seconds.
Y-T Viewers, but also signal data storage files may have a problem with that. Please thoroughly check the schematic behind a switch if there are no unforeseen problems because of this.

On the other hand, the breaking of the time line may also deliberately be used. You could write an application that picks single samples (by switching the Switch one sample period of time) from a signal and displays them in a X-Y Plotter, or stores them in a CSV file. Most math operators won't have a problem with signals with broken time lines, so you could do calculations on the 'picked' samples.
This way, you could record results of culculations at specific moments in time. This may be the better alternative for using a Sample and Hold operator (link).

Things you can use the Switch for


The schematic above shows a typical use of the Switch and Switch Converge, that together form the equivilent of what in other computer languages would be called IF..THEN..ELSE. Using the constant button either the high pass filter is chosen, or the low pass filter.

Examples

Example: Switch demo
Example of the use of the Switch operator. The Switch switches the input signal to one of both viewers, depending on the state of the Constant Button.
Examples\DF0411131_001_Switch Demo.xmc