简体   繁体   English

如何在 TwinCAT 中热启动一个方法?

[英]How can warm start a method in TwinCAT?

One of the features of the method based on the definition of Beckoff site is that:基于 Beckoff 站点定义的方法的特点之一是:

All data of a method are temporary and are only valid while the method is executed (stack variables).方法的所有数据都是临时的,并且仅在方法执行时有效(堆栈变量)。 This means that TwinCAT re-initializes all variables and function blocks, which you have declared in a method, with each call of the method.这意味着 TwinCAT 会在每次调用方法时重新初始化您在方法中声明的所有变量和 function 块。

Is there any way to use a method in the plc loop as warm start!有没有办法在plc循环中使用方法作为warm start!

it means that we use the method without re_initializing and method declare variations run just once at the first time we call it and the rest of the time that is called the variables retain their own values?这意味着我们使用没有re_initializing的方法并且方法声明变体在我们第一次调用它时只运行一次,而被称为变量的时间的rest保留它们自己的值?

Yes, this is possible through VAR_INST or VAR_STAT .是的,这可以通过VAR_INSTVAR_STAT Just declare your variables as VAR_INST/VAR_STAT instead, then they will retain their values between the calls.只需将您的变量声明为VAR_INST/VAR_STAT ,然后它们将在调用之间保留其值。

VAR_INST means it will be unique for every instantiation of the function block of where the method resides, while VAR_STAT will act as a static/global (all instances will point to the same memory location). VAR_INST意味着它对于方法所在的 function 块的每个实例化都是唯一的,而VAR_STAT将充当静态/全局(所有实例将指向相同的 memory 位置)。

https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/2528798091.html&id= https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/2528798091.html&id=

https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/2528787339.html&id= https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_plc_intro/2528787339.html&id=

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM