One way to implement that detection system consists of three stages:
- Detecting when the signal changes signs.
- A counter that increases with every zero-value detection.
- A comparison block that compares the counter to the value "1".
The screenshots below show an example of this implementation:
Stage 1 is a combination of a "Memory" block, which outputs the value of its input at the previous time step, a multiplication block, and a comparison to zero. The output of the multiplication block will only be zero or negative when the original signal (the cosine) changes signs, and the output of the comparison block ("<=") will be a value of "1" in those cases.
Stage 2
is a counter implemented through a "Triggered subsystem". This subsystem is activated by the comparison block. The count is stored inside a "Memory" block, and every time the subsystem is activated, the input to the memory is increased by one. The model is shown below.
Stage 3 is simply a comparison to the value "1". The counter from stage 2 will keep increasing as the signal crosses zero many times, and this third stage filters it to only detect the first zero crossing. Note that the signal drops back to zero after the second zero crossing. If you would like the output signal to persist at the value "1" for the rest of the simulation, consider adding another "triggered subsystem" activated by the output of the comparison block ("==").
The scope visualization is shown below: