# 5v opamp single rail with variable gain

**URL:** <https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487>\
**Category:** DIY STUFF\
**Created:** [May 7, 2021, 1:46pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487 "2021-05-07T13:46:18Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![twinturbo](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@twinturbo](https://lookmumnocomputer.discourse.group/u/twinturbo)\
**Post date:** [May 7, 2021, 1:46pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/1 "2021-05-07T13:46:18Z")

</div>

I need to build a little op-amp circuit on a single rail +5V

It needs to have variable gain.

I can’t find an example on internet that actually works. Very confused,.

---

<div class="post-metadata">

**Author:** ![lu.caas](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/lu.caas/32/12420_2.png) [@lu.caas](https://lookmumnocomputer.discourse.group/u/lu.caas)\
**Post date:** [May 7, 2021, 1:48pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/2 "2021-05-07T13:48:54Z")

</div>

I could show you a circuit for that! It’s pretty easy to build and understand, why do you need it? 😁

---

<div class="post-metadata">

**Author:** ![BoneMusic](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/bonemusic/32/23323_2.png) [@BoneMusic](https://lookmumnocomputer.discourse.group/u/BoneMusic)\
**Post date:** [May 7, 2021, 1:51pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/3 "2021-05-07T13:51:45Z")

</div>

Sorry to hijack but I’m also looking for a simple op amp circuit and getting confused. Either 5V or +/-12V is fine. I’m looking to boost the signal from a signal generator thats a couple of hundred mV up to a volt to something suitable for synth so maybe gain of 5.

---

<div class="post-metadata">

**Author:** ![fredrik](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/fredrik/32/682_2.png) [@fredrik](https://lookmumnocomputer.discourse.group/u/fredrik)\
**Post date:** [May 7, 2021, 1:55pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/4 "2021-05-07T13:55:19Z")

</div>

> [@twinturbo](#):
>
> I can’t find an example on internet that actually works.

Yeah, that’s a bit puzzling because the only thing you have to do is to replace the feedback resistor with a potentiometer.

(…but are you sure the problem is the gain and not that you get too close to the rails on the way in or out? What opamp are you using?)

---

<div class="post-metadata">

**Author:** ![lu.caas](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/lu.caas/32/12420_2.png) [@lu.caas](https://lookmumnocomputer.discourse.group/u/lu.caas)\
**Post date:** [May 7, 2021, 1:56pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/5 "2021-05-07T13:56:12Z")

</div>

The supply voltage that you put on the opamp just set the “limit” of your opamp. You won’t be able to output more or less voltage than the supply voltage

---

<div class="post-metadata">

**Author:** ![BoneMusic](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/bonemusic/32/23323_2.png) [@BoneMusic](https://lookmumnocomputer.discourse.group/u/BoneMusic)\
**Post date:** [May 7, 2021, 1:58pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/6 "2021-05-07T13:58:46Z")

</div>

My supply voltage is +/-12V.

 ![Screenshot 2021-05-07 at 14.56.45](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/2X/3/3b9de85946d5834a3dcafdf148cd81ce3f00110f.png)

Basically I want to build the image here but I don’t know if there’s any ‘real world’ gotchas because I haven’t used an op amp before.

---

<div class="post-metadata">

**Author:** ![lu.caas](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/lu.caas/32/12420_2.png) [@lu.caas](https://lookmumnocomputer.discourse.group/u/lu.caas)\
**Post date:** [May 7, 2021, 2:00pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/7 "2021-05-07T14:00:40Z")

</div>

This is an inverting gain setup, you need to “re-invert” the output signal to get the perfect image of the input gained signal

---

<div class="post-metadata">

**Author:** ![BoneMusic](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/bonemusic/32/23323_2.png) [@BoneMusic](https://lookmumnocomputer.discourse.group/u/BoneMusic)\
**Post date:** [May 7, 2021, 2:02pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/8 "2021-05-07T14:02:44Z")

</div>

Thank you, that’s cool I don’t think it matters but I have designs for non-inverting too 🙂

I’ll give it a go

---

<div class="post-metadata">

**Author:** ![analogoutput](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/analogoutput/32/29663_2.png) [@analogoutput](https://lookmumnocomputer.discourse.group/u/analogoutput)\
**Post date:** [May 7, 2021, 2:15pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/9 "2021-05-07T14:15:01Z")

</div>

For a single supply and positive-only input use an LM358 (dual) or LM324 (quad) or similar op amp that is designed to operate down to 0 V on single supply. If your input is bipolar then you need to offset it.

For dual supply you can use TL07x.

---

<div class="post-metadata">

**Author:** ![twinturbo](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@twinturbo](https://lookmumnocomputer.discourse.group/u/twinturbo)\
**Post date:** [May 7, 2021, 4:51pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/10 "2021-05-07T16:51:33Z")

</div>

I think I may have been over complicating things far too much.

The requirement is to set present levels on 3 audio sources so they match.

All devices in the circuit are powered from either 5V or 3.3V single rail.

I was using a TOL7x so as Rich points out not ideal.  
All the examples I was following I think expected a bipolar signal. and biased the voltage.

Revised plan, make a simple micro mixer with a LM358 just as a buffer.

---

<div class="post-metadata">

**Author:** ![twinturbo](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@twinturbo](https://lookmumnocomputer.discourse.group/u/twinturbo)\
**Post date:** [May 7, 2021, 4:51pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/11 "2021-05-07T16:51:44Z")

</div>

Thanks for all the input .

---

<div class="post-metadata">

**Author:** ![fredrik](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/fredrik/32/682_2.png) [@fredrik](https://lookmumnocomputer.discourse.group/u/fredrik)\
**Post date:** [May 8, 2021, 6:44am UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/12 "2021-05-08T06:44:21Z")

</div>

> [@twinturbo](#):
>
> I was using a TOL7x so as Rich points out not ideal.

This bit from the datasheet explains why (the values are min and typical, for a ±15V supply):

 ![image](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/2X/e/ed454f11f9e6b285867021711937f3063c98fe45.png)

Note that the valid input range starts at 3-4 V above the negative supply, so using a single 5 V supply doesn’t give you a lot of range…

Same parameters for LM358 (here given for 5 V and 30 V supplies):

 ![image](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/2X/6/6685b5e888089607076c01220c6a012c375374ef.png)  
 ![image](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/2X/b/b1c198aeee17a8cb8d8388fa455dbae8013c7131.png)

Note that the TL07x input range is relative to the negative rail, while the LM358 is relative to the positive rail. This reflects the design of the input stage; basically on which side of the input amplifier the bias current circuitry is (which needs a bit of voltage to work). True rail to rail opamps often have two separate input stages in parallel, to get full coverage.

---

<div class="post-metadata">

**Author:** ![BoneMusic](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/bonemusic/32/23323_2.png) [@BoneMusic](https://lookmumnocomputer.discourse.group/u/BoneMusic)\
**Post date:** [May 10, 2021, 5:40pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/13 "2021-05-10T17:40:31Z")

</div>

Can I ask a favour??

I’d love to see a simple op amp inverting amplifier stage something like a TL072 on a breadboard or similar so I can compare with what I’ve been trying to do and trouble shoot. If anyone has a photo/ doesn’t mind taking one!

All I get out is 50Hz hum. I’m going to be away with work for a while but it’d be great to at least learn something before I go!

I find it really helpful to be able to compare schematics with physical builds

---

<div class="post-metadata">

**Author:** ![analogoutput](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/analogoutput/32/29663_2.png) [@analogoutput](https://lookmumnocomputer.discourse.group/u/analogoutput)\
**Post date:** [May 11, 2021, 12:18pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/14 "2021-05-11T12:18:29Z")

</div>

The schematic is really simple:

 ![image](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/2X/2/205e2e9d0e57cdb6c3bea69ad149f0672d20c005.png)

Connect the input to resistor R1 and the other end of R1 to pin 2. Connect the output to pin 1. Connect a resistor from pin 1 to pin 2. Connect pin 3 to ground, 4 to -12 V, 8 to +12 V.

That’s it for one stage but if the other op amp is unused it’s best practice to connect pin 6 to pin 7 and pin 5 to ground.

Gain is -R2/R1.

A photo isn’t any clearer than a schematic. If you’re having a problem, what would help is if _you_ posted a photo, top and bottom, so someone can look for errors.

---

<div class="post-metadata">

**Author:** ![BoneMusic](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/bonemusic/32/23323_2.png) [@BoneMusic](https://lookmumnocomputer.discourse.group/u/BoneMusic)\
**Post date:** [May 11, 2021, 12:28pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/15 "2021-05-11T12:28:54Z")

</div>

This is super helpful, thank you. as far as I can tell, I did what you described but I’m going to start fresh and look for any errors/ omissions. If it doesn’t work I’ll share some pics 🙂

---

<div class="post-metadata">

**Author:** ![BoneMusic](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/bonemusic/32/23323_2.png) [@BoneMusic](https://lookmumnocomputer.discourse.group/u/BoneMusic)\
**Post date:** [May 14, 2021, 2:40pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/16 "2021-05-14T14:40:02Z")

</div>

I was connecting the negative side of the input to the inverting input of the op amp, rather than just straight to ground. I’m getting some amplification now 🙂 Progress! Thanks again

---

<div class="post-metadata">

**Author:** ![BoneMusic](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/bonemusic/32/23323_2.png) [@BoneMusic](https://lookmumnocomputer.discourse.group/u/BoneMusic)\
**Post date:** [May 14, 2021, 9:33pm UTC](https://lookmumnocomputer.discourse.group/t/5v-opamp-single-rail-with-variable-gain/3487/17 "2021-05-14T21:33:33Z")

</div>

![IMG_20210514_220336](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/2X/d/df5a165913e9f75a6230073b5d2662680714602d.jpeg)

Not much to see, but the op amp is in place on my arduino oscillator work in progress now. Need to add CV control and connect up the controls.
