i still would like to try the periodic task.
Again, I doubt the sample timing is the problem.
That said, an alternative, basically the same idea suggested by @5618, would be to use the rising edge of bit 19 of WallClockTime/CurrentValue instead of /LocalDateTime, which is a LINT (DINT[2]) counter that run at 1Mhz. Bit 19 of DINT[0] has a rising edge every 1,048,576µs i.e. 2**20 ticks of the clock, so the CPT formula would become
Code:
((MAG gpm)/57.22046)+(HMI Total)
where
µs 1 sample sample
60000000 --- * ------- ------ = 57.22046 ------
min 1048576 µs min
so (MAG gpm/57.22046) is in units of gal/sample.
and triggered by the rising edge of that bit 19. The WallClockTime comes from a GSV instruction.
It's a bit busier than one CPT instruction in a periodic task, but then again the periodic task has its own development overhead.
It should all fit on one rung and gets rid of the TON:
Code:
[B]us[/B][0].19 [B]usONS[/B]
--[GSV ]-----] [-----[ONS]---[CPT...]--
[WallClockTime]
[CurrentValue ]
[[B]us [/B] ]
Where
[B]us[/B] is a DINT[2] array
[B]usONS [/B]is a BOOLEAN, the storage bit for the ONS instruction
Also, for diagnostics, we could log the values every 16+ seconds, like this:
Code:
begtot
------] [-------[CLR]--[CLR ]--
[idx] [HMI total]
us[0].23 ONS16
--[LES]----] [-----[ONS]--[MOV ]--[MOV ]--[ADD]--
[idx] [HMI total ] [MAGgpm ] [idx]
[32 ] [totarr[idx]] [gpmarr[idx]] [1 ]
[idx]
Where
idx is an INT
totarr is a REAL[32] array
gpmarr is a REAL[32] array
ONS16 is a BOOLEAN
begtot is a BOOLEAN and oneshot that triggers the start of totalizing
Then, after a 1500gal run, the contents of the array could be posted here for diagnosis. The 21 or 22 unique totals in array totarr should be linear since the pump runs at a constant rate, the latter being verified or not by the array gpmarr, and the total through 700 gpm is correct, so at some point after 700gpm we should see a deviation.