Converting/Inverting Analog Sensor Output From 5V-0V to 0V-5V

ebp

Joined Feb 8, 2018
2,332
In the circuit at #5:

The supply polarities are correct, though I don't like a battery symbol with an assigned polarity that conflicts with the normal use of the symbol (long line positive, short negative). I recommend flipping the symbol and setting the value to 7, rather than using the symbol upside down and setting the value to -7 - like Crutschow has done at #19.

The reason that +5 V input will not yield 0 V output is that the gain for the offset voltage is wrong. Using -7 V to produce an offset of +5.0 V requires a gain of -0.714. 10k & 15k yield offset gain of -0.667 for offset of +4.667 V, meaning with +5V input you will get -0.333 V output, exactly as your simulation has shown. Since you don't want to change the signal gain, you don't want to change the ratio of R1 to R2, so you would need to change the value of R3 to change the offset gain. I'll leave you to calculate the required value as an exercise.

==
You might be able to use a single supply op "rail to rail" op amp in Crutschow's circuit, but you'll need to evaluate it carefully. The signal current forces the output of the amplifier to "sink" current to its negative supply rail, and even so-called rail to rail amps can't get really close to the negative rail when sinking current (or the positive when sourcing). This means a single supply amp might only get within several tens of millivolts of zero, but if that is acceptable you save the need for a negative power supply. Since you want 5 volts out from the amp circuit, I'm guessing you want to use +5 V as the reference for the 3915 to keep everything ratiometric. This makes the not-quite-zero problem less of an issue.
Scaling all of the resistors in Crutshow's circuit up by a factor of 5 or 10 would reduce the amount of current and allow getting a little closer to the rail.

==
Your circuit at #3 should produce exactly zero volts output for the full range of your input signal because it is a differential amplifier with the same signal to both inputs, so the difference is always zero. In practical circuits a small mismatch in resistors ratios will cause the output to deviate from zero (interesting and instructive to play with mismatching in a simulation or doing the math). Imperfections in the op amp, such as input offset voltage, will also lead to non-zero output.
 
Last edited:

ArakelTheDragon

Joined Nov 18, 2016
1,362
The exact circuit is only for reference, because I needed to give a circuit instead of the principle. For me it works perfectly, but It does not matters.
 

Thread Starter

mohala

Joined Nov 30, 2017
14
Eric
I put in the 4.7K Ohms Resistor from your advice on #6, unfortunately, I still had the issue of the Blue signal output as -333.299mV. Here is the Screenshot:
upload_2018-8-29_12-44-34.png

From posts: #9, 20 and 21:
Also, Danadak and ScottWang and ebp, thank you for pointing that out about the negative voltage at pin 4. I used -7V just that it made it easier to see when I work late (and go into zombie mode) that I can clearly see it. But I understand I should follow engineering etiquette so that other engineers who see the layout would understand.

------
From Posts 19 and 21:
I see so if I used a rail to rail then I won't have to use an expensive negative voltage regulator which I just saw them be around 3-4 pounds. Am I correct in saying that? Also, am I correct in thinking that Rail to Rail mean that I can connect a 12V DC-DC Regulator to the Postive V pin and the negative straight to ground? Doing a quick search on Digikey on whats available I choose 'Rail-to-Rail' as the output type. I have found these ones on Digikey which are also on the Multisim simulation database to simulate: MCP6H01T-E/SN, TLV171IDBVR (On Multisim as TLV171IDBVT) and LM8261M5X/NOPB (On Multisim as LM8261M5). Using the circuit which crutschow simulated on LTspice I replaced the part with a rail to rail on Multisim (I used the TLV11IDBVT (Digikey Part TLV171IDBVR)).

This came out as a nice outcome when there is a 5V signal in the output comes out as 8.562mV and when the Input was at 0V the output was at 4.975V. This looks to be a much simpler design layout and lower cost as to the idea I was working with and came out to have a much closer outcome than mine. I have attached some more pictures for people so they can use it for their projects
upload_2018-8-29_12-59-50.png
upload_2018-8-29_13-0-3.png


Many Thanks goes to everyone on the thread, especially to Crutschow, ebp, ericgibbs and Scottwang.

The cost of the parts are now a lot lower and should cost me below £3 including the linear regulators to power the op-amp.

Again thank you very much for helping and to anyone else reading I hope this thread helps
 

ScottWang

Joined Aug 23, 2012
7,400
From Posts 19 and 21:
I see so if I used a rail to rail then I won't have to use an expensive negative voltage regulator which I just saw them be around 3-4 pounds. Am I correct in saying that?
The rail to rail function is provide the output high voltage close to the +Vcc and the low voltage close to Gnd(0V).

Also, am I correct in thinking that Rail to Rail mean that I can connect a 12V DC-DC Regulator to the Positive V pin and the negative straight to ground?
The Vout of 12V DC-DC converter with Regulator is connected to the +Vcc of op amp and the negative pin is connected to Ground.

What you said about a 12V DC-DC Regulator that it should be a 12V DC-DC converter with a regulator.
 

ericgibbs

Joined Jan 29, 2010
18,849
hi mo,
When using OPA positive and negative supply voltages of +/-12v, add over +5v and below 0v output protection for the MCU analog input.

The circuit in post #19 is the type I use and would recommend.

E
 

ebp

Joined Feb 8, 2018
2,332
If you don't need 12 volts for anything else, you can run a rail to rail amplifier on just +5 V, but again the amp won't be able to output a full 5 volts, which may or may not be a problem. However, because the LM3915 can be configured with a lower reference voltage, the full-scale input doesn't have to be 5 V - it could be 4.5 V, which would eliminate the need for the amp to swing to fully 5 V. This would mean you would need to recalculate the resistors to get the offset and gain you need (e.g. gain of -0.9 instead of -1.0 for the signal). But as long as the amp's output goes high enough to light the top LED, it doesn't matter if it gets all the way to 5 volts, so changing the offset resistor would be all that is required. That works out nicely, since you can use four resistors of the same value.
 
Top