Sign in to follow this  
Followers 0
mhowasso

Analog Input with Time Weighted Average

10 posts in this topic

Hi All, Working with a MicroLogix 1400 with a 1762-IF4 Analog Input module measureing a signal that is 4-20ma. This is from a gas sensor with a scaled value of 0-100ppm. I need to provide a time weighted average where if the gas value average gets over 10ppm during an 8 hour period I set off an alarm and then reset this average after the 8 hours, then start another 8 hour period. Looking for some advice how how this "Time Weighted Average" will work. Whats the best way to start this..?? As always, all advice is appreciated. Thanks

Share this post


Link to post
Share on other sites
The program in my last post HERE has a flow weighted average calc routine in it. It should give you some ideas. You could do it a lot simpler by calling a routine when Sample > 10 and 1 sec Timer/DN. Then use a counter to accumulate number of triggers. Add block to add Old value to new value = current value. Then current value divided by counter. Or some version of this Edited by Michael Lloyd

Share this post


Link to post
Share on other sites
Hi Michael, Thanks for the Info. Im going to look at this file and let you know. But I have a question... Is the term "Time Wieghted Average" just a way of saying.. IF a value goes above/below a setpoint value for xx time then turn output ON..??? Edited by mhowasso

Share this post


Link to post
Share on other sites
And here's a link to a PDF file that might help

Share this post


Link to post
Share on other sites
Hi Michael, Thanks for the info. I looked at the file, but I dont think this is what Im looking for. I read the link that you sent but the question I have now is..where and how was the 500ppm arrived at..?? Was it the max value during the shift..?? Or the average during the shift..?? This could have an impact on the calculation.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites
I can't remember, does the ML1400 have a real time clock? If it does your problem can be easily handled.

Share this post


Link to post
Share on other sites
Ken - The ML1400 has an RTC Lets back up to your original post. Is the 8 hour period based on a clock or is it based on time above 10ppm? Time weighted average isn't too hard to calculate. In a ML1400 it's a little clunky compared to a CLX (there are nice FB's to use in a CLX). In you're case you only want to know the average if the value is above 10ppm. So, you need to limit the routine to only run when the value is above 10. You could do that a number of ways. Call the routine when X>10. But you also need to determine the sampling frequency. If you use 1 sec intervals then you'll need a timer /DN bit ORed with X>10 so that every second and when the value is > 10 you'll start the calculation. Now the fun. Are you sampling once a second or once a minute? Once a second is going to take a lot of registers. Once a minute may be too coarse. You need to accumulate the ppm value every time the routine runs- Lets say it runs 8 times and the values are 11, 15, 14, 13, 21, 18, 33, 12. Run 1 = Current Value (0) + 11 = CV (11). Run 2 = CV (11) + 15 = 26. Run 3 = CV (26) + 14 = 40, etc, etc. If you increment a counter each time you can use the counter as the divisor (Count +1 since it starts at 0) and keep a running average where CV/(Count +1). In Run 3 the result would be 13.33333 or 13 if integer. At the end of 8 samples the average would be (R1+ R2 + R3 + R4 + R5 + R6 + R7 + R8) / 8 = 137 / 8 = 17.125 or 17 if using an integer. 17 is the Time weighted average of 8 seconds worth of data if the sample time is once per second. There's a lot of ways to skin this rabbit. Edited by Michael Lloyd

Share this post


Link to post
Share on other sites
I used to work at a chemical plant, and the way I understand the rules, the limits are based on workers exposure during an entire 8 hour shift. So if you get a small spike at the beginning of a shift, but only small ripples the rest of the time, then the time weighted average will be within limits. So the average must be over an 8 hour period, you want the low values so the high values are evened out over time. The big question is how often do you sample. If this was my project, I would record the values once a minute and then average every hour, at the end/start of a new shift, average the last eight hourly averages. Or you could do a rolling 8 hour average also. Someone within your organization has to specify exactly what the requirements are, until then you have no way of knowing how to write the logic.

Share this post


Link to post
Share on other sites
Hi Ken, Thanks for the reply, I appreciate it. OK, this what I have done so far. I have connected "one" sensor up to my ML1400 and and wrote a program to monitor this 4-20ma signal and scaled it to 0-100 PPM. The reason I have only done one sensor (and I just laid the cable on the floor so I can move it around and just get some readings in several areas to kind of see exactly what kind of values I could expect) this way I can identify exactly where I want to mount the sensor permanently (there will be six total). This allows me to see how all the things like doors opening, part removals, etc. has what kind of effect on values. I am using a four color stacklight (Green-Blue-Yellow-Red) to indicate when the value is within these four levels (0-100PPM). Green = <5 Blue = 6 - 15 Yellow = 16 - 25 Red = >25 I currently change to the appropriate color immediately when the level enters that level, but on red I latch it and sound a horn that can only be reset via password by a supervisor. Now that I have some kind of idea of what values I will be getting, I want to take a reading every second and average this reading over a 10 second period to give me six averages per minute and use this in some kind of hour formula. Here is where Im wondering what to do now...?? Also, using this TWA way, what IF an operator is working in an area that spikes high but the TWA is OK, he could be dead but the TWA says he should have been OK..??? The vapors I am sensing is Trichloroethylene in a degreasing department. The program I have is working great for immediate level reading (Phase 1) but I feel I need to now move to (Phase 2) and make it per the TWA format, and this is where Im am getting lost. Thanks..and any advice is greatly appreciated. Mark Edited by mhowasso

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0