Rate Transition

Handle transfer of data between blocks operating at different rates

Library

Signal Attributes

Description

Transition Handling Options

The Rate Transition block transfers data from the output of a block operating at one rate to the input of a block operating at a different rate. Use the block parameters to trade data integrity and deterministic transfer for faster response or lower memory requirements. To learn about data integrity and deterministic data transfer, see Data Transfer Problems in the Simulink® Coder™ documentation.

Transition Handling OptionsBlock Parameter Settings
  • Data integrity

  • Deterministic data transfer

  • Maximum latency

Select:

  • Ensure data integrity during data transfer

  • Ensure deterministic data transfer

  • Data integrity

  • Nondeterministic data transfer

  • Minimum latency

  • Higher memory requirements

Select:

  • Ensure data integrity during data transfer

Clear:

  • Ensure deterministic data transfer

  • Potential loss of data integrity

  • Nondeterministic data transfer

  • Minimum latency

  • Lower memory requirements

Clear:

  • Ensure data integrity during data transfer

  • Ensure deterministic data transfer

Dependencies

The behavior of the Rate Transition block depends on:

Block Labels

When you update your diagram, a label appears on the Rate Transition block to indicate simulation behavior.

LabelBlock Behavior
ZOHActs as a zero-order hold
1/zActs as a unit delay
BufCopies input to output under semaphore control
Db_bufCopies input to output using double buffers
CopyUnprotected copy of input to output
NoOpDoes nothing
MixedExpands to multiple blocks with different behaviors

The block behavior label shows the method that ensures safe transfer of data between tasks operating at different rates. You can use the sample-time colors feature (see View Sample Time Information in the Simulink documentation) to display the relative rates that the block bridges. Consider, for example, the following modelmodel:

Sample-time colors and the block behavior label show that the Rate Transition block at the top of the diagram acts as a zero-order hold in a fast-to-slow transition and the bottom Rate Transition block acts as a unit delay in a slow-to-fast transition.

For more information, see Handle Rate Transitions in the Simulink Coder documentation.

Effects of Synchronous Sample Times

The following table summarizes how each label appears if the sample times of the input and output ports (inTs and outTs) are periodic, or synchronous.

Block Settings

Block Label

Rate Transition

Conditions for Rate Transition Block

With Data Integrity and Determinism

With Only Data Integrity

Without Data Integrity or Determinism

inTs = outTs

(Equal)

inTsOffset < outTsOffset

None (error)

Buf

Copy or NoOp (see note that follows the table)

inTsOffset = outTsOffset

Copy or NoOp (see note that follows the table)

Copy or NoOp (see note that follows the table)

inTsOffset > outTsOffset

None (error)

Db_buf

inTs < outTs

(Fast to slow)

inTs = outTs / N

inTsOffset, outTsOffset = 0

ZOH

Buf

inTs = outTs / N

inTsOffsetoutTsOffset

None (error)

inTs = outTs / N

inTsOffset > outTsOffset

None (error)

Db_buf

inTsoutTs / N

None (error)

inTs > outTs

(Slow to fast)

inTs = outTs * N

inTsOffset, outTsOffset = 0

1/z

Db_buf

inTs = outTs * N

inTsOffsetoutTsOffset

None (error)

inTs = outTs * N

inTsOffset > outTsOffset

None (error)

inTsoutTs * N

None (error)

KEY

  • inTs, outTs: Sample times of input and output ports, respectively

  • inTsOffset, outTsOffset: Sample time offsets of input and output ports, respectively

  • N: Integer value > 1

When you select Block reduction in the Optimization pane of the Configuration Parameters dialog box, Copy reduces to NoOp. No code generation occurs for a Rate Transition block with a NoOp label. To prevent a block from being reduced when block reduction is on, add a test point to the block output (see Test Points in the Simulink documentation).

Effects of Asynchronous Sample Times

The following table summarizes how each label appears if the sample time of the input or output port (inTs or outTs) is not periodic, or asynchronous.

Block Settings

Block Label
With Data Integrity and DeterminismWith Only Data IntegrityWithout Data Integrity or Determinism

inTs = outTs

Copy

Copy

Copy

inTsoutTs

None (error)

Db_buf

KEY

  • inTs, outTs: Sample times of input and output ports, respectively

Data Type Support

The Rate Transition block accepts most signals that Simulink supports, including fixed-point and enumerated data types. For more information, see Data Types Supported by Simulink in the Simulink documentation.

However, do not use the Rate Transition block with frame-based signals. For rate transitions with such signals, use one of these blocks from the DSP System Toolbox™ instead:

  • Buffer

  • Unbuffer

  • CIC Decimation

  • CIC Interpolation

  • FIR Decimation

  • FIR Interpolation

  • Downsample

  • Upsample

Parameters and Dialog Box

Ensure data integrity during data transfer

Selecting this check box results in generated code that ensures data integrity when the block transfers data. If you select this check box and the transfer is nondeterministic (see Ensure deterministic data transfer below), depending on the priority of input rate and output rate, the generated code uses a proper algorithm using single or multiple buffers to protect data integrity during data transfer.

Otherwise, the Rate Transition block is either reduced or generates code using a copy operation to effect the data transfer. This unprotected mode consumes less memory. But the copy operation is also interruptible, which can lead to loss of data integrity during data transfers. Select this check box if you want the generated code to operate with maximum responsiveness (i.e., nondeterministically) and data integrity. For more information, see Rate Transition Block Options in the Simulink Coder documentation.

Ensure deterministic data transfer (maximum delay)

Selecting this check box results in generated code that transfers data at the sample rate of the slower block, that is, deterministically. If you do not select this check box, data transfers occur as soon as new data is available from the source block and the receiving block is ready to receive the data. You avoid transfer delays, thus ensuring that the system operates with maximum responsiveness. However, transfers can occur unpredictably, which is undesirable in some applications. For more information, see Rate Transition Block Options in the Simulink Coder documentation.

Initial conditions

This parameter applies only to slow-to-fast transitions. It specifies the initial output of the Rate Transition block at the beginning of a transition when there is no output from the slow block connected to the input of the Rate Transition block. Simulink does not allow the initial output of this block to be Inf or NaN.

Output port sample time options

Specifies a mode for setting the output port sample time. The options are:

  • Specify — Allows you to use the Output port sample time parameter to specify the output rate to which the Rate Transition block converts its input rate.

  • Inherit — Specifies that the Rate Transition block inherits an output rate from the block to which the output port is connected.

  • Multiple of input port sample time — Allows you to use the Sample time multiple (>0) parameter to specify the Rate Transition block output rate as a multiple of its input rate.

If you specify Inherit and all blocks connected to the output port also inherit sample time, the fastest sample time in the model applies.

Output port sample time

This parameter is visible when you set Output port sample time options to Specify. Enter a value that specifies the output rate to which the block converts its input rate. The default value (-1) specifies that the Rate Transition block inherits the output rate from the block to which the output port is connected. See Specify Sample Time in the Simulink documentation for information on how to specify the output rate.

Sample time multiple (>0)

This parameter is visible when you set Output port sample time options to Multiple of input port sample time. Enter a positive value that specifies the output rate as a multiple of the input port sample time. The default value (1) specifies that the output rate is the same as the input rate. A value of 0.5 specifies that the output rate is half of the input rate, while a value of 2 specifies that the output rate is twice the input rate.

Bus Support

The Rate Transition block is a bus-capable block. The input can be a virtual or nonvirtual bus signal, with the restriction that Initial conditions must be zero, a nonzero scalar, or a finite numeric structure. For information about specifying an initial condition structure, see Specify Initial Conditions for Bus Signals.

All signals in a nonvirtual bus input to a Rate Transition block must have the same sample time, even if the elements of the associated bus object specify inherited sample times. You can use a Rate Transition block to change the sample time of an individual signal, or of all signals in a bus. See Composite Signals and Bus-Capable Blocks in the Simulink documentation for more information.

You can use an array of buses as an input signal to a Rate Transition block. For details about defining and using an array of buses, see Combine Buses into an Array of Buses.

Characteristics

Bus-capable

Yes, with restrictions as noted above.

Direct Feedthrough

No, for slow-to-fast transitions for which you select the Ensure data integrity during data transfer check box. Yes, otherwise.

Sample Time

This block supports discrete-to-discrete transitions.

Scalar Expansion

Yes, of input.

Dimensionalized

Yes

Multidimensionalized

Yes

Zero-Crossing Detection

No

Was this topic helpful?