LM358 Voltage Follower / Buffer

I'm trying to setup a buffer using the LM358 dual op amp.
I'm supplying it 5V from arduino, connected ground to arduino ground.

  • Input = Pin9 on arduino, analogWrite = 127
  • Input = Connected to output
    Output - connected to + of multimeter.

Then I have ground from the multimeter to ground of the circuit, which as above goes to the ground on arduino.

Basic Math - 5V is what is put out on the pins at analogWrite 255, so if I use 127, I expect to find ~2.5V.

At the arduino this is the case, I put the multimeter to it and got 2.46V.
I expect to find 2.46V at the output of the LM358.

I find 1.83V.

Why is that? :-?

Interesting also, I put 3.3V into the opamp (from arduino 3V3 pin) and the multimeter = 3.30V

So it has to be something related to PWM :S

Hooked up 9V batteries to the circuit, 3.3V from arduino registers as 7.2V through op amp.

Your multimeter is probably not designed to accuratly measure a PWM waveform duty cycle, but rather just DC or sine wave AC voltages.

What is missing in your setup is a simple low pass filter between the pwm output pin and the + input of your opamp. Try a 5k ohm resistor between the pwm pin that the + input to the op amp and a 10mfd capacitor from the + input pin of the opamp pin to ground. This should filter out the PWM frequency and give you a pretty good DC voltage out of the opamp.

Lefty

But why do I get 7V when it's 3.3V from arduino (no PWM), and 9V batteries to the op amp circuit?

But why do I get 7V when it's 3.3V from arduino (no PWM), and 9V batteries to the op amp circuit?

I would first have to see a actual schematic drawing of what you have before I speculate on that. Sounds like you are forcing the op-amp to it's positive rail limit, which on many opamps is somewhat less then it's +vcc value.

Lefty


Please forgive my poor drawing.

I also removed 3.3V (leaving input open), and that gives 7.24V on output to multimeter.

First thing to fix is adding a wire from the 9 volt battery's negitive terminal to a Arduino ground pin. Your external circuitry and the arduino must share the same common reference ground.

Also about that meter? does it really measure something using just one lead? :wink:

Lefty

First thing to fix is adding a wire from the 9 volt battery's negitive terminal to a Arduino ground pin. Your external circuitry and the arduino must share the same common reference ground.

That did it!
I'll have to look up why !

Also about that meter? does it really measure something using just one lead?

Nah (I wish), it's negative is to the breadboard's ground :slight_smile:

Hmm, I didn't need the resistor or the capacitor with the external 9V supply.

Pin 9 PWM = 2.49V from the op amp output

I'll have to look up why !

EASY. Very basic concepts related to circuits.

If two different circuits with different DC voltages will never interact... there is no need for common ground. Like 2 different flashlights... they just don't care about each other.

BUT

When two essentially different circuits need to work together that each have a different voltage potential for a power source... they NEED a common ground, or a point of reference if you will to be able to correctly interact.

Without that common point of reference... you just don't have a completed circuit. The value coming from your op amp to the Arduino essentially is invisible until there is a common point of reference... "ground"

Hmm, I didn't need the resistor or the capacitor with the external 9V supply.

Pin 9 PWM = 2.49V from the op amp output

Again your meter is really not designed to measure other then pure DC or sine wave AC on the ac volt function. So it's reading what you expect that's nice, but it's not the correct way to measure PWM waves. One uses either an oscilloscope or as I said pass the signal through a low pass filter and measure the resulting duty cycle as a pure DC voltage.

I'll have to look up why !

Yes, it is important that you understand the why a common reference is needed when two different circuits are going to be working together. If the circuits are sharing the same DC power supply that happens without having to think or understand it, but if they are being powered by different voltage sources then there must be a common reference connections made between them. Ground (or common) can be more complex then many beginners realize. :wink:

Lefty

Being self taught... I struggled with this when I was young... (I guess I was 13 or so). I asked around and finally got this answer from an engineer.

Ok, it was eons before the Internet but we really could get questions answered before 1992...

He said think of "ground" like a large flat surface such as you would find stepping out onto a nearby street. Think of voltage as height above that surface... like 5 volts = height of 5 feet. 5 feet above the street ( Your ground) is consistent and we all know what that it looks like... but it's because we know the reference point... the street or "ground".

Soo... what if your buddy calls you and says "I'm at 10 feet!" but you don't know where he is? He could be 10 feet above you... 10 feet above the street. 10 feet below the street... 10 feet up in his house.

Until you have the same common reference point... the street... 10 feet has no meaning to you sitting 5 feet about your street... (ground).

Well... it worked for me since this is how I have been thinking about it since I was young.

I'll have to look up why !

Hane a look here Power Supplies
Scroll down ! until you find multiple power supply
GrumpyMike is really Cool :slight_smile:

That raises questions :slight_smile:

I want to read the voltage across a thermistor from another device.
The other device has resistors and the like providing power across the thermistor, so I just want to read that voltage and make my own conclusions from it using the arduino.

So, the 'signal' ground of the sensor, does that need ground in my op amp circuit (the purpose of the buffer circuit, I take it, is to not affect the resistance of the circuit being checked).

If so, should I take the ground and attach it to the circuit ground? Will this impact on the resistance of the circuit being monitored (ideally this will not even know it's being monitored).