| Using Simulink | Search  Help Desk |
Zero Crossings
Simulink uses zero crossings to detect discontinuities in continuous signals. Zero crossings play an important role in:State Event Handling
A system experiences a state event when a change in the value of a state causes the system to undergo a distinct change. A simple example of a state event is a bouncing ball hitting the floor. When simulating such a system using a variable-step solver, the solver typically does not take steps that exactly correspond to the times that the ball makes contact with the floor. As a result, the ball is likely to overshoot the contact point, which results in the ball penetrating the floor. Simulink uses zero crossings to ensure that time steps occur exactly (within machine precision) at the time state events occur. Because time steps occur at the exact time of contact, the simulation produces no overshoot and the transition from negative to positive velocity is extremely sharp (that is, there is no rounding of corners at the discontinuity). To see a bouncing ball demo, typebounce at the MATLAB prompt.
Integration of Discontinuous Signals
Numerical integration routines are formulated on the assumption that the signals they are integrating are continuous and have continuous derivatives. If a discontinuity (state event) is encountered during an integration step, Simulink uses zero crossing detection to find the time at which the discontinuity occurs. An integration step is then taken up to the left edge of the discontinuity. Finally, Simulink steps over the discontinuity and begins a new integration step on the next piece-wise continuous portion of the signal.Implementation Details
An example of a Simulink block that uses zero crossings is the Saturation block. Zero crossings detect these state events in the Saturation block:zcSignal = UpperLimit - u, where u is the input signal.
Zero crossing signals have a direction attribute, which can have these values:

Caveat
It is possible to create models that exhibit high frequency fluctuations about a discontinuity (chattering). Such systems typically are not physically realizable; a mass-less spring, for example. Because chattering causes repeated detection of zero crossings, the step sizes of the simulation become very small, essentially halting the simulation. If you suspect that this behavior applies to your model, you can disable zero crossings by selecting the Disable zero crossing detection check box on the Diagnostics page of the Simulation Parameters dialog box. Although disabling zero crossing detection may alleviate the symptoms of this problem, you no longer benefit from the increased accuracy that zero crossing detection provides. A better solution is to try to identify the source of the underlying problem in the model.Blocks with Zero Crossings