Teensy 3.6 ADC voltage limits increasing with external circuits

Status
Not open for further replies.

128ITSH

Active member
Hello everyone,
My current project with the T3.6 is a basic oscilloscope, and because the ADC's are only capable of 0V-3.3V measurement, I wondered how I can step down higher (and lower) voltages like ±12. My first thought was using op-amps even though I don't understand them fully yet, but playing with them in an online simulator gave me this circuit:
adc input.png

The first op amp is stepping down the voltage in the inveting configuration, according to R5 which can be a 10k digital potentiometer controlled by the teensy.
for example:
5V-->3.3V
A(gain) = Vout/Vin
A = -3.3/5 = -0.66
A = -Rf/Rin
Rin = 10000
-0.66 = -Rf/10000
Rf = 6600
R5 = 6600Ω.
The second op amp inverts the signal back and (optionally) applies a 1.65V (3.3/2) dc offset so AC can get measured too. This makes the 0V point of the input to appear as 1.65V at the output. (not sure why the voltage at the non-inverting input should be 0.825V (3.3/4) and not 1.65V for this offset to occure, but it seam to work this way).
All of the control over this can be implemented in software, but I have two questions yet:
1. Is this circuit bandwidth-friendly? The sampling rate I'm getting out of the teensy is ~800msps, which means I would like this circuit to "tolerate" around 1mhz bandwidth (at least).
I am not sure what are the calculations for the max bandwidth in op amps, so I will be glad if you help me here!
2. What input protection should I add to the ADC input? for example if R5 is set for 12V-->3.3V but a 24V signal is accidentaly apllied, the ADC input voltage will be 6.6V!
I've read about different types of input protections, but not sure which is the best for this scenario, since bandwidth is critical and I don't want to use a method that will block lower-than-1mhz frequencies.

Hope I was clear enough (tell me if not),
128ITSH
 
First & most important, the Teensy 3.6 pins must not be driven with voltage below ground or higher than ~3.3V. Doing so would risk damage to the chip.

Opamps with +/- 15V power supply are a terrible risk. Even if your circuit keeps its output within the allowed 0-3.3V range under normal conditions, consider what may happen during startup or shutdown. This sort of circuit is very likely to damage your Teensy.

If you're going to use this circuit with a standard 10X oscilloscope probe, you'll probably want to model the probe's 9M resistor in your simulation. Maybe even model the prope's variable capacitor and the cable's characteristic impedance. I'm pretty sure you'll quickly discover that 10K input impedance could be an issue.
 
Thanks for your quick replay!
I know about the teensy's limitation, that is why I created this circuit.
The reason I used a 15V power supply is because op amp inputs must stay within the rails, so If I supply it with 3.3V and GND , the input voltage will have to be between them.
Does adding another (rail to rail) op amp in a buffer configuration before the output, with 3.3V and GND rails solve this problem?
Does lowering that 10k resistor help me get a better bandwidth?
I must admit I don't understand all of this input/output impedance stuff, so please be easy with me.
 
Hi 128-

Rather than jumping straight into op amps, why not start with your requirements and work up to what you need?

Sounds like you want to match a range of ±12V (24V total span) to the 0-3.3V range of the ADC. As Paul suggests, you may also want your circuit to work with a standard 10x oscilloscope probe. This means your input should "look like" a 1 Megohm resistance to ground from the outside (in parallel with about 20 picofarads capacitance; we can come back to that later). So, (1) you want 3.3/24ths of the input voltage to appear at the ADC pin; and (2) the total resistance should be 1 Meg.

Start with a 2-resistor divider: draw a resistor R1 from the ADC pin to ground, and another R2 from your input to the ADC pin.

From (2) you then just need R1+R2 = 1 Meg (we are going to assume the ADC has a very high resistance, much higher than 1M).

Then from (1) you want xxR2/(R1+R2)xx R1/(R1+R2)= 3.3/24. You should check my math, but I believe this gives you R1 = 137.5 kOhms. You will have to round off to available R values, and if you need precision, you may need to include a trimming potentiometer (as you have in your opamp circuit). Remember, though, that
this is going into a micro controller; it's almost always better/faster/cheaper to trim and calibrate digitally.

But you wanted ±12V, centered at zero, whereas the ADC can only see 0 to +3.3V. So let's add half of 3.3V to the answer. One way is to split R1 into equal parts, say R1A = R1B = 2* R1 (275 kOhms each in this example), and connect one end to ground, and the other end to the 3.3VDC supply.

The divider still works in the 24:3.3 ratio, as "in parallel" it's still the same value; but your reference (corresponding to "0V" at your input) is now centered halfway up the ADC range.

Depending how fast your signals are, this might be enough. But if you are looking for fast response (say, audio or faster), it won't perform that well. First, with the scope probe you do need to add the 30 pF or so the probe expects to see; this will compensate the capacitance across the probe, which is trimmed to make the ratio of C's and the ratio of R's match.

The other problem is the ADC; such a high impedance input circuit (over 100 kOhm) will slow down settling of the ADC input, due to its own input capacitance (maybe 10 pF or so). I believe, to reach rated conversion speed, your ADC wants to be fed by something less than 5 or 10 kOhms.

So again, look at your requirements. If you need speed, can you sacrifice input impedance? If your oscilloscope project can have, say, 10 kOhms input, instead of 1MOhms, then just reduce all the R values above by 100x.

Otherwise, if you need both speed _and_ high input impedance, you might need an opamp after all. Good place to start (and what is actually used in real oscilloscopes) is simply a x1 buffer between the above moderately high-impedance junction of R's, and your ADC pin. This will just copy the signal, but with a very low output impedance able to quickly satisfy the ADC's thirst.

You might even be able to use a "rail-to-rail" opamp (e.g., LT1366) that can accept and deliver voltages right up to its own supply rails. Then you could maybe use the 3.3V supply from the Teensy without adding an external supply.

Hope this helps!

mike
 
Last edited:
Thanks for your help!
I understand that using op-amps may be an overkill for this purpose, but I kinda lost you in the resistor divider explanation. which is R1 and which is R2? solving the formula will give
R2 = 137.5k , not R1, and I am not sure where should I put the 3.3V and ground, so I would be happy if you can make a schematic for that.
I would like to have a bandwidth of around 200khz supported. Will this resistor divider solution work? I think I need the high input impedance for the scope so it won't drop the voltage of the source and the fast convertion rate of the ADC, so the Op-Amp buffer is probably needed.
just to mention, I did considered the lower voltage limit of the adc (0V), and for this is the voltage offset (0.825V) which can be selected with S1.
 
Good catch, hadn't had my coffee! So you did check my math, awesome ;^)

I edited #4.

Not sure how to draw a readable picture in here, the editor mangles ascii graphics. Let's try a cell phone picture.

IMG_3479.JPG


First example A (where R1 ~ 137k, and R2 ~ 863k) and then, to fix the DC offset problem, example B (where R2 is still 863k, and R1A = R1B = 275k each).

But for that bandwidth, yes you may need a buffer (C). I noticed your original has 10k input impedance, if that was really acceptable it really is perhaps as easy as the three resistors. But if you need the buffer, this would just go between the junction of the three resistors and the ADC pin. You'll also likely need to compensate the capacitance of a probe (if used), and maybe also the input C of the buffer.

BTW another opamp to consider might be LTC1638 (1 MHz dual, micro power, rail to rail in/out).

In each case (with or without a buffer), the Teensy is protected by either a) having a large series resistance, so very little current can pass into the ADC pin if there's an over/undervoltage, or b) restricting the voltage swing to the allowed input range. As Paul indicates, if you do use an amplifier with higher supply rails, you should add additional circuitry to insure one or both conditions are satisfied.
 
Thanks for the clarification, However in the simulator, if I apply a sine wave to the input of this circuit with 12V and -12V peaks, the result is a sine wave with 3.07V to -225mV peaks:
resistor adc.png
Maybe I interpreted your description wrong.
Edit:
Saw your picture now, Should I check your math again?:rolleyes:
maybe the dc offset should be implemented in the op-amp instead? this however will require a -3.3V rail which may be problematic
 
Wow... I feel so dumb now that I am designing op-amp circuits but can't even analyze this simple 3 resistor circuit... looking at it for an hour and I can't figure out whats happening there. even after changing all R's to 1 ohm, Vcc to 1V, and Vin to 3V I'm getting 1.33V at the output and have no freaking idea why. Please guide me through this.
 
OK 128, no worries. Suppose you allow the pair R1A and R1B to be not quite equal anymore. In fact, suppose they're the two legs of a potentiometer, and the ADC node is the wiper (close to the middle, but variable). Tweaking the ratio R1A:R1B a little will change the DC bias point a bit, no? Shouldn't take much to cancel out your 225 millivolts.

Of course you can play with this in your simulation. However a good trick to think about it (or any mess of resistors and voltage sources) is to make the Thevenin equivalent for each piece.

I suggest looking at any edition of Horowitz and Hill (e.g., https://archive.org/details/TheArtOfElectronics-2ndEdition , page 11) if this concept is unfamiliar (in which case congratulations, you're in for an "AHA!" rush!).

For example, let's combine R1A and R1B and the DC supply Vcc. With Vin and Vout left open, the equivalent Thevenin voltage Vth = Vcc * R1B/(R1A+R1B) (I think I put R1B on the bottom in that diagram) But if you now short Vout to ground, the current that flows will be Ith = Vcc/R1A; so the Thevenin resistance of that part of the circuit must be Rth = Vth/Ith = R1A*R1B/(R1A+R1B) = R1A || R1B. (Which is kind of convenient, because remember we already chose R1A || R1B to equal the old R1, to make the correct divider ratio with R2; we thus know what it should be).

Now the whole circuit looks like just 2 series resistors (R2 and Rth = R1A || R1B). Your input goes to R2 as before, the Thevenin equivalent voltage source Vth connects (like a battery) to the far end of Rth, and the center junction between Rth and R2 goes to the ADC.

From here it shouldn't be too much work to find that, for your ADC to see Vcc/2 when Vin = 0V, R1B needs to be about 38% bigger than R1A (again, check my math! my 'simulator' is old, grey mush!!).

If you are super OCD, you can then scale the 2 resistors by a bit to continue exactly satisfying the other 2 constraints; and then, develop series/parallel combinations to make up the exact R values you calculated from available stock values. Taking account, of course, of each resistor's temperature coefficient... blah blah blah...

OTOH, if you are like me, you will dig up 10k, 3.3k and a 2.4k resistors (5% values many folks would have on hand), hook up your Teensy, and get on with the fun part.

Cheers,

zike
 
Thanks for this help! I was in a real "AHA!" rush, since I have never heard about this Thevenin theory, and It helped me to solve this.
Firstly, the 2 resistors divider equation:
CodeCogsEqn.png
(difference in voltage X resistor divider formula)
Then I can plug R1A and R1B instead of their Thevenin equivalents:
CodeCogsEqn (2).png
And then plug Vout = Vcc/2 and Vin = 0, and after playing with the math I get R1B/R1A = ~1.38
I want to thank you again for this guidance, learned a lot from it in the last days!
 

Attachments

  • CodeCogsEqn (5).png
    CodeCogsEqn (5).png
    974 bytes · Views: 550
  • CodeCogsEqn (1).png
    CodeCogsEqn (1).png
    1.6 KB · Views: 83
Status
Not open for further replies.
Back
Top