SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By qwertymodo
#165047
I've been working on a project involving reading a set of resistive flex sensors using the built-in ADC channels of an AVR microcontroller. The flex sensors are just 2-terminal variable resistors, so I initially just hooked up a fixed resistor in series, then used the resulting voltage divider as the input for the ADC. This is working fine, but due to the nature of the divider, the inputs are limited to a given range, and even having optimized it for the most range, I still only get a range of 140 on the ADC, out of a possible 1024. So, I've been looking into sensor conditioning, and am trying to figure out how to go about that. The simplest option I've found is to use a single-active Wheatstone Bridge fed into an op-amp. My understanding of that setup is that I want to select the other 3 resistors to be roughly equal to one end of the variable resistor's range. So, for the flex sensors I'm using, which range from ~80K-400K, 82K seems reasonable. Now, ideally, I'd like to get full rail-to-rail output, even if it means clipping the edges of the input range (some input clipping would actually be desirable, since it would give a "dead zone" on either end). However, I'm not entirely solid on op amps, so I have a few questions, mostly about achieving rail-to-rail outputs.

-The op-amp I have selected (Microchip MCP6024, which contains 4 op amps, because I have 4 sensors) is rated for rail-to-rail inputs and outputs. Due to variance in the resistors in the Wheatstone Bridge, especially the flex sensors, it's possible that, at the low end, there may be a negative voltage differential across the op amp's inputs, though both voltages will always be positive wrt ground (the Wheatstone Bridge is using the same V+ and ground as the op amp rails). Do I understand correctly that this should result in a 0V output, assuming that the negative rail is tied to ground? I don't ever want a negative output to occur. If this is not the case, I'll have to calibrate the fixed resistances (probably by using a potentiometer in place of one of the fixed resistors) so that the differential input is never negative, but then I'd lose the input clipping, which I would have liked.

-On the high end of the outputs, it should be just a matter of selecting a feedback resistor to select the proper gain, right? I get an input range of ~1V, and I want a rail-to-rail output range of 3.3V, so I need roughly a 3.5x gain.

-Is driving an op amp rail-to-rail considered "bad"? Is it harmful to the device, or to other devices in the circuit? The inputs aren't going to be driven rail-to-rail, but I would like the outputs to be.

The reason I would find input range clipping/clamping desirable is that these flex sensors are connected to the fingers of a glove, and it would be desirable to have "dead zones" at both the "fully flexed" and "fully relaxed" positions.

I've attached my current draft schematic for a single sensor. The 80K-400K range on RFLEX is known from measurement (though it varies from one sensor to the next, +/- 10%), so the 82K values for R1-R3 are selected based on that, I haven't yet calculated the proper value for RF.
You do not have the required permissions to view the files attached to this post.
By waltr
#165050
Driving this op-amp's output to its rails does hurt it and shows no bad behavior. Study figure 2-27 in the data sheet.
Your next step is to wire it up and try it out.
Start with 82k for Rf which would give unity gain. then increase Rf to get the desired gain and output.
By qwertymodo
#165052
waltr wrote:Driving this op-amp's output to its rails does hurt it and shows no bad behavior. Study figure 2-27 in the data sheet.
Do you mean "doesN'T hurt it? Otherwise this is confusing... :P
waltr wrote:Your next step is to wire it up and try it out.
Start with 82k for Rf which would give unity gain. then increase Rf to get the desired gain and output.
Yep, just waiting for them to get here, so I figured I'd make the best of the wait and ask these questions.
By Mee_n_Mac
#165060
qwertymodo wrote:-On the high end of the outputs, it should be just a matter of selecting a feedback resistor to select the proper gain, right? I get an input range of ~1V, and I want a rail-to-rail output range of 3.3V, so I need roughly a 3.5x gain.
Not quite. The way you have it, the bridge is (almost) balanced with the flex sensor at one end of it's range. That will produce an output from the op-amp that's halfway btw the op-amp's supply voltages, ~1.65v. Given the tolerances and 80k of sensor and op-amp input offset voltage, you may see slightly less than 1.65v.

As you flex the voltage will increase and w/Rf = 82k, full flex (400k) would try to push the output to peg at 3.3v. So you need to think how to re-bias your circuit (and reduce the gain) if you want the full dynamic range.
By Mee_n_Mac
#165064
Here I used Rf = 20k just to show you the bias issue. Note that the simulation shows just above 1.6v @ 80k flex and just under 3.3v @ 400k flex.
flex_ckt.jpg
(click on to open & enlarge)
flex_ckt_plot1.jpg
I did not use a model of your op-amp, but a generic, "perfect" op-amp. Your results might not be as good as the above.
You do not have the required permissions to view the files attached to this post.
By qwertymodo
#165066
Would increasing R2 (to ~240K) fix the bias issue by allowing the differential to vary negative-to-positive, rather than 0-to-positive? Also, what program did you use for the simulation?
By Mee_n_Mac
#165072
That helps but not all that much, you span 1.35v to 3.3v. Let me think about it. The program is the free version of LTSpice.
By qwertymodo
#165073
Ok, I'll probably go ask one of the EE professors and see if they have any ideas. I'm an Embedded Systems major, not EE, so the analog domain isn't exactly my strong suit...
By UhClem
#165077
Another way to do this is to use a constant current source for excitation. Pass a few microamps through the sensor and run the output to an opamp. (See attached)

The current is set by R2 and to add more sensors all you need to duplicate are Q1 and R2. The bases can all share the same reference. R2 sets the sensor current and is 0.7V/I. V2 can be a voltage divider buffered by a unity gain opamp.

You can adjust the sensitivity by varying the current (Not too much or the source stops working.) and the opamp gain. Adjust V2 for the offset you want.

You might want a better current source if you need to operate over a wide temperature range.
cond.gif
You do not have the required permissions to view the files attached to this post.
By waltr
#165079
I though some thing was not right with this circuit. Found out what it is.
the circuit need three more resistor. The four in the bridge are the Voltage sources and not part of the Differential amp circuit. The circuit should look like this:
BridgeAmp.gif
I used LT Spice to simulate the circuit. Its free from Linear Tech.
You do not have the required permissions to view the files attached to this post.
By qwertymodo
#165082
waltr wrote:I though some thing was not right with this circuit. Found out what it is.
the circuit need three more resistor. The four in the bridge are the Voltage sources and not part of the Differential amp circuit. The circuit should look like this:
. . .
I used LT Spice to simulate the circuit. Its free from Linear Tech.
Ding ding ding, we have a winner. :D

I may have to play around with the values a bit more to adjust the dead zones, but that'll come down to UX testing, and it's simple enough to do now that I have a circuit that actually does what I want. Thanks guys, you're amazing.
You do not have the required permissions to view the files attached to this post.
By waltr
#165111
Yes, It is fun to figure out these.
The circuit UhChem posted is another way of using a resistive sensor and is the recommend circuit for using RTD temperature sensors.

The best circuit for a Bridge is an Instrument Amp. And if being followed by an ADC then an op-amp wired as a low pass (anti-aliasing) filter.
By qwertymodo
#165134
Technically, all we have is a single-resistive-element flex sensor, I only put it into the bridge because of things I had read online suggesting that to be a desirable configuration. I just got the parts in and hooked it up in the circuit I posted above (the LTSpice one, not the OP), and it works great (though, for lack of 270K resistors, I substituted 220K and changed R6 and R7 to 2.2K to compensate, which gave a different curve, but it's fine for now, and I'll play around with values later when I have the chance). I do prefer the single voltage-source configuration over UhClem's version, just for simplicity. The plan is to connect Vout from the op-amp directly into the ADC input, but I'll try adding a second op-amp for the low-pass filter and see how that turns out. Preferably, though, I'd rather just use a capacitor from Vout to ground for filtering, depending on how well it works.
By waltr
#165152
That's a plan. If a single cap clears up the signal then that's good enough and you won't need an op-amp filter stage.