Description
You can use the "Generate pulse" instruction to set the Q output for a programmed duration. The instruction is started when the result of logic operation (RLO) at input IN changes from "0" to "1" (positive signal edge). The programmed time PT begins when the instruction starts. Output Q is set for the duration PT, regardless of the subsequent course of the input signal. While the time PT is running, the detection of a new positive signal edge at the IN input has no influence on the signal state at the Q output.
You can query the current time value at the ET output. The timer value starts at T#0s and ends when the value of the time duration PT is reached. When the time PT has elapsed and the signal state at input IN is "0", the ET output is reset. If the instruction is not called in the program because it is skipped, for example, the ET output returns a constant value as soon as the time PT has expired.
The "Generate pulse" instruction can be placed within or at the end of the network. It requires a preceding logic operation.
Each call of the "Generate pulse" instruction must be assigned to an IEC timer in which the instance data is stored.
For S7-1200 CPU
An IEC timer is a structure of the data type IEC_TIMER or TP_TIME that you can declare as follows:
-
Declaration of a data block of system data type IEC_TIMER (for example, "MyIEC_TIMER")
-
Declaration as a local tag of the type TP_TIME or IEC_TIMER in the "Static" section of a block (for example, #MyIEC_TIMER)
For S7-1500 CPU
An IEC Timer is a structure of the data type IEC_TIMER, IEC_LTIMER, TP_TIME or TP_LTIME that you can declare as follows:
-
Declaration of a data block of system data type IEC_TIMER or IEC_LTIMER (for example, "MyIEC_TIMER")
-
Declaration as a local tag of the type TP_TIME, TP_LTIME, IEC_TIMER or IEC_LTIMER in the "Static" section of a block (for example, #MyIEC_TIMER)
Updating the actual values in the instance data
The instance data from "Generate pulse" is updated according to the following rules:
-
IN input
The "Generate pulse" instruction compares the current RLO with the RLO from the previous query, which is saved in the IN parameter in the instance data. If the instruction detects a change in the RLO from "0" to "1", there is a positive signal edge and the time measurement is started. After the "Generate pulse" instruction has been processed, the value of the IN parameter is updated in the instance data and is used as edge memory bit for the next query.
Note that the edge evaluation is disrupted when the actual values of the IN parameter are written or initialized by other functions.
-
PT input
The value at the PT input is written to the PT parameter in the instance data when the edge changes at the IN input.
-
Q and ET outputs
The actual values of the Q and ET outputs are updated in the following cases:
-
When the instruction is called, if the ET or Q outputs are interconnected.
Or
-
At an access to Q or ET.
If the outputs are not interconnected and also not queried, the current time value at the Q and ET outputs is not updated. The outputs are not updated, even if the instruction is skipped in the program.
The internal parameters of the "Generate pulse" instruction are used to calculate the time values for Q and ET. Note that the time measurement is disrupted when the actual values of the instruction are written or initialized by other functions.
-
|
|
Danger |
|
Danger when reinitializing the actual values Reinitializing the actual values of an IEC timer while the time measurement is running disrupts the function of the IEC timer. Changing the actual values can result in inconsistencies between the program and the actual process. This can cause serious damage to property and personal injury. The following functions can cause the actual values to be reinitialized:
Before you execute these functions, take the following precautions:
|
|
Parameters
The following table shows the parameters of the "Generate pulse" instruction:
|
Parameters |
Declaration |
Data type |
Memory area |
Description |
||
|---|---|---|---|---|---|---|
|
S7-1200 |
S7-1500 |
S7-1200 |
S7-1500 |
|||
|
IN |
Input |
BOOL |
BOOL |
I, Q, M, D, L or constant |
I, Q, M, D, L, T,C, P or constant |
Start input |
|
PT |
Input |
TIME |
TIME, LTIME |
I, Q, M, D, L or constant |
I, Q, M, D, L, P or constant |
Duration of the pulse. The value of the PT parameter must be positive. |
|
Q |
Output |
BOOL |
BOOL |
I, Q, M, D, L |
I, Q, M, D, L, P |
Pulse output |
|
ET |
Output |
TIME |
TIME, LTIME |
I, Q, M, D, L |
I, Q, M, D, L, P |
Current timer value |
Pulse timing diagram
The following figure shows the pulse timing diagram of the "Generate pulse" instruction:
Example
The following example shows how the instruction works:
The following table shows how the instruction works using specific operand values:
|
Parameters |
Operand |
Value |
|---|---|---|
|
IN |
Tag_Start |
Signal transition "0" => "1" |
|
PT |
Tag_PresetTime |
T#10s |
|
Q |
Tag_Status |
TRUE |
|
ET |
Tag_ElapsedTime |
from T#0s => T#10s |
When the signal state of the "Tag_Start" operand changes from "0" to "1", the time programmed for the PT parameter is started and the "Tag_Status" operand is set to "1". The current time value is stored in the "Tag_ElapsedTime" operand. When the time expires, the "Tag_Status" operand is reset to signal state "0".