Counter code for a pump on/off value tag

Hello.

I have two pumps (tags), the value goes 1 when the pump Is on and 0 when off, I want to write a code to keep a counter for the number of times it goes ‘1’ and the number of time times it remains ‘0’. Could you help me with this?

Regards

You need a memory tag for each of the pumps. These tags will be the counters. Then in the basic script use ONCHANGE for each of the existing pump on off tags. The ONCHANGE will call a function in the basic script that adds a 1 to the value of the memory tag.

Hello Ados,

Ted is correct.

The code would look something like this:

ONCHANGE “Tank”, “GOTO Counter”

COUNTER:
IF (Tank@ = 1) THEN
HighCount@ = HighCount@ + 1
ELSE
LowCount@ = LowCount@ + 1
ENDIF

Hello,

Would you have a link for an example of the same?

Hello Ados,

For your convenience, you can find the BASIC IDE scripting manual at the link below. You can also find some examples of BASIC scripts as well.

https://developer.ewon.biz/content/basic-1

Support generally does not create script upon request, but we will gladly assist with some troubleshooting of issues related to the code.

Thank you,