Ladder logic flow integration

Steve Bailey

Lifetime Supporting Member + Moderator
Join Date
Apr 2002
Location
The boondocks of Western Massachusetts USA
Posts
8,619
There have been many threads started about integrating the signal from an analog flow sensor to get a total volume along with comments (some by me) that it's not the most accurate or reliable method. And if the flow meter has an option to output a pulse at some increment, to use that signal as the more reliable.
So, I set out to see how well I could integrate a signal in ladder logic. I used a 25 year-old GE Fanuc 90-30 CPU351. I didn't bother with an analog signal. Instead I started with constant flow rate of 100 (let's say GPM, but it could represent anything that varies with time) and imposed a +/- 10 percent sinusoidal variation on that rate so that it varied between 90 and 110 at some frequency.
I've implemented three methods; integration over a time period with samples taken at a constant interval, integration over a number of samples taken at a constant interval, and integration over a fixed time period with samples taken every scan.
I've included some results along with the ladder logic in the attachment. If anyone cares to look it over, I've got a pretty thick hide, so comment away. If you've got any suggestions for other approaches or other tests you'd like to see, I'm open to suggestions.
 
I like the simulations and testing different methods. I would simply count/accumulate pulses over time if counts are provided. I would use the real time clock for measuring the time period. The only assumption is that the flow sensors can respond accurately to higher frequency changes inflow. Another issue is often do you need the total volume?

The analog only problem requires short intervals between the samples. Otherwise, there could be a short burst of flow that could be missed between samples. I would use a 10 ms timed interrupt.

Something I would look at is the bandwidth of the analog flow sensor and the analog input card. I would be tempted to put a scope in the analog output of the flow sensor to see how much noise there is or how the data is filtered.
 
Very nice work Mr. Bailey! ...and noted!

As you mentioned, the best accuracy will come from a pulse output. I've did a job in the fuel industry where they used a highly sophisticated mass flow meter that compensated for temperature and pressure. (Just to mention other factors)

As for the analog, I share Peter's concerns about noise. I've found the more accurate you measure, the more you factor in, including....

Wouldn't the scan-based sampling be much faster than the analog conversion time?

There are a lot of great points to be noted from your experiments. Thanks for sharing!
 
Wouldn't the scan-based sampling be much faster than the analog conversion time?
That will depend on the analog module and the scan time. In the 90-30 the spec for an analog module was 2.5 mS conversion for all channels. My application was running longer scan times, so no problem. With a newer, faster model PLC it could have been an issue.
 
The document I cited in the first post of the thread no longer appears. It was originally an MS Word document (.docx). Docx files are not listed among the allowable file extensions. Perhaps that was different back in December. At any rate, here it is as a pdf in case someone comes across this thread in the future.
 

Attachments

  • LadderLogic_Integration.pdf
    629.7 KB · Views: 28
Last edited:
I'd be concerned using a signal that has consistent periodicity and elements of symmetry for example data. I didn't follow your code exactly to figure out how you integrated, but using the typical numerical methods for integration (trapezoid, Euler's, Simpson's) your errors will perfectly cancel themselves in the next quarter period. I believe a much better stress test that you can use which still has a known ideal integral value would a sin function, like you have, but where n*pi/2 - n*2*pi forced to zero. This way the errors don't necessarily self-cancel. It's not quite as realistic seeming as a true sine function, but the key is that the sine function has perfect periodicity and is just rotations and translations of itself across its four quarters, characteristics that real data most certainly would not have. As long as your sample rate is sensibly fast, pretty much any integration method applied to a scalar of a sine function will converge to the correct value eventually.
 
I recently had to do this in logix with a flow sensor, I attempted to use a timer and every scan took the .acc value minus the previous scans value times the flow rate added to the total. It went completely haywire and I couldn't get it to work. I ended up using a timer with a 200ms preset that just took the flow rate when it was done and multiplied it by the time and added to the total. It works pretty well (it's thick grease, so the flow rate isn't extremely accurate anyways). I would use that method again for any low flow substances that can't change speed very quickly.
 

Similar Topics

I'm running an Allen Bradley CompactLogix L32E plc with Logix5000. I am in need of a method to which fmy Function Block flow totalizers to Ladder...
Replies
5
Views
7,832
Can any one advise to the process to carry out when converting ladder logic to state flow diagrams?
Replies
1
Views
3,792
In ladder logic, how can I generate totalized flow data from a flowmeter input? My flowmeter input is 12 bit analog (0-4095) which I use in a PID...
Replies
14
Views
17,352
Hello, I am going over some old code from days gone by. I would like the expert to confirm my findings to see if I got it correct. 1. B64:22/3...
Replies
7
Views
484
Hello, I´m having a problem trying to program in Ladder. An output should be trigged by two possible contacts. Take a look on the printscreen...
Replies
5
Views
188
Back
Top Bottom