This block detects the time instants at which the input signal
crosses the level specified by the user, and produces an output
with a constant value vOut.
It may seem a bit strange that the generated output values are
always the same (constant). Considering however that the
CrossDetect block is aimed at detecting the time instants
when a signal crosses the given level, the actual value of
the output does not matter, but only the fact that there are output
events in the appropriate moments. The interesting output variable
is therefore the auxiliary variable showEvents. It is a very simple
Integer variable that is incremented by 1 each time an output event
is generated, the scope of which is just to have a variable with a
value that changes at event instants.
The picture below illustrates the behaviour of a CrossDetect block
that discovers the crossing instants of a given level (green) and
the actual input signal, the sine signal (blue). The variable
CrossDetect.uVal[1] is given in pink, but as can be easily seen it
is of little use, since after the first crossing instant it just
jumps from its initial value (zero) to vOut and stays there. For
this reason, also the variable showEvents, the time component of
the output vector, is depicted. Given the fact that this variable
indicates the time instants when the sine signal crosses the level,
it can be said to be the actual output of the CrossDetect block
while the usual output variable (CrossDetect.uVal[1]) is rather a
dummy variable, this time.