we have membrain that runs every 12 minutes and they need they total[izer?] flow[?] when its in running mode but the flow is in gpm and they need the totalizer in [units of] MGD [sic]
The documentation for the TOT function block instruction is
here; the explanations of what TimeBase and Gain parameters are
here.
Since we are changing the volume units from gal to Mgal, the Gain parameter should be 1.0e-6 (= Mgal/gal); the time units are irrelevant to the Gain parameter.
The input (gpm) time units are minutes, so the TimeBase parameter should be 1; there is no time units on the output from the TOT block, so D (Day) has no meaning, see TL;DR below.
The Timing Modes, controlled by the TimingMode parameter and possibly using the RTSTime and RTSTimestamp parameters, are explained
here. If there is not a timestamp on the input gpm value, then RTSTime and RTSTimeStamp are irrelevant, and it is likely that Periodic Timing Mode (TimingMode input parameter value = 0) is the choice here. Enabling instruction should either be synchronized with, or be one-shot'ed at 1/5-1/10, the gpm input sample cadence; the instruction should not be enabled for every scan cycle of the continuous task, or roundoff errors will occur.
The limitations of IEEE-754 floating point representation (32 bits: 1 sign; 8 exponent; 24 mantissa) used in the REAL data type should be considered. For example, if the TOT block is enabled (executed) at 1Hz over the course of a day, then the gpm input values at the beginning of a day will have effective errors (resolution) of ~60ppb (2
-24, assuming similar magnitudes of all gpm input values throughout the day), while values at the end of a day will have effective errors of about half a percent (86400 / 2
24). It might be more accurate to take an average of instantaneous gpm over a minute and enable the TOT block once per minute i.e. each time the average is calculated; the effective errors of such one-minute averages at the end of the day will be about a hundredth of a percent (1440 / 2
24).
TL;DR
If the input in units of gpm, Gallons Per Minute, then the units of "totalizer" cannot be MGD, Millions of (or Mega) Gallons Per Day.
MGD is an instantaneous
flow rate, as is gpm; the multiplicative conversion factor from gpm to MGD is 0.00144 (Mmin/d) as noted. MGD is not a
volume.
The TOTalizer block will integrate
flow rate, in units of gpm, over time to give a
volume i.e. gal (gallons) or Mgal (Mega-gallons), not a flow rate.
Perhaps the totalizer is reset daily, so the final number is Mgal (
volume) over a day, but that is not MGD (instantaneous
flow rate).
So we need clarification: do "
they" want an instantaneous
flow rate in units of MGD, or do "
they" want an accumulated (totalized)
volume in units of Mgal?
Also, we still know neither the data types nor the tag names of the input and output analog values to the TOT block.