Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to accurately sample 0-6V with 0-3V ADC?

Status
Not open for further replies.
If you have a good inamp, programmable for a gain of 1, you can connect its output to its (-) input and the gain becomes 1/2. The precision resistors, high linearity, and low drift are built in.


View attachment 70566


Hi ccurtis, I've been having some trouble with the instrumentation amplifier circuit you suggested - oscillating on me. I've been doing some measurements using your inamp suggestion as a divide-by-two circuit. The accuracy is definitely there, but I'm running into a pretty big problem that the output starts oscillating. I'm using your circuit and going straight into the analog input pin of my microcontroller. The microcontroller that I'm using calls for .01uF caps to be placed as close to the inputs as possible, and when that capacitor is present, I get some pretty bad high frequency oscillation when my input voltage crosses a certain point. As soon as I pull that capacitor, the oscillation goes away. The oscillation happens whether or not the microcontroller is powered up and running.

The measurements from the microcontroller are a lot better with that capacitor present though, so I'd like to keep it in. No clue why it's oscillating though... is there anything you can suggest?

Just to see, I placed a small resistor (10 ohm) between the output of the inamp and the microcontroller and capacitor and the oscillation went away almost completely, but still gets triggered as the inamp input voltage gets high enough.

Any suggestions? I can post the complete schematic, but it's basically an op-amp feeding 0-6V DC going straight into the instrumentation amplifier divide-by-two circuit.
 
Hi. Glad to see it works more or less in the real world. A few questions:

1. Are there pulses or noise spikes present at the input of the inamp? If they are present, the inamp may not respond fast enough to them, resulting in oscillations at the output. A capacitor at the output of the inamp can exacerbate the oscillations by slowing the response of the inamp even further. In this case, suggest putting a .01uF capacitor from inamp input to ground with 2K resistor between op amp output and inamp input. Additional filtering can be placed before the input of the op amp.

2. Are power supply bypassing capacitors used directly at the inamp and microcontroller? If not, suggest adding them, regardless of the specific cause of the oscillation.

3. What is the p-p amplitude of this oscillation? Is the amplitude constant when present, or is it periodically varying in amplitude?

4. How many .01uF capacitors are you using at the output of the inamp?

Edit: In simulation, a .01uF cap at the output of the inamp causes 250 mV of oscillation at the output with a clean 6V input. A cap .005uF or larger results in oscillation. Not a good idea to put a capacitor that large there. It is apparently causing a phase shift large enough to create an oscillator. If a cap at the input to your ADC is necessary then I suggest a buffer op amp, selected for very low input offset voltage and high load capacitance capability. Alternatively, you can try putting a 120nF cap in series with a 27 ohm resistor connected from the inamp output to ground (i.e., the series combination connected in parallel with the .01uF load capacitor) to compensate somewhat for the .01uF load capacitor. That works in simulation and will not decrease DC accuracy.
 
Last edited:
Hi. Glad to see it works more or less in the real world. A few questions:

1. Are there pulses or noise spikes present at the input of the inamp? If they are present, the inamp may not respond fast enough to them, resulting in oscillations at the output. A capacitor at the output of the inamp can exacerbate the oscillations by slowing the response of the inamp even further. In this case, suggest putting a .01uF capacitor from inamp input to ground with 2K resistor between op amp output and inamp input. Additional filtering can be placed before the input of the op amp.

At the input of the inamp, the noise is only about 5mvpp and I don't see any spikes on my scope.

2. Are power supply bypassing capacitors used directly at the inamp and microcontroller? If not, suggest adding them, regardless of the specific cause of the oscillation.

This is just built up on breadboard right now. But in the final design there will be of course. I did add them directly to the breadboard when I was trying to solve the oscillation, but they didn't help.

3. What is the p-p amplitude of this oscillation? Is the amplitude constant when present, or is it periodically varying in amplitude?

The oscillation is .6Vpp and has a period of 3 uS with a rough sine shape. As the inamp output approaches about 2.5V (5V input) there's another oscillation that happens even without the .01uF capacitor - .2Vpp and a period of 1mS.

4. How many .01uF capacitors are you using at the output of the inamp?

I am just using a single .01uF capacitor at the output. As soon as I pull that out, the high frequency oscillation goes away.

Edit: In simulation, a .01uF cap at the output of the inamp causes 250 mV of oscillation at the output with a clean 6V input. A cap .005uF or larger results in oscillation. Not a good idea to put a capacitor that large there. It is apparently causing a phase shift large enough to create an oscillator. If a cap at the input to your ADC is necessary then I suggest a buffer op amp, selected for very low input offset voltage and high load capacitance capability. Alternatively, you can try putting a 120nF cap in series with a 27 ohm resistor connected from the inamp output to ground (i.e., the series combination connected in parallel with the .01uF load capacitor) to compensate somewhat for the .01uF load capacitor. That works in simulation and will not decrease DC accuracy.

I'll try these things for sure and get back to you, thank you ccurtis.
 
The oscillation is .6Vpp and has a period of 3 uS with a rough sine shape. As the inamp output approaches about 2.5V (5V input) there's another oscillation that happens even without the .01uF capacitor - .2Vpp and a period of 1mS.

The oscillation at 2.5V input without the .01uF cap is difficult for me to explain assuming all the usual steps of proper bypassing are in place, short leads, and good routing. Hmmmm.

I'm puzzled for the need of the .01uF capacitor at the output of the inamp if the microcontroller you are using is the Freescale model in the link you gave previously. In the datasheet for that micro, page 37, it specifically states (for reason unknown to me) that the R/C time constant of the output resistance of the source (80 ohms at 300KHz for the inamp) and the output capacitance of the source (added .01uF cap) should be less than 1nS, which it is NOT. Based on that, if the .01uF cap is for filtering the 5mV of noise you mentioned at the input of the inamp, you should do the filtering between the op amp buffer and the input of the inamp (as a described in my last post) instead of the output of the inamp, and/or before the input to the op amp buffer, and forgo the .01uF at the output of the inamp. Then, it's not clear if the note in the datasheet means Rs/Cs as a division operation, or the "time constant" which is Rs*Cs.

Something curious is that the datasheet for the micro gives an input resistance of 2Kohm typical, but in figure 10 that resistance is shown in series with the input of an "ADC SAR Engiine", the input current of which is not specified.

I'm interested in how your experiments work out, in any case.
 
Last edited:
Hi

How about this?
+/-6v in, 3v out with 3v bias.

eT
 

Attachments

  • 6v-3v-scaler.png
    6v-3v-scaler.png
    63.2 KB · Views: 104
The oscillation at 2.5V input without the .01uF cap is difficult for me to explain assuming all the usual steps of proper bypassing are in place, short leads, and good routing. Hmmmm.

I'm puzzled for the need of the .01uF capacitor at the output of the inamp if the microcontroller you are using is the Freescale model in the link you gave previously. In the datasheet for that micro, page 37, it specifically states (for reason unknown to me) that the R/C time constant of the output resistance of the source (80 ohms at 300KHz for the inamp) and the output capacitance of the source (added .01uF cap) should be less than 1nS, which it is NOT. Based on that, if the .01uF cap is for filtering the 5mV of noise you mentioned at the input of the inamp, you should do the filtering between the op amp buffer and the input of the inamp (as a described in my last post) instead of the output of the inamp, and/or before the input to the op amp buffer, and forgo the .01uF at the output of the inamp. Then, it's not clear if the note in the datasheet means Rs/Cs as a division operation, or the "time constant" which is Rs*Cs.

Something curious is that the datasheet for the micro gives an input resistance of 2Kohm typical, but in figure 10 that resistance is shown in series with the input of an "ADC SAR Engiine", the input current of which is not specified.

I'm interested in how your experiments work out, in any case.

Hi ccurtis,

I've spent most of the night experimenting with the circuit. I think some of the problems might be from my prototyping set up (lots of pretty long wires on a breadboard). I added an RC low-pass filter on the input of the inamp with a 10K resistor and .1uF capacitor. My input signal is mainly DC with at most 20Hz oscillations. That cleaned up a lot of the noise at the input. I also added a 1K resistor in series with the output of the inamp . Both of those things seemed to stop the two different high frequency oscillations that were happening under different conditions, and it all seems to play nice with the .01uF capacitor at the microcontroller input to keep it happy.

I'm concerned that the 1K resistor before the microcontroller input would throw off the measurements though if the input impedance was 2K as you mentioned, but it seems like the microcontroller's input impedance goes quite high when the microcontroller is powered up. My meter measures it as totally open (greater than 10M?) but only about 200K when not powered up. Maybe because the microcontroller is on it's own power source with it's own ground, and the inamp and everything else (reference voltage, etc) is only connected through the voltage reference low/ground input? no clue.. but everything still scales fine!
 
Hi ccurtis,

I've spent most of the night experimenting with the circuit. I think some of the problems might be from my prototyping set up (lots of pretty long wires on a breadboard). I added an RC low-pass filter on the input of the inamp with a 10K resistor and .1uF capacitor. My input signal is mainly DC with at most 20Hz oscillations. That cleaned up a lot of the noise at the input. I also added a 1K resistor in series with the output of the inamp . Both of those things seemed to stop the two different high frequency oscillations that were happening under different conditions, and it all seems to play nice with the .01uF capacitor at the microcontroller input to keep it happy.

I'm concerned that the 1K resistor before the microcontroller input would throw off the measurements though if the input impedance was 2K as you mentioned, but it seems like the microcontroller's input impedance goes quite high when the microcontroller is powered up. My meter measures it as totally open (greater than 10M?) but only about 200K when not powered up. Maybe because the microcontroller is on it's own power source with it's own ground, and the inamp and everything else (reference voltage, etc) is only connected through the voltage reference low/ground input? no clue.. but everything still scales fine!

Fine business. It seems the input resistance into the ADC pin is much higher than the datasheet seems to imply, and that the internal 2K ohm resistor is only important in conjunction with the internal capacitance if higher frequency AC is being measured by the ADC. It still seems odd to me why you need/want the .01uF cap at the input of the microcontroller, unless you are looking for rock stable digital conversion to the lowest significant bit. It causes instability in the inamp without compensation/isolation (resistor). Yep, one can't be too careful with layout/bypass considerations. Thanks for the feedback.
 
Fine business. It seems the input resistance into the ADC pin is much higher than the datasheet seems to imply, and that the internal 2K ohm resistor is only important in conjunction with the internal capacitance if higher frequency AC is being measured by the ADC. It still seems odd to me why you need/want the .01uF cap at the input of the microcontroller, unless you are looking for rock stable digital conversion to the lowest significant bit. It causes instability in the inamp without compensation/isolation (resistor). Yep, one can't be too careful with layout/bypass considerations. Thanks for the feedback.

Thanks ccurtis, I really appreciate the help. The .01uF cap at the microcontroller definitely helps with conversion, having ran some tests both with it and without it. I'm definitely looking to get some accurate measurements here... 14 bits of usable data would be great for this application from this 16 bit ADC.
 
Status
Not open for further replies.

Latest threads

Back
Top