SUBROUTINE_BLOCK 读取UTC时间:SBR5
TITLE=子程序注释
VAR_INPUT
Start:BOOL; // 启动
AddrPoint_input:DWORD; // 当前实时时钟
Begin_UTC_inout:DWORD; // UTC时钟
END_VAR
VAR
Temp_BYTE:BYTE;
TempDay_INT:INT;
TempMonth_INT:INT;
TempYear_INT:INT;
TempYear_DIV:INT;
TempYear_DIV_BOOL:BOOL;
TempYear_DIV_W:INT;
TempHour_INT:INT;
Temp_BYTE_RESULT:BYTE;
TempMonth_BYTE:BYTE;
TempDay_BYTE:BYTE;
TempYear_BYTE:BYTE;
END_VAR
BEGIN
Network 1
// 读取时钟
LD SM0.0
LPS
CALL SBR6, LD1
MOVD LD1, AC1
AENO
+D +4, AC1
AENO
MOVD LD5, AC2
AENO
+D +4, AC2
AENO
MOVB *AC1, *AC2
LPP
MOVD LD1, AC1
AENO
+D +5, AC1
AENO
MOVD LD5, AC2
AENO
+D +5, AC2
AENO
MOVB *AC1, *AC2
Network 2
LD SM0.0
LPS
MOVD LD1, AC1
AENO
+D +6, AC1
AENO
MOVD LD5, AC2
AENO
+D +6, AC2
AENO
MOVB *AC1, *AC2
LPP
MOVD LD1, AC1
AENO
+D +7, AC1
AENO
MOVD LD5, AC2
AENO
+D +7, AC2
AENO
MOVB *AC1, *AC2
Network 3
// 顺控指令启动
LD L0.0
S S0.0, 1
R S0.1, 3
Network 4
LSCR S0.0
Network 5
// 处理小时
LD SM0.0
LPS
MOVD LD1, AC1
AENO
+D +3, AC1
AENO
MOVB *AC1, LB9
AENO
BTI LB9, LW21
AENO
-I 8, LW21
AENO
ITB LW21, LB23
LPP
MOVD LD5, AC2
+D +3, AC2
Network 6
LD SM0.0
LPS
AW>= LW21, 0
MOVB LB23, *AC2
LRD
AW< LW21, 0
MOVW LW21, AC3
AENO
+I +24, AC3
AENO
MOVB AC3, *AC2
LPP
SCRT S0.1
Network 7
SCRE
Network 8
LSCR S0.1
Network 9
// 处理天数
LD SM0.0
LPS
MOVD LD1, AC1
AENO
+D +2, AC1
AENO
MOVB *AC1, LB25
AENO
BTI LB25, LW10
AENO
-I 1, LW10
AENO
ITB LW10, LB23
LRD
MOVD LD5, AC2
+D +2, AC2
LPP
MOVD LD1, AC3
AENO
+D 1, AC3
AENO
MOVB *AC3, LB24
AENO
BTI LB24, LW12
Network 10
LD SM0.0
AW>= LW21, 0
MOVB LB25, *AC2
Network 11
// 处理闰年2月及非闰年2月
LDW< LW21, 0
LPS
AW> LW10, 0
MOVB LB23, *AC2
LPP
AW<= LW10, 0
LPS
MOVW *LD1, LW16
AENO
+I +2000, LW16
AENO
CALL SBR7, LW16, 4, L18.0, LW19
LRD
A L18.0
AW= LW12, 3
MOVW +29, AC3
AENO
+I LW10, AC3
AENO
MOVB AC3, *AC2
LPP
AN L18.0
AW= LW12, 3
MOVW +28, AC3
AENO
+I LW10, AC3
AENO
MOVB AC3, *AC2
Network 12
// 当月是1、2、4、6、9、11时
LDW< LW21, 0
AW<= LW10, 0
LDW= LW12, 2
OW= LW12, 4
OW= LW12, 6
OW= LW12, 9
OW= LW12, 11
OW= LW12, 1
ALD
MOVW +31, AC3
AENO
+I LW10, AC3
AENO
MOVB AC3, *AC2
Network 13
// 当月是5、7、8、10、12时
LDW< LW21, 0
AW<= LW10, 0
LDW= LW12, 5
OW= LW12, 7
OW= LW12, 8
OW= LW12, 10
OW= LW12, 12
ALD
MOVW +30, AC3
AENO
+I LW10, AC3
AENO
MOVB AC3, *AC2
Network 14
LD SM0.0
SCRT S0.2
Network 15
SCRE
Network 16
LSCR S0.2
Network 17
问题补充:
再提问一次
图片说明:
最佳答案
程序段太长超出限制范围,可以以截图形式上传。
这是一段处理UTC通用协调时间的子程序。
提问者对于答案的评价:
没有满意答案
原创文章,作者:ximenziask,如若转载,请注明出处:https://www.zhaoplc.com/plc279872.html