Author Topic: Opamp inputting to microcontroller  (Read 4834 times)

0 Members and 2 Guests are viewing this topic.

Offline FaringdonTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 2124
  • Country: gb
Opamp inputting to microcontroller
« on: September 05, 2023, 05:46:05 am »
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?
'Perfection' is the enemy of 'perfectly satisfactory'
 

Offline djsb

  • Frequent Contributor
  • **
  • Posts: 964
  • Country: gb
Re: Opamp inputting to microcontroller
« Reply #1 on: September 05, 2023, 06:03:26 am »
Test it on a breadboard and find out for yourself.
David
Hertfordshire, UK
University Electronics Technician, London, PIC16/18, CCS PCM C, Arduino UNO, NANO,ESP32, KiCad V8+, Altium Designer 21.4.1, Alibre Design Expert 28 & FreeCAD beginner. LPKF S103,S62 PCB router Operator, Electronics instructor. Credited KiCad French to English translator
 
The following users thanked this post: Faringdon

Offline Gyro

  • Super Contributor
  • ***
  • Posts: 10032
  • Country: gb
Re: Opamp inputting to microcontroller
« Reply #2 on: September 05, 2023, 11:25:21 am »
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?

Troll 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!
Best Regards, Chris
 
The following users thanked this post: Faringdon

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3903
  • Country: nl
Re: Opamp inputting to microcontroller
« Reply #3 on: September 05, 2023, 12:22:29 pm »
Troll 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!

This 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).
 
The following users thanked this post: Faringdon

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 20770
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Opamp inputting to microcontroller
« Reply #4 on: September 05, 2023, 12:41:31 pm »
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?

Another 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.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: Kean, tooki, golden_labels, Faringdon

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 20770
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Opamp inputting to microcontroller
« Reply #5 on: September 05, 2023, 12:51:56 pm »
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.

Would you agreeTM that it is a strange question from a professional engineer with several decades experience in many companies?

Would you agreeTM that it is strange to post the question in the "Beginners" section?
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: David Aurora, Kean, tooki, Faringdon

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4778
  • Country: dk
Re: Opamp inputting to microcontroller
« Reply #6 on: September 05, 2023, 01:00:44 pm »
Troll 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!

This 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).

quite 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

 
The following users thanked this post: Faringdon

Offline FaringdonTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 2124
  • Country: gb
Re: Opamp inputting to microcontroller
« Reply #7 on: September 05, 2023, 07:25:10 pm »
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
« Last Edit: September 06, 2023, 06:48:44 am by Faringdon »
'Perfection' is the enemy of 'perfectly satisfactory'
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 7249
  • Country: pl
Re: Opamp inputting to microcontroller
« Reply #8 on: September 05, 2023, 08:23:08 pm »
There is only one right answer:
Omitting that resistor will still not make your product cheaper than those imported from China, so do it right :box:

Knowing TL084, its output may very well shoot up to +20V if the negative rail is too slow to start or dead altogether.
 
The following users thanked this post: Faringdon

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1212
  • Country: lt
Re: Opamp inputting to microcontroller
« Reply #9 on: September 05, 2023, 08:40:00 pm »
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?
 
The following users thanked this post: Faringdon

Offline FaringdonTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 2124
  • Country: gb
Re: Opamp inputting to microcontroller
« Reply #10 on: September 05, 2023, 09:02:43 pm »
Thanks, yes its into the ADC....

TL084C opamp
https://www.ti.com/product/TL084

STM32F103V micro (100pin)
https://www.st.com/resource/en/datasheet/stm32f103c8.pdf

The 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?
'Perfection' is the enemy of 'perfectly satisfactory'
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1212
  • Country: lt
Re: Opamp inputting to microcontroller
« Reply #11 on: September 05, 2023, 09:14:46 pm »
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.
 
The following users thanked this post: Faringdon

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6278
  • Country: es
Re: Opamp inputting to microcontroller
« Reply #12 on: September 05, 2023, 09:17:58 pm »
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.
« Last Edit: September 05, 2023, 10:13:42 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: Faringdon

Offline djsb

  • Frequent Contributor
  • **
  • Posts: 964
  • Country: gb
Re: Opamp inputting to microcontroller
« Reply #13 on: September 05, 2023, 10:05:50 pm »
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.
« Last Edit: September 06, 2023, 04:51:01 am by djsb »
David
Hertfordshire, UK
University Electronics Technician, London, PIC16/18, CCS PCM C, Arduino UNO, NANO,ESP32, KiCad V8+, Altium Designer 21.4.1, Alibre Design Expert 28 & FreeCAD beginner. LPKF S103,S62 PCB router Operator, Electronics instructor. Credited KiCad French to English translator
 
The following users thanked this post: Faringdon

Offline ArdWar

  • Frequent Contributor
  • **
  • Posts: 721
  • Country: sc
Re: Opamp inputting to microcontroller
« Reply #14 on: September 05, 2023, 10:25:54 pm »
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.... ;D

Why not just power it with 3.3V?
If 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 VDD rail, and especially AVDD.
Opamps max output current is 26mA....maybe micro can survive it for a little bit?
Use 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 RAIN values for specific sampling rate, look at it.
« Last Edit: September 05, 2023, 10:33:57 pm by ArdWar »
 
The following users thanked this post: Faringdon

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7526
  • Country: ca
Re: Opamp inputting to microcontroller
« Reply #15 on: September 06, 2023, 03:44:48 am »
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/
 
The following users thanked this post: tooki, Faringdon

Offline xavier60

  • Super Contributor
  • ***
  • Posts: 2993
  • Country: au
Re: Opamp inputting to microcontroller
« Reply #16 on: September 06, 2023, 05:34:33 am »
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.
HP 54645A dso, Fluke 87V dmm,  Agilent U8002A psu,  FY6600 function gen,  Brymen BM857S, HAKKO FM-204, New! HAKKO FX-971.
 
The following users thanked this post: Faringdon

Offline FaringdonTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 2124
  • Country: gb
Re: Opamp inputting to microcontroller
« Reply #17 on: September 06, 2023, 05:51:00 am »
Quote
Why do you power the op-amp at +20v/-3v when it's going to feed a 3.3V device?
Thanks, its part of a quad opamp...some of them need the -3v and 20v.
'Perfection' is the enemy of 'perfectly satisfactory'
 

Offline FaringdonTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 2124
  • Country: gb
Re: Opamp inputting to microcontroller
« Reply #18 on: September 06, 2023, 05:53:02 am »
Quote
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?
Thanks, 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?
Quote
If the issue is reaching GND or VDD, use a rail-to-rail amp.
Thankyou so much....that isnt the issue here, thanks anyway.

« Last Edit: September 06, 2023, 06:19:59 am by Faringdon »
'Perfection' is the enemy of 'perfectly satisfactory'
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 7249
  • Country: pl
Re: Opamp inputting to microcontroller
« Reply #19 on: September 06, 2023, 06:08:49 am »
You have bigger things to worry about than offset :-DD
 
The following users thanked this post: Faringdon

Offline FaringdonTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 2124
  • Country: gb
Re: Opamp inputting to microcontroller
« Reply #20 on: September 06, 2023, 06:18:02 am »
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?

Quote
plus you have opportunity to low pass / anti-alias the signal a little bit.
Thanks, but we're not up against Nyquist,,,no need for filter here.

Quote
Use a -0.3V negative rail or similar if you need the signal to swing to exactly zero.
Thanks, Its one of a quad...and some need the +20v, -3v3 rails
« Last Edit: September 06, 2023, 06:22:46 am by Faringdon »
'Perfection' is the enemy of 'perfectly satisfactory'
 

Offline xavier60

  • Super Contributor
  • ***
  • Posts: 2993
  • Country: au
Re: Opamp inputting to microcontroller
« Reply #21 on: September 06, 2023, 06:26:33 am »
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.
« Last Edit: September 06, 2023, 06:30:57 am by xavier60 »
HP 54645A dso, Fluke 87V dmm,  Agilent U8002A psu,  FY6600 function gen,  Brymen BM857S, HAKKO FM-204, New! HAKKO FX-971.
 
The following users thanked this post: Faringdon

Offline xavier60

  • Super Contributor
  • ***
  • Posts: 2993
  • Country: au
Re: Opamp inputting to microcontroller
« Reply #22 on: September 06, 2023, 07:10:52 am »
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.

HP 54645A dso, Fluke 87V dmm,  Agilent U8002A psu,  FY6600 function gen,  Brymen BM857S, HAKKO FM-204, New! HAKKO FX-971.
 
The following users thanked this post: Faringdon

Offline liaifat85

  • Regular Contributor
  • *
  • !
  • Posts: 172
  • Country: bd
Re: Opamp inputting to microcontroller
« Reply #23 on: September 06, 2023, 11:01:32 am »
I think it's best to test with a multimeter.
 
The following users thanked this post: Faringdon

Offline magic

  • Super Contributor
  • ***
  • Posts: 7249
  • Country: pl
Re: Opamp inputting to microcontroller
« Reply #24 on: September 06, 2023, 01:05:28 pm »
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.
It will be +19V before the -3.3V rail comes up ;)

Actually, about +4V >:D
 
The following users thanked this post: Faringdon


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf