Flexy counter/timer function

Hi

I have the following code in the IDE:

index@ = index@ + 1
IF index@>359 Then
hourmeter@=hourmeter@+0.1
index@=0
ENDIF

but it doesn’t capture 24hours over a full 24hour period. According to the historical logs there are periods where the hourmeter@ doesn’t increment.

I have previously tried using TSET with 360 as the timer, but I have other timers in the IDE as well and it affected the other timers, hence i nested this code within an existing timer (so as to not create additional TSET)

is there any reason this could be happening?

Many thanks in advance

Hello Jean,

What are you using to trigger the code above?

Also can you provide a backup with support files so that we may be able to see the configuration, code, and errors? You can generate a back up with support files using ebuddy while connected to the unit.

If you running this every second there is a chance that it is already triggered when the next second happens. a backup with support files would help so we can see how the rest of the code is setup.

Hi

I have the following code in the IDE:

index@=index@+1

IF index@>359 Then
    hourmeter@=hourmeter@+0.1
    index@=0
ENDIF

That is supposed to function as an hourmeter, but it doesn’t capture 24hours in a 24hour period. I have previously set a TSET to accomplish this but it also doesn’t work as intended (i have multiple timers in the code).

Is there any way to solve this?

Thanks in advance

hi Zach and Kevin,

Apologies for the double post, I was unaware that the first one had gone through. Here is the backup file
Backup (9).etar.gz.zip (20.0 KB)

, although I’ve changed the code yesterday to this

TSET 4, 360
ONTIMER 4, “GoTo Hourmeter”

Hourmeter:
hourmeter2@ = hourmeter2@+0.1
END

and i’ve found that there are occasions in the historical log where the tag value still doesn’t increment with this code as well
image

To answer what triggered the first one - I had a TSET 1,1, but as mentioned above i have changed it.

Hi Support,

Any update for this?

Hello Jeen,

I am still testing this issue out and trying to replicate it on my end. I apologize for the lack of updates. I am have trouble trying to reproduce it.

Hi Kevin,

Its been a few months, and i’ve tried a variation of other solutions, one of which uses the ondate function instead, and another issue comes up
image

As you see above, the value would regress back for no discernible reason, and then it would run fine after awhile, resulting in a loss of several hours every few days.

The code i have in place is this

ONDATE “*/6 * * * *”,”GOTO Hourmeter”

Hourmeter:
hourmeter@=((hourmeter@)*10+1)/10
hourmeter$= SFMT hourmeter@, 20, 0, “%07.1f”
hourmeter@=VAL(hourmeter$)
If hourmeter@>10000 Then
hourmeter@=0
EndIf
END
Any help would be greatly appreciated

Do you have a backup with support files that show the whole code?

While this is a heavily involved scriping question, we cannot dig too deeply.

What is the purpouse for the counter/timer function?

You can also check our tech forum for more Scripting posts.

https://techforum.ewon.biz/

No update from customer

Hi Kevin,

Apologies for the late reply, i am not getting notifications for this thread. The purpose of the counter/timer is to record how long the Flexy runs as it performs a certain calculation using the tag value from an analog input.

Is there an alternative code that can achieve this?

You could use LogEvent, and use the event logs to have the timestamp.

Unfortunately, we do not have a native way to do what you are proposing.