Finding The Right Hack Is Half The Battle

Sometimes you just get lucky. I had a project on my list for a long time, and it was one that I had been putting off for a few months now because I loathed one part of what it entailed — sensitive, high-accuracy analog measurement. And then, out of the blue I stumbled on exactly the right trick, and my problems vanished in thin air. Thanks, Internet of Hackers!

The project in question is a low-vacuum regulator for “bagging” fiberglass layups. What I needed was some way to read a pressure sensor and turn on and off a vacuum pump accordingly. The industry-standard vacuum gauges are neat devices, essentially a tiny little strain gauge on a membrane between the vacuum side and the atmosphere side, in a package the size of a dime. (That it’s a strain gauge is foreshadowing, but I didn’t know that at the time.) I bought one for $15 ages ago, and it sat on my desk, awaiting its analog circuitry.

See, the MPX2100 runs on 12 V and puts out a signal around 40 mV on top of a 6 V offset. That voltage level is inconvenient for modern 3.3 V microcontroller ADCs, and the resolution would get clobbered by the 6 V signal if I just put a voltage divider on it. This meant whipping together some kind of instrument amplifier circuit to null out the 6 V and amplify the 40 mV for the ADC. The circuits I found online all called for 1% resistors in values I didn’t have, and mildly special op-amps. No fun, for me at least. So there it sat.

Picture of sketchy-looking vacuum apparatus.
Cut the blue wire or the red wire? HX711 module and pressure sensor on the left.

Until I ran into this project that machetes through the analog jungle with one part, and it happened to be one I had on hand. A vacuum pressure sensor is a strain gauge, set up like a Wheatstone bridge, just like you would use for weighing something with a load cell. The solution? A load-cell ADC chip, the HX711, found in every cheap scale or online for under a buck. The only other trick was finding a low-voltage pressure sensor to work with it, but that turns out to be easy as well, and I had one delivered in two days.

In all, this project took months of foot-dragging, but only a few clicks and five minutes of soldering once I got the right idea. The industrial applications and manufacturers’ app notes all make sense if you are making hundreds or millions of these devices, where the one-time cost of prototyping up the hard bits gets amortized, but the hacker solution of using a weight-scale chip was just the ticket for a one-off. That just goes to show how useful sharing our tips and tricks can be — you won’t get this from the industry. So send us your success stories, and your useful failures too, and Read More Hackaday!

25 thoughts on “Finding The Right Hack Is Half The Battle

  1. I wonder if using a zener diode to dump the 6v off the bottom of the signal from the MPX2100 would have worked, kinda like an analog power supply but the other way around.
    I’m guessing that you already thought of that and it wouldn’t have worked, but I find it interesting to consider.

    1. Nope. Won’t work.

      It’s worth to emphasize this because a lot of people (including me) start with thoughts in that direction.

      The reason this does not work in practice is that you’re measuring very low level signals. 40mV can easily be about the maximum differential output of such sensors, and you want resolution all the way down to the microvolt range.

      Zener diodes (around 5.6V) can have a very low temperature coefficient (around room temperature), but then you still have the fact that the voltage over the zener diode is heavily dependent on the current through the zener diode.
      So to get the current stable, you need a stable reference voltage and extra circuitry to make a stable current out of that.

      So you can force it to work with a zener (or a TL431 or other extra reference) but it’s just not going to be cost effective.

      ———–
      On the other hand. If you fix the whole thing with a few resistors, and keep everything radiometric, then you do not even need a stable voltage reference for your AD converter. If the reference voltage for the ADC is twice as big, then the voltage over your wheatstone bridge will also be twice as big, and with that, the differential output voltage will also be twice as big, and the ADC will read the same value.

      In these days, a 16-bit ADC is cheaper then a voltage reference with 1ppm/K, and a voltage reference with 1ppm/K will still give an error when the temperature deviates over more then 15Kelvin or so.

      And that is the beauty of a Wheatstone bridge.
      The strain gauges in a load cell also vary in resistance with temperature, but because of the radiometric setup these differences cancel out (a long as all strain gauges have the same temperature).
      The better quality loadcells also have an extra strain gauge just for temperature compensation, but I can’t recall the exact details.

      Note: I use Kelvin not out of nerdiness, but because “degree celcius” (centigrade?) is such a bore to type and the obscure circle does not even exist on my keyboard.

      ———————
      And there is nothing special about radiometric measurement and wheatstone bridges. Several manufacturers have made ADC’s to directly interface with this kind of signal, and the HX711 is just an example ADS1118 is another one, and has a better voltage reference and more flexible PGA. HX711 is about the cheapest you can get though, and I’ve also got a few. But sometimes your memory needs to get kicked to be reminded of the obvious.

      I also would not use the MD-PS002. Paying 50ct more for a sensor in an enclosure and a connection for a tube probably makes it a lot easier to get the vacuum into the sensor (or the sensor into the vacuum?) Both this article and the linked in intstructables do not make this clear easily. It probably results in drilling a hole, putting wires through and then gluing everything in place, and then you can still suck in air between the wire and it’s insulation if you’re unlucky.

        1. Not sure what you are using, but I have always held down the “Alt” key and typed 248 on the Numpad for °F or °C or even °K I could not get it to work with the top row number keys in either format… Maybe if you could describe the actual key sequence in more detail? (I need a higher ° of detail! LOL)

        1. Not a bad idea, but then I’m left with the 40 mV total range on the sensor still.

          I’m pretty stoked about the HX711 being a dirt-cheap part that did exactly what I wanted, and as paulvdh points out, it supplies the excitation voltage as well, so the whole thing’s ratiometric.

          In practice, I have no idea if it’s got 24 bits, but if I draw a vacuum and let it slowly leak down, which I’m pretty sure is physically monotonic, the values drop fairly consistently in all but a few least significant digits.

          Anyway, given that my requirements are more like “hold this around -0.5 atm with some arbitrarily chosen deadband”, the parts are awesome.

    2. No need to compensate a large DC offset because there is none, the output voltage of this bridge circuit is the voltage difference between the two output terminals. You need some circuitry that converts this floating differential voltage to a ground referenced one. A differential (instrumentation) amplifier is what you need. Or excite the bridge with AC and use a transformer, like it was done before integrated OpAmps were available.

        1. Actually, since the precision requirements are rather low anyways, all you need to do is amplify one of the outputs around the bias voltage (the average of the outputs) until you get enough voltage gain that you can drop it down with a resistor divider to your MCU.

          Since there’s presumably a 12 V source driving the sensor, then you could have a single op-amp turning the 6 V +- 40 mV into 6 V +- 4 V or anything you like with two resistors and a trimmer.

  2. I agree- I take the approach that if you have plenty of ideas/projects/problems plus lots of stuff and some patience (parallel processing helps if your brain works that way) every now and then, everything comes together…

    If you fight just one project, there are less chances for parts to align themselves when you need them.

    Amazing things brains…

  3. “That just goes to show how useful sharing our tips and tricks can be — you won’t get this from the industry.”

    I imagine the book publishing industry has hit it a time or two. ;-)

  4. Or you could simply have used any random opamp, with regular resistors, and either use a single trimmer pot for adjustment, or measure the error and use a high-value resistor in parallel with a lower value one to balance it.

    As I see it, you were lazy and ignorant and eventually you found out somebody else solved your trivial problem for you, that doesn’t strike me as something a self-proclaimed hacker should be proud of.

    1. If you only need to build one or a handful of circuits, you can get by with manual trim/calibration. For a production run or circuits that others could build without the extra steps, it might be more economical to use a better parts.
      Ultimately boils down to cost/time trade offs. e.g. having to stock/wait for these parts for yourself for all your prototyping needs or paying your contract manufacturers for calibrations for each units.

      1. And as the author says, this was a one-off deal.

        Spending months thinking about the issue when they could have just used a trimpot to do away with the requirement for precision components. With analog designs, you usually start with the assumption that your components are not accurate or precise, and you always have to trim or calibrate anyways.

      1. Having been in the same place with a standard kitchen scale load cell, I futzed together the required circuit in an afternoon around a TLC272 and a 5 Volt regulator for excitation. It’s a fun exercise, and the kitchen scale makes a signal in the microvolts if you want to measure grams, so it’s got some challenge to it.

        There is actually a ridiculously simple solution to the task using an op-amp. Since this is a passive massive piezoresistive sensor with a somewhat well defined output impedance, the sensor itself can become part of the amplifying circuit. You amplify the 40 mV signal roughly around its bias point by an arbitrary factor which you can trim, and then drop it down to the range that your MCU can measure with a divider. The rest of the calibration is done in software.

        Would be interesting to see if this works at all: (Falstad link)

        https://tinyurl.com/yk5rnycq

  5. I have manually sort through a small pile of 10K +/-1% resistors with a multimeter to find more closely matched ones for building differential amplifier. I was able to match multiple pairs less than 10 ohms, so it was pretty good.

    I only care about matching values of the pair for CMMR (relative differences in ohms) not too much about the gain (limited by by the multimeter). The gain error (if you care) can be corrected with system level calibration. You likely have other sources of errors anyways e.g. voltage reference, ADC gain+offset, sensor, opamp etc.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.