Magnetic Flow Meter
We all know that magnets are pretty much voodoo: invisible forces acting on the real world in unknown and unexpected ways. But engineers have developed a number of methods to harness that magic to perform useful and beneficial tasks, including answer that age old question: How do you measure the flow of a liquid in a pipe? Stay tuned to see what happens when a civil engineer mixes water and electricity. From metering the dose of a medicine in an IV to measuring the flow of irrigation water on a farm to tracking your fuel fill-up, flow meters play a role in nearly every area of our lives. In fact, there’s probably a meter outside your home counting your water usage for your monthly bill. There are a whole host of ways we can measure flow, but today I want to talk about a method I think is particularly fascinating: the magnetic flow meter. We’ll walk through some of the electrical engineering behind this ingenious device and try to overcome the challenges that arise when the real world doesn’t quite match the theory.
But the theory comes first and so we’ll start at the beginning. A magnetic flow meter relies on Faraday’s Law of Induction which basically says this: Moving a conductor through a magnetic field will generate an electromotive force which is proportional to the velocity. Let’s break that down just a bit with an example. I’ve got a magnet and a conductor, in this case a coil of wire. The conductor is connected to a new toy in the shop: an oscilloscope, which is just an instrument for measuring a changing voltage and displaying it on a screen. For example, here’s a typical AC sine wave similar to what you’d measure at a wall outlet. If I keep the conductor still within the magnetic field, nothing happens. But as soon as I move the magnet, we see a spike in voltage. This is the electromotive force or EMF in Faraday’s law. The faster the coil passes through the magnetic field, the higher the voltage spikes, demonstrating that the EMF is proportional to the velocity.
A magnetic flow meter works exactly the same way, except instead of wire, the conductor is the fluid in the pipe. Magnets outside the pipe create a magnetic field. Electrodes are located perpendicular to the magnets. A conductive fluid moving through the pipe will generate a voltage between the electrodes due to Faraday’s law. The faster the fluid moves through the pipe, the higher the voltage. Once you know the velocity of the fluid, you can calculate flow using the cross sectional area of the pipe. It seems pretty straightforward, but let’s see if it really works.
Here's the test setup: I've got a length of PVC pipe with a pump on one side. I can control the flow of water using this valve. Two stainless steel bolts serve as electrodes to measure the EMF. And to create the magnetic field, I'm starting with two permanent neodymium magnets. I’m measuring the EMF using a differential amplifier to boost the signal into my oscilloscope. Once I get the water flowing, watch what happens when I move the magnets up to the pipe. We see a tiny jump in voltage. We are definitely getting an electrical response to the flowing water, but you can see we have a fairly noisy signal. It would be a major challenge to try and convert this signal into a flow reading.
The problem is electrical noise. And there are quite a few potential sources of noise here. First, depending on the fluid chemistry and the type of metal used for the electrodes, an electrolytic reaction between the liquid and the electrode can generate an electric potential. Second, stray voltages can sometimes existing within the fluid from other equipment along the pipe, like the pump. Finally, the liquid in the meter can have some capacitance. To a very limited extent, it can actually “charge up” like a battery which can create noise in the voltage signal between the electrodes. The problem is that there’s no way to know what part of the signal is due to the flow and what part is just noise, and the noise in the signal can be significantly bigger than the part of the signal we actually care about. In addition, having a constant long-term electric potential between the electrodes can induce electrolysis in the fluid. This will eventually corrode the electrodes, shortening the lifespan of the meter.
In other words, the theory behind the magnetic flow meter is sound, but the real world is getting in the way of things. This is where the physicists throw up their hands and the electrical engineers step in. And the electrical engineers have found that one way to avoid the issues mentioned above is to change the magnetic field over time. Here’s how it works. This is a graph of a magnetic field which varies in strength as a series of biphasic DC pulses: biphasic because it has negative and positive pulses, and DC because unlike a typical AC sine wave which is constantly changing, the waveform only has two values, on or off. Above it is an example of the resulting EMF from a magnetic flow meter. Remember, we only care about the portion of the EMF generated by the magnetic field since this is the only part of the signal which is proportional to the velocity of the fluid – everything else is just noise. Notice that even when there is no magnetic field, there may still be a non-zero voltage between the electrodes. But, if we sample the signal at the peak of the magnetic field, and subtract the voltage measured when the magnetic field is zero, we’re left with only the part of signal we care about. Even if the noise is changing over time, we’re only measuring the part of the signal which is induced by the magnetic field. Since the waveform is biphasic, it also solves the problem of corroding electrodes. Since the magnetic field is constantly reversing directions, there’s less opportunity for electrolysis to occur.
Obviously there’s no easy way to generate this type of waveform with permanent magnets, so we’ll have to switch to electromagnets. Of course I’m using artisan electromagnet coils, hand-wound in small batches with locally sourced magnet wire. Here’s a diagram of the overall setup. The electromagnets on the flow meter are powered using an H-bridge. This is a circuit that allows a small signal to control high current devices like electric motors and electromagnets. The control signal in this case is provided by an Arduino. I've written some simple code so I can control the frequency and duty cycle of the biphasic DC pulses. The blue line shown here is the voltage waveform going to the electromagnets. I’m using a frequency of 7 hertz and a duty cycle of 50 percent.
Unfortunately, even with all the trouble, this setup wasn’t quite strong enough to give me a reliable signal. From some literature I read, a well set up meter typically only generates about 100 microvolts for every foot per second of velocity or about 300 microvolts for a meter per second. For my garage workshop and the pump I’m using, that’s a needle in a haystack of RF noise and hum, especially considering that my crude apparatus can hardly be considered well setup. Every once in awhile if I was standing at just the right spot in the room, I could get a clean response from the electrodes, but I just wasn’t ever able to catch it with the camera. But this video is all about the devil in the details so I guess I should have expected this to be a bigger challenge. For now, let me use some some example data to demonstrate how a real meter would calculate flow.
Let’s say I was able to measure the induced voltage in the electrodes for a number of different flow rates in the pipe. I could plot those point on a graph. Since the EMF is linearly proportional to velocity and velocity is linearly proportional to volumetric flow rate, these points should fall in roughly a straight line. The slope of this line can be used as a proportionality constant in the signal processing of the flow meter - and the math becomes dead simple. Step one measure the induced voltage, step two multiply the voltage by the calibration constant. You just measured the flow. It really is that simple, assuming you get a good signal from your electrodes.
From the generators at a power plant, to the pickups on an electric guitar, Faraday’s Law of induction is working behind the scenes in some of the most unlikely places, including an ingenious method of measuring the flow of liquid through a pipe. I am a bit disappointed I couldn’t get the prototype working better, but I think there were some good lessons that came out of it: namely that electrical engineering is hard. I thought about not making a video at all, but I think documenting your failure is just as important as documenting success, and this is hardly the most shameful thing I’ve put on the internet. After some feedback on the EEV blog forums and some additional reading, I think fixing the demo would require a full redesign. For anyone thinking of trying this, here are some ideas that may make yours more successful than mine:
Electrodes should be thin, flat, conductive plates attached to the inner wall of the pipe.
Orient the demo vertically to ensure the pipe is flowing full.
Minimize anything which could cause turbulence immediately before or after the electrodes
Use twisted pairs of shielded wire to minimize RF interference
Filter and amplifier design is key to getting a good response
Use very strong electromagnets, and get the flow velocity as fast as you can
A few more comments/suggestions for anyone trying this at home I received from Steven Rogers (4/12/2019):
Another major source of confounding voltage is the transformer voltage that arises from the change in magnetic field intensity as the polarity reverses. This one will occur at the same frequency as the signal so must be avoided by synchronizing the coil and electrode processing.
It's easiest if you ground the fluid independent of the electrodes.
There is also an electrochemical voltage between the electrodes that shifts slowly over time.
You probably need an instrument amplifier and a low pass filter to see the signal on an oscilloscope.
Some additional helpful info on doing this yourself can be found here: nehagirme.wordpress.com.