Averaging using the CPT function in SLC 500

DebPeterson

Member
Join Date
Apr 2010
Location
Houlton, WI
Posts
31
I want to average a phorsphorus reading (F8:20) over an hour (4 samples/hr). Ranged 0.03 to 3.0 mg/l. I may want to increase it to 4 or an 8 hr average.
Could someone show the Algorithm needed. Thanks

(F8:20 * ?)+ (? * F8:21) = F8:21
 
DebPeterson,
1. have an n register to store your sample rate.
2. divide 60 minutes by the sample rate and put into a floating point reggister.
3. then compute the number of seconds from this results.
4. when the time starts initialize your resultant registers to zero.
5. when the timer with the seconds froim step 3 times out, store the data.
6. contine this and add to it every x seconds from step 3.
7. when the hour runs out, take the sum and divide it by the number of samples and put into float register.
8. reset all data registers used in the math to zero except the final result, and start over.

hope this helps,
regards,
james
 
Maybe the brute force method could be an option to consider. This will give you a running average of the past hour.

Use an unconditional 15min timer
Clear SubTotal File 21 and Divisor File 22
When Timer Done Move Current Reading Into Storage File 34 and Copy Storage File 31-34 to 30-33
If 33<>0 Then Add Storage File 33 to Subtotal File 21 and Add 1 To Divisor File 22 repeat for all Storage Files.
Then Divide Subtotal File 21 By Divisor File 22 to get Average File 23
timer Done Reset Timer



TON T4:0 1.0 900 0
XIC T4:0/DN BST MOV F8:20 F8:34 NXB COP #F8:31 #F8:30 4 BND
BST MOV 0.0 F8:21 NXB MOV 0.0 F8:22 BND
NEQ F8:33 0.0 BST ADD F8:33 F8:21 F8:21 NXB ADD 1.0 F8:22 F8:22 BND
NEQ F8:32 0.0 BST ADD F8:32 F8:21 F8:21 NXB ADD 1.0 F8:22 F8:22 BND
NEQ F8:31 0.0 BST ADD F8:31 F8:21 F8:21 NXB ADD 1.0 F8:22 F8:22 BND
NEQ F8:30 0.0 BST ADD F8:30 F8:21 F8:21 NXB ADD 1.0 F8:22 F8:22 BND
DIV F8:21 F8:22 F8:23
XIC T4:0/DN RES T4:0
 
Thanks TConnolly, and thanks for building the code, that really helps. What do I need to consider to decide between the two examples. I want to control Alum injected in the front of the plant and it takes about 10 hrs to reach the phosphate sampler. I wanted to use an hourly average or longer for the process variable for the PID to control the injection of the Alum based on the sample of phosphate. Have any ideas about how I might control the amoutn of Alum to be added with a 10 hr lag time in the process? Much appreciated. Deb
 
With a ten hour time lag you are going to play he!! getting PID to work well.

I suggest you consider a feed forward control. I am going to assume this is a wastewater application, and that the phosphorus concentration in the influent doesn't vary too much or too fast. 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.

You might also take a look at the cost of another sampler located closer to the point of injection.
 
It is wastewater, they reiceved the sampler from a grant. Phosphororus varies from .45 to .75 the permit is at .8. They take composite samples daily and only make a change after a few days to see if it is really going up or down. Buying another sampler would not be considered. Do you think the final value should be an average of 1 hr or maybe longer, as the engineer asked for that? Or doesn't it matter. Thanks for taking the time to respond, I agree and should not use a PID, I will look at using ratios. Thanks, Deb
 
With a ten hour time lag you are going to play he!! getting PID to work well.
That is if the PID is reading the 15-minute phosphorus samples in real time. What you need is the alum rate to be adjusted for the PID output of 10 hours ago.

If you set up a FIFO with Length = 40 (4 samples per hour X 10 hours = 40 samples), and trigger the FIFO Load every 15 minutes to save a PID output for each new sample, then after 10 hours, the first PID output should be used to control the alum rate. That is done by doing a FFU or FIFO Unload initially starting at Time = 10 hours and thereafter for each 15-minute period.
 
Lance1, Thanks for the info, how did you create a new data file called L for Long INT? I don't see that type in my data file list. Have a SLC 5/05. Update on how they run Alum in manual right now. They take a compostie sample over 24 hours, it takes 19 hrs for the Alum to move through the plant. We use a CPT (Influent Flow * .00144) * a Hi or Lo Dosage Setpoint = Req Flow in GPD. Setpoint is at about 80 PPM and operators move that PPM up or down depending on the sample (usually adding or subtracting 5 PPM). Thinking of doing basically the same thing with a 24 hr composite sample and make a minor ratio change up or down for the gals per day of Alum. Alum standalone takes our gal per day and moulates the speed of the alum pump. Would your Ladder 3 give me a 24 hr composite sample? Vendors actually turned down selling their sampler because of the lag time in this plant. Not sure how its going to work but I need to start somewhere. Thanks for everyone input.
 
In your project tree, right click on the data files and click New. Change the type to Long.

Not all PLC's support the Long data type though, in which case you may have to use a Float. I think that'll work more or less the same way for you unless you're trying to do individual bit addressing of the value (I'm sure someone will jump back in and correct me if I'm wrong!)
 
Yes, the SLC 5/05 does not have the "L" long integer available, but "F" for floating-point is available.

Thinking of doing basically the same thing with a 24 hr composite sample and make a minor ratio change up or down for the gals per day of Alum.
Do you plan for this ratio change to be manually made, or automatic?
 
Floating good, Automatically but would like to put a switch in for the operators to increase ratio in manual. Do you think your logic in Lad 3 would cover the 24 composite sample and then I'll add ratio increases or decreases based on how high or low it is over setpt? Thanks for your help, its so cool to be able to ask for help and get it! Don't know if in the end they will save that much on alum cost, but as we are paying closer attention to it probably some. Their permit is measured by throwing out the highest and the lowest readings, then its averaged out over the month. We will have to run alot closer to permit now, but it should be ok. Thanks again,
 
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.
 
Last edited:

Similar Topics

Micrologix 1400 reading an anderson flow meter. HSC is used to detect flow. Meter set to 1000 pulses per HL. I need to display the flow rate on an...
Replies
2
Views
1,801
Hi, I have a bit of PLC experience in Siemens and have unfortunately been blessed with working on Automation Studio and B&R which has been a big...
Replies
5
Views
1,367
The PLC code calculates oil flow rate and outputs it on D420. It is represented on the HMI as a vertical bar. Problem is that the operator says...
Replies
33
Views
4,941
Hello, I am working with a laser encoder that is providing the speed of a fiber strand to our AB 1756-L61 PLC. In order to calculate the amount...
Replies
3
Views
3,155
Hi ;Configure A1s64AD card in slot 3 is as attached. This is averaging count. my signals are coming in at channel 3 and 4. There are spiking so i...
Replies
1
Views
1,636
Back
Top Bottom