Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Pulse Generator - Generate square wave pulses at regular intervals

Library

Sources

Description

The Pulse Generator block generates square wave pulses at regular intervals. The block's waveform parameters, Amplitude, Pulse Width, Period, and Phase Delay, determine the shape of the output waveform. The following diagram shows how each parameter affects the waveform.

The Pulse Generator can emit scalar, vector, or matrix signals of any real data type. To cause the block to emit a scalar signal, use scalars to specify the waveform parameters. To cause the block to emit a vector or matrix signal, use vectors or matrices, respectively, to specify the waveform parameters. Each element of the waveform parameters affects the corresponding element of the output signal. For example, the first element of a vector amplitude parameter determines the amplitude of the first element of a vector output pulse. All the waveform parameters must have the same dimensions after scalar expansion. The data type of the output is the same as the data type of the Amplitude parameter.

Use the Pulse type parameter to specify whether the block's output is time-based or sample-based. If you select sample-based, the block computes its outputs at fixed intervals that you specify. If you select time-based, Simulink software computes the block's outputs only at times when the output actually changes. This choice can result in fewer computations for computing the block's output over the simulation time period.

Depending on the pulse's waveform characteristics, the intervals between changes in the block's output can vary. For this reason, a time-based Pulse Generator block has a variable sample time. Simulink software uses brown as the sample time color of such blocks (see Displaying Sample Time Colors for more information).

Simulink software cannot use a fixed-step solver to compute the output of a time-based pulse generator. If you specify a fixed-step solver for models that contain time-based pulse generators, Simulink software computes a fixed sample time for the time-based pulse generators. Then the time-based pulse generators simulate as sample-based.

If you select time-based as the block's pulse type, you must specify the pulse's phase delay and period in units of seconds. If you specify sample-based, you must specify the block's sample time in seconds, using the Sample Time parameter, then specify the block's phase delay and period as integer multiples of the sample time. For example, suppose that you specify a sample time of 0.5 second and want the pulse to repeat every two seconds. In this case, you would specify 4 as the value of the block's Period parameter.

Data Type Support

The Pulse Generator block outputs real signals of any numeric data type supported by Simulink software, including fixed-point data types. The data type of the output signal is the same as that of the Amplitude parameter.

For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

Opening this dialog box causes a running simulation to pause. See Changing Source Block Parameters During Simulation in the online Simulink documentation for details.

Pulse type

The pulse type for this block: time-based or sample-based. The default is time-based.

Time

Specifies whether to use simulation time or an external signal as the source of values for the output pulse's time variable. If you specify an external source, the block displays an input port for connecting the source. The output pulse differs as follows:

  • If you select Use simulation time, the block generates an output pulse where the time variable equals the simulation time.

  • If you select Use external signal, the block generates an output pulse where the time variable equals the value from the input port, which can differ from the simulation time.

    Note   If you select Use external signal and click OK, an Apply button appears the next time that you open the block dialog box. This Apply button disappears if you select Use simulation time and click OK.

Amplitude

The pulse amplitude. The default is 1.

Period

The pulse period specified in seconds if the pulse type is time-based or as number of sample times if the pulse type is sample-based. The default is 10 seconds.

Pulse width

The duty cycle specified as the percentage of the pulse period that the signal is on if time-based or as number of sample times if sample-based. The default is 5 percent.

Phase delay

The delay before the pulse is generated specified in seconds if the pulse type is time-based or as number of sample times if the pulse type is sample-based. The default is 0 seconds.

Sample time

The length of the sample time for this block in seconds. This parameter appears only if the block's pulse type is sample-based. See How to Specify the Sample Time in the Simulink User's Guide for more information.

Interpret vector parameters as 1-D

If you select this check box and the other parameters are one-row or one-column matrices, after scalar expansion, the block outputs a 1-D signal (vector). Otherwise the output dimensionality is the same as that of the other parameters. See Determining the Output Dimensions of Source Blocks.

Characteristics

Sample Time

Inherited

Scalar Expansion

Yes, of parameters

Dimensionalized

Yes

Zero Crossing

No

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS