Do you think your logic in Lad 3 would cover the 24 composite sample
You must be referring to Troy's programs. As much as I would like to take credit for those, I have posted no programs in this thread! Yes, either of his methods wll give you an average reading over some settable time period.
The big question: Is an average reading the best control parameter? It seems that an average will give you a number that is always wrong - either too high or too low for the phosphate-contaminated water that is exiting the plant at this moment.
Would not a more accurate method be to simply use the last 15-minute reading to make an adjustment in the alum rate? That is, after all, your latest and best measuremnt of the problem. In this case, it seems that averaging the data points over 19 hours simply dilutes the value of the best and latest measurement. If the averaging is being done to reduce "noise" in the sample, then average 3 or 4 15-minute samples (instead of over 19 hours).
Does the alum require 10 hours (as you first stated) or 19 hours to move through the plant?
Either way, it seems to me that where a PLC program could help would be to save the 15-minute alum setpoint for 10 hours (40 values) or 19 hours (76 alum values, whichever is the actual time lag), in a FIFO-type register. Then the alum setpoint from 10 (or 19) hours in the past could be matched up with the last phosphate ratio sample that it most affected. This would give a clear Cause & Effect graph that could be used to calculate the setting for the next 15-minute period.
Listen to the expert Tom Jenkins:
Use a simple ratio control for feeding the alum based on the wastewater flow rate. You can use feedback from the final phosphorus value to tweak the ratio up or down.