Main Content

Hit Crossing

Detect crossing point

  • Hit Crossing block

Libraries:
Simulink / Discontinuities
Simulink / Messages & Events
HDL Coder / Discontinuities
SimEvents

Description

TheHit Crossingblock detects when the input reaches theHit crossing offsetparameter value in the direction specified by theHit crossing directionproperty.

You can configure the block to output a1or0signal, a message, or a function-call event. SeeOutputfor more information.

Ports

Input

expand all

Input signal that the block detects when it reaches the offset in the specified direction.

Data Types:double

Output

expand all

Output indicating if the input signal crossed the hit offset. This port is visible only when you select theShow output portparameter check box.

Signal Output

If you select theShow output portcheck box and set theOutput typeparameter toSignal, the block output indicates when the crossing occurs.

  • If the input signal is exactly the value of the offset value after the hit crossing is detected in the specified direction, the block continues to output a value of 1.

  • If the input signals at two adjacent points brackets the offset value, the block outputs a value of 1 at the second time step.

  • If theShow output portcheck box isnotselected, the block ensures that the simulation finds the crossing point but does not generate output.

  • If the initial signal is equal to the offset value, the block outputs 1 only if theHit crossing directionproperty is set toeither.

  • If Boolean logic signals are enabled, then the output is aBoolean.

Message Output

TheHit Crossingblock can also output a message when theOutput typeparameter is set toMessage.

  • If the input signal crosses the offset value in the specified direction, the block outputs a message.

  • 如果输入信号在到达抵消价值e specified direction and remains there, block outputs one message at the hit time and one message when the signal leaves the offset value.

  • If the initial input signal is equal to the offset value, the block outputs a message withCrossing TypevalueNoneonly if theHit crossing directionis set toeither.

The message output signal is astructwith four fields.

Note

If the message output signal crosses model reference boundaries or is used as an input to a Stateflow®chart, you need to create a bus object for the message. SeeTips.

函数调用Output

TheHit Crossingblock can also output a function-call event when theOutput typeparameter is set to函数调用.

  • Each time the input signal crosses the offset value in the specified direction, the block outputs a single function-call event.

  • The function-call event can be sent to the function-call input port of a function-call subsystem or function-call model.

  • The output is equivalent to the output of a函数调用Generatorblock at each time step with theNumber of iterationsparameter of that block set to1.

This field shows the direction in which the signal crosses theHit crossing offsetvalue. Negative, Zero, and Positive are defined relative to the offset value. The data type isslHitCrossingTypewhich is anenumerated data type. SeeUse Enumerated Data in Simulink Modelsfor more information. For example, ifHitCrossingOffsetis set to 2, a rising signal crossing this offset value would be recorded as aNegativeToPositivehit crossing.

Note

A hit crossing is recorded based on theHit crossing directionsetting. In other words, if you setHit crossing directionto detect afallinghit crossing, aNegativeToPositivehit is not recorded.

Note

In a SimEvents®block, if theCrossing Typeof an entity is aNegativeToPositivehitcrossing thenentity.CrossingType == slHitCrossingType.NegativeToPositivereturns logical 1(true).

If the signal reaches theHitCrossingOffsetvalue and holds it, a singleNegativeToZeroorPositiveToZero, depending on the direction, hit is registered at the time of the hit crossing.

Data Types:slHitCrossingType

Fornsignals being passed to theHit Crossingblock, this field denotes which signal had a hit crossing event. For a matrix input, this field follows MATLAB®linear indexing. SeeArray Indexing.

Data Types:uint32

TimeTof the hit crossing event.

Data Types:double

Hit crossing offset value as specified by theHit crossing offsetparameter.

Data Types:double

Data Types:double|Boolean|struct

Parameters

expand all

Specify the value the block detects when the input crosses in the direction specified byHit crossing direction.

Programmatic Use

Block Parameter:HitCrossingOffset
Type: character vector
Values: real values
Default:'0'

Direction from which the input signal approaches the hit crossing offset for a crossing to be detected.

When set toeither, the block serves as analmost equalblock, useful in working around limitations in finite mathematics and computer precision. Used for these reasons, this block might be more convenient than adding logic to your model to detect this condition.

When theHit crossing directionproperty is set toeitherand the model uses a fixed-step solver, the block has the following behavior. If the output signal is 1, the block sets the output signal to 0 at the next time step, unless the input signal equals the offset value.

Programmatic Use

Block Parameter:HitCrossingDirection
Type: character vector
Values:'either'|'rising'|'falling'
Default:'either'

If selected, create an output port on the block icon.

Programmatic Use

Block Parameter:ShowOutputPort
Type: character vector
Values:'off'|'on'
Default:'on'

WhenOutput typeis set toSignal, the output signal is set to one whenever the input signal crosses theHit crossing offsetvalue in theHit crossing directionand is zero at other times.

When theOutput typeis set toMessage, the output signal becomes a message.

WhenOutput typeis set to函数调用, the output signal becomes a function-call event.

Programmatic Use

Block Parameter:HitCrossingOutputType
Type: character vector
Values:'Signal'|'Message'|'Function-Call'
Default:'Signal'

Select to enable zero-crossing detection. For more information, seeZero-Crossing Detection.

Programmatic Use

Parameter:ZeroCross
Type:character vector, string
Values:'on'|'off'
Default:'on'

Block Characteristics

Data Types

double

Direct Feedthrough

是的

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

是的

Tips

If theHit Crossingblock is configured to output a message and the output signal:

  • Crosses into or out of a referenced model

  • Is fed to the input of a Stateflow chart

then you need to create a bus object for the message signal. In the MATLAB Command Window, runSimulink.createHitCrossMessageto check for and, if needed, create a hit crossing message bus object in the base workspace.

集的数据类型对应的端口Bus: HitCrossMessage.

Extended Capabilities

版本历史

Introduced before R2006a