Totalizer Function Block Using Level Sensor

Totalizer Function Block Using Level Sensor We are currently using a level sensor with 4-20mA input into our AXC 2152… trying to find a good way to totalize the volume change so we can see total volume that has been dosed with a system as well as average dosage rates (per last 24 hours) using this data. Any ideas on how to do this? Any help would be much appreciated, thanks!

// xAnalog_scaled is the input value from 4-20mA scaled to your process

// xAnalog_hold1 is used to hold the reset value
// xSet is used to set the totalizer start
// xTotalizer is the difference between the saved value and current value
// xHour is the RTC clock INT
// xHour_totalizer is the array of real numbers holding the last 24 hours // You will need to make an array of REAL numbers [0..24] IF xSET THEN
xAnalog_hold1 := xAnalog_scaled;
xSet := False;
END_IF xTotalizer := xAnalog_hold1 - xAnalog_scaled x := xHour-1; // Moves values into the Array the hour dictates the position in the array it will roll over and only hold the last 24 hours in this configuration.
// The final value of the hour is stored in the xHour_totalizer[array number] IF xHour <> xHold_hour THEN
xHour_totalizer := xTotalizer;
xHold_hour := xHour;
END_IF This is very crude but should give you an idea of where to start