continuous-凯发k8网页登录

main content

continuous-time modeling in stateflow

hybrid systems use modal logic to transition from one mode to another in response to physical events and conditions. in these systems, continuous-time dynamics govern each mode. a simple example of this type of hybrid system is a bouncing ball. the ball moves continuously through the air until it hits the ground, at which point a mode change or discontinuity occurs. as a result, the ball suddenly changes direction and velocity. for more information, see .

simulate hybrid systems that respond to continuous and discrete mode changes by configuring stateflow® charts for continuous-time modeling. in a stateflow chart, you can represent modal logic succinctly and intuitively as a series of states, transitions, or flow charts. you can also represent state information as continuous local variables with automatic access to time derivatives.

continuous-time simulation is supported only in stateflow charts in simulink® models. if your continuous system does not contain modal logic, consider using a simulink model. for more information, see (simulink).

configure a stateflow chart for continuous-time simulation

to enable continuous updating in a stateflow chart, set the update method chart property to continuous, as described in .

by default, zero-crossing detection is enabled. to disable this option, clear the enable zero-crossing detection check box. for more information, see disable zero-crossing detection.

note

you cannot use moore charts for continuous-time modeling.

interaction with simulink solver

maintain mode in minor time steps

during continuous-time simulation, a stateflow chart updates its mode only in major time steps. in a minor time step, the chart computes outputs based on the state of the chart during the last major time step. for more information, see (simulink).

compute continuous state at each time step

when you define local continuous variables, the stateflow chart provides programmatic access to their derivatives. the simulink solver computes the continuous state of the chart at the current time step based on the values of these variables and their derivatives at the previous time step. for more information, see (simulink).

register zero crossings on state transitions

to determine when a state transition occurs, a stateflow chart registers a zero-crossing function with the simulink solver. when simulink detects a change of mode, the solver searches forward from the previous major time step to detect when the state transition occurred. for more information, see (simulink).

disable zero-crossing detection

zero-crossing detection on state transitions can present a tradeoff between accuracy and performance. when detecting zero crossings, a simulink model accurately simulates mode changes without unduly reducing step size. for systems that exhibit chattering, or frequent fluctuations between two modes of continuous operation, zero-crossing detection can potentially impact simulation time. chattering requires a simulink model to check for zero crossings in rapid succession, which can slow simulation. in these situations, you can:

  • disable zero-crossing detection.

  • choose a different zero-crossing detection algorithm for your chart.

  • modify parameters that control the frequency of zero crossings in your simulink model.

open the configuration parameters dialog box and, in the solver pane, change the zero-crossing options for your model. for more information, see (simulink).

guidelines for continuous-time simulation

to maintain the integrity and smoothness of the results of a continuous-time simulation, constrain your charts to a restricted subset of stateflow chart semantics. by restricting the semantics, the inputs do not depend on unpredictable factors such as:

  • the number of minor intervals that the simulink solver uses in each major time step.

  • the number of iterations required to stabilize the integration and zero-crossings algorithms.

by minimizing these side effects, a stateflow chart can maintain its state at minor time steps and update its state only during major time steps. therefore, a stateflow chart can compute outputs based on a constant state for continuous time.

continuous-time charts must have at least one state

during continuous-time simulation, a chart updates its outputs at minor time steps corresponding to the during actions of the active state. a chart with no states produces no output. to mimic the behavior of a stateless chart in continuous time, create a single state that calls a graphical function in its during action.

update local data in entry, exit, and transition actions

to maintain precision in continuous-time simulation, update discrete and continuous local data only during major time steps corresponding to state transitions. during state transitions, only these types of actions occur:

  • state exit actions, which occur before leaving the state at the beginning of the transition.

  • state entry actions, which occur after entering the new state at the end of the transition.

  • transition actions, which occur during the transition.

  • condition actions on a transition, but only if the transition directly reaches a state. for example, this chart executes the action n even when conditions c2 and c3 are false. because there is no state transition, the condition action updates n in a minor time step and results in an error.

    stateflow chart with states called a, b, and c.

do not write to local continuous data in state during actions because these actions occur in minor time steps.

compute derivatives in state during actions

in minor time steps, a continuous-time chart executes only state during actions. because simulink models read continuous-time derivatives during minor time steps, compute derivatives in during actions to provide the most current calculation.

do not read outputs or derivatives in state during actions or in transition conditions

in minor time steps, it is possible that outputs and derivatives do not reflect their most current values. to provide smooth outputs, compute values from local discrete data, local continuous data, and chart inputs.

do not call simulink functions in state during actions or in transition conditions

you cannot call simulink functions during minor time steps. instead, call simulink functions only in actions that occur during major time steps: state entry or exit actions and transition actions. calling simulink functions in state during actions or in transition conditions results in an error during simulation. for more information, see .

use discrete variables to govern conditions in during actions

to prevent mode changes between major time steps, conditions that affect control flow in during actions depend on discrete variables. discrete variables do not change value between major time steps.

do not use input events

the presence of input events makes a chart behave like a triggered subsystem and unable to simulate in continuous time. for example, this model generates an error if the chart uses a continuous update method.

simulink model containing a stateflow chart with an input event.

to mimic the behavior of an input event, pass the input signal through a hit crossing block as an input to the continuous-time chart.

simulink model containing a stateflow chart and a hit crossing block.

do not use inner transitions

when a mode change occurs during continuous-time simulation, the entry action of the destination state indicates to the simulink model that a state transition occurred. with an inner transition, the chart never executes the entry action. for more information, see inner transitions.

limit use of temporal logic

do not use event-based temporal logic because in continuous-time simulation, there is no concept of a tick. use only absolute-time temporal logic for continuous-time simulation. for more information, see .

do not use change detection operators

to implement change detection, stateflow buffers variables in a way that affects the behavior of charts between a minor time step and the next major time step.

do not modify operating point values

operating points for continuous-time charts are read-only. you can save an operating point for a continuous-time chart and use it as the initial state for a simulation. however, you cannot modify the state activity or any data values in the operating point. for more information, see .

related topics

  • (simulink)
  • (simulink)
网站地图