Siemens Simatic S7-200 System Manual page 229

Programmable controller
Hide thumbs Also See for Simatic S7-200:
Table of Contents

Advertisement

PWM Initialization
To initialize the PWM for Q0.0, follow these steps:
1.
Use the first scan memory bit to set the output to 1, and call the subroutine that you need
in order to perform the initialization operations. When you use the subroutine call,
subsequent scans do not make the call to the subroutine. This reduces scan time
execution and provides a more structured program.
2.
In the initialization subroutine, load SM67 with a value of 16#C3 for PWM using
microsecond increments (or 16#CB for PWM using millisecond increments). These
values set the control byte to enable the PTO/PWM function, select PWM operation,
select either microsecond or millisecond increments, and set the update pulse width and
cycle time values.
3.
Load SM68 (word size value) with the desired cycle time.
4.
Load SM70 (word size value) with the desired pulse width.
5.
Execute the PLS instruction so that the S7-200 programs the PTO/PWM generator.
6.
Load SM67 with a value of 16#C2 for microsecond increments (or 16#CA for millisecond
increments). This resets the update cycle time value in the control byte and allows the
pulse width to change. A new pulse width value is loaded, and the PLS instruction is
executed without modifying the control byte.
7.
Exit the subroutine.
Optional steps for synchronous updates. If synchronous updates are required, follow these
steps:
1.
Execute the global interrupt enable instruction (ENI).
2.
Using the condition you will use to update pulse width, enable (ATCH) a rising edge
event to an interrupt routine. The condition you use to attach the event should be active
for only one scan.
3.
Add an interrupt routine that updates the pulse width, and then disables the edge
interrupt.
Note
The optional steps for synchronous updates require that the PWM output is fed back to
one of the interrupt inputs.
Changing the Pulse Width for PWM Outputs
To change the pulse width for PWM outputs in a subroutine, follow these steps:
1.
Call a subroutine to load SM70 (word size value) with the desired pulse width.
2.
Execute the PLS instruction to cause the S7-200 to program the PTO/PWM generator.
3.
Exit the subroutine.
S7-200 Programmable Controller System Manual
C79000-G7076-C230-02
Instruction Set
10-41

Advertisement

Table of Contents
loading

Table of Contents