I am conditioning the signal from a temperature IC (MCP9701) in order to get the best resolution from the ADC I'm hooking it up to. This means subtracting an offset and then adding some gain.
Currently I'm doing this with a bunch of op amps, but it sure is tempting to instead perform the subtraction by running it through a few diodes (each subtracting roughly 0.6v).
Is diode subtraction considered a no-no for working with precision signals? I'm looking for feedback about how using a diode for subtraction is a bad idea because of X Y and Z...
The forward voltage across a diode is not a constant, it's roughly an exponential function of the current flowing through the device. It also varies from diode to diode and with temperature.
Anyway, you can do it using opamps better because you can feed one input a precise reference voltage. Not sure what you meant by "a bunch" of opamps.
not to mention better temperature stability and linearity.
Thanks for the feedback guys, that's about what I expected.
Here's what I was originally planning on doing, using 3 op amps (basically a poor-man's instrumentation amp?).
The interesting thing to me was that the diodes might actually work in this particular application, as I'm basically making a tiny little oven to keep a component (a vishay foil resistor) at exactly (well, +/- 0.1C is the goal) the same temperature, to create a "resistance standard" which I could potentially have calibrated, and then use that to calibrate my meters.
So in this particular case, I don't actually care what specific temperature the PID loop settles on, I only care that it stays as stable and repeatable as possible.
I think I'll use the op-amps, but its interesting to think that in this particular case, the diodes might be a useable alternative? I'm not sure which would drift more over time (in a constant temperature environment): op amp offset voltage, or diode voltage drop?
(oops, there's a typo in that LTSpice setup. the 0C offset for the MCP9701 is 400mV, not 500mV)
Yes you can pare it down to two opamps and I suspect that you could safely use just one op amp.
Although I can't say that I know more about your application than I do, I would probably use a Voltage Reference for your "offset" rather than a voltage divider. If not, then you will probably want some decently precise resistors for R11 and R7 at least. And temperature stable as well.
And all that just to feed another control loop... another opamp, right? You should be able to do the whole thing with just that one opamp. Examples
here using a thermistor in a resistive bridge to generate the measured and reference voltages and feed an opamp as a PI controller, but I think you can adapt it to use your IC instead.
Quote from: cellularmitosis on Today at 02:10:04 PM>The interesting thing to me was that the diodes might actually work in this particular application, as I'm basically making a tiny little oven to keep a component (a vishay foil resistor) at exactly (well, +/- 0.1C is the goal) the same temperature, to create a "resistance standard" which I could potentially have calibrated, and then use that to calibrate my meters.
So in this particular case, I don't actually care what specific temperature the PID loop settles on, I only care that it stays as stable and repeatable as possible.
I think I'll use the op-amps, but its interesting to think that in this particular case, the diodes might be a useable alternative? I'm not sure which would drift more over time (in a constant temperature environment): op amp offset voltage, or diode voltage drop?
It depends on where these diodes are kept relative to the temperature oven. Your device (MCP9701) uses a diode junction for temperature measurement, and has amplifier-linearizing circuits that convert the PN junction temperature coefficient to an analog voltage. I think you will just complicate the circuit by doing this (using diodes to drop voltage), and if you ever change the set point temperature, the diodes will cause more frustration with their calibration influences.
And all that just to feed another control loop... another opamp, right? You should be able to do the whole thing with just that one opamp. Examples here using a thermistor in a resistive bridge to generate the measured and reference voltages and feed an opamp as a PI controller, but I think you can adapt it to use your IC instead.
Thanks for the link, lots of interesting reading in that thread. Some circuits I had seen before and a few new ones.
Actually, I wanted to try out digital control, so this would be driving the ADC pin on an ATTiny, which would run PID and then control a DAC (MCP4821) which would drive a constant-current op amp / TIP21 (as heater) / sense resistor setup. I wanted to keep it digital so that I could easily tweak and fool around with it over a serial line, rather than having to take it apart and desolder resistors, etc.
The whole mess will be put in a mason jar. The inner temperature controlled environment will be a pair of circular PCB's sealing off a small section of PVC pipe, which will make a "jar within a jar" setup. The empty space around the PVC / PCB sandwich will be filled with styrofoam microbeads. I've had lots of fun designing it!
I decided the whole project was practical as a fun exercise when I realized the $20 vishay foil resistors can be found used (salvaged?) on ebay for $4.
It depends on where these diodes are kept relative to the temperature oven. Your device (MCP9701) uses a diode junction for temperature measurement, and has amplifier-linearizing circuits that convert the PN junction temperature coefficient to an analog voltage. I think you will just complicate the circuit by doing this (using diodes to drop voltage), and if you ever change the set point temperature, the diodes will cause more frustration with their calibration influences.
Interesting.
My plan is to try to keep the entire circuit within the temperature controlled environment, in hopes that it would reduce the temperature coefficient of the entire unit as a black box against the slowly changing temperature in my room.
When using an ADC you may realize you can often get fractional bits of precision by sampling many times and averaging (dithering)? This could be simpler than various analog circuitry that is going to distort the signal on its way from the signal source to the ADC.
If you mount the diode next to the MCP9701 then any temperature dependent Vforward changes won't matter, you needn't pull a constant current through the diode either, any non-linearities can be compensated through a LUT. If your application is just to maintain a set point, you might not even need an LUT.
Vforward will be different on diodes from the same reel, probably not enough to worry about though.
You can do this a whole hell of a lot easier -- use one amp, a series resistor from sensor to +in, a feedback resistor from out to -in, and resistors from +/-in to VCC/GND as needed to pull the output into the right voltage range.
You can use textbook ideal circuits as a starting point, but chaining them together is, well... you know what it is, that's why you're asking
Tim
When using an ADC you may realize you can often get fractional bits of precision by sampling many times and averaging (dithering)? This could be simpler than various analog circuitry that is going to distort the signal on its way from the signal source to the ADC.
The first circuit I breadboarded used VCC (5V) as the VREF for the ATTiny, which meant that one LSB was about 0.25 degrees C. I was able to get the PID loop to mostly bounce around the setpoint by 1 LSB (+/- 0.25C). That's what started me down this path: the desire for finer resolution (which means either reducing VREF, or offset + gain, or both).
But you raise an interesting point. e.g., if you consider the sequence of samples [5, 5, 5, 4, 4], instead of turning that into a 5, I should instead turn that into a 4.6, is that right?
But you raise an interesting point. e.g., if you consider the sequence of samples [5, 5, 5, 4, 4], instead of turning that into a 5, I should instead turn that into a 4.6, is that right?
Yes, but it is even easier to do in binary with a power of two sample count. For example, take 8 samples in succession [5, 5, 5, 4, 4, 5, 4, 5] and sum them up.
In binary:
5 = 101
4 = 100
sum(5,5,5,4,4,5,4,5) = 37 = 100101
You can divide by 8 by shifting right three times, so the average is 100.101, which in decimal would be 4 + 0.5 + 0.125 = 4.625.
If you are clever you can even do your PID calculations in fixed point arithmetic and not ever convert to floating point.
You can do this a whole hell of a lot easier -- use one amp, a series resistor from sensor to +in, a feedback resistor from out to -in, and resistors from +/-in to VCC/GND as needed to pull the output into the right voltage range.
You can use textbook ideal circuits as a starting point, but chaining them together is, well... you know what it is, that's why you're asking
Tim
Tim,
Thanks for the idea! You are saying that I just need the right set of resistor values in something like this?
Wow, a few minutes of guess-and-check lead to a decent solution, and then I realized I don't even need the resistors around the MCP9701! this is way simpler!
Thanks Tim!
Yup!
You can calculate the slope or gain (dVout / dVin) of the amp based on the R4 into R1 || R5 voltage divider. Don't forget that the input is attenuated by R6 into R2 || R3. Then, offset by following the voltage offsets around (if the R2-R3 divider has the same potential as R1-R5, then when R6 has no current flow, the output's at zero).
Further, if you actually have a negative supply handy, you only need one bias resistor (up or down as needed).
A good example and way-of-thinking about this:
Suppose you have a current shunt. So, zero referenced, no offset, low impedance. But too low voltage. Say you want 0-5V from a 100mV shunt. So you need a gain of 50. So, from op-amp output, 49k to -in, 1k to GND. Shunt to +in via 1k resistor (match input resistances -- helps to match the offsets due to input bias current). If the amp has +/-1mV input offset, it's 50mV at the output, which kind of sucks (1% error). So, suppose we bias the input by 1mV, and bias the other by 0-2mV from a trimmer, so you can calibrate it to zero offset. From a 10V supply, you'd use a 10Meg resistor to +in to guarantee an offset of 0-2mV, then a trimpot spanning GND to supply (0-10V) with the wiper to a 5Meg resistor to -in (which has a Thevenin equivalent of a little under 1k, so twice the offset needs half the dropping resistor). Or since Megs are kind of sucky, you could run the trimpot as a divider (say, a 1k trimmer with 100k from supply = 0.1V) and use smaller values (100k from the top of the trimmer, and 50k from the trimmer wiper).
Note that, in a case like this, you can approximate the voltage divider equation (R2 / R1+R2 and related) as linear (R2/R1) and parallel resistors as ignored (1k || 50k is barely less than 1k). Take advantage of whatever approximations you can, then fine tune it with real math (set up the full equations and tweak, or just play around in the simulator for the same effect).
Tim
What a nice reduction in parts count!
Also--the second one is better because it puts less load on the MCP9701. The maximum output current according to the data sheet is 100 µA [edit: corrected value], so you have to be careful about loading down its output with resistors to ground.
A good example and way-of-thinking about this:
Suppose you have a current shunt. So, zero referenced, no offset, low impedance. But too low voltage. Say you want 0-5V from a 100mV shunt. So you need a gain of 50. So, from op-amp output, 49k to -in, 1k to GND. Shunt to +in via 1k resistor (match input resistances -- helps to match the offsets due to input bias current). If the amp has +/-1mV input offset, it's 50mV at the output, which kind of sucks (1% error). So, suppose we bias the input by 1mV, and bias the other by 0-2mV from a trimmer, so you can calibrate it to zero offset. From a 10V supply, you'd use a 10Meg resistor to +in to guarantee an offset of 0-2mV, then a trimpot spanning GND to supply (0-10V) with the wiper to a 5Meg resistor to -in (which has a Thevenin equivalent of a little under 1k, so twice the offset needs half the dropping resistor). Or since Megs are kind of sucky, you could run the trimpot as a divider (say, a 1k trimmer with 100k from supply = 0.1V) and use smaller values (100k from the top of the trimmer, and 50k from the trimmer wiper).
I'll be thinking about that one for a while