ONCHANGE double input

Hi,
i want to log a tag in the Historical Data Logging using a tag as trigger. I wrote this code in the Init Section

``ONCHANGE “log”, “GOTO LogHistory”
END

LogHistory:
IF(log@ = 1) THEN
LOGIO “Tag”
ENDIF
END
The Tag gets registered to the History but every time the Tag “log” changes state and not just when is ON, like the IF statement gets ignored

Hi @danieleIMode

That section is only called once because you’re using an Onchange for it. You could do an onchange to enable a timer that would then call the function at a set interval to try and do this though.

I have an example of logging this way I’ve written below if you want to use it as an example

Trigger Based Logging on Flexy.pdf (335.3 KB)

-Tim

Hi @Tim_hms , thanks for the quick reply.
I explained myself badly. What i’m trying to do is register the Tag when i get the signal “log” that last for just 5 seconds. I want to register the Tag value just once, not when log goes from 0 to 1 and when it goes from 1 to 0.
I tried to use IF statement and check if log=1, so i would expect that when log goes from 0 to 1 the section gets called and the data does get registered but when log goes from 1 to 0 it doesn’t.
I’ve uploaded i picture of the History Log so it’s easiear to understand (The Tag name is pluviometro (italian for rain meter)

Try this and see if it works

ONCHANGE “log”, “@LogHistory()”

Function LogHistory()
IF log@ = 1 THEN
LOGIO “Tag”
ENDIF
END

It didin’t work
Basic_Ewon_Function

Can I take a look at this with you over TeamViewer?

Ok, i’ll send you Id and password

If anybody else runs into this issue, it appears that the logging was enabled for both the tag and through basic and it was causing additional logs to be produced

Yes, i turned on History Logging for the log Tag while testing the code and when seeing the History Tables shown above i thought that the system was registering the Tag “precipitazioni” two times.