Documentation

Frequency Output

Generate and output pulse-width-modulated square wave to timer output

Library

Simulink® Desktop Real-Time™

Description

Generate and output a pulse-width-modulated square wave to an analog output.

The square wave alternates between low (0) and high (1) with a specified frequency and duty cycle.

You specify the frequency in hertz (Hz).

You specify the duty cycle as a decimal fraction from 0 through 1 inclusive. It determines the amount of time that the output signal value is high (1).

After you have added a Frequency Output block to your model, double-click the Frequency Output block to open the Block Parameters: Frequency Output dialog box.

Parameters

Install new board

Click this button to register a board with Simulink Desktop Real-Time.

When you click Install new board, the software displays a list of manufacturers of supported boards. When you select a manufacturer, the software displays a list of boards available from that manufacturer. When you select a board, the software adds the board to the list of registered boards and makes that board the current board.

By default, the initial selection in the list of registered boards is < no board selected >. When you select a board in the list, the Delete current board and Board setup buttons become active.

Delete current board

Click this button to delete the current board. The initial selection of the list of registered boards changes to < no board selected >, and the Delete current board and Board setup buttons become inactive.

Board setup

Click this button to set up the board.

A board-specific dialog box opens for you to use to set up the board. For more information to set up the board, see the board manufacturer documentation.

Sample time

Enter a value representing how frequently you want the block to execute and interact with the I/O hardware. The block also synchronizes your model with the real-time clock at this sample rate.

    Tip   If you are using a fixed-step solver, you must enter the value that you entered in the Fixed step size box in the Configuration Parameters dialog box, or an integer multiple of that value.

Maximum missed ticks

In Normal Mode, enter the number of timer ticks that your model can lag behind the real-time kernel. When the model lags by this number or less, the software assumes that the lag is temporary and allows the model to catch up, even if the model misses some ticks. When the model lags by more than this number, the software reports an error and simulation stops.

In External Mode, the software ignores this value.

Show "Missed Ticks" port

In Normal Mode, select this check box to display the number of missed ticks as a block output.

In External Mode, The "Missed Ticks" port displays zero.

Yield CPU when waiting

In Normal Mode, select this check box to grant other programs more CPU time while the kernel waits for a response from the hardware.

In External Mode, the software ignores this value.

Output channels

Enter a vector that selects the output channels that you are using on this board. The vector can be any valid MATLAB® vector form.

Output signal frequency source

From the list, select the source that specifies the frequency to output, in hertz. The Output signal frequency source can be either of the following:

  • internal — A tunable parameter named Frequency specifies the frequency.

    If you specify internal, Frequency replaces Frequency initial value, and Frequency final value is disabled.

  • external (default) — An input signal specifies the frequency. An input port appears on the block to accept the signal.

    The software can require additional settings for Frequency initial value and Frequency final value .

Frequency

Specify the desired frequency in hertz.

This tunable parameter appears when Output signal frequency source is internal.

Frequency initial value

Optionally specify an initial frequency in hertz. The specified frequency takes effect when you connect to the target. It persists until simulation starts, at which time the value of the frequency signal takes effect. You can use this parameter to specify initial conditions and give them time to stabilize. If no value appears, connecting to the target has no effect on the frequency.

This parameter appears when Output signal frequency source is external.

Frequency final value

Optionally specify a final frequency in hertz. The specified frequency takes effect when simulation is complete and persists indefinitely. Disconnecting from the target does not change the frequency. You can use this parameter to put a connected device into a neutral state after simulation. If no value appears, the frequency in effect at the end of simulation persists afterwards.

This parameter appears when Output signal frequency source is external.

Output signal duty source

From the list, specify the source that determines the duty cycle. The Output signal duty source can be either of the following:

  • internal (default) — A tunable parameter named Duty specifies the duty cycle.

  • external — An inport signal specifies the duty cycle. An input port appears on the block to accept the signal.

    If you specify external, Duty initial value replaces Duty, and Duty final value is enabled.

Duty

Specify the duty cycle as a decimal fraction from 0 through 1 inclusive. It determines the amount of time that the output signal value is high (1). For example, a duty cycle of 0.7 specifies that the output is high 70% of the time, and low 30% of the time.

Two duty cycle values have special significance:

  • 0 — The output signal is continuously low (0) regardless of the frequency specification currently in effect.

  • 1 — The output signal is continuously high (1) regardless of the frequency specification currently in effect.

This tunable parameter appears when Output signal duty source is internal.

Duty initial value

Optionally specify an initial duty cycle. The specified duty cycle takes effect when you connect to the target. It persists until simulation starts. If no value appears, connecting to the target has no effect on the duty cycle. You can specify any duty cycle. Often the Duty initial value is 0 or 1, enforcing a continuously low or high initial output signal. Specifying 0 or 1 overrides any Frequency initial value setting.

This parameter appears when Output signal duty source is external.

Duty final value

Optionally specify a final duty cycle. The specified duty cycle takes effect when simulation is complete and persists indefinitely. Disconnecting from the target does not change the duty cycle. If no value appears, the duty cycle in effect at the end of simulation persists indefinitely afterwards. You can specify any duty cycle. Often the Duty final value is 0 or 1, enforcing a continuously low or high initial output signal. Specifying 0 or 1 overrides any Frequency final value setting.

This parameter appears when Output signal duty source is external.

Was this topic helpful?