Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to convert an integer into the time format of s5time?
How to convert an integer into the time format of s5time?
S7 can be converted to S5time data type:

1. Write integer int or real number from upper computer to PLC. First, the value should include the time value in milliseconds. After writing into the data storage area of PLC, use ITD (integer to double integer with rounding) or RND (real to double integer with rounding) to convert the value into a double integer, then write the value into a variable of type TIME, and call FC40 in the program to convert the time into S5TIME.

2. When the upper computer writes WORD to PLC, the numerical value should first include the time value in a certain time base. After being written into the data storage area of PLC, WOR_W instruction under word logic will add this value to its time base, and then use MOVE instruction to write the obtained value into a variable of type S5TIME.

3. If WinCC is used as the host software, or the host software supports 32-bit signed floating-point numbers, you can write 32-bit signed floating-point numbers into variables defined as TIME in PLC from the host, and then call FC40 in the program to convert TIME into S5TIME.

FC33 is used for the conversion from S5TIME to TIME. FC40 is used for the conversion from time to S5TIME. These two blocks are located in the path of Library \ Standard Library \ IEC function block. For descriptions of function blocks, please refer to the online help.