Detect threshold crossing of accumulated nonzero inputs
Signal Management / Switches and Counters
The Event-Count Comparator block records the number of nonzero inputs to the Data port
during the period that the block is enabled by a high signal (the value
1) at the Int port. Both inputs must be scalars.
When the number of accumulated nonzero inputs first equals the Event
threshold setting, the block waits one additional sample interval, and
then sets the output high (
1). The block holds the output high until
recording is restarted by a low-to-high (
transition at the Int port.
The Event-Count Comparator block accepts real and complex floating-point and fixed-point inputs. However, because the block has discrete state, it does not support constant or continuous sample times. Therefore, at least one input or output port of the Event-Count Comparator block must be connected to a block whose Sample time parameter is discrete. The Event-Count Comparator block inherits this non-infinite discrete sample time.
In the ex_eventcountcomp_ref model, the Event-Count Comparator block (Event threshold = 3) detects two threshold crossings in the input to the Data port, one at sample 4 and one at sample 12.
All inputs and outputs are multiplexed into the workspace variable
yout, whose contents are shown in the figure below. The two left
columns in the illustration show the inputs to the Data and Int ports, the center column
shows the state of the block's internal counter, and the right column shows the block's
- Event threshold
Specify the value against which to compare the number of nonzero inputs. Tunable (Simulink).
Supported Data Types
Double-precision floating point
Single-precision floating point
Fixed point (signed and unsigned)
8-, 16-, and 32-bit signed integers
8-, 16-, and 32-bit unsigned integers
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Generated code relies on the
memset function (
string.h) under certain