Engee documentation

Pulse Generator

Generator of rectangular pulses of a given frequency.

pulse generator

Description

The Pulse Generator generates rectangular pulses at regular intervals. The block’s waveform parameters Amplitude, Pulse Width, Period, and Phase delay determine the output waveform. The following diagram shows how each parameter affects the waveform.

pulse generator parameter effects

The Pulse Generator can generate scalar, vector, or matrix signals. To generate a scalar signal, use scalars to set the waveform parameters. To generate a vector or matrix signal, use vectors or matrices, respectively. Each element of the waveform parameters affects the corresponding element of the output signal. For example, the first element of the vector amplitude parameter determines the amplitude of the first element of the vector output pulse.

The unit can operate in two modes defined by the Pulse type parameter:

  • Simulation time-based mode (Time-Based).

  • The mode based on calculation steps (Sample-Based).

Simulation time-based mode

In Simulation Time-Based mode, Engee calculates the block output value only when the output actually changes. This approach results in fewer calculations. To enable this mode, set the Pulse type parameter to Time based.

The block does not support a configuration that results in a constant output signal. Engee returns an error if the Pulse Width and Period parameters satisfy either of these conditions:

The Pulse Generator block in the * Time based Simulation Time mode is discrete, although it does not have a *Sample time field. As Sample time, the block selects a value that will fit both the pulse width and the period an integer number of times at the same time, so as not to miss values. The formula is as follows:

If the block is set to Time based External Signal mode, then all parameters except Amplitude must be multiples of the Sample time coming to the block input to also not miss values.

If the block uses vector parameters, in addition to taking the greatest common divisor between the elemental parameters, it will also take the greatest divisor between the calculated values.

Mode based on calculation steps

In calculation step based mode, the block calculates its output parameters at fixed intervals set by the block parameters. To enable this mode, set the Pulse type parameter to Sample based.

In `Sample Based' mode, the block is always discrete.

The unit does not support Sample Based External Signal mode

An important difference between time-based and step-based modes is that in time-based mode the block output is based on the simulation time, while in step-based mode the block output depends only on the start of the simulation, regardless of the elapsed time.

Ports

Input

t - time
scalar | vector | matrix

The source of time for calculating the value of a signal.

Dependencies

To use this port, set the Time parameter to Use external signal.

Output

Port_1 - generated output signal
scalar | vector | matrix

Generated rectangular pulse signal defined by parameters.

Data types: Float64.

Parameters

Pulse type - mode of operation
Time based (by default) | Sample based

Block operation mode: Time based or Sample based.

Some parameters in the dialogue box are active depending on which mode is selected.

Usage in program code

Block parameter

PulseType

Value

Time based | Sample based

By default

Time based Time based

Time (t) - time source.
Use simulation time (by default) | Use external signal

Selects the time source for calculating the signal value.

Use simulation time - the unit generates the output signal based on the simulation time.

Use external signal - the block generates an output pulse based on the value on the input port t (may differ from the simulation time). The block icon shows the input port for source connection.

Usage in program code

Block parameter

TimeSource Use simulation time Use external signal

Value

Use simulation time | Use external signal

By default

Use simulation time

Amplitude - amplitude of the signal
1 (by default) | scalar | vector | matrix

Amplitude of the generated signal.

Usage in program code

Block parameter

Amplitude

Value

scalar | vector | matrix

By default

1

Period (secs) - pulse period
10 (by default) | scalar | vector | matrix

The pulse period is specified in seconds when Pulse type is set to Time based.

Usage in program code

Block parameter

Period

Value

scalar | vector | matrix

By default

10

Period (number of samples) - period of pulses
10 (by default) | scalar | vector | matrix

If Pulse type is set to Sample based, the period is set as the number of sampling steps.

Usage in program code

Block parameter

PeriodNum

Value

scalar | vector | matrix

By default

10

Pulse Width (% of period) - pulse width
5 (by default) | scalar | vector | matrix

The pulse width is defined as:

  • a fraction in per cent of the period if Pulse type is set to Time based.

The value must be in the range [0,100].

Usage in program code

Block parameter

PulseWidth

Value

scalar | vector | matrix

By default

5

Pulse Width (number of samples) - pulse width
5 (by default) | scalar | vector | matrix

The pulse width is defined as:

  • number of calculation steps if the Pulse type parameter is set to Sample based.

The value must be in the range [0,100].

Usage in program code

Block parameter

PulseWidthNum

Value

scalar | vector | matrix

By default

5

Phase Delay (secs) - delay before the first pulse
0 (By default) | scalar

The delay before the first pulse is generated, specified in seconds, if Pulse type is set to Time based.

Usage in program code

Block parameter

PhaseDelay

Value

scalar | vector | matrix

By default

0

Phase Delay (number of samples) - delay before the first pulse
0 (By default) | scalar

The delay before the first pulse is generated, specified as the number of calculation steps if Pulse type is set to Sample based.

Usage in program code

Block parameter

PhaseDelayNum

Value

scalar | vector | matrix

By default

0

Sample time - interval between calculation steps
-1 (by default) | scalar

Specify the interval between calculation steps as a non-negative number.

To inherit a calculation step, set this parameter to -1.

Dependencies

To use this parameter, set the Pulse type parameter to Sample based.

Usage in program code

Block parameter

SampleTime

Value

scalar | vector | matrix

By default

0

Additional options

C code generation: Yes