Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, an initiative of Stroud Water Research Center designed to help people advance knowledge and stewardship of fresh water.
New to EnviroDIY? Start here

Precise analog voltage measurement using Arduino

Home Forums Other Data Loggers Precise analog voltage measurement using Arduino

Viewing 4 reply threads
  • Author
    Posts
    • #1574
      Jeff Horsburgh
      Participant

        I’ve been working on an application using the Arduino UNO Ethernet and the Adafruit Datalogger Shield for creating an Ethernet enabled datalogger for some water meters that I have recently installed in residential buildings on Utah State University’s campus. The output of the meters is a 4-20 mA current loop that requires a supply voltage of 12-24 volts. So, my current plan is to power the UNO with an external 12 V power supply via the power jack and use the Vin to power the current loop with 12 V. Right now I’ve got a 240 Ohm current shunt resistor in the loop, which gives me a voltage output range from 0.96 V to 4.8 volts. My setup seems to be working (despite my crappy soldering), and I’m getting pretty close to the right voltage values using a 4-20 mA loop simulator I picked up from the Automation Store to simulate the actual water meter.

        Now to my question – the voltage measurements made by the UNO are off a little bit, and they are a bit noisy. When I make the same measurements using my Fluke multimeter on the output from the simulator, they are very close to what they should be (the simulator can output both 4-20 mA and 0-5 V DC) and there isn’t any fluctuation (the simulator is actually a nice little tool!). I’ve read a lot of forum posts on other sites about the analog voltage reference in the Arduino being not quite 5 V and that it may fluctuate. I suspect this as at least part of my problem.

        Have others had issues with inaccurate or noisy analog measurements?
        What have you done to improve them?

        I’m considering the following, but I’m not sure which will have the best impact on the results (and be worth the potential added cost as I’ve got about 15 different meters I need to instrument):

        1. A better analog to digital converter via a breakout board (e.g., something like this)
        2. A better voltage reference via a breakout board (e.g. something like this)
        3. Modifying my code to collect a bunch of samples over a short time window and then average

        Ultimately it comes down to this – for these water meters, an output of 4 mA (what should be 0.96 V in my loop) means there is zero flow and an output of 20 mA (4.8 V in my loop) is some maximum flow value set on the water meter. For residential buildings, there may be significant time where the flow is 0 (e.g., late night) – and it’s important to see the low flows because we want to know if there are leaks. If the converted voltage measurements are bouncing around a little on the low end, it might look like there is a leak when it is really just an artifact of the measurements. Any ideas are much appreciated.

      • #1575
        neilh20
        Participant

          Hi Jeff, I think you’ve taken on a difficult challenge with estimating what is exactly ‘0’ at 4mA, and you would want to look at what is a theoritical low flow and can your ADC even detect that.
          Just wondering what the history is with having a 4-20mA flow detector in this location.
          Just to compare it against something I’ve done, for monitoring and leak detection I’ve used a water meter with a gallon clicker – Jerman.com DLJSJ75C.
          So every time a gallon passes it closes/releases a relay. Then I have an Arduino SAM3X that measures the clicks. I could publish the code on that if you are interested.
          It sends the results to thingspeak – I can then read the data from thingspeak and create a graph. I attach a graph – the blue is the water used on the house water meter, and the black line is the garden water meter.
          For leak detection – this is guaranteed to show every gallon and the way I do it is to count over 15minutes.
          The actual reed relay closes/opens on 0.1G passing and stays open for the next 0.9G – so technically it would be possible to detect a continuous leak down to 0.1G over some period.

          The basic issue with looking for leaks at 4ma/ is that the trace ability of the measurements is challenging.
          On the 4-20mA side its how accurate is the 4mA to indicate low flow, and how you integrate it, and on your Uno side how accurate is the Vref and how much accuracy can you get from the ADC digitization.
          I personally stay away from anything that hasn’t got at least 12bits on the ADC and a good ADC ref. The Mayfly has a good analog monitoring – see its specs. Then you need to understand your analog flow meters and come up with a definition of what is the leak flow rate that you want to catch.

          So the 4-20mA is useful for communicating over wires over a long distance, and for interfacing to specific types of monitoring equipment.

          Sorry to not be more helpful on 4-20mA, but hope the reasoning is visible.

        • #1577
          Jeff Horsburgh
          Participant

            Thanks for the reply @neilh. The meters are commercial grade (read that as $$$$$), and USU will eventually work them into their building automation (SCADA) system. But, they don’t have it deployed yet in all the buildings and so I need a cheap way to collect high frequency data from the meters and get them on USU’s network until that happens – hence my attempt with the Arduino Ethernet.

            The meters are ultrasonic and have an actuation flow of 1/16 gal/min. So, anything less than that should be output as 4 mA on the 4-20 mA output from the meter. Obviously, there are limits to the accuracy of the meters themselves at flows that low. The top end of the meter output is configurable (e.g., I can set the max flow rate that is output from the meter as 20 mA).

            So, theoretically, if I choose to integrate a stable voltage reference of 4.096 V via a breakout (I ordered one today), I set the top end of the meter output at 50 gal/min (which is probably reasonable for these buildings), and calculate the theoretical resolution I should get with the 10-bit ADC on the UNO, I get 1/16 gal/min. This might be OK for my needs. I’m going to test tomorrow on a meter that they just installed this week, so I’ll have some real data to have a look at.

            As an aside – I would love to use the Mayfly. I’ve got one, and I’m working with Stroud on a project right now that will be using them. I really like the specs. Two things pushed me toward the UNO:

            1. The ability to input 12 V on the barrel power jack and supply 12 V to power my 4-20 mA current loop using the Vin pin
            2. I think I need Ethernet to reliably get them on USU’s network because WIFI is a little iffy in some of the spaces where these meters are located (although, I did get an XBee WIFI module working nicely with the Mayfly).

          • #1579
            neilh20
            Participant

              Hey Goodluck
              Sounds like you have got the measurement traceability going. The local water company here installed a German ultrasonic meter, on the recommendation of Siemens. So far it seems to be slightly under-reading the water flow compared to the impeller meter I have, but haven’t done any detailed measurements on it. I’m waiting to see if there will be any visibility of the readings to customers (me).
              I’m using 12V and 4-20mA on a project. Its a using the commercial Onset U30-C3G with analog interface and reporting in over cellular. It has a WiFi option.
              The 4-20mA interface has been very good, accurate and stable signal across the 12bit ADC.
              I first tested it with some resistors to see how stable it is.

              Our issue was accuracy – we wanted to measure changes of 1/100′ or 0.01′. That limited the dynamic range to 10′ depth of water.
              So technically the dynamic range is about 10bit- 2**10=1024. Then you need to take into account digital quantization – the accuracy of the ADC and potential slight drifts that can occur. Temperature drift also needed to be accounted for, and potentially there can be a 20C change in temperature across a day/24hr cycle.
              I enclose a graph taken from a snapshot of two sensors tied together over 24hrs of pre-deployment testing in a stable 3.6′ water column. Typically I tested in 0.5′ of water, but wanted to test them at different depth. I believe the noise is coming from the sensors – both sensors are the same type of depth gage, but different responses.
              The graph demonstrates the value in doing some acceptance testing in known conditions – in this case level water (except for slight evaporation).
              You may want to consider how you can generate a 1/16 gallon flow/leak and then monitor the meters over a couple of weeks.

              Attachments:
            • #1608
              Jeff Horsburgh
              Participant

                Update!

                I switched to a 12-bit ADC that I had laying around from another project (this one). You can supply it with a range of voltage up to about 5.5 V i think, but it has it’s own voltage reference. That cleaned up the noise I was getting, and I’m now getting voltage readings across the resistor in my current loop that put me very close – it’s right on at 0 gal/min at the bottom end and within about 0.05 gal/min if I set my top end at 50 gal/min. I did have to apply a small correction factor to the output voltages (let’s call this a single point calibration), which I’m assuming is due to the fact that my shunt resistor is not exactly 240 ohms (its a 5% resistor). I just got some precision resistors that will probably take care of that.

                So, now on to some live testing in the lab. I’ve got the guys downstairs in our hydrualics lab plumbing one of the 2 inch meters into a line that should give me up to 200 gal/min of flow, which is right near the top end of the manufacturer’s stated accurate operation range of the meter.

                Your information about the depth sensors is interesting. I’m dubious about how well I will be able to do with flows at the very low end. For testing, I’m not sure yet how much control I will have over getting really low flow through the meter in the lab, but I’m going to see what I can do.

            Viewing 4 reply threads
            • You must be logged in to reply to this topic.