View Single Post
Old January 14th, 2020, 06:05 PM   #2

AustralIan is online now
Join Date: Jan 2013
Location: Germany
Posts: 1,098
With CODESYS all variables are reinitialised to whatever you set in the declaration editor on powerup, unless you explicitly mark them as retain and or persistent.

So declare your variable

Powerupbit : BOOL := TRUE;

and then reset it at the end of the task you wish to reset it in.
Powerupbit := FALSE;

Of course, you could write a function "isFirstCycleOfTask", but I think your own powerupbit is cleaner.
Use the cmpIecTask library
You will need the following parts:

Help file here
  Reply With Quote