3
\$\begingroup\$

I have a 5V power supply and an input voltage that’s between 0V-5V. I need to create a circuit where, after feeding the input voltage X (X is between 0V-5V), the output voltage is 5-X (5 MINUS X) V. Would this be possible to achieve without any ICs?

Edit: The output is supposed to be used as the inverting input of an Op-Amp. Some give is okay (~300mV).

\$\endgroup\$
8
  • 1
    \$\begingroup\$ You can use the LM358 as a differential amplifier. But the rail-to-rail feature of the LM358 will let you down. \$\endgroup\$
    – Tyassin
    Commented 2 days ago
  • \$\begingroup\$ You want the output to be 5 times X, or 5 minus X? I read your question as 5 minus X, but the two answers have me questioning... \$\endgroup\$ Commented 2 days ago
  • 3
    \$\begingroup\$ Its 5 MINUS X, I don’t know how some got that confused.. I wrote “-“. \$\endgroup\$
    – Victor Ban
    Commented 2 days ago
  • \$\begingroup\$ Not sure about the final application nor the limitations of your input voltage X. A simple resistor with one end connected to +5V and the other to X, would produce a differential voltage across the resistor...More details may be needed but measuring across this resistor will yield the difference albeit not directly referred to GND \$\endgroup\$
    – Big6
    Commented 2 days ago
  • \$\begingroup\$ Do you have a minus supply voltage available? \$\endgroup\$ Commented 2 days ago

7 Answers 7

10
\$\begingroup\$

If you're OK with the output only swinging to within 150mV of each rail, you can try this IC-less circuit.

It's a current mirror where the input current flows through R4 and Q1 and is duplicated in R5 and Q2 which provides an output inverted with respect to input.

If the signal were connected directly to R4 the current through Q1 would crap out when its base reached 0.6V, so instead R1-R2-R3 attenuate the signal and center it around 2.5V such that the negative peak never turns off Q1. R5 being higher than R4 adds gain to compensate for the attenuation.

EDIT: answer to “how did you choose those odd values?”

There’s plenty of leeway in the selection of values.

I wanted the signal at the top of R4 (Vatten) to only go as low as 0.7V so that Q1 would never fully turn off and cause clipping. How high should Vatten go? Although not strictly necessary, for simplicity I opted to keep the Vatten swing centered around 2.5V, same as the input. This put Vatten max at 4.3V for a total pk-pk swing of 3.6V.

The required attenuation from Vin to Vatten was then 5.0 to 3.6, or 0.72. This attenuation is achieved by the resistor divider R1 to the parallel combination of R2 and R3, that being the Thevenin equivalent resistance into 2.5V.

Arbitrarily choosing 1K for R1, this worked out to 2K6 for the Thevenin resistance (2.6K / (2.6K + 1K) = 0.72) so therefore R2 and R3 are both 5K2.

But 5K1 is a standard value and that’s just fine – I should have just used that.

Note that this calculation assumes the output impedance from your Vin source is essentially zero, as from an opamp output. If it is not zero, it needs to be added to the R1 in this analysis.

For R4 and R5 I just chose an arbitrary large value for R4 (100K) so that it didn’t affect the R1-R2-R3 equation and that dictated R5: the input gain was 0.72 so the output gain should be 1.39 to restore total to 1.00. But again, 139K is not a standard value so I should have chosen 137K (140K starts showing distortion).

But it could be argued that R5 should ideally be made lower to decrease the output impedance. If we lower it (and R4) by a factor of 10 then the new value of 10K for R4 does start impinging on the R1-R2-R3 equation and we get a bit more attenuation. So we need a bit more gain: making R5 = 15K appears to solve it and we actually get a better Vout max because Q1 is closer to turning fully off.

Final answer:

R1 = 1K

R2 = R3 = 5K1

R4 = 10K

R5 = 15K

Vout max = 4.91V

Vout min = 0.16V

Caveats:

-R1 needs to include output impedance of Vin source

-real world transistor may be slightly different, requiring R tweaks to avoid Q1 cutoff

-the output impedance is R5 so any resistive load in the next stage will attenuate: either keep load’s impedance very high (e.g. non-inverting opamp input) or if necessary make R5 even lower (and adjust other resistors accordingly).

Good luck!

\$\endgroup\$
2
  • 4
    \$\begingroup\$ This is simple enough and works great fot my use case. Could you tell me how did you choose those resistor values? Some seem pretty odd. Thanks! \$\endgroup\$
    – Victor Ban
    Commented yesterday
  • 1
    \$\begingroup\$ Awesome solution! +1 \$\endgroup\$ Commented 8 hours ago
6
\$\begingroup\$

Unfortunately I only have a LM358 which is not Rail-To-Rail.

Then you can add an NPN transistor to achieve nearly a rail-to-rail output;

enter image description here

Note that the + and - inputs of the op-amp are reversed to make up for the fact that the NPN transistor inverts the signal. The output ranges from 4.8 V to about 0.2 V. You may need to add a small capacitor across the feedback resistor to avoid oscillations. Also, add a 100 nF capacitor across the 5 V supply close to the IC.

\$\endgroup\$
6
  • \$\begingroup\$ you don't actually need the transistor, just the 1K pull up is enough. \$\endgroup\$ Commented 2 days ago
  • 1
    \$\begingroup\$ also the output doesn't go above 4.8V \$\endgroup\$ Commented 2 days ago
  • 1
    \$\begingroup\$ It's a shame this didn't get accepted, since it is superior to the current mirror solution in almost every respect, particularly high precision and zero output impedance. I don't think frequency compensation is necessary here, because open loop gain increase is severely reduced by the 10k base resistor, and \$\beta=\frac{1}{2}\$ - technically this is not a voltage voltage follower which would probably need compensation. \$\endgroup\$ Commented 13 hours ago
  • 1
    \$\begingroup\$ @SimonFitch It didn't get accepted because OP specifically asked for a solution that doesn't use an IC. \$\endgroup\$ Commented 11 hours ago
  • \$\begingroup\$ @evildemonic - I see that now! You're right, of course. \$\endgroup\$ Commented 11 hours ago
3
\$\begingroup\$

If your 5 V supply and 0 V to 5 V signal don't need to share a common ground you can connect them in series opposing (in series with positive to positive) and take the output from across a load resistance. The signal then subtracts from the supply voltage, inverting the signal.

This is about as simple as it gets, but again, it relies on the signal voltage being floating. You'll also have to take into account the signal source impedance as it will affect the output voltage. The load resistor should be at least two orders of magnitude higher (x100) than the signal source impedance. So if the source impedance was 100 Ω the load should be at least 10 kΩ.

enter image description here

In the schematic E1 is just there to give a ground referenced version of V2 so it's easier to chart, you would leave it out in hardware.

\$\endgroup\$
2
\$\begingroup\$

Would this be possible to achieve without any ICs?

Yes. But it would be much more complicated.

With a IC: It requires an op-amp with rail-to-rail output and 4 resistors.

enter image description here

Without an IC: You could recreate the op-amp functionality with discrete transistors, which would add at least 5 transistors, a capacitor, and a few more resistors. For example, this one.

With minimal components and no ICs, you could use a relay and 2 capacitors. It's ugly, but workable.

enter image description here

\$\endgroup\$
5
  • \$\begingroup\$ Unfortunately I only have a LM358 which is not Rail-To-Rail. Could you tell me more about the transistors circuit? \$\endgroup\$
    – Victor Ban
    Commented 2 days ago
  • \$\begingroup\$ I added a link to a page that describes how to make an op-amp with discrete components. \$\endgroup\$ Commented 2 days ago
  • 1
    \$\begingroup\$ Thank you very much, I’ll definitely look into it! \$\endgroup\$
    – Victor Ban
    Commented 2 days ago
  • 3
    \$\begingroup\$ the relay circuit is unlikely to work well, the NO contacts may not actually close. \$\endgroup\$ Commented 2 days ago
  • \$\begingroup\$ @Jasen Слава Укра?н? As I said: it's ugly. \$\endgroup\$ Commented yesterday
2
\$\begingroup\$

Don’t expect much accuracy and you must give up about 0.5V on both sides (Vcc and Gnd) from 0-5V range.

Make R6 variable from 220 ohm trimmer to set some bias current when a 0V is on input.

Blue is V2 , a green is Q1 collector.

enter image description here

Note: The Q2 compensates the Q1 BE offset (0.7V) and increases the input impedance.

\$\endgroup\$
1
\$\begingroup\$

You can try use this circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

It is very important that Rc is big enough so that Q1 is in saturation.The output impedance(under no load) of this circuit is Rc||Re and since typically Rc>>Re it will be a little bit smaller than Re.

\$\endgroup\$
0
\$\begingroup\$

something like this perhaps.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.