Skip to main content
Skip table of contents

ControlOp

Overview

Control signal operations module

Discussion

The module computes control operations (e.g. control signals from CAN) which are simple arithmetic operations using two input values. The module is controlled via the .packedConf array. The array size is numOps x 3 and there is a single row devoted to each operation:

Column 1 specifies what operation should be performed:

op=0, CONST 0 (out = 0).

op=1, CONST 1 (out = 1).

op=2, Pass through the first input unchanged (out = in1).

op=3, Sum (out = in1 + in2).

op=4, Diff (out = in1 - in2).

op=5, Average (out = (in1 + in2) / 2).

op=6, Time Derivative (out = (in1[n] - in1[n-1]) * SR)

op=7, Division (out = in1 / in2).

op=8, UNDB20 ( if (in1 == 0) --> out = undb20(in2), else out = undb20(-in2) )

op=9, Max (in1, in2)

op=10, Min (in1, in2)

op=11, Equal One Pass 2 (if (in1 == 1) --> out = in2, else out = 1)

op=12, Not Equal One Pass 2 (if (in1 != 1) --> out = in2, else out = 1)

op=13, Greater Than, (if (in1 >= in2) --> out = 1, else out = 0)

op=14, Boolean invert (if (in1 < 0.5) --> out = 1, else out = 0)

op=15, FlipFlop - 1 for in1 = 1 until in2 = 1, else output 0

op=16, FlipFlop - 1 if in1 = 1 for sample count in in2, else output 0

Column 2 contains the channel index of the first input argument (0-based). Column 3 contains the channel index of the second input argument (0-based).

If an index is out of range or the op is out of range then the module outputs 0 for that operation.

This module supports only control data where block size is 1.

Type Definition

CODE
typedef struct _ModuleControlOp
{
    ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
    INT32 numOps;                                 // Number of operations to be computed
    INT32 numOpsPackedSize;                       // Size in 4 bytes packed for internal use
    INT32 updateActive;                           // Specifies whether the configuration is updating (=1) or fixed (=0).
    INT32* config;                                // Controls the operations. One row per op.
    INT32* packedConf;                            // Operations configuration with each row packed into a word.
    FLOAT32* lastValue;                           // Previous sample value on all input channels
    INT32* firstBlock;                            // Array of flags set on first block of each channel before lastValue is valid
    INT32* triggerPulse;                          // Array of flags set on in operation 16 to trigger pulse output
    INT32* prevTriggerState;                      // Array of flags set on in operation 16 to trigger pulse output
    INT32* outPulseCnt;                           // Array of pulse high period count in samples for operation 16
    INT32* triggerPulse2;                         // Array of flags set on in operation 15 to trigger pulse output
} ModuleControlOpClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

numOps

int

const

0

1

Unrestricted

numOpsPackedSize

int

const

0

1

Unrestricted

updateActive

int

parameter

1

1

0:1

config

int*

derived

0

[1 x 3]

Unrestricted

packedConf

int*

parameter

0

[1 x 1]

-2147483648:2147483647

lastValue

float*

state

1

[1 x 1]

Unrestricted

firstBlock

int*

state

1

[1 x 1]

Unrestricted

triggerPulse

int*

state

1

[1 x 1]

Unrestricted

prevTriggerState

int*

state

1

[1 x 1]

Unrestricted

outPulseCnt

int*

state

1

[1 x 1]

Unrestricted

triggerPulse2

int*

state

1

[1 x 1]

Unrestricted

Pins

Input Pins

Name: in

Description: Input signal

Data type: float

Channel range: Unrestricted

Block size range: 1

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out

Description: Output signal

Data type: float

MATLAB Usage

File Name: control_op_module.m

CODE
 Performs various arithmetic operations that are typically applied
 to CAN control inputs. The opreation is applied to the two inputs, 
 which can be also multichannel. The second argument specifies how many 
 operations shall be performed. Each result is placed on a separate 
 output channel.  
 Arguments:
    NAME - name of the module.
    NUMOPS - number of operations to compute.  By default equals 1.

JavaScript errors detected

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

If this problem persists, please contact our support.