News:

  • April 30, 2026, 04:02:14 PM

Login with username, password and session length

Author Topic: "Offset timer"  (Read 15888 times)

unsyndicated

  • Full Member
  • ***
  • Posts: 21
"Offset timer"
« on: February 10, 2021, 10:15:02 AM »
I'm looking for an option to add or subtract to five individual timers, what i'll call an "offset"

I have five valves that all open at the same time and they each have there own timer controlling how long they are open for.

I'm looking to create a separate timer/function that can add/subtract whatever time I want to all five timers at the same time.  But once completed the offset timer/function resets to zero but the five individual timers retain there value.

So for instance if I wanted to subtract 200 milliseconds off all timers I would just put -200 and all timers would automatically go down 200 milliseconds.

I know it sounds trivial but we have this function on another machine with factory programing and it is rather handy.

Bolt

  • Hero Member
  • *****
  • Posts: 595
Re: "Offset timer"
« Reply #1 on: February 10, 2021, 10:24:56 AM »
Have you tried using a MATH function, the Result being T0.Acc, and the Formula being Timer0.Acc + D0, D0 being your defined offset?  All triggered by a Delta contact of D0?

unsyndicated

  • Full Member
  • ***
  • Posts: 21
Re: "Offset timer"
« Reply #2 on: February 10, 2021, 10:48:40 AM »
Would D0 reset to zero and the timers would retain their new value?

Bolt

  • Hero Member
  • *****
  • Posts: 595
Re: "Offset timer"
« Reply #3 on: February 11, 2021, 12:56:35 AM »
I'm not following if you want the accumulated value to change or the setpoint value. Either way, you could reset D0 after adjusting or offsetting the necessary values.

unsyndicated

  • Full Member
  • ***
  • Posts: 21
Re: "Offset timer"
« Reply #4 on: February 11, 2021, 06:46:47 AM »
My ladder logic speak probably leaves a lot to be desired.

TImers1-5 are all down timers to fill a bottle.  If they are all at 2500 milliseconds.  I want to add 500 milliseconds to all 5 with D0.  After they are all at 3000 milliseconds I want D0 to return to 0, but retain my 3000 milliseconds on t1-5.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: "Offset timer"
« Reply #5 on: February 11, 2021, 07:19:48 AM »
My ladder logic speak probably leaves a lot to be desired.

TImers1-5 are all down timers to fill a bottle.  If they are all at 2500 milliseconds.  I want to add 500 milliseconds to all 5 with D0.  After they are all at 3000 milliseconds I want D0 to return to 0, but retain my 3000 milliseconds on t1-5.

The .Acc member of the timer structure is writeable. You can manipulate it through MATH.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

ADC Product Engineer

  • Hero Member
  • *****
  • Posts: 270
Re: "Offset timer"
« Reply #6 on: February 11, 2021, 08:22:42 AM »
I think you are asking for something like this.

Bolt

  • Hero Member
  • *****
  • Posts: 595
Re: "Offset timer"
« Reply #7 on: February 11, 2021, 10:19:26 AM »
My ladder logic speak probably leaves a lot to be desired.

TImers1-5 are all down timers to fill a bottle.  If they are all at 2500 milliseconds.  I want to add 500 milliseconds to all 5 with D0.  After they are all at 3000 milliseconds I want D0 to return to 0, but retain my 3000 milliseconds on t1-5.

Sounds like you will want to use variables instead of hard coded timer variables. Let's say D1 through D5 for T1 through T5. Then, when you change D0, add it to D1 through D5, then copy 0 to D0. Then D1 through D5 will retain the new values.

unsyndicated

  • Full Member
  • ***
  • Posts: 21
Re: "Offset timer"
« Reply #8 on: February 11, 2021, 10:30:22 AM »


Sounds like you will want to use variables instead of hard coded timer variables. Let's say D1 through D5 for T1 through T5. Then, when you change D0, add it to D1 through D5, then copy 0 to D0. Then D1 through D5 will retain the new values.
[/quote]

I think you have me on the right track, will I need the delta contact for the math and copy or will my current normally open suffice?

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: "Offset timer"
« Reply #9 on: February 11, 2021, 11:25:08 AM »
My ladder logic speak probably leaves a lot to be desired.

TImers1-5 are all down timers to fill a bottle.  If they are all at 2500 milliseconds.  I want to add 500 milliseconds to all 5 with D0.  After they are all at 3000 milliseconds I want D0 to return to 0, but retain my 3000 milliseconds on t1-5.

If you want the change to be permanent, then you don't want to write to the accumulator; that will only affect the current cycle.

You can have the presets of the five timers point any 32-bit register instead of a hard-coded time in minutes, seconds, ms, etc.   Then your ladder can write to that value.
  The register will be interpreted in ms.   If all the timers always share the same value, then you can just use one D or whatever 32-bit location for the preset on all 5.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: "Offset timer"
« Reply #10 on: February 11, 2021, 11:30:16 AM »
Sounds like you will want to use variables instead of hard coded timer variables. Let's say D1 through D5 for T1 through T5. Then, when you change D0, add it to D1 through D5, then copy 0 to D0. Then D1 through D5 will retain the new values.

I think you have me on the right track, will I need the delta contact for the math and copy or will my current normally open suffice?

Oh OK, I see others got there before I did.    Either way will work.   With your logic, the MATH runs every scan which is unnecessary, but since you clear your differential register after updating the presets, it won't hurt anything.    Using a delta will conserve CPU time.   It will run on the initial change and then clear the register.   Then it will run again on the next scan since there's been another value change, but won't run on successive scans till you enter a new offset value.
« Last Edit: February 11, 2021, 11:33:21 AM by Controls Guy »
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

unsyndicated

  • Full Member
  • ***
  • Posts: 21
Re: "Offset timer"
« Reply #11 on: February 12, 2021, 06:56:41 AM »
Just wanted to thank you folks for the help, the D0+(D1-5) in math, then copying the 0 in did the trick.

Just had to realize I had the separate the display tag from the data tag on the HMI to get the actual fill times.  Everything is working great, now to get it revalidated.