Skip to main content
Skip table of contents

HysteresisFract32

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.

This version of the module works with fract32 data.

Type Definition

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

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

upperThreshold

fract32

parameter

0

0.1

Unrestricted

lowerThreshold

fract32

parameter

0

-0.1

Unrestricted

state

int*

state

0

[1 x 1]

Unrestricted

Pins

Input Pins

Name: in

Description: Input signal

Data type: fract32

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_fract32_module.m

CODE
 M = hysteresis_fract32_module(NAME)
 This module implements Boolean selection above and below a threshold
 and adds hysteresis to the design to avoid frequent switching.  This
 module works with fract32 data types.  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.