I have a project where I need to report via SMS when a digital signal or an PLK IO island (via ModuleOK) drops.
The digital signal is normally active, as is ModuleOK in normal operation.
In order to catch the changing state I use EDGENEG and EDGEPOS, which activates the code sending the SMS.
However, whenever I transfer some updates to the project, the code for the SMS gets activated, so that the signals that are normally TRUE go to false during the transfer.
I tried to set a timer for a delay of 10..30 seconds, and to only activate the code sending the SMS after this time has passed, but I see that the edgepos is activated even though it occurred 30 seconds before.
What is the internal mechanism for these functions?
How could I get around this issue ? I tried to “consume” the EDGEPOS in some code that gets executed before my timer is up, but this would not work.
This is rather a funny issue, as I clearly remember some projects in the past where EDGEPOS code would not get activated because I thought, some other code would “consume” the transition.
I’m using AS 4.12.5.95, and testing on APC2200/AR I4.93, and CP0484-1/AR H.4.93.
Edgepos and Edgeneg have a “hided” variable in background. Each time you execute edgepos or edgeneg it compares both value and when there is a match it give you a flag.
In the end, you have no influence what is happening inside.
In your case, you probably know when you transfer the project. Maybe you can set a Variable in initup which hides the flag for the sms after moduleok once becomes TRUE. After that it works as you used to have.
Also when “hiding” the first flag you need to execute edgepos or edgeneg cyclic.
2nd try: execute the edgepos or edgeneg without a evaluation inside initup, just to make sure that the calculation once done when it starts
in past i have similar problems. So i build my own Edgepos which i have complete access to what is happening.
Be careful with timers. The system will become asynchron. In your situation i would prefer waiting up to first time moduleOK. when it swapes a couple times there is a different problem behind.
If you use EDGEPOS in cyclic content it will work correct. But if you put it inside some conditions, it can happen that the edge-Memory is not updated in a correct way.
Here the code to evaluate a Edge by yourself. With this code you can place the Memory-Update to the correct cyclic context.
IF EdgeValue = 1 and EdgeValueOld = 0 THEN
// EdgePositive detected
END_IF
EdgeValueOld := EdgeValue;