Pulse Generator

Generate square wave pulses at regular intervals




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.

A time-based configuration using parameters Pulse Width and Period that results in a constant output signal is not supported. Simulink returns an error if these parameters satisfy either of the following conditions:


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 View Sample Time Information 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.

    Tip   If you use a fixed-step solver and the Pulse type is time-based, you must choose the step size such that the period, phase delay, and pulse width (in seconds) are integer multiples of the step size. For example, suppose that the period is 4 seconds, the pulse width is 75% (i.e., 3 s), and the phase delay is 1 s. In this case, the computed sample time is 1 s. Therefore, you must choose a fixed-step size that is 1 or that divides 1 exactly (e.g., 0.25). You can guarantee this by setting the fixed-step solver's step size to auto on the Solver pane of the Configuration Parameters dialog box.

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 that Simulink supports, including fixed-point data types. The data type of the output signal is the same as that of the Amplitude parameter.

For more information, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

Pulse type

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


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.


The pulse amplitude. The default is 1.


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 Specify 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.


The following Simulink examples show how to use the Pulse Generator block:


Sample Time


Scalar Expansion

Yes, of parameters



Zero-Crossing Detection


Was this topic helpful?