当前位置:网站首页>CoDeSys get system time
CoDeSys get system time
2022-06-11 04:34:00 【qq_ twenty-five million one hundred and twenty-six thousand and】
codesys Get system time
- Add get time library Add library input caa dtutil Search the library , Select double click Add

2. Define function blocks , Read time
PROGRAM PLC_PRG
VAR
// Define the function block to read the current time
ReadCurrentTime:dtu.GetDateAndTime;
// Current system time , Note that the time at this time is world time, not local time
dtTime:DT;
// Update time changes
RTC_BLOCK:RTC;
dtTime2:DT;
END_VAR
ReadCurrentTime(
xExecute:= TRUE,
xDone=> ,
xBusy=> ,
xError=> ,
eError=> ,
dtDateAndTime=>dtTime ,
ePeriode=> );
RTC_BLOCK(EN:= ReadCurrentTime.xDone, PDT:= dtTime, Q=> , CDT=> dtTime2);
3. function Codesys SoftMotion Win Download run , The effect is as follows :
4. Note that the time read at this time is world time and needs to be converted to Beijing time
PROGRAM PLC_PRG
VAR
// Define the function block to read the current time
ReadCurrentTime:dtu.GetDateAndTime;
// Current system time , Note that the time at this time is world time, not local time
dtTime:DT;
// Update time changes
RTC_BLOCK:RTC;
dtTime2:DT;
// Total seconds of time
w_TotalSeconds :LINT;
// Total seconds of local time
l_TotalSeconds:LINT;
sysCurrentTime:DT;
END_VAR
ReadCurrentTime(
xExecute:= TRUE,
xDone=> ,
xBusy=> ,
xError=> ,
eError=> ,
dtDateAndTime=>dtTime ,
ePeriode=> );
RTC_BLOCK(EN:= ReadCurrentTime.xDone, PDT:= dtTime, Q=> , CDT=> dtTime2);
// Get the total seconds of time
w_TotalSeconds:=DT_TO_LINT(dtTime2);
// It should be the difference between Beijing time and world time 8 Hours
l_TotalSeconds:=w_TotalSeconds + 8 * 60 * 60;
// Convert to time format
sysCurrentTime:=LINT_TO_DT(l_TotalSeconds);5. You can get the local time by downloading and running again 
Source download
边栏推荐
- What are the similarities and differences between the data center and the data warehouse?
- Guanghetong "carbon" seeking green sharing 5g/lte module solution for two rounds of travel
- Unity 遮挡剔除
- Unity 高級背包系統
- AI helps release legal potential energy! Release of iterms contract intelligent review system
- Unity advanced backpack system
- 项目架构演进
- Emlog新版导航源码/带用户中心
- Guanghetong successfully won the bidding for China Unicom Yanfei CAT1 customized module with the largest share
- 数据中台和数据仓库有什么异同?
猜你喜欢

数据类型的转换和条件控制语句

Unity 高级背包系统

From the first generation of sowing to the first generation of flowers, 5g commercial "gave birth to all things" for the third anniversary

数据中台和数据仓库有什么异同?

Unity creates rivers on uneven terrain

MySQL stored procedure

Unity music playback Manager

PCB地线设计_单点接地_底线加粗

Production of unity scalable map

Guanghetong launched a new generation of 3GPP R16 industrial 5g module fg160 engineering sample
随机推荐
Unity 伤害值的显示
Unity advanced backpack system
Guanghetong "carbon" seeking green sharing 5g/lte module solution for two rounds of travel
Exness: Liquidity Series - order Block, Unbalanced (II)
JVM (4): active and passive use of classes, internal structure of runtime data area, JVM thread description, PC register
Unity的URP的RenderFeature相关编程内容梳理
L'avenir est venu, l'ère 5G - Advanced s'ouvre
PHP话费充值通道网站完整运营源码/全解密无授权/对接免签约支付接口
ACTS:高效的测试设计(并赠送一个优秀的测试设计工具)
What are the similarities and differences between the data center and the data warehouse?
From the first generation of sowing to the first generation of flowers, 5g commercial "gave birth to all things" for the third anniversary
记一次ES 事故
梅州P2实验室建设方案阐述
Unity 高級背包系統
[server data recovery] data recovery case of RAID5 crash of buddy storage
Record an ES accident
JVM (3): classloader classification and parental delegation mechanism
Detailed decomposition of the shortest path problem in Figure
PostgreSQL database replication - background first-class citizen process walreceiver receiving and sending logic
JVM(4):类的主动使用与被动使用、运行时数据区域内部结构、JVM线程说明、PC寄存器