Pulse Width Modulator (PWM)

Short description

The Pulse Width Modulator (PWM) instruction modulates the analog input value Ax to a pulsed digital output signal. The pulse width is proportional to the analog value Ax.

LOGO! 9 and later versions support two data types: integer (16-bit) and float (32-bit).

Connection

Description

Input En

A positive edge (0 to 1 transition) at input En enables the PWM function block.

Input Ax

Analog signal to be modulated to a pulsed digital output signal.

Input  is one of the following analog signals (integer or float):

  • AI 1:

    • LOGO! 9: AI1 to AI16 3

    • 0BA8: AI1 to AI8 4

  • AM 1:

    • LOGO! 9: AM1 to AM128

    • 0BA8: AM1 to AM64

    • 0BA7: AM1 to AM16

    • 0BA6: AM1 to AM6

  • NAI 1:

    • LOGO! 9: NAI1 to NAI128

    • 0BA7 or 0BA8: NAI1 to NAI32

  • AQ 1:

    • LOGO! 9: AQ1 to AQ16

    • 0BA8: AQ1 to AQ8

    • 0BA7: AQ1 and AQ2

  • NFAI 2:

    • LOGO! 9: NFAI1 to NFAI16

  • FAM 2:

    • LOGO! 9: FAM1 to FAM32

  • The block number of a function with analog output 1 2

Parameter

Value range

Integer

Float

Gain

  • Analog resolution 0 - 1000: -10.00 to 10.00

  • Analog resolution 0 - 4095: -10.00 to 10.00

  • Analog resolution 0 - 10000: -10.00 to 10.00

-3.402823E38 to +3.402823E38

Offset

  • Analog resolution 0 - 1000: -10000 to 10000

  • Analog resolution 0 - 4095: -32768 to 32767

  • Analog resolution 0 - 10000: -32768 to 32767

Range Min

  • Analog resolution 0 - 1000: -20000 to 20000

  • Analog resolution 0 - 4095: -32768 to 32767

  • Analog resolution 0 - 10000: -32768 to 32767

Range Max

  • Analog resolution 0 - 1000: -20000 to 20000

  • Analog resolution 0 - 4095: -32768 to 32767

  • Analog resolution 0 - 10000: -32768 to 32767

Pt

Periodic time over which the digital output is modulated

Range of value: 0 to 99

p (Number of decimals)

0, 1, 2, 3

/

Output Q

Q is set or reset for the proportion of each time period according to the proportion of the standardized value Ax to the analog value range.

1 If the data type of Ax is integer and the data type of this FB is configured as float, LSC will convert Ax into 32-bit receivable float data.

2 If the data type of Ax is float and the data type of this FB is configured as integer, LSC will cut off the decimal numbers of Ax and convert it into 16-bit receivable integer data.

3 AI1 to AI16: 0 to 10 V corresponds with 0 to 1000, 0 to 4095 or 0 to 10000 (internal value).

4 AI1 to AI8: 0 to 10 V corresponds with 0 to 1000 (internal value).

0BA1- 0BA5:

The PWM function block did not exist prior to 0BA6.

Parameter PT

The periodic time PT can be provided by the actual value of another already-programmed function:

  • Analog comparator: Ax - Ay

  • Analog threshold trigger: Ax

  • Analog amplifier: Ax

  • Analog multiplexer: Aq

  • Analog ramp: Aq

  • Mathematic instruction: Aq

  • PI controller: Aq

  • Up/Down counter: Cnt

For the 0BA7 and later version devices, you can additionally use the actual values of the following already-programmed functions:

  • On-delay: Ta

  • Off-delay: Ta

  • On-/off-delay: Ta

  • Retentive on-delay: Ta

  • Wiping relay(pulse output): Ta

  • Edge triggered wiping relay: Ta

  • Asynchronous pulse generator: Ta

  • Stairway light switch: Ta

  • Multiple function switch: Ta

  • Stopwatch: Aq

  • Analog filter: Aq

  • Average value: Aq

  • Max/Min: Aq

  • Threshold trigger: Fre

For the 0BA8 and later version devices, you can additionally use the actual values of the following already-programmed functions:

  • Float/Integer converter: eAq

  • Integer/Float converter: eAq

For the LOGO! 9 and later version devices, you can additionally use the actual values of the following already-programmed functions:

  • Float calculation instruction: Aq

You select the required function by the block number.

Parameter p (number of decimals)

Parameter p applies only to the display of the Ax value in a message text.

Description of the function

The function reads the value of the signal at the analog input Ax.

This value is multiplied by the value of parameter A (gain). Parameter B (offset) is added to the product, as follows:

(Ax * Gain) + Offset = Actual value Ax

The function block calculates the proportion of the value Ax to the range. The block sets the digital output Q high for the same proportion of the PT (periodic time) parameter, and sets Q low for the remainder of the time period.

Examples with Timing Diagrams

The following examples show how the PWM instruction modulates a digital output signal from the analog input value:

Example 1

Analog input value: 500 (range 0 to 1000)

Periodic time T: 4 seconds

The digital output of the PWM function is 2 seconds high, 2 seconds low, 2 seconds high, 2 seconds low and continues in that pattern as long as parameter "En" = high.

Example 2

Analog input value: 300 (range 0 to 1000)
Periodic time T: 10 seconds

The digital output of the PWM function is 3 seconds high, 7 seconds low, 3 seconds high, 7 seconds low and continues in that pattern as long as parameter "En" = high.

Calculation rule

Q = 1, for (Ax – Min) / (Max – Min) of time period PT
Q = 0, for PT – [(Ax – Min) / (Max – Min)] of time period PT.

Note: Ax in this calculation refers to the actual value Ax as calculated using the Gain and Offset. Min and Max refer to the minimum and maximum values specified for the range.

Particular characteristics to be noted when configuring

Refer to the help on analog block parameters in the Analog value processing section.

Overview