Replace TIME-ON parameter with a variable

a programming line is written as follows:

IF TIME-OFF ( R1 ) > 03:00:00 THEN …

and implies that if the operating time of relay R1 exceeds 3 hours, then…

I’d like to replace this absolute time with a variable defined in pure numerical terms (e.g. 180 to equal 3 hours, which I can vary via my app). What would be the right instruction to use in this case?

Thank you

Solved my own problem.

1 set 3 variables: TimerRUN, TimerSET, TimerUPD

I replaced my line :

10 rem VR=1 means Relay1 is closed, VR=0 means Relay1 is opened
15 rem R1 is my motor
20 IF TIME-OFF ( R1 ) > 03:00:00 THEN VR1 = 1

By:

20 IF INTERVAL ( 00:01:00 ) THEN TimerRun = TimerRUN - 1
30 IF TimerRun = 0 THEN VR1 = 1 , TimerRUN = TimerSET
40 IF TimerSET <> TimerUPD THEN TimerUPD = TimerSET , TimerRUN = TimerSET

In that case, every minute, my counter (TimerRUN) decreases.
When the counter is equal to 0 (times’up), the motor runs and the timer is reset to the TimerSET value. And the process begins again.

In case (if TimerRUN did not reach 0) I change the TimerSET (because I want to change the interval), the value is compared to my last setting (TimerUPD) and updated, and my TimerRun is now set to the new value of this variable.

That’s it

I think you are programming a pump to go on for 5 minutes and then stop and wait three hours before coming on again, in a repeating cycle. You will need to create some variables with the range as TIME ( range ID = 51 I think it is) as opposed to some of the other integer ranges of hours, minutes, seconds.

10 VAR1 = TIME-ON( OUT1 )
20 VAR2 = TIME-OFF( OUT1 )

Once you have defined these vars you can use them in your programming logic like so:

30 IF VAR2 > 03:00:00 THEN START OUT1
40 IF VAR1 > 00:05:00 THEN STOP OUT1

Going a step further, instead of hard coding the 03:00:00 you can create a VAR3 using the time range as well. Also do one for the running time of 5 minutes, store that in VAR4

30 IF VAR2 > VAR3 THEN START OUT1
40 IF VAR1 > VAR4 THEN STOP OUT1

Now you can place VAR1 thru VAR4 and OUT1 on a display to show the user exactly what’s going on in the system. The timers are counting and updating every second as opposed to every minute in your program. The user can see how long till the output will trigger and they can also adjust the timer interval without digging around in the system, they just edit VAR3 and VAR4 from the user graphics screen, if you want that.

2 Likes