Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ Electronics
➜ Operational Amplifiers
➜ How to use an op-amp as a buffer
How to use an op-amp as a buffer
|
This subject is now closed.
Refresh page
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | Top |
|
Posted by
| Scott927
(1 post) 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? | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | 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.
29,125 views.
This subject is now closed.
Refresh page
top