# Unary Signal Processor

## Common Use Cases

Implement series of mathematical operations to incoming signals. Use this gizmo to perform interesting signal processing on incoming data, such as power in band, RMS, or scaling. Can also perform complex thresholding or type conversion on signals.

Data Stored | |
---|---|

Epoc (optional) | Parameter values and timestamp of changes |

Outputs | |

Main | Single or multi-channel floating point signal |

Par Output | Full parameter stream |

AltOut | Output from logic test if converting to TTL |

## Gizmo Help Slides

## Reference

The Unary Signal Processor gizmo applies a series of mathematical operations to a single or multi-channel signal. Operations such as RMS and power band calculations are available as presets. Other available operations include adding custom FIR or IIR filters, calculating absolute value, converting data types, and many others, all in one gizmo. Example uses include triggering based on power in a frequency band, or processing/converting external sensor voltages.

The gizmo uses a bounded parameter table (see Using Parameters) to define values for some operations, such as filter settings and scale/shift parameters. Optionally, you can enable runtime control or storage of these gizmo parameters.

### The Runtime Interface

#### Runtime Plot

This gizmo is not specifically associated with any plotting, other than optionally storing parameter values when they change, which is not typical. If you want to view the output data during an experiment, you can add a Stream Data Storage gizmo to the output.

#### Runtime Parameter Controls

The gizmo parameters will be shown at runtime. You can enable runtime control of
any parameter by selecting **Widget** in the parameter table. See
Using Parameters for more information.

### Unary Signal Processor Configuration Options

Options Area |

The Unary Options area displays the mathematical formula, an image showing the
operations and parameters used by each operations, and the corresponding
editable parameters. You can choose a "Preset" formula, such as **RMS** or
**Power In Band**, or create your own. By default, the formula is set to
**Bypass** (output = input).

The gizmo unary formula consists of up to three stages. If you want to view or
customize the stages, select the **Detail** check box. The stages are numbered to
reflect the order of operations and you can click or clear the check box for
each stage to enable or disable it.

Unary Options Area - Detail View |

As stages are enabled or modified the parameter table is updated to show the updated parameters in use. See Using Bounded Parameters for more information on using the table.

When you are happy with a modified formula you can use the **Copy to** button to
save it for later use. The name you choose will then appear in the Preset list.
This also ensures the formula is included with all files, if you ever wish to
export or share the experiment. To show the path where Presets are stored, click
the **Path** check box.

#### Stage 1 and 2

Each of these stages provide a filter and two operations.

Filter Type | Description |
---|---|

Biquad | An IIR filter of a selectable shape (Lowpass, Highpass, Bandpass, Notch) and order. The Fc-{N} parameter determines the center frequency.If shape is Bandpass or Notch, the Bw-{N} parameter determines the bandwidth in in fractional bandwidth Bw-{N}*Fc-{N}.If shape is User, the filter coefficients are defined in a file generated by the user. This must be a CSV text file format with the coefficients in a single row separated by commas, or with a single coefficient in each row. |

Parametric | A second order linear filter used to pass or suppress a particular frequency band. The Fc-{N} parameter determines the center frequency.The Bw-{N} parameter determines the bandwidth in fractional bandwidth Bw-{N}*Fc-{N}. |

FIR | A finite impulse response filter defined by the coefficient file generated by the user. This must be a CSV text file format with the coefficients in a single row separated by commas, or with a single coefficient in each row. |

Smooth | A simple exponential smoothing filter applied to the input. The Fc-{N} parameter determines the effective low pass corner frequency. |

Operation | Description |
---|---|

Scale/shift | Multiplies by a scalar (OpParA-{N} parameter) and adds a shift value (OpParB-{N} parameter). |

Bound | Output is bound to min (OpParB-{N} parameter) and max (OpParA-{N} parameter) values. |

Square | Output is the square of the input. |

Sqr Root | Output is the square root of the input. |

AbsVal | Computes the absolute value of the signal. |

Sign | Determines the sign of the input and outputs either -1 (signal with negative value), 0 (signal with no value), or 1 (signal with positive value). |

#### Stage 3

This stage provides an exponential smoothing filter and a way to change the data
type. The **Fc-3** parameter determines the effective low pass corner frequency of
the filter.

**Integer**

Scales the input by the **OpParA-3** parameter and then converts to an integer.

**Logic**

The operations available use natural language labels and apply a truth test using editable values in the parameter table for comparison. The operation outputs a "1" if true or a "0" if false.

Select **Logic Out to Alternate** if you wish to have both the logic output and
the signal before the logic test available as outputs to the gizmo. For example,
if making an RMS threshold detector, you can output both the threshold crossings
and the RMS value used for the detection for visualization with other gizmos. In
this case, the **Main** output will be the RMS signal and the **AltOut** output will
be the logic signal.

### Working with Single and Multi-Channel Signals

The gizmo can be used with single or multichannel signals and automatically detects the number of channels in the input signal. The formula is applied independently to each channel. The Unary Signal Processing gizmo can handle up to 96 channels. If more channels are required, use a second gizmo and a Signal Merger gizmo to combine the results back into one processing stream.

Tip

To pick one channel for processing from a multichannel signal, use the Selector gizmo