Read 5v analog with 3v3 ADC and a differential opamp? - Page 1
Forum section: electronics / projects

author: JustMeHere
author_rank: Frequent Contributor
timestamp: August 24, 2018, 12:15:37 am
content: I want to read one of those 5v water pressure guage that has an analog output 0v5 to 4v5.In my current design, I used a 5v ADC with a level translator on my SPI bus. That cost about $7.00I've been looking around and I stumbled on a differential opamp circuit. If I had one set up with a 0.66 gain, would that safely translate my signal to the 3v3 range? The ADCs are cheaper and I don't need a level translator.

author: Aodhan145
author_rank: Frequent Contributor
timestamp: August 24, 2018, 01:06:36 am
content: A differential opamp would be a good way to do it but the simplest would just be a potential divider with 2/3 gain.

author: JustMeHere
author_rank: Frequent Contributor
timestamp: August 24, 2018, 02:22:43 am
content: Thanks, I had thought of a potential divider, but Google results came back with people complaining about inaccurate measurements. The responses suggested you had to watch out for not having enough (or maybe too little) impedance? in the low side resistor.Part two is that the datasheet really wants me to buffer and filter their ADC via an opamp.The differential opamp seems like a great approach. I'm worried about about overvolt and really keeping the output at or below 3v3. It seems that if my resistors are spot on, that just won't happen. It will intentionally choose an opamp that can not go rail to rail. My signal never will.

author: DaJMasta
author_rank: Super Contributor
timestamp: August 24, 2018, 03:12:27 am
content: There shouldn't be anything wrong with a simple resistive divider if you plan for the potential pitfalls:Will the temperature of the divider be constant? Are the tempcos of your resistors matched? What tolerance resistors do you need to get an accurate measurement? Can you calibrate the offset in software?How much current can your sensor source? If the source current is very low, maybe the relatively high value resistors required wouldn't be cheap for tight tolerance or would be too high thermal noise.If you can live with reduced dynamic range, you could do a half divider or something instead of a 4.5:3.3 divider and be covered up to 6.6V. You could also use diodes in series, a pair of them could give you a 1.3V drop, but then you'd lose the bottom end of the measurements not being able to overcome the measurement. You could do the opposite and just put in a voltage clamp at 3.3V and lose the top end of the potential measurement, or one of each and get your 0.5V or so diode drop to get the minimum output from the sensor and then a clamp at 3.3V on the ADC side, losing only 0.7V of dynamic range.You could also use your resistive divider and then use a zener clamp on the high side at 5V, so that if the input ever goes beyond what, after division, the ADC can handle, it's dealt with.Opamp circuits can do just fine, but if you can deal with the potential issues with resistors or diodes, then they offer MUCH cheaper design options. Even springing for low tempco 0.5% resistors could be cheaper than an opamp and the associated passives in the design.

author: Zero999
author_rank: Super Contributor
timestamp: August 24, 2018, 12:57:26 pm
content: Quote from: DaJMasta on August 24, 2018, 03:12:27 amI suspect a potential diver is better suited to the job. Diodes have an appalling temperature coefficient and op-amps introduce other errors due to the offset and bias currents.I don't believe the temperature coefficient of resistors is a big deal, since providing they're the same material, they should be reasonably well matched. How many bits is the ADC?Attached are some suggested resistor values to get 5V to 3.3V exactly.

author: IDEngineer
author_rank: Super Contributor
timestamp: August 24, 2018, 04:24:21 pm
content: Quote from: JustMeHere on August 24, 2018, 12:15:37 amNot sure what you're trying to do here. I believe what I'm reading is:* You have a sensor that runs on a 5V rail and emits 0.5-4.5V.* You previously used an A/D that also ran on a 5V rail, so it was able to read the sensor output directly.* Now you want to use an A/D that runs on a 3.3V rail, and you're concerned about 4.5V exceeding the A/D's input voltage limit.Do I have that correct?If so, then if the sensor's output impedance is very high at all, your best approach will be to scale the output of the sensor with a resistor divider and then buffer that with an opamp configured as a voltage follower. This will allow you to control the dynamic range applied to the A/D input AND insure you're driving the A/D with a sufficiently low impedance. Run the opamp on the same supply as the A/D to help insure you don't exceed the A/D's input limits. The values of the resistors in the divider will be controlled by the output abilities of the sensor; the opamp will appear as almost no load to the divider so the divider itself will be the "load" seen by the sensor.If you don't use an opamp buffer, your divider could either 1) present too much of a load to the sensor, or 2) appear as an excessively high impedance to the A/D. You'd also be entirely relying on the sensor to provide the charging current for the S/H cap, and the divider would increase the source impedance from the sensor. All of these problems are eliminated by the use of a divider followed by an opamp buffer.

author: rstofer
author_rank: Super Contributor
timestamp: August 24, 2018, 05:04:23 pm
content: Assuming you want to use an op amp to feed the ADC, you can find everything you want to know about offset and scaling in Chapter 4 of "Op Amps For Everyone" but the short answer to your question is 'yes', you can do it with 4 resistors and an op amp.There is a gotcha when using just a resistive voltage divider in that the input impedance of the ADC can upset the ratio (sometimes this is overcome by putting a capacitor in parallel with the input) and the ADC isn't a constant load (sample and hold). All in, the op amp is a better solution because it doesn't load the divider and it provides a very low impedance source to the ADC.

author: Zero999
author_rank: Super Contributor
timestamp: August 25, 2018, 08:58:48 am
content: Quote from: rstofer on August 24, 2018, 05:04:23 pmI can't believe I didn't consider the load of the potential divider on the source.Yes, an op-amp may be required as a buffer, so the source sees a high impedance. The offset can be removed in software by applying the same voltage (this can be a potential divider running off the supply voltage) to the op-amp and to the ADC, storing it and subtracting the difference from future readings.You're right about the ADC's sample and hold affecting the output voltage of the potential divider. Yes a capacitor can help, at the cost of reduced bandwidth, which won't matter for a DC application