Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 50

Thread: Overvoltage protection when interfacing an op amp to analog input

  1. #1

    Overvoltage protection when interfacing an op amp to analog input

    I'm monitoring the current of a small DC motor by measuring the voltage drop across a low resistance sense resistor in series with the motor and using an op amp to raise that to span the 0 to 3v range. All works fine except I sometimes see spikes as high as 16v appearing on my DVM. I suppose that is due to the fact that DC motors generate some noise. According to the spec sheet, the analog inputs cannot tolerate a voltage greater than 3.3v. My concern of course is that I don't want to fry my Teensy 3.1. So my question is what is the best way to protect the teensy input from overvoltage in this case? Thanks.
    Last edited by Axiom Greg; 09-26-2015 at 09:20 PM.

  2. #2
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,408
    I'd consider a couple of different approaches.

    One is drop the shunt approach and use a current transformer instead. You get galvanic isolation and can put a 3.4V zener on the output to absorb any spikes.
    Another approach could be using a linear opto-isolator like the ones made by Avaya. Not cheap, but you also get isolation.

    IIRC, you may be able to get away with using a simple buffer chip with a 3.3V supply. The outgoing voltage cannot be higher than VCC. However. you may still damage that chip with a VIN that is too high. This approach also does not isolate the Teensy from errant currents.

    You could also use a external ADC that is more tolerant of high voltages, designed for voltage and current measurements, and set up for dealing with associated issues. I happen to like the MCP3910 front end.

    Lastly, the least expensive and simplest approach may be to use a zener diode on the output of your op-amp to eliminate high voltage spikes.

    However, I am not a fan of not isolating the Teensy. For my voltage and current measurements, I rely on a current transformer and voltage transformer. There are obvious drawbacks to this approach besides cost but I like my stuff isolated from high voltages and/or high currents.

  3. #3
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    461
    Actually a current transformer won't work -- it only handles changing current, not DC. There are some similar Hall-effect sensors which do handle DC, but they are expensive.

    A resistor should not generate 16 V spikes across it (even if the motor does generate large spikes), and it is strange that the DVM even picks those up.

    1) Is the resistor in the ground line of the motor ? Connecting it in the supply line is possible, but increases the complexity (and errors) of the opamp circuit.
    2) I would assume that the R is low enough in value that 'normal' currents only generate a few 100 mV across it -- if so, then a normal diode connected in the forward direction would clamp the voltage to < 0.6 V.
    3) Be sure that the 'top' end of the R goes to the op amp circuit's oinput (with a separate wire if necessary directly from the R), and the bottom end of the R goes directly to the opamp's ground. This is called a 'Kelvin connection' and avoids errors which effectively make it appear that the R is a different value than you expect.
    4) Use an opamp in a non-inverting configuration (senseR -> '+' input; R1 from output to '-' input; R2 from '-' input to GND. Wire the opamp GND, bottom of R2, and Teensy GND together. If your sense R dropped (say) 100 mV, then a gain of ~ 10x may be appropriate -- make R1 9k, and R2 1k.
    5) Choose an opamp that has a common-mode range that includes ground (0 V). Most new ones do.
    4.5) power the opamp from the Teensy's 3.3 V supply -- that will avoid overloading the analog inputs.
    6) Be aware that when heavily loaded (or stalled, or just starting up), a motor could draw 10x or more current than when lightly loaded. If you need to track that, then you may not be able to use the values above.
    7) Given that motor behavior is not particularly consistent, and you probably don't need incredible accuracy. Consider eliminating the opamp and just using the inputs from the sense R directly and configure the ADC to use the PGA (internal preamp) suitably. To avoid serious mishaps, do consider using a protection R (1k..10k) from the sense R (which is probably in the 1 ohm range ?) to the ADC input.

  4. #4
    Thanks for your suggestions. I'd like to keep it simple, if I can at this point, so I'm leaning towards using zener diodes for protection. Most likely I would use a pair of 1N4728 (1W 3.3v) zeners back to back. Although I won't non-isolation, hopefully I'll get sufficient protection. Do you think that will work?

  5. #5
    Regarding the DVM reading, I wonder if it's some artifact of the particular meter I'm using (an older Radio Shack "calculator" style DVM). Actually, the spike is on the op amp output (not the resistor) so I figure it's just amplifying the mv level spikes across the sense resistor. I tried it with a different DVM (a cheapo) and didn't see that behavior.

    Yes, the resistor is in the ground line of the motor. It is a .1 ohm resistor. I'm doing "low side" current sensing. So yes, it is generating voltage in the millivolt range which is why I'm using an LM324 Op Amp to get it into the 3 volt range. It is in the non-inverting configuration. I do have the Kelvin connection that you are referring to. Powering the op amp from the Teensy seems like a good idea, I'll have to look into the internal pre-amp (didn't think about that). The 10x current factor is what concerns me. Ideally I'd like to keep the circuit I have and add protection. Also to clarify, I'm looking for overvoltage protection on the output side of the op amp.
    Last edited by Axiom Greg; 09-27-2015 at 01:58 AM.

  6. #6
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    461
    Zeners are diodes with a specific breakdown voltage. So back-back (anti-parallel) won't work as you expect (it'll just look like 2 diodes back-back, or 0.6 V in each direction) -- if you really needed + and - 3.3 V protection, you'd need to use 2 zeners in series with opposite polarity. However, that gives 3.3 + 0.6 V, or +/- 3.9 V protection.

    Since you expect the current to be in one direction only, a single zener would work -- +3.3 V in 1 direction, and -0.6 in the other.

    However, you can't get 3 V across 0.1 ohm without high currents (30 A), so in fact I don't think this is what is causing your spikes, and so zeners or diodes won't prevent that. If you don't power the opamp from 16 V, then it can't generate a 16 V output. If you are powering the motor from 16 V, then use your 3.3 V zener instead to power the opamp (R from 16 V to zener; zener to GND, opamp powered from the junction). Make the R so that you get sufficient current to power the opamp (1 mA would be a guid guess, so (16-3.3)/1k, or about 10k ohm.

    I'd suspect your cheap DVM is switching ranges (200 mV - 2 V - 20 V ?), and giving false results during the switch. See if you can't force a fixed range.

  7. #7
    Ah, the DVM that is giving the strange results is auto-ranging so that may be the culprit and no way to force it to a fixed range with this particular DVM.

    I tried measuring the mv current directly across the sense resistor and didn't see any voltage spikes so I'm beginning to think that it's an artifact of the auto-ranging meter and that there may be no problem with my circuit.
    Last edited by Axiom Greg; 09-27-2015 at 04:39 AM. Reason: new information

  8. #8
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    461
    That circuit will work. However consider that if there really are large spikes, you'll need to protect the opamp's input also.

    I suggest you use 2 back-back diodes (e.g. 1N4148, or 1N914 -- standard, general purpose diodes, or IN4001,2,4,7 if you can't get the others) across your sense resistor, and design the 'normal' voltage across it less than (say) 0.2 V (unless you are operating at very high temperatures inside an enclosure). Then configure the opamp for a gain of 10x or so. The opamp's input won't need much protection if you do use back-back diodes, but a 10k in series with the '+' input won't hurt. Then to prevent the opamp's output from overdriving the ADC input, connect an R between its output and a clamp diode to 3.3 V AREF (as in the diagram). 1-10k would work. Then connect another 1k from that node to the ADC input (this limits the current in case the opamp does drive the diode).

    In theory you also need another R to put a load on the 3.3 V line -- this depends on the Teensy operating mode and how much current it does draw, however the LM324 can't actually drive much above 3.3 V on its output (when using a 5 V supply), so you're probably OK.

    You don't need the lower diode in the diagram -- the opamp's output can't go negative.

    Instead of the diode to 3.3 V, you could use a 3.3 V zener to GND instead.

  9. #9
    Thanks for your analysis, it looks like I can add some safety by using the diode to shunt any overvoltage back to the power rail. I want to point out that I used the same auto-ranging meter across the shunt resistor and saw no spikes at all which makes me think that the circuit may actually work fine as is (and what I'm seeing is an auto-ranging glitch). This is where I think a scope would come in handy. Either way, it won't hurt to have some protection, especially on the output side.

  10. #10
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    329
    For general input protection, I'd use some input resistance and BAT54S diodes, one to the positive rail and one to ground.

  11. #11
    Thanks everyone for the great suggestions. I do have a question regarding the following:

    Then to prevent the opamp's output from overdriving the ADC input, connect an R between its output and a clamp diode to 3.3 V AREF (as in the diagram). 1-10k would work. Then connect another 1k from that node to the ADC input (this limits the current in case the opamp does drive the diode).
    Is the 2nd 1k R there because when the diode is sinking current at a voltage above 3.3, it essentially prevents it from entering the analog input? That being the case, is it better for it to be a higher value than the R used for the diode (in essence a bigger "stopper" just before we reach the input)?

    Thanks.

  12. #12
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    461
    Quote Originally Posted by Axiom Greg View Post
    Thanks everyone for the great suggestions. I do have a question regarding the following:



    Is the 2nd 1k R there because when the diode is sinking current at a voltage above 3.3, it essentially prevents it from entering the analog input? That being the case, is it better for it to be a higher value than the R used for the diode (in essence a bigger "stopper" just before we reach the input)?

    Thanks.
    Yes. When the diode is clamping the opamp's output votlage, the value will be 3.3 + 0.7 V, or 4 V. The 1k then limits the current that can flow into the Teensy's pin to 'reasonable' values. Higher R would be better, but probably not necessary, and v. high values (e.g. 100 k) might noticeably affect the accuracy.

    p.s. I haven't checked -- while the the ADC cannot convert votlages > 3.3 V, I'm not sure if the pin can withstand voltages up to 5 V. If the pin can withstand 5V, then the diode at the output of the opamp is not necessary.

  13. #13
    For the output side here's what I'm thinking (see image). I would use a zener diode with a breakdown voltage of 3.3v and two resistors. I think this would work. If so, then my only question would be whether there is any advantage in making R3 in my diagram a higher value than that of R2 so that when the zener is sinking current, there would be less chance of any making its way into the analog input.

    Click image for larger version. 

Name:	Image.png 
Views:	169 
Size:	12.0 KB 
ID:	5184

    (BTW, my understanding is that the analog inputs on the Teensy 3.1 that are part of the GPIO are 5v tolerant. The others which are "pure" analog inputs are not.)
    Last edited by Axiom Greg; 09-30-2015 at 07:11 PM.

  14. #14
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    461
    OK -- if the Teensy's inputs are 5 V tolerant, then you don't need any protection on the output of the opamp -- since it is powered from the 5 V supply, it cannot overdrive teh Teensy's inputs.

    if you are using the circuit above, you need to connect R3 to the junction of R2 and the zener -- the way it is now, the zener won't clamp the opamp's output. Note however, that low V zeners (those below 5.1 V) are 'soft', so leak some current even below 3.3 V. This current will flow in R2, thus the signal seen by the ADC won't be exactly the opamp's output. You could fix this by connecting R2 in series with the opamp's output instead:

    Click image for larger version. 

Name:	Capture1.PNG 
Views:	179 
Size:	17.7 KB 
ID:	5187Click image for larger version. 

Name:	Capture2.PNG 
Views:	244 
Size:	22.0 KB 
ID:	5188

  15. #15
    Thanks for the clarification. I'm still not clear on why the position of R2 matters in this case (I thought the resistor was simply there to limit current flowing through the zener), but the way you've drawn it with the zener at the junction seems typical for zener limiters.

    As you point out though, this may be overkill if the input can handle 5v.

  16. #16
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    461
    Yes, R2 does limit the current through the zener -- but the zener is there to protect the downstream circuits.

    Basically, when the opamp output is < 3.3 V, the zener does nothing (it acts like an open circuit), and the voltage at the end of R2 is the same as the opamp's output. When the opamp is > 3.3 V, the zener limits the voltage at it to just 3.3 V; thereby protecting (if needed) the downstream circuits.

    R2 does limit the current in the zener (else, the opamp could drive an arbitrarily high current into the zener, and while the zener would 'win', the overall behavior would not be desirable).

  17. #17
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    993
    This is interesting, i wonder if the adc using the 1.2V internal reference be able to handle 5V?

    This might help also http://www.digikey.com/en/articles/t...al-electronics

  18. #18
    Thanks for the link. So I believe the reason that the zener has to be at the junction between the two resistors as opposed to having the first resistor (R2) inline with it (as I had drawn it) is because that would create a higher impedance path to the zener than to the analog input and thus the zener wouldn't conduct when it needs to. However if R3 were of a higher value than R2, I would have thought the zener would conduct before overloading the input and that would be OK.

  19. #19
    Senior Member
    Join Date
    Sep 2013
    Location
    Sonoma County, CA
    Posts
    141
    Quote Originally Posted by Axiom Greg View Post
    Thanks for the link. So I believe the reason that the zener has to be at the junction between the two resistors as opposed to having the first resistor (R2) inline with it (as I had drawn it) is because that would create a higher impedance path to the zener than to the analog input and thus the zener wouldn't conduct when it needs to. However if R3 were of a higher value than R2, I would have thought the zener would conduct before overloading the input and that would be OK.
    The reason that the zener needs to be at the junction of the two resistors is because the zener only regulates the voltage across its terminals, so the input of R3 will not go above 3.3V.

    In the original diagram, the input of R3 is tied directly to the output of the opamp, so it will always be at that potential, no matter how much current the zener pulls.

    It may be helpful to model the circuit using a simple voltage source for the opamp. The zener can be modeled as a 3.3V source when it is conducting, and an open when it is not (it will start conducting when the opamp output voltage is >3.3V). The input of the microcontroller can be modeled as an open or very high impedance. It's a very rough model, but it will show you the difference between the two schemes.

  20. #20
    That explanation makes sense and helps a lot, thanks. The only part that I'm unclear on is why the zener can be modeled as a 3.3v source when it's conducting. I would think that when it's conducting, it would be modeled as a short circuit between R2 and ground since its internal resistance is close to zero at that point.

  21. #21
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    461
    Think of a zener as a device that clamps the voltage from going above 3.3 V -- it does this by conducting enough current to keep the voltage low. When the voltage is less than 3.3 V, it doesn't conduct anything (open circuit).

    While you may think of a voltage source as a battery -- and only supplying current, imagine the zener as a battery being charged (and consuming current) -- while being charged, the voltage between the terminals will be (roughly) constant.

    In some sense it acts as a short between R2 and GND, but it's probably better to imagine it as a battery being charged when the current is positive into it, and as an open circuit otherwise. Yes, its internal impedance is low, but this doesn't make it a short circuit in the same way as a wire would be -- think of it as a battery that can only be charged !

  22. #22
    OK, that makes sense since the zener conducts in such a way as to maintain approx. 3.3v across its terminals. Because of that behavior it's really not a true "short", I don't think I can easily model/analyze this circuit by reducing it to equivalent components.

    jp3141, regarding what I've been referring to as "R3", you wrote:

    (this limits the current in case the opamp does drive the diode)
    I'm wondering if R3 is really necessary since the analog input already provides a high impedance input (e.g. 20 megohms). It appears to me that R3 would just be adding a very slight value to that. In the link below they are not showing a resistor downstream of the junction.

    http://www.mosaic-industries.com/emb...ion/atd-inputs

    What do you think?
    Last edited by Axiom Greg; 10-02-2015 at 01:37 PM.

  23. #23
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    461
    I haven't had time to look into the details of Teensy's input pin. If it is capable of withstanding 5 V, then neither the zener or R2, R3 are really necessary (if the opamp is also only powered from 5 V). If it is only rated at 3.3 V, then -- while it might be 20 Mohm for inputs between 0 and 3.3 V -- it may have internal components (diodes) that mean that if the V is above 3.3, there are additional current paths. Note that there really isn't a 20 Mohm resistor in the circuit, just that's the effective value of some of the circuits.

    Notwithstanding all this, there could be some cases where the zener and R2,3 are still necessary -- when powering up and down the system, it is possible that the opamp is powered up before the Teensy, and equally remains powered after the Teensy. This can also create incorrect voltage conditions, and the zener etc. will protect that.

    The relative importance of these details depends on if you are just making a 1-off circuit for your own use, or intending to make many for use by unsuspecting users.

  24. #24
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,490
    Quote Originally Posted by Jp3141 View Post
    I haven't had time to look into the details of Teensy's input pin. If it is capable of withstanding 5 V, then neither the zener or R2, R3 are really necessary (if the opamp is also only powered from 5 V). If it is only rated at 3.3 V, then -- while it might be 20 Mohm for inputs between 0 and 3.3 V -- it may have internal components (diodes) that mean that if the V is above 3.3, there are additional current paths. Note that there really isn't a 20 Mohm resistor in the circuit, just that's the effective value of some of the circuits.
    If memory serves, the Teensy 3.0 and LC are not 5v safe at all. The Teensy 3.1/3.2 analog input pins that can be used for digital input/outputs, can tolerate 5v input. Note that any voltage that is over 3.3v will read as 3.3v. The analog only pins (A10-A14) are not 5v safe, and you must clamp the input to 3.3v.

  25. #25
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    993
    Teensy 3.1/2
    https://www.pjrc.com/teensy/K20P64M72SF1.pdf


    1. All 5 V tolerant digital I/O pins are internally clamped to VSS through a ESD protection diode. There is no diode connectionto VDD. If VIN greater than VDIO_MIN (=VSS-0.3V) is observed, then there is no need to provide current limiting resistors at the pads. If this limit cannot be observed then a current limiting resistor is required. The negative DC injection currentlimiting resistor is calculated as R=(VDIO_MIN-VIN)/|IIC|.
    2. Analog pins are defined as pins that do not have an associated general purpose I/O port function.
    3. All analog pins are internally clamped to VSS and VDD through ESD protection diodes. If VIN is greater than VAIO_MIN(=VSS-0.3V) and VIN is less than VAIO_MAX(=VDD+0.3V) is observed, then there is no need to provide current limiting
      resistors at the pads. If these limits cannot be observed then a current limiting resistor is required. The negative DCinjection current limiting resistor is calculated as R=(VAIO_MIN-VIN)/|IIC|. The positive injection current limiting resistor iscalculated as R=(VIN-VAIO_MAX)/|IIC|. Select the larger of these two calculated resistances.
    Teensy LC
    https://www.pjrc.com/teensy/KL26P64M48SF5.pdf

    1. All I/O pins are internally clamped to VSS through a ESD protection diode. There is no diode connection to VDD. If VIN greater than VIO_MIN (= VSS-0.3 V) is observed, then there is no need to provide current limiting resistors at the pads. Ifthis limit cannot be observed then a current limiting resistor is required. The negative DC injection current limitingresistor is calculated as R = (VIO_MIN - VIN)/|IICIO|.
    2. Open drain outputs must be pulled to VDD.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •