Engee documentation

PWM

Generates an ideal pulse-width modulated signal according to the input signal well.

pwm

Description

The PWM unit generates an ideal pulse width modulated signal.

Pulse Width Modulation (PWM) is a method of encoding an analogue signal by usage of rectangular pulses. The principle of PWM is to change the pulse width at a constant pulse frequency. The ratio of pulse width to period is called the * duty cycle*. The relationship between the modulated signal and duty cycle is described as follows:

,

where and are the upper and lower limits of the output signal, respectively.

For the PWM block, the duty cycle lies in the range [0,1]. The ideal PWM signal is proportional to the duty cycle D.

Ports

Input

D - duty cycle
scalar

Relative pulse duration P as a scalar in the range [0,1].

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool.

Output

Port_1 - output signal
scalar | vector | matrix

PWM signal with duty cycle equal to the value of the input signal.

Data types: Float64.

Parameters

Period - pulse period
1 (by default) | real scalar | vector | matrix

The time between rising edges of successive pulses of the output signal. A small value corresponds to a high frequency pulse.

Usage in program code

Block parameters

Period

Values

real scalar

* By default*

1

Disallow zero duty cycle - avoid algebraic loops
off (false) (by default) | on (true)

Enable this parameter to break algebraic loops containing a PWM block.

Enabling this parameter causes the signal value to become 0 or lower, causing an input signal error.
Usage in program code

Block parameter

DisallowZeroDutyCycle

Values

disabled (false) | enabled (true)

By default

disabled (false)

Data types: Bool.

Sample Time - interval between calculation steps
0.1 (by default) | scalar

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

A value of -1 for the Sample Time parameters causes an error.

Algorithms

Continuous sampling mode

continuous sampled pwm

For a pulse starting at time tk

where is the pulse width.

For a given period P, is proportional to the squirt rate D