My classmates and I are creating a device which needs to dump a tray of sand after it has reached a specific mass. We attempted to follow this tutorial:
We are using a load cell salvaged from a pocket scale capable of measuring to one tenth of a gram.
This is our circuit at the moment:
And here is the code:
// Arduino as load cell amplifier
// by Christian Liljedahl
// christian.liljedahl.dk
// Load cells are linear. So once you have established two data pairs, you can interpolate the rest.
// Step 1: Upload this sketch to your arduino board
// You need two loads of well know weight. In this example A = 10 kg. B = 30 kg
// Put on load A
// read the analog value showing (this is analogvalA)
// put on load B
// read the analog value B
// Enter you own analog values here
float loadA = 10; // kg
int analogvalA = 200; // analog reading taken with load A on the load cell
float loadB = 30; // kg
int analogvalB = 600; // analog reading taken with load B on the load cell
// Upload the sketch again, and confirm, that the kilo-reading from the serial output now is correct, using your known loads
float analogValueAverage = 0;
// How often do we do readings?
long time = 0; //
int timeBetweenReadings = 200; // We want a reading every 200 ms;
void setup() {
Serial.begin(9600);
}
void loop() {
int analogValue = analogRead(0);
// running average - We smooth the readings a little bit
analogValueAverage = 0.99*analogValueAverage + 0.01*analogValue;
// Is it time to print?
if(millis() > time + timeBetweenReadings){
float load = analogToLoad(analogValueAverage);
Serial.print("analogValue: ");Serial.println(analogValueAverage);
Serial.print(" load: ");Serial.println(load,5);
time = millis();
}
}
float analogToLoad(float analogval){
// using a custom map-function, because the standard arduino map function only uses int
float load = mapfloat(analogval, analogvalA, analogvalB, loadA, loadB);
return load;
}
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
When we run the code the analog value displayed on the serial stays at a constant value (13 or 200 something depending on the white/green positive/negative wiring) unless a large amount of force is applied (at least 10 or more pounds), when it then jumps rapidly.
We would like our device to be accurate to at least one hundredth of a gram. Do we need a different amplifier? Would it be better to order a different load cell instead of using an unknown and possibly damaged one? And if so, what load cell would you recommend for our purpose?
Thanks for your help, we're attempting to climb the learning curve rather quickly.
Well I would recommend that first you just apply +5vdc and ground to the E+ and E- terminals and then use a digital multimeter to measure the DC millivolt output on the S+ and S- wires while being disconnected from the op-amp circuit. Then use various test weights to see what range of value Vs weights you get. If that seem linear and repeatable then work on the -wiring and component values to get a usable measurement range.
I suspect your goal of being able to have "accurate to at least one hundredth of a gram" is going to be very difficult using normal arduino analog input. A better path might be to research for I2C or SPI ADC chips that are designed to measure low millivolt input ranges directly (some have programmable gain settings) and have a stable accurate voltage reference built in. These are available in much higher resolution (12-24 bits of conversion) and are much better suitable for high accuracy and resolution requirements.
You need to fiddle with your gain more. Use a ~100R pot, connect your multimeter, and adjust the pot until you see the voltage start to change. In my experience the "sweet spot" was in the range of about +/- 2 ohms.
1/100th of a gram would suggest you could only measure 10 gram ranges with the Arduino's 10 bit (0-1023) precision. ADS1231 would be a recommended replacement for the INA125, but it's a 16 pin SOIC.
I don't know if the result I got is related the above, but I've been doing some experimenting too with a load cell robbed from a cheap set of kitchen scales, and my first results were very disappointing, but I think I just realized why - and I haven't seen this written about in any of the load cell projects I've been reading.
I was finding that even with the gain as high as I could make it with a INA125P, the voltage on my meter was barely deflecting hardly at all with a 100g test weight. It's true the scales were cheap, but they were way better than that! And then it crossed my mind that the load cell might have a certain hysteresis to it, i.e. maybe it needs a certain minimum load before it starts registering properly. Sort of "taking up the slack" or "taking up the backlash".
That does indeed seem to be the case. I haven't yet pinned down the exact "preload" weight required for my cell (and anyway it presumably varies for other cells), but I've found that if I have a 400g weight on the cell then I can see clear voltage changes when I add even 1g.
My own project is not quite the same as the OP in that I'm looking for (say) a 0-5kg range, accuracy not too important, so say +/- 10g. There's some room for maneuver in my spec, but no deflection at all with 100g weight was worrying!
I thought it might be useful to put this info out there.
I've seen statements that a load cell responds linearly so all you need is two points to determine the scale. I'm betting that in fact it's strongly non-linear at very low and very high strains but if you preload it so it never sees teeny weights then you can treat it as having linear response.
I appreciate the attempt to help, but why the link? I don't see anything relevant in there. I'm not asking about how to connect a load cell, nor do I have a problem with the INA125P. I simply passed along an observation about non-linear response at low strains.
To confirm that the loadcell is behaving 'usual' , measure resistance all the 4 resistors. They should be equal when cell is not loaded.
If the are 'far off', there may be a (pre)load neccecery. (even though I dont belive this is a 'standard' way to solve such problems)
The INA125 does not have rail-to-rail output, in particular the output doesn't go all the way down to 0V is you run it from a single +5V supply. To get sensible readings at low loads, you need to use a negative supply as well. This is quite easy to generate if you have a spare PWM pin.
The input offset voltage of the INA125P and the offset voltage of the load cell will cause the output to be nonzero at zero load.
knut_ny:
To confirm that the loadcell is behaving 'usual' , measure resistance all the 4 resistors. They should be equal when cell is not loaded.
By the "4 resistors" are you referring to the resistors in the Wheatstone bridge? I.e. the strain gauges? I have no direct access to those as they're covered in white epoxy. I guess that will always be the case for salvaged load cells. However I know that the donor kitchen scales seemed to be happy enough.
knut_ny:
To confirm that the loadcell is behaving 'usual' , measure resistance all the 4 resistors. They should be equal when cell is not loaded.
By the "4 resistors" are you referring to the resistors in the Wheatstone bridge? I.e. the strain gauges? I have no direct access to those as they're covered in white epoxy. I guess that will always be the case for salvaged load cells. However I know that the donor kitchen scales seemed to be happy enough.
The four 'resistance values' can be read directly from just the two sense wires and two excitation wires.
retrolefty:
The four 'resistance values' can be read directly from just the two sense wires and two excitation wires.
I don't see how... I'd be reading the value of the overall resistor network won't I? In any case I'm not sure of the purpose of sending me down this rabbit hole: the kitchen scales worked, therefore the load cell is ok.
Only thing to confirm is that ALL resitors are the same value. You need to know this to be able to designe your amplifier.
From figure: measure resistance RU1-0V , RU1-5V , RU2-0V , RU3-5V (they should ALL read the same value)
Now put power on (5V and GND) measure voltage U1-U2 (great if this is a few mV)
Load the cell to the max. measure again. (voltage will change. Note differece)
Change in voltages should be amplified to 5V (3.3?) calculate gain-factor G
connect the two U1/U2 to diff-amp (the one which increases with incr.load to positive input)
A trimmer may be needed to adjust offset
DonMilne:
I was finding that even with the gain as high as I could make it with a INA125P, the voltage on my meter was barely deflecting hardly at all with a 100g test weight. It's true the scales were cheap, but they were way better than that! And then it crossed my mind that the load cell might have a certain hysteresis to it, i.e. maybe it needs a certain minimum load before it starts registering properly. Sort of "taking up the slack" or "taking up the backlash".
You can't jack the gain to the max and expect any result. With the gain too high you get a consistent reading (~4V) and with the gain too low it will be consistent as well (~.3V). You have to keep messing with the gain resistor value until you hit the sweet spot and that can be a window of just a few ohms. I'd suggest using a ~47R resistor with a 100R trimmer for this, adjusting the trimmer until you see the output voltage somewhere in between that .3V and 4V.
It's also to be expected that your load cell will be a little out of balance so you won't hit that .3V-4V range that the INA125P is capable of -- at rest, one sense wire will always show a higher voltage than the other. That can be adjusted out but it's not necessarily a simple task.
Chagrin:
You can't jack the gain to the max and expect any result.
I didn't start with the gain wound that high. I started with 20R and wasn't seeing anything with a 100g test weight. So I tried 10R, then 5R, 2R and .22R ... and basically it made no difference. However if I attached a 400g weight I could vary that weight by as little as 1g and see a clear change. I concluded that the load sensor needs a certain minimum load, but now I'm leaning towards it being a voltage offset problem as described by "dc42" in the other thread, cured by a negative voltage to the amp. A pity, as I'm not that keen to complicate the voltage regulation or give up another PIO for pwm. Still, for my application I only need to know that a load is present, it isn't actually necessary to weigh it accurately.