Author Topic: Read 5v analog with 3v3 ADC and a differential opamp?  (Read 2527 times)

0 Members and 1 Guest are viewing this topic.

Offline JustMeHereTopic starter

  • Frequent Contributor
  • **
  • Posts: 918
  • Country: us
Read 5v analog with 3v3 ADC and a differential opamp?
« on: August 24, 2018, 12:15:37 am »
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.00

I'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.   
 

Offline Aodhan145

  • Frequent Contributor
  • **
  • Posts: 404
  • Country: 00
Re: Read 5v analog with 3v3 ADC and a differential opamp?
« Reply #1 on: August 24, 2018, 01:06:36 am »
A differential opamp would be a good way to do it but the simplest would just be a potential divider with 2/3 gain.
 

Offline JustMeHereTopic starter

  • Frequent Contributor
  • **
  • Posts: 918
  • Country: us
Re: Read 5v analog with 3v3 ADC and a differential opamp?
« Reply #2 on: August 24, 2018, 02:22:43 am »
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.
 

Offline DaJMasta

  • Super Contributor
  • ***
  • Posts: 2470
  • Country: us
    • medpants.com
Re: Read 5v analog with 3v3 ADC and a differential opamp?
« Reply #3 on: August 24, 2018, 03:12:27 am »
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.
« Last Edit: August 24, 2018, 03:14:17 am by DaJMasta »
 
The following users thanked this post: Mr. Scram

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22437
  • Country: gb
  • 0999
Re: Read 5v analog with 3v3 ADC and a differential opamp?
« Reply #4 on: August 24, 2018, 12:57:26 pm »
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.
I 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.
« Last Edit: August 24, 2018, 01:03:03 pm by Hero999 »
 

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1978
  • Country: us
Re: Read 5v analog with 3v3 ADC and a differential opamp?
« Reply #5 on: August 24, 2018, 04:24:21 pm »
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.00.
Not 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.
« Last Edit: August 24, 2018, 04:26:59 pm by IDEngineer »
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 10088
  • Country: us
Re: Read 5v analog with 3v3 ADC and a differential opamp?
« Reply #6 on: August 24, 2018, 05:04:23 pm »
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.
 
The following users thanked this post: JustMeHere

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 22437
  • Country: gb
  • 0999
Re: Read 5v analog with 3v3 ADC and a differential opamp?
« Reply #7 on: August 25, 2018, 08:58:48 am »
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.
I can't believe I didn't consider the load of the potential divider on the source. :palm: 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
 
The following users thanked this post: JustMeHere


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->