This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Dinamically update FB operating hour counter data in W4K
#1
Hello,

I'm using the operating hour counter block to record the activation of an object, is it possible to update that value dinamically even if it's still ON?

For example:

I have an object (a simple relay) and I want to record how long it stays ON, if it's activated for 3 hours how can I update the object every 15 minutes?

Many thanks
Reply
#2
There's a script solution for run time counter: https://forum.logicmachine.net/showthread.php?tid=3769
Reply
#3
Very cool, thanks.

Right now I'm using FB but I'm considering this solution because I've got another problem:

I have a simple script that trigger on or off three objects simultaneously, each one of these objects has its own FB script that counts the total activation time but sometimes (even if the activation is synced) it fails.

For example: I'm testing 6 different objects that switches on or off by a group of 3 with a fixed time period, so the time count has to be the same between the objects in the same group. Sometimes I found one of the objects in the group desynced, what could it be? Any Ideas?

Oh and I manage to update the time counted by simply read the trigger object every 15 minutes, could this be the problem?

Since it comes out at random I cannot find the pattern and I'm going a little bit crazy
Reply
#4
If they all start at the same time, and all script run te same minute, it cant.
what is the time difference?
Are you sure it dont trigger by another thing, or switch or LM?
Maybe you can activate the log function of the output and the FB of the output?
and look in the log when and who trigger or disable the output?
Reply
#5
(04.02.2022, 07:23)Dré Wrote: If they all start at the same time, and all script run te same minute, it cant.
what is the time difference?
Are you sure it dont trigger by another thing, or switch or LM?
Maybe you can activate the log function of the output and the FB of the output?
and look in the log when and who trigger or disable the output?

They all start at the exact same time,

The logic is:

A simple 1 bit object trigger on or off a group of three virtual 1 bit objects, another one triggers on another group of three AND turns off the previous three as long as the second group remains triggered.
Works like a charm, I've tested it with a scheduled script that triggers on and off the second object.
Every 15 minutes a scheduled script reads the first object, waits two seconds and read the second one so all the time measures are updated.
When the time (in h/100) is updated some scripts convert it into minutes and then into another unit of measure.

That's it, very simple.

I've checked the logs many times and everything seems to work fine, it is a random bug. I'm going mad.

The difference is of a few minutes, but I would like to fix it, because it's very very annoying that it works for 5 objects out of 6...the other group of three seems good

There it is!

There is a script (I don't know which one since in none of my scripts I manipulate that object, I checked...only in FB) that overwrites that value...I will try to wipe everything and start again...

Attached Files Thumbnail(s)
   
Reply
#6
and if you look at the Object logs, what do you see?

   

Are they all triggered at the same time?

Is this also correct, i did made a mistake about it.
you need to change the storage key ('ontime'), not the variable name:

I have 4 timers running and they all work correct.
Reply
#7
Yes, only a minimum delay.

Now I remade the FB script and I organized better all the scripts by delaying the operations that can be delayed and it seems to work fine.

I noticed that maybe it's the script that update the time counter that can cause some problems. Since I read two values it causes all the other scripts to run twice and maybe it sometimes causes a little delay on the execution.

I don't know, what else could it be.

(04.02.2022, 10:42)Dré Wrote: Is this also correct, i did made a mistake about it.
you need to change the storage key ('ontime'), not the variable name:

I have 4 timers running and they all work correct.

I didn't try that script, I'm using the operating time counter block from FB
Reply


Forum Jump: