How, in WinCC (TIA Portal), do you specify the duration for a timer via an operator panel, and how do you output the remaining time?
1) Operating the Visualization
In the example you can perform the actions below in the visualization:
Select the required timer (1)
- TP (generate pules)
- TON (generate ON delay)
- TOF (generate OFF delay)
Monitor the signal (2)
- Green: Signal on
- Gray: Signal off
Start the timer (3)
You can start the time if the counter is not active.
Reset the timer (Reset) (4)
Resetting the timer restores the initial status before the timer was started.
You can do a reset even if the timer is active. This interrupts the timer's counting procedure.
Preset the duration of the timer(time units: milliseconds/seconds/minutes/hours/days)
The input is accepted only if the option field of the relevant selection is active.
- Input the time via the drop-down list box of the selected time unit (5)
The maximum possible duration is either 106,751 days, 2,562,047 hours,
153,722,867 minutes, 9,223,372,036 seconds or 9,223,372,036,854 milliseconds.
- Input the time as a total of multiple time units (6)
The maximum possible duration is 106,751 day, 23 hours, 47 minutes, 16 seconds and 854 milliseconds.
- Accept the duration from the process (7)
The input process value of the data type "LTIME" is displayed in the visualization as a value of the data type "TIME". This means that the maximum range that can be displayed is 24 days, 20 hours, 31 minutes, 23 seconds and 647 milliseconds or 2,147,483,647 milliseconds. If the value is greater, #### is displayed. In the controller the value is nevertheless processed normally and the remaining time is displayed correctly in the visualization.
Delete the input and output fields (Clear) (8)
The Clear command resets to zero the duration that was set manually (5) (6).
Monitor the remaining time
- Output of the time in the time unit selected in the drop-down list box (9)
The number of places after the decimal point in this type of output depends on the number of decimal places of the displayed number.
- 1 digit > 3 places after the decimal point
- 2 digits > 2 places after the decimal point
- 3 digits > 1 place after the decimal point
- 4 digits and more > no places after the decimal point
- Output the time as the sum of multiple time units (10)
- The visualization in the sample project is compatible with all Comfort Panels and the Runtime Advanced.
- When used in the Runtime Professional, at least changes to the buttons are required.
- When using Basic Panels, you cannot control the operability of the input elements, like using scripts to reset the preset duration. These functions can be replaced optionally by using "Visibility" instead of "Operability" and the call of the system commands stored in the VB Scripts on the "CLEAR" buttons.
2) Functions of the Control Block
The control block FB50 "TimerTimeRemaining" is kept modular. You can delete networks that are not needed.
The networks below are needed.
1. At least one of the three lower-level networks in the "Network 1 - Inputs" for the Preset Duration
- The "Network 1a - Single Input" permits manual input of the duration as a single value (in a time unit) via the input mask (5) in the visualization. The time unit depends on the value of the "InputTimeUnit" variable which depends on the selection in the associated drop-down list box.
- The "Network 1b - Mixed Input" permits manual input of the duration split into multiple mixed partial values (with different time units) via the input mask (6) in the visualization.
- Alternatively you can also go via "Network 1c - Input Value from Process" to link a process value of the data type "LTIME" directly to the FB50. Display of the process value is via the output (7).
The active network transfers the preset duration in the data format "LTIME" to "Network 2 - Timer" via the variable "LTimeToTimer".
The active input network depends on the value of the variable "InputType". The "InputType" variable is set by operating the buttons for selecting the input masks (5), (6) and (7).
2. The "Network 2 - Timer" for selection and control of the active timer
- Via the drop-down list box "Type of timer" (1) the active timer is selected in the "Network 2 - Timer" via the "TimerType" variable.
- When you operate the "START" button (3) the active timer is started by setting the "StartTimer" variable.
- You operate the "RESET" button (4) to reset the active timer by setting the "Reset" variable.
3. At least one of the three lower-level networks in the "Network 3 - Outputs" for the output of the remaining time
- The "Network 3a - Single Output" permits output of the remaining time as a single value (in a time unit) via the output mask (9) in the visualization. The time unit depends on the value of the "OutputTimeUnit" variable which depends on the selection in the associated drop-down list box.
The "Network 3a" - Single Output with Changed Decimal Places" is an optional add-on to the Network 3a. In the visualization the network controls the visibility of multiple output fields which lie on top of each other and have different parameters. Depending on the number of digits before the decimal point, this permits a visualization with dynamic changing of the number of places after the decimal point (9).
- The "Network 3b - Mixed Output" permits output of the remaining time split into multiple mixed partial values (with different time units) via the output mask (10) in the visualization.
- Alternatively, via "Network 3c - Output Value from Process" you can make the remaining time in the data type "LTIME" a direct output of the FB50.
The active network accepts the remaining time in the data format "LTIME" via the "LTimeFromTimer" variable from the "Network 2 - Timer".
The active output network depends on the value of the "OutputType" variable. The "OutputType" variable is set by operating the buttons for selecting the output masks (9) and (10).
The outputs of the FB50 can be used for visualizing and further processing in the process.