Followers 0

# How to accumulate gallons from a flow meter

## 20 posts in this topic

Hello I have a flow meter Signet 2551. Trying to figure how to convert 4-20ma output to gallons and add gallons to a total count. Using Micrologix 1400. Thank you for your help

##### Share on other sites
Having never used the Micro logix 1400 - just to clarify, is the input max really 5000 ? in the past with SLC it was I believe 16384 for 20mA ... just curious... OR were you miss using the SCL function because your eng unit is 20..... (so were you really trying to scale the analogue from 4-20mA = 0 - 5000 gallons ? Then once you have your scaling worked out correctly, for example 4-20mA (signal) = (xxxx - xxxxx PLC values unscaled) = 0 - 10 gal / sec scaled, think of how you could totalise something. Ie if you had a jar and were adding candy one at a time... jar_total = jar_total + 1. the same can be said for flow every one second, ie do the following calc on a positive edge of a 1 sec pulse flow_period_total = flow_period_total + X gal/sec. You can work out the logic.

##### Share on other sites
FYI, If the OP is using the ML1400's base analog inputs then their raw data is 12 bit 0-4095. They are voltage inputs. See picture below. If the OP is using an analog expansion module then they have there own resolution. As you pointed out the OP needs to tell the forum what the 4-20ma represents ( engineering units) and what its connect to. Edited by Mickey

##### Share on other sites
Or are we using an analog expansion module. 4-20mA on those is 6240 to 31200.

##### Share on other sites
Depends on the input and settings. From AB Technote 19719: In raw/proportional mode, 0 mA = 0, 4 mA = 6241, 20 mA = 31206, 21 mA = 32767 In "scaled for PID" mode, 0 mA = -819, 4 mA = 0, 20 mA = 16383, 21 mA = 17407 It's a 15 bit bipolar (aka 16 bits with sign) ADC (does not say but most likely delta-sigma or successive approximation). There is no resolution "loss" in either mode. Since zero is zero with the "scaled for PID" mode, I'd go for that mode and use a simple multiply instead of dealing with the vagaries of the SCP instruction if you are out of range (over/under). Suppose the scale with the Signet is 0-1000 GPM = 4-20mA, then 16383 counts = 1000 GPM, so multiply by 1000/16383 = 0.061038882. If the output is under/overrange, you'll get something <0 or >1000 GPM which is easily verified. You can also use the over/under-range bits on the analog input card if you want to. You must also make sure the dip switches in the top of the module are set correctly (down/"on" in the current mode). The Signet module you are referring to is loop powered. So you must supply an external power supply to make it work. The "common" is not electrically connected to the chassis, but the 4 inputs are single ended and they do not supply loop power. So connect your 24 VDC power supply V+ to the transmitter V+, transmitter V- to IN+, and connect "common", IN-, and the power supply V- together (for 2-wire). Connect shield to common/ground as well at the IO module ONLY (or alternatively at the IO module ONLY, never both) if you are using shielded wiring. As a followup, I've had zero luck with insertion mags and Signet in particular. It's not a "real magmeter". Accuracy is about as good as a flume, orifice plates/vortex/targets, or transit time ultrasonics. For the money/effort, I'd go with one of the others, leaning towards transit time flow meters since they don't require cutting holes in pipes (orifice plates, vortex, targets), don't clog up (targets/vortex meters), and don't have special mounting requirements (flumes). Real magmeters are expensive but have the highest accuracy for the money in the 6-24" size range. Low end coriolis beats them out on the small diameter end, and they are cost prohibitive on the upper end. The biggest downside of them is fluid compatibility, and wear (in slurries).

##### Share on other sites
Paul is heading in right direction. Before embarking on programming up the application, one should develop or review the specifications for the application. You may spend a lot of time programming a solution to find that the accuracy is too wide for the results one garners. The analog value from the flowmeter will have an accuracy range; sampling the analog value (i.e., 1 sec snapshots), totalizing and averaging to get an average flow rate (i.e., over 1 minute) with be accruate to +/- (potential variation of the process). What is the purpose for the flowmeter gallons figure? If this is a regulation monitoring application, such as recording effluent discharge gallons, the permit requirements may dictate a different method with a lower range of variation (i.e., higher accuracy). I personally was given a similar project some years ago that would have saved a lot of programming hours had I analyzed the specification of the application and the instrument prior to jumping in with both feet. The physics of the application (discharge pipe not full at all times, large variation in flow rates) and the instrument yielded an end result with variation far greater than the requirements of the discharge monitoring permit. End result was a replacement of the instrument with a model of higher accuracy.

##### Share on other sites
Hello Thank you everybody for your feedback. I am using Micrologix 1400 with 1762-IF4 AI card. Input is coming into IF4 card. At 0 gpm I get 6265 Raw and at 180gpm I get 31283 Raw. 4-20ma. Was wondering if somebody can post an example of how to accumulate gallons based on gpm. It is always easier to understand by looking at an example. Thank you in advance

##### Share on other sites
Your code for the scl function is still wrong. You have the parameters in your statement above. To totalise the flow ie total gallons, simlpy sample the scaled value every second, divided that figure by 60 (ie min -> seconds) and write logic that will represent total = x + total. At least have a go at trying to work this out. A lot of people have led you in the right direction, show a bit more effort on your behalf.

##### Share on other sites
I apologize for asking so many questions. I am new to this. Not sure how to find out what would be the scale in gpm? Ex. 0-1000gpm. Is it calculated based on pipe size? Once I have scale where do I do suggested conversion(0.061038882): "Suppose the scale with the Signet is 0-1000 GPM = 4-20mA, then 16383 counts = 1000 GPM, so multiply by 1000/16383 = 0.061038882" I am getting a reading(nothing is flowing) every second but it does not add two floats together? I am using 1762-IF4 with 4-20ma and Scaled PID Once again, I thank everybody for their time.

##### Share on other sites
Actually another issue. While the precision after conversion and division by 60 looks impressive that precision will soon be lost after multiple additions. I would add one more thing to the one second STI. Each time the float accumulated total is equal to or greater than 1.0... then add 1 to a DINT total and subtract 1.0 from the float. The DINT will go up in whole gallons allowing a truly large number while continuing adding to the float will over time begin to lose the least significant results of your scaling and division. After a while you would see no accumulation at all because all the lower significant digits are being lost. To see what I mean create a continuously running rung with an addition block adding .0000001 to a float. You'll see it operate for a while but then no additional increase will take place.

##### Share on other sites
Thank you for your tips I have total flow and flow GPM calculated: Total Flow in GPM samples every second: F8:19 * (Scaled Max/Input Max/60 seconds)* 2 (because RTC:0:SEC only does update every two seconds in MicroL1400) + F8:22 Existing Flow in GPM: F8:19 * (Scaled Max/Input Max/ 2(because of RTC scan)) Are those formulas correct or am I missing something? I also have panelview compact which has a scale connected to F8:23 to show present flow and even though F8:23 has 0 reading, PanelView shows solid -.19 instead of 0? Thank you for your help Edited by bearsgone

##### Share on other sites
There is no reason to divide by 2 if your intent is to get GPM. If you are doing all the scaling in the CPT blocks, then the SCP instruction is no longer needed at all. The purpose of the SCP instruction is to do a linear scale from one range to another. ie, m=(ymax-ymin)/(xmax-xmin), b=ymax-xmax*m, y=m*x+b. This is the full linear scaling formula assuming you know the endpoints. If ymin=xmin=0, then it simplifies considerably to simply y=m*x where m=ymax/xmax and the SCP instruction is much less useful than a simple MUL or CPT. Be aware also that CPT is slower than the basic math instructions (CLR, ADD, SUB, MUL, DIV, MOV). Whenever practical, convert to the basic instructions.
1 person likes this

##### Share on other sites
I use flow totalizers in a lot of the programs i write. Assuming you are getting flow in GPM, what i usually do is divide the input by 60 and move it into a new register, say F112:0. That new register represents Gallons per second. Then create a one second timer, we'll call it T4:0. When T4:0/DN is true (once a second) you add F112:0 to a register like F112:1, and put the result IN F112:1. that way it compiles your total flow every second. Then to get more depth, on the next rung, say if F112:1 > 1000 you add .001 to a new register like f112:2 and move IT into f112:2 to compile, and then you move a zero into F112:1, reseting it. this new F112:2 is your flow total in Millions of gallons. So essentially you add your gallons per second to a register every second, and every time it hits a thousand you add a .001 to a new register giving you your total in millions. Let me know if i need to explain it better

##### Share on other sites
Thank you for the feedback The other question I had was: I also have panelview compact which has a scale connected to F8:23 to show present flow and even though F8:23 has 0 reading, PanelView shows solid -.19 instead of 0? How can I set it so that Panelview would ignore +- values or is there another way of dealing with this? Thank you

##### Share on other sites
No don't move a zero into F112:1, subtract 1000.0 from F112:1

##### Share on other sites
Subtracting actually does seem like a more accurate measure now that i think about it, that way you dont lose whatever few gallons passed through before the rung was executed

##### Share on other sites
1 person likes this

##### Share on other sites
as for zeroing out a floating point youre right, as stated above, a better idea is to subtract 1000 so you dont knock off the decimal. As for the timer issue, my applications have never been critical enough to where its become a problem, but you are 100% right. I think the infinite timer is the most straightforward approach

##### Share on other sites
All of the errors that have been discussed are why I normally don't use the 4-20 ma option on their flow meters. Next time consider putting a 1 instead of a 2 at the end of your part number. You can connect this directly inputs 0-7 on the Micrologix 1400 and configure an EII to do simple ADD instruction. This way one pulse equals X amount of water. Actually if you are using their 515 or 2536 series paddlewheels ever, don't even bother purchasing a transmitter such as a 8550. You can connect the pulse off of the paddle wheel directly to the Micrologix input. Just put a 5K resistor between your 24VDC and the input.