 |
plc.myforum.ro PLCs users www.plc.myforum.ro!
|
| View previous topic :: View next topic |
| Author |
Message |
grig100 Member 3


Joined: 01 Jan 2015 Posts: 752
|
Posted: 20/12/2016 12:41 Post subject: S7 data type IEC time (TIME) displayed in WinCC? |
|
|
How can you have a tag of the S7 data type IEC time (TIME) displayed in WinCC?
An S7 tag of the data type IEC time (TIME) is a signed 32-bit value that contains a time stamp in milliseconds.
It is useful to have suitable data preparation to display this data type. The following instructions take the example of how to convert a tag of the data type IEC time into a character string in order to display the value with a WinCC text field entitled "Static Text".
1. Creating an external tag in the WinCC Tag Management
In the WinCC Tag Management you create an external tag of the data type "Unsigned 32-bit value". Fill in the fields for the address description of the S7 controller.
2. Dynamizing the "Fill Pattern Color" property of the static text
Create an object of the type "Static Text" in a WinCC picture. Dynamize the property "Fill Pattern Color" with the tag created in Step 1.
3. Dynamize the event "Fill Pattern Color > Change" of the static text
The C action required in this step is available for downloading. Download it.
WinCC_S7_IEC_TIME_Verwenden.zip ( 1 KB )
https://support.industry.siemens.com/cs/attachments/1138415/WinCC_S7_IEC_TIME_Verwenden.zip
Open the dialog to dynamize the event "Property Topics > Colors > Fill Pattern Color > Change" of the static text with a C action.
Import the downloaded C function. Fig. 04 shows the "Import action" button.
Notes:
This example is structured so that no direct access to a WinCC tag can be made in the C function. If several displays of this type have to be shown in WinCC pictures, the object dynamized in this way can be copied. Then all you have to do is replace the tag with a new one in the dynamization of the "Fill Pattern Color" property. It is no longer necessary to edit the C script.
In a project it might be useful for the purpose of central changing to store the C action from Fig. 05 in a project function. |
|
| Back to top |
|
 |
grig100 Member 3


Joined: 01 Jan 2015 Posts: 752
|
Posted: 20/12/2016 12:43 Post subject: How do you incorporate a tag of the data type S5TIME in WinC |
|
|
How do you incorporate a tag of the data type S5TIME in WinCC?
The data type S5TIME is stored in the binary code decimal format (BCD) whereby the associated time base is bit coded. Direct access to this data type is not possible in WinCC.
An S7 tag of the data type S5TIME is a 16-bit value. Bits 0 to 11 represent the time value in BCD format. Bits 12 and 13 represent the time base in bit code. Bits 14 and 15 are not used.
Access to this data type is only possible via a script in WinCC. Different VB scripts are used respectively for reading and writing the S5TIME tag.
Read access
The value of the S5TIME tag is read out of the controller and processed in WinCC. You then get a display of the time value in hours, minutes, seconds and milliseconds.
Define four tags of the "Integer" type ("HH", "MM", "SS" and "MS", for example) without controller connection.
Link these tags to four output fields for displaying the time value in hours, minutes, seconds or milliseconds.
Define a tag of the "WORD" type ("S5T", for example) with controller connection, which receives the "S5TIME" value from the controller.
Link the VB script to the call of an event (a button, for example).
Source text
| Code: | Dim S5T, TimeBase, TotalTime, Buffer
Set S5T = HMIRuntime.Tags("S5T")
'Determine time base
S5T.Read
If S5T.Value < 4096 Then
TimeBase = 10 'time base: 0.01 seconds
Elseif S5T.Value < 8192 Then
TimeBase = 100 'time base: 0.1 seconds
Elseif S5T.Value < 12288 Then
TimeBase = 1000 'time base: 1 second
Else
TimeBase = 10000 'time base: 10 seconds
End If
'Calculate absolut time in ms
Buffer = S5T.Value And 4095
TotalTime = Fix(Buffer/256)*100
Buffer = Buffer And 255
TotalTime = TotalTime+Fix(Buffer/16)*10
Buffer = Buffer And 15
TotalTime = TotalTime+Buffer
TotalTime = TotalTime*TimeBase
'Write values
HMIRuntime.Tags("HH").Write Fix(TotalTime/3600000)
TotalTime = TotalTime - HMIRuntime.Tags("HH").Read*3600000
HMIRuntime.Tags("MM").Write Fix(TotalTime/60000)
TotalTime = TotalTime - HMIRuntime.Tags("MM").Read*60000
HMIRuntime.Tags("SS").Write Fix(TotalTime/1000)
TotalTime = TotalTime - HMIRuntime.Tags("SS").Read*1000
HMIRuntime.Tags("MS").Write TotalTime
|
|
|
| Back to top |
|
 |
grig100 Member 3


Joined: 01 Jan 2015 Posts: 752
|
Posted: 20/12/2016 12:44 Post subject: Write access |
|
|
Write access
In WinCC there is input in hours, minutes, seconds and milliseconds. This input is then converted so that the value can be used as S5TIME to supply a timer in the controller.
Define four tags of the "Integer" type ("HH", "MM", "SS" and "MS", for example) without controller connection.
Link these tags to four input fields into which you can input the values for hours, minutes, seconds or milliseconds.
Define a tag of the "WORD" type ("S5T", for example) with controller connection. This is the "S5TIME" value for supplying the timer in the controller.
Link the VB script to the call of an event (a button, for example).
Source text
| Code: |
Dim TotalTime, Result, Point1, Point2, Point3
'Calculate integral amount of milliseconds
TotalTime = HMIRuntime.Tags("MS").Read _
+ 1000 * HMIRuntime.Tags("SS").Read _
+ 60000 * HMIRuntime.Tags("MM").Read _
+ 3600000 * HMIRuntime.Tags("HH").Read
'Limiting maximum value
If TotalTime > 9990000 Then TotalTime = 9990000
'Determine bit values
If TotalTime > 999000 Then
Result = 12288 'time base: 10 seconds
Point1 = Fix(TotalTime/1000000)
TotalTime = TotalTime - Point1*1000000
Point2 = Fix(TotalTime/100000)
TotalTime = TotalTime - Point2*100000
Point3 = Fix(TotalTime/10000)
TotalTime = TotalTime - Point3*10000
Elseif TotalTime > 99990 Then
Result = 8192 'time base: 1 second
Point1 = Fix(TotalTime/100000)
TotalTime = TotalTime - Point1*100000
Point2 = Fix(TotalTime/10000)
TotalTime = TotalTime - Point2*10000
Point3 = Fix(TotalTime/1000)
TotalTime = TotalTime - Point3*1000
Elseif TotalTime > 9990 Then
Result = 4096 'time base: 0.1 seconds
Point1 = Fix(TotalTime/10000)
TotalTime = TotalTime - Point1*10000
Point2 = Fix(TotalTime/1000)
TotalTime = TotalTime - Point2*1000
Point3 = Fix(TotalTime/100)
TotalTime = TotalTime - Point3*100
Else
Result = 0 'time base: 0.01 seconds
Point1 = Fix(TotalTime/1000)
TotalTime = TotalTime - Point1*1000
Point2 = Fix(TotalTime/100)
TotalTime = TotalTime - Point2*100
Point3 = Fix(TotalTime/10)
TotalTime = TotalTime - Point3*10
End If
'Calculate word value
Result = Result + Point1*256
Result = Result + Point2*16
Result = Result + Point3
HMIRuntime.Tags("S5T").Write Result
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro
|