Skip to main content
Skip table of contents

Hysteresis

Overview

Threshold with hysteresis

Discussion

The hysteresis module implements switching above and below a threshold. The module accepts floating-point inputs and outputs 0 when the signal level is below the threshold and 1 when above. Instead of just a single threshold the module incorporates hysteresis by having separate upper and lower thresholds. The output switches from 0->1 when the input signal rises above the upperThreshold and then stays at 1 until the signal drops below the lowerThreshold. The module is thus above to avoid frequent switching when signal levels are close to the threshold.

If you need just a straightforward comparison against a threshold without hysteresis, use the logic_compare_const_modulue.m.

The module accepts multichannel signals and outputs a separate Boolean value per channel. The module operates on a sample-by-sample basis and the block size of the output equals the block size of the input.

When bypassed, the module continues to process data normally. That is, the module's processing function is called even when it is bypassed.

Type Definition

CODE
typedef struct _ModuleHysteresis
{
    ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
    FLOAT32 upperThreshold;                       // Upper switching threshold
    FLOAT32 lowerThreshold;                       // Lower switching threshold
    INT32* state;                                 // Current state per chanel
} ModuleHysteresisClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

upperThreshold

float

parameter

0

1

Unrestricted

lowerThreshold

float

parameter

0

-1

Unrestricted

state

int*

state

0

[1 x 1]

Unrestricted

Pins

Input Pins

Name: in

Description: Input signal

Data type: float

Channel range: Unrestricted

Block size range: Unrestricted

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out

Description: Output signal

Data type: int

MATLAB Usage

File Name: hysteresis_module.m

CODE
 M = hysteresis_module(NAME)
 This module implements Boolean selection above and below a threshold
 and adds hysteresis to the design to avoid frequent switching.
 Arguments:
    NAME - name of the module.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.