读取系统时间,解析时间
FUNCTION_BLOCK FB12
TITLE = 'Block Title'
//
// 用AT指令解释输入DATE_AND_TIME类型变量
//
VERSION: '1.0'
AUTHOR: Author
NAME: Name
FAMILY: Family
// 定义输入变量
VAR_INPUT
DateInpt:DATE_AND_TIME;
ptr AT DateInpt:ARRAY[0..5] OF BYTE;
END_VAR
VAR_IN_OUT
year:BYTE;
mounth:BYTE;
day:BYTE;
hour:BYTE;
minite:BYTE;
second:BYTE;
END_VAR
year:=ptr[0];
mounth:=ptr[1];
day:=ptr[2];
hour:=ptr[3];
minite:=ptr[4];
second:=ptr[5];
END_FUNCTION_BLOCK
程序调用如下:
其中输入参数#OB1_DATE_TIME是OB1系统参数,运行后监控DB12中的数据如下: