发布于 2005-07-18 10:40:50
0楼
参见如下帮助:
Format of the Data Type S5TIME (Time Duration)
When you enter time duration using the S5TIME data type, your entries are stored in binary coded decimal format. The following figure shows the content of the time address with a time value of 127 and a time base of 1 s.
When working with S5TIME, you enter a time value in the range of 0 to 999 and you indicate a time base (see the following table). The time base indicates the interval at which a timer decrements the time value by one unit until it reaches 0.
Time base for S5TIME
Time Base
Binary Code for Time Base
10 ms
00
100 ms
s
10
10 s
11
You can preload a time value using either of the following syntax formats:
L1) W#16#wxyz
Where w = time base (that is, the time interval or resolution)
Where xyz = the time value in binary coded decimal format
L1) S5T#aH_bbM_ccS_dddMS
Where a = hours, bb = minutes, cc = seconds, and dd?爉illiseconds
The time base is selected automatically and the value is rounded to the next lower number with that time base.
The maximum time value that you can enter is 9,990 seconds, or 2H_46M_30S.
1) = L only to be specified in STL programming
因此在HMI里变量为整形数设置时间,在CPU程序里做相应转换,若时间单位为秒,则最高四位设置为0010,其他的12位用该变量转换为相应的BCD码格式,然后将这16位整合即可。