[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  Electronics
. -> [Folder]  Operational Amplifiers
. . -> [Subject]  How to use an op-amp as a buffer

How to use an op-amp as a buffer

This subject is now closed.     [Refresh] Refresh page


Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Sat 29 Oct 2011 04:23 AM (UTC)

Amended on Sun 30 Aug 2015 02:04 AM (UTC) by Nick Gammon

Message
The circuit below demonstrates how you can use an op-amp to buffer output from an Arduino.

This example is to demonstrate taking the PWM (Pulse Width Modulation) output from an Arduino and convert it into a DC voltage (more or less).

This simple sketch shows how you can read a potentiometer and depending on its position, output a PWM signal:


void setup () { }

void loop () {
  analogWrite (3, analogRead (A0) / 4);
}


The PWM output is a square wave, where the 5V output is turned on and off at around 490 Hz. The smaller the value passed to analogWrite the lower the duty cycle is (that is, it is off more often than on).

To convert that into a voltage level that varies we can use an RC filter. This uses a capacitor to smooth out the pulses into a fairly level voltage.



However the RC filter is somewhat sensitive to load. That is, the more load you place on it, the lower the voltage is.

So we can add on a "unity gain" op-amp circuit as a buffer. Now the output of the op-amp does not vary much regardless of load (within the specs of the op-amp).

In order to keep the output in the range 0V to 5V, the op-amp needs a slightly higher supply voltage (pin 8) because it cannot output 5V if its supply voltage is 5V. In fact, it outputs a maximum of about 3.4V with a 5V supply voltage. Something in the order of 7V to 12V would be suitable.

Alternatively, use a "rail to rail" op-amp such as the TS922IN.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Scott927   (1 post)  [Biography] bio
Date Reply #1 on Thu 29 Dec 2011 12:43 AM (UTC)
Message
Great post Nick. Will it work for other things besides Arduino?
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Thu 29 Dec 2011 04:25 AM (UTC)
Message
Absolutely. It is just a general circuit. See Dave Jones talking about something similar on his blog:

http://www.eevblog.com/2011/12/07/eevblog-225-lab-power-supply-design-part-4-pwm-control/

He describes using PWM to get a reference voltage for a lab power supply. He describes a more sophisticated filter than mine where he does two lots of filtering before the op-amp.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


27,803 views.

This subject is now closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]