Heartbeat Communication to PLC
I am trying to run a simple heartbeat between my PLC and an eWon Flexy. The idea for those not familiar is I will send a pulse from the PLC to the Flexy. Upon receiving the pulse, the Flexy will send a "1" back to the PLC. This is not a critical system just an operator indication, so I am sending the PLC heartbeat only every ten seconds. On the PLC side I run a 30 second timer that is reset by the incoming bit form the Flexy. If I haven't received that bit for 30 seconds, the timer finished, and notifies my operator that there is a network problem.
I am running a script in the IDE. I have tags set up and they do work, but I don't believe my function is firing. Here is my code:
Onchange "Heartbeat_In", "@heartbeat()"
Function heartbeat()
If Heartbeat_In@=1 Then
Heartbeat_Out@=1
Endif
ENDFN
Seems simple enough. What did I miss?
-
Seems my code never ran because I put it inside a new section.
Do I need to "call" new sections?
0 -
Are you running the code in the init section? This will run when the Flexy starts and set up the on change to run the function.
Deryck
0 -
No, I had originally made a new section. Seems that the code in my new section didn't run, I proved this to myself by putting some garbage test in there. I moved my code to "cyclic" and things worked fine.
For my future reference, if I make a new "section", am I also required to "call" that section?
0 -
Hello @jscannell,
If it is in the cyclic section it is getting run every cycles. This is not recommended, you should be able to put your code as is in the init section. This runs when the Ewon boots then the onchange will trigger the heartbeat function to run.
It should look something like this:
0
サインインしてコメントを残してください。

コメント
4件のコメント