Circuit#
Load Cell#
Imagine a conductive rubber band. If you pull on it, it gets longer and narrower. Now current must take a more arduous path, and just like traffic on a congested highway, slows down. Hence the resistance of the stretched rubber band increases.
Strain gauges are not made of rubber but work similarly. They are used to measure distortion in cars, airplanes, buildings, bridges; they are quite versatile.
Load cells consist of our strain gauges attached to a metal bar (image credit: Sparkfun):
Many commercial scales are based on load-cells. We’ll use one that looks like this:
You can get them online from many sources. I suggest you get one with a weight rating or 1kg or less - unless you want to get a workout lifting weights.
The bending of the load cell is imperceptibly small, even with the full rated weight applied. We need to build a very sensitive circuit to ovserve it.
Readout Circuit#
Reading out a load cell-the amount it bends and hence the force applied to it-is simple. Electrically the four strain gauges are just resistors. Arrange them in a “bridge configuration”, paring gauges in tension and compression like so:
With no force applied, all resistors are (nominally) equal and
Amplifier#
A problem with this circuit is that
Instrumentation amplifiers are ideal for this purpose. They take a (small) voltage at the input. The output the input voltage multiplied with a gain factor G that is set with a resistor. For example, if G=100 a 1mV input results in 100mV at the output.
We’ll use an INA126, primarily since it operates down to 2.7V and hence can be powered from the same 3.3V supply as the microcontroller. Unlike many newer parts, it is available in a dual inline package and therefore breadboard compatible.
Here is the wiring diagram from datasheet:
Resistor
Like most amplifiers, the INA126 takes both a positive (V+) and negative (V-) supply. The positive one we get from the microcontroller breakout board. But what about the negative supply? Rather than dealing with laboratory supplies or batteries, let’s generate it ouselves.
Use two equal sized resistors in series to generate 1.65V from the 3.3V supply. Then connect that to ground (pin 5 of the INA126). The “real” ground (0V) from the breakout board goes to V- (pin 4) and the 3.3V supply is tied to V+ (pin 7). Just remember that the output of the INA126 for
An updated circuit is shown below.
ADC#
The output from the INA126 (and the load cell) is an analog voltage. The microcontroller works with digital signals. Hence this voltage must be converted to a digital number.
Many microcontrollers have ADCs (Analog-to-Digital Converters) built-in. The ADC in the ESP32 isn’t particularly good (actually, pretty awful would be a better term), but ok for a simple demo.
The Adafruit Huzzah32 makes five ADC channels available, marked blue in the diagram below:
Connect the output from the INA126 to ADC3
and ADC6
. You can use different ADC pins, just remember to change the pin number in the code.