Vous êtes sur la page 1sur 5

Hi,

Here there is some tips about the use of PWM in S7-1200.


To configure a PWM do you need:
1 Configure the properties of the PWM in the CPU properties (Device Configuration). Important
properties:
1 a Time Base: that is the unit scale used in the property 1c.
1 b Pulse width format: define the pulse width scale in the user program. For example: if you choice
100, the user set point should stay between 0-100. if you choice 1000, the user set point should stay
between 0-1000. And so on. (if you use S7-analogic format, the set point should stay between 0-27648).
1c Cycle time: corresponds to the ON time + OFF time of each cycle.
1d Initial Pulse width: initial value of the setpoint to the PWM (when there is a start of the CPU).
2 You need to call a block (CTRL_PWM) in OB1, give the PWM name and an enable signal.

Behavior:
While the PWM is not enabled by the CTRL_PWM, the digital output works like a normal digital output.
Once the PWM is enabled, the output is dived by the PWM. Note however that the monitoring of the
digital output, follow the digital logic.
Sample program:
The follow sample program is very simple. There is just the device configuration settings and a
CTRL_PWM call. In the watch table, you can modify the digital output, and enable / disable the PWM to
see how they works.
Attachment:

PWM.zip (1859 Downloads)

Description
You can change the pulse length for the pulse width modulation (PWM) in the user program. Proceed as follows.

No. Procedure
1

In STEP 7 Basic V11 you open the device configuration of the S7-1200 CPU in your project.

In the inspector window you switch to the "Properties" tab.

In the "Properties" tab you select "Pulse generators (PTO/PWM) > PTO1/PWM1 > General".
Enable the "Enable this pulse generator" option.

Fig. 01
4

In the "Properties" tab you select "Pulse generators (PTO/PWM) > PTO1/PWM1 > I/O addresses".
Here you define the output addresses. In this example, the output word AW1000 is defined and
assigned as output address.

Fig. 02
5

In this example the enable pulse generator has the following ID:

266 (dec) = 10A (hex)

The hardware ID of the pulse generator is created as a system constant in the PLC variable table of
the S7-1200 CPU.

Fig. 03
6

In the user program, insert the MOVE instruction at the point where the pulse length is to be
changed. In this example the MOVE instruction is inserted in Network 1 of the Main(OB1) program
block. The MOVE instruction is to be found in the task card "Instructions" > "Basic instructions >
Move operations" palette.
Specify the new pulse length at the IN input (value range: 0 to 100).
At the OUT1 output you specify the output word AW1000. The output word AW1000 is the assigned
output word of the pulse generator.


Fig. 04
7

Insert the CTRL_PWM instruction after the MOVE instruction. In this example the CTRL_PWM
instruction is inserted in Network 2 of the Main(OB1) program block. The CTRL_PWM instruction is
to be found in the task card "Instructions" > "Advanced instructions > Move operations" palette.
You specify the hardware identifier of the pulse generator at the PWM input. For the hardware ID of
the pulse generator you select the corresponding system constant from the drop-down list box.

Fig. 05

The pulse generator is enable and disabled through the ENABLE input.

Vous aimerez peut-être aussi