quick question: is it possible to run a cylic function (eg every second) in the new TE2000 HMI? If so, how can I do so?
Asked
Active
Viewed 312 times
-1
-
Please provide enough code so others can better understand or reproduce the problem. – Community Apr 29 '22 at 02:56
2 Answers
0
You can use the JavaScript method setInterval
.
setInterval(logTwinCat, 1000);
function logTwinCat() {
console.log("Hi TwinCAT!")
}

Roald
- 2,459
- 16
- 43
-
Yeah, I figured that out already, but the question is where to call this script? When calling in an event (eg .onAttached) the script is only run once. – wouters May 02 '22 at 07:31
-
@wouters that would have been useful information in your question. Maybe you can use [CodeBehind](https://infosys.beckhoff.com/content/1033/te2000_tc3_hmi_engineering/4990648459.html?id=279163822013422521)? – Roald May 13 '22 at 06:08
0
I hope it's not too late for the answer. The code is as mentioned above.. And for the Event call you need to go to TwinCAT HMI Configuration window and from there go to Global Events and click edit on onInitialized event call. Here you can add JavaScript call and copy paste code that Roland gave. Hope this answers your question.
setInterval(logTwinCat, 1000);
function logTwinCat() {
console.log("Hi TwinCAT!")
}