Opamp inputting to microcontroller - Page 1
Forum section: electronics / beginners

author: Faringdon
author_rank: Super Contributor
timestamp: September 05, 2023, 05:46:05 am
content: Hi,We have an opamp buffer which has Vcc of -3v to 20v. Its non-inv input is always positive.Its output connects directly (no series resistor) to a micro pin, whose rail is 0v to 3v3.Is there any chance, during startup, or whatever, that the opamp could output the negative rail into the micro pin?

author: djsb
author_rank: Super Contributor
timestamp: September 05, 2023, 06:03:26 am
content: Test it on a breadboard and find out for yourself.

author: Gyro
author_rank: Super Contributor
timestamp: September 05, 2023, 11:25:21 am
content: Quote from: Faringdon on September 05, 2023, 05:46:05 amTroll Treez question! What kind of idiot would feed the output of a -3V/+20V supply opamp into a 3V3 micro input with no current limiting!

author: Doctorandus_P
author_rank: Super Contributor
timestamp: September 05, 2023, 12:22:29 pm
content: Quote from: Gyro on September 05, 2023, 11:25:21 amThis would indeed be quite silly to do. You risk SCR latchup of your microcontroller or other nasty things.But the question is still good to ask though, and the answer is simple: Just don't do it, even when it seems to work while testing on your bench.There are application notes for mains voltage zero crossing detection with a microcontroller by just connecting a series resistor to a microcontroller pin (Watch it's voltage rating). Microchip did this 20 to 30 years ago. Atmel followed 10+ years later, and now they are one company again. Other uC manufacturers may have similar application notes.uC datasheets are very sparse about specification of the internal ESD protection. I have seen one reference that wrote that a 2mA (DC) injection current into an I/O pin is safe. From another manufacturer I once saw 4mA specified. Some datasheets also specify a maximum current for which SCR latchup is guaranteed to not occur, but those specifications are probably for a short current burst (which is probably good enough for you).

author: tggzzz
author_rank: Super Contributor
timestamp: September 05, 2023, 12:41:31 pm
content: Quote from: Faringdon on September 05, 2023, 05:46:05 amAnother asinine Faringdon/Treez question. What a surprise!For a start he couldn't even be bothered to phrase the first sentence in an unambiguous way. So the "Vcc is -3v to 20v". What's the opamp's other supply pin's voltage range?Then he couldn't even be bothered to define the circuit. So what if the non-inv pin is always positive? That's only a small part of the necessary information.Finally he couldn't be bothered to define the opamp or micro. Details matter.And he couldn't even be bothered to try it himself.

author: tggzzz
author_rank: Super Contributor
timestamp: September 05, 2023, 12:51:56 pm
content: Quote from: Doctorandus_P on September 05, 2023, 12:22:29 pmWould you agreeTMthat it is a strange question from a professional engineer with several decades experience in many companies?Would you agreeTMthat it is strange to post the question in the "Beginners" section?

author: langwadt
author_rank: Super Contributor
timestamp: September 05, 2023, 01:00:44 pm
content: Quote from: Doctorandus_P on September 05, 2023, 12:22:29 pmquite few ICs fpga/mcu/logic used to specify several mA in both directions via the ESD diodes, but now many MCU have 5V tolerant input have zener like ESD protection and specify that you are not allowed to inject current

author: Faringdon
author_rank: Super Contributor
timestamp: September 05, 2023, 07:25:10 pm
content: Thanks, its as in the attached......to see what is the situation that could cause the negative output into the micro?LTspice and jpeg attached.I guess its deemed that noise at startup will make inv greater then non-inv and itll go output to the negative rail?...the actual opamp is the Texas one....TL084C...not the LT1006

author: magic
author_rank: Super Contributor
timestamp: September 05, 2023, 08:23:08 pm
content: There is only one right answer:Omitting that resistor will still not make your product cheaper than those imported from China, so do it rightKnowing TL084, its output may very well shoot up to +20V if the negative rail is too slow to start or dead altogether.

author: Manul
author_rank: Super Contributor
timestamp: September 05, 2023, 08:40:00 pm
content: If V2 is PWM, can I ask why you deside to use op amp in the first place? If the signal is binary in it's nature, I don't see a point to use linear components, especially if it's just a buffer. Or are you feeding that PWM into the ADC for some reason?

author: Faringdon
author_rank: Super Contributor
timestamp: September 05, 2023, 09:02:43 pm
content: Thanks, yes its into the ADC....TL084C opamphttps://www.ti.com/product/TL084STM32F103V micro (100pin)https://www.st.com/resource/en/datasheet/stm32f103c8.pdfThe opamp goes into pin 35 of the micro which is labelled as an Analog input. ("PB0/ ADC_IN8 /T3_C3")Opamps max output current is 26mA....maybe micro can survive it for a little bit?

author: Manul
author_rank: Super Contributor
timestamp: September 05, 2023, 09:14:46 pm
content: So why not add RC filter on the output? Resistor will limit DC current plus you have opportunity to low pass / anti-alias the signal a little bit.

author: DavidAlfa
author_rank: Super Contributor
timestamp: September 05, 2023, 09:17:58 pm
content: In first place: Why do you power the op-amp at +20v/-3v when it's going to feed a 3.3V device?Why not just power it with 3.3V?If the issue is reaching GND or VDD, use a rail-to-rail amp.It this actually trolling? Feels like it.

author: djsb
author_rank: Super Contributor
timestamp: September 05, 2023, 10:05:50 pm
content: Very strange power supply setup.No handling of any DC offset into MCU Analogue input.Why would you feed a PWM signal (which is digital- A pulse that has its width modulated) into an Analogue input without low pass filtering?WHERE IS THE LOW PASS FILTER?As the dragons say, I'M OUT.

author: ArdWar
author_rank: Frequent Contributor
timestamp: September 05, 2023, 10:25:54 pm
content: Why can't you just use normal proven circuits in your designs like everyone else. Your ideas somehow never fail to draw a "what the fuck" reaction here. You need to either stop trying to reinvent the wheel, or maybe apply as application engineer in ADI or something serious....Quote from: DavidAlfa on September 05, 2023, 09:17:58 pmIf rail-to-rail is important, even a +5V supply is still infinitely safer. Most STM32 can tolerate 5V input to some extent if you limit the current. It's a specified operating mode in their datasheet. Although in my experience it may even survive without current limiting (don't intentionally do it in prod designs duh.)Use a -0.3V negative rail or similar if you need the signal to swing to exactly zero. Something enough for the opamp output to slew into, but not enough to reverse bias whatever input structure on the uC.Depending on how important the ADC accuracy is, a much better approach is to scale the ADC input into 0 - 2.048 V and use external 2.048 VREF. There's much less chance that a slight overdrive will mess the VDDrail, and especially AVDD.Quote from: Faringdon on September 05, 2023, 09:02:43 pmUse actual resistor to limit the current, don't rely on output drive limitation alone. Make sure the resistor value is large enough to limit the current to safe value but not too large to affect sample and hold circuitry. STM32 datasheets specify maximum recommended RAINvalues for specific sampling rate, look at it.

author: floobydust
author_rank: Super Contributor
timestamp: September 06, 2023, 03:44:48 am
content: Should we start a Go Fund Me to buy a reel of resistors for Treez Co. ?MCU injection current rating is only 5mA, side effects include corrupting other A/D channel readings, amongst other problems.Just as happy cross-posted thread:https://www.edaboard.com/threads/will-microcontroller-be-damaged-by-input-from-opamp.408262/

author: xavier60
author_rank: Super Contributor
timestamp: September 06, 2023, 05:34:33 am
content: Forward biasing the microcontroller's input protection diodes by even a small amount, can cause a sort of crosstalk to other analog inputs.Edit: just noticed it has been mentioned.

author: Faringdon
author_rank: Super Contributor
timestamp: September 06, 2023, 05:51:00 am
content: QuoteThanks, its part of a quad opamp...some of them need the -3v and 20v.

author: Faringdon
author_rank: Super Contributor
timestamp: September 06, 2023, 05:53:02 am
content: QuoteThanks, micro needs to know when high and low, but also, if its "High enough".A low pass filter wont be needed.....it just samples it every millisecond or so.......A low pass filter , is only needed if you have nyquist sampling rate issues...but we dont.There is a school of thought that the opamp is a buffer...and that since its non-inv pin is never <0V, then neither should be the output.....though is there something with offset voltages of certain batches?...that when inv and non-inv are both 0V......it could be that non-inv "looks like" it is less than 0V?...so opamp output goes to negative rail?QuoteThankyou so much....that isnt the issue here, thanks anyway.

author: magic
author_rank: Super Contributor
timestamp: September 06, 2023, 06:08:49 am
content: You have bigger things to worry about than offset

author: Faringdon
author_rank: Super Contributor
timestamp: September 06, 2023, 06:18:02 am
content: Thanks, surely the offset is the main problem here...?..after all, its a buffer.....the + and - inputs should always be the same, and since + is always 0V or more...we should have nothing to worry about....since output should never be able to go negative......but the offset ......is whats screwing this up...i think?QuoteThanks, but we're not up against Nyquist,,,no need for filter here.QuoteThanks, Its one of a quad...and some need the +20v, -3v3 rails

author: xavier60
author_rank: Super Contributor
timestamp: September 06, 2023, 06:26:33 am
content: From memory, up to -0.3V, maybe a bit more is allowed. Offset won't be anywhere near that.Definately test for power up and power down glitches.Edit: I would still add a resistor.

author: xavier60
author_rank: Super Contributor
timestamp: September 06, 2023, 07:10:52 am
content: I had a close look at the schematic in post #7. All indicates that the opamp's output should always be in the range of 0V to 2.4V.

author: liaifat85
author_rank: Regular Contributor
timestamp: September 06, 2023, 11:01:32 am
content: I think it's best to test with a multimeter.

author: magic
author_rank: Super Contributor
timestamp: September 06, 2023, 01:05:28 pm
content: Quote from: xavier60 on September 06, 2023, 07:10:52 amIt will be+19Vbefore the -3.3V rail comes upActually, about +4V

author: ArdWar
author_rank: Frequent Contributor
timestamp: September 06, 2023, 03:48:45 pm
content: Quote from: magic on September 06, 2023, 01:05:28 pmJust put a diode to clamp Vee smh.

author: xavier60
author_rank: Super Contributor
timestamp: September 06, 2023, 05:19:52 pm
content: Not sure if I'm on the right track here.First, I thought that putting a diode across the -3.3V would fix it but the common mode input range would still be violated.If the VAS stage loses drive, output goes high.

author: floobydust
author_rank: Super Contributor
timestamp: September 06, 2023, 05:24:42 pm
content: Does the TL084 have the same big problem as theTL074? That is the phase-inversion and wonky gain when the common-mode voltage is low, near the -ve rail.If so I would expect a MCU +ve wallop on power up. Treez, have you ever tried using a breadboard?I curse TI for blending in the _H "upgraded" parts and butchering old datasheets, stripping them of anything too stressful for their lazy literature dept.Second, RTFM:"Injecting a negative current on any analog input pins should be avoided as this significantly reduces the accuracy of the conversion being performed on another analog input. It is recommended to add a Schottky diode (pin to ground) to standard analog pins which may potentially inject negative current.""Any positive injection current within the limits specified for IINJ(PIN) and sum INJ(PIN) in Section 5.3.12 does not affect the ADC accuracy." {is 5mA}

author: tggzzz
author_rank: Super Contributor
timestamp: September 06, 2023, 05:34:22 pm
content: Quote from: floobydust on September 06, 2023, 05:24:42 pmThis is Standard Operating Procedure for treez/ocset/faringdon.The only hope for preventing it is if thesecondposter to any of his threads warns people to look at who the OP is. With luck that will dissuade people from engaging with his asinine topics, and with luck that will starve him of attention.For sensible first posts, there would be no need for that. Hehasstarted some reasonable threads, but also far too many asinine threads.

author: floobydust
author_rank: Super Contributor
timestamp: September 06, 2023, 06:27:28 pm
content: Imagine pissing off the Internet.I find no treeze thread is reasonable. He withholds details of the application, gives us an LTSpice pseudo-schematic, a long story that can include feelings, then in the thread argues why ____ must follow his beliefs "yes but customer says", "yes but we have no room", "as we all know", then he disappears.At the end, there is no decision, no fix, no conclusion, no closure - just an abandoned thread and hundreds of them. #5EEVblognew thread starter (554). I'm only in it for the thanks.It must look like Burning Man Festival right now, garbage and mud everywhere

author: magic
author_rank: Super Contributor
timestamp: September 06, 2023, 06:34:18 pm
content: Quote from: floobydust on September 06, 2023, 05:24:42 pmBingoTL08x and TL07x are more or less the same thing, rumor has it that there used to be some difference in noise specs in a distant past, but I'm not even sure if I have ever seen those datasheets.Besides, I don't think I would necessarily trust any random opamp, TL072 or not, not to do some questionable things during turn-on, before it reaches minimum voltage for guaranteed proper operation.Another potential concern is "fail-safety" - if something in the analog stuff goes wrong, do you really want to replace the MCU as well?(This of course is not applicable to modern consumer products)

author: Faringdon
author_rank: Super Contributor
timestamp: September 06, 2023, 06:38:40 pm
content: OK thanks....the attached sim is nearer what we are doing with the circuit........in the attached LTspice sim, after a few ms, the 20V rail goes down as the product is switched OFF......but the neg_3V3 rail stays about neg_3v3...its at this point where the big injection of current goes through the ADC pin 's ESD diodes....because the opamp output goes negative.I think this is the danger point of the circuit...would you agree?....so in other words, the danger only happens when the product gets switched off...so its not actually a problem...would you agree?....the current is limited by the opamps current clamped output....and so the ESD diodes in the micro ADC pin will likely be able to handle this one-off surge?[i must confess, i never encountered this before, as i always put a series resistor there...but this board has already been done and there's no room for the eight series resistors that would need adding......the whole board would have to be totally ripped up and started over. (a consultancy actually sent us this as they are overloaded at the mo)]

author: floobydust
author_rank: Super Contributor
timestamp: September 06, 2023, 06:42:49 pm
content: It's on power up I think. +20V comes up first, the -3.3V comes up late which causes the op-amp to misbehave.P.S. - oh the "we have no room" thing? This is already in production? All that smoke

author: magic
author_rank: Super Contributor
timestamp: September 06, 2023, 06:50:08 pm
content: The converse is also possible.If you remove the positive rail but keep the negative (due to charge stored in all those caps along the way) the opamp will work with -3.3V/0V rails.If it can't swing to the top rail, it may end up pulling the output below ground.Although I think TL084 may actually be OK, because as long as IN+ is above VCC or above IN-, the VAS will be cut off and the output PNP will lack base drive.There is also 64+128Ω in series with the output, for what it's worthLastly, with merely 3.3V across the rails, I'm not even sure if TL084 will bias up and do anything at all.Somewhere here there is a lesson not to relay on SPICE, and certainly not on models of unrelated parts, when contemplating operation outside specification

author: Faringdon
author_rank: Super Contributor
timestamp: September 06, 2023, 07:00:19 pm
content: QuoteThanks, do you mean the ADC pin's internal input resistance?

author: floobydust
author_rank: Super Contributor
timestamp: September 06, 2023, 07:41:32 pm
content: This is a bad design with no easy or economical fix. Investors will hold on to a money losing stock, it's called "hope mode".I would say you are pooched.Testing failed, field trials failed to flush out this H/W error.There are 8 analog channels configured like this, and no room to add 8 resistors, you say. The rework labour costs would be too high.Even with a well behaved op-amp, no guarantee the analog input signals stay in range.The auto-destruct feature must be damaging MCU's. Too costly to repair.Just throw the boards in the garbage and bite the bullet. Otherwise, what you are you hoping for?

author: Gyro
author_rank: Super Contributor
timestamp: September 06, 2023, 08:36:31 pm
content: Quote from: Faringdon on September 06, 2023, 06:38:40 pmOh, I don't know what everyone was getting worked up about then. I mean, what are the chances of someone switching it off? There's a special exemption for exceeding the Absolute Maximum ratings while somebody is switching things off, I'm sure I read it somewhere!

author: magic
author_rank: Super Contributor
timestamp: September 06, 2023, 08:40:26 pm
content: The real question:will it fail before warranty ends?

author: tggzzz
author_rank: Super Contributor
timestamp: September 06, 2023, 10:38:43 pm
content: Quote from: magic on September 06, 2023, 08:40:26 pmWill it fail before a contractor gets their fees?IWill it fail before an employee is paid their salary and outstanding expenses.Will it fail before trees can land the blame on someone else or another country?

author: dmills
author_rank: Super Contributor
timestamp: September 07, 2023, 12:35:13 pm
content: I used to think contractors got to be contractors by being the best of the best, then I worked with a few...They move companies every six months or so for a REASON, it takes that long for the incompetence to surface, and by then they are gone leaving a cloud of burning silicon and cursing behind themselves.I have some names in my little black book, oh yes.

author: tggzzz
author_rank: Super Contributor
timestamp: September 07, 2023, 01:55:49 pm
content: Quote from: dmills on September 07, 2023, 12:35:13 pmI think it depends on the speciality and age. I've worked with very competent middle-aged RF engineers. There skill takes a long time to accumulate.Typical software weenies, OTOH, base their behaviour on HR droids that think old=> bad, new => better, and experience => pointing out fundamental flaws.

author: Zero999
author_rank: Super Contributor
timestamp: September 07, 2023, 05:16:34 pm
content: Quote from: DavidAlfa on September 05, 2023, 09:17:58 pmThere's no such thing as a rail-to-rail op-amp. The output never really swings from rail-to-rail and the input circuitry uses various hacks to switch between the positive and negative ends of the common mode range, which can introduce distortion.If I had +20V & -3V available and I wanted to connect it to a device powered from 0V and 3.3V, I would consider adding limiting diodes and a resistor to the output first, before resorting to a rail-to-rail op-amp.Quote from: Faringdon on September 06, 2023, 07:00:19 pmLook at the internal schematic of the TL072.