Opamp for 3.3V to 5V

Status
Not open for further replies.

HR19

Member
OK so I've found lots of videos on YouTube and stuff explaining the general function of an opamp and how it can be used. I'm planning to try to make a circuit which uses a device with has analog 0-3.3V out, but the receiving device can go as high as 5V in. I was thinking if someone knows how to do it (or can tell me how to figure it out), an opamp with the right feedback resistance should theoretically be able to provide this. Essentially I need a 50% gain via the opamp (unless a DC-DC converter circuit is easier or more accurate at this sort of thing). Is that doable? Is there an easy way to figure it out, or do I just need to buy an opamp and try some different feedback resistor values until I find the right one?

EDIT: Turns out that level shifters breakouts are REALLY cheap (just got 10x for $6 on Amazon).
 
Last edited:
Turns out that level shifters breakouts are REALLY cheap
What are those?
They sound like digital level shifters which don't do analog.

For converting 0-3.3V analog to 0-5V analog you could use a rail-rail type op amp with a non-inverting gain of 1.515 (LTspice simulation of example circuit below):

 
Firstly, thanks, that's a really awesome diagram!
Secondly, here's the one I just bought from Amazon https://www.amazon.com/dp/B08C9PFVGP/ref=cm_sw_r_cp_apa_fabc_2HYP7Q58QM1R363JXV3V

No clue if it's analog compatible, it doesn't say.
 
Ah, ok, thanks. What are 11C and 12C signals? Do you know would it work with PWM signals? Low or high frequency?

It's not helping that he used the wrong letters (he used '1' - the number one) instead of the capital 'i' - 'I'. I2C is an inter-IC communication system invented by Philips, and intended to simplify PCB design in TV's.

As it's simply a (crude) digital level shifter it will work fine with PWM, but obviously MUST be before the filtering.
 
So I took your diagram and used 10k and 5.1K resistors (what I had handy), and did some more experimenting. The opamp I have is an LM358, and like this it seems to give me 2:1 output to input, and then it's saturated (stops rising) at about 3.5Vout. If I take out the feedback resistor then I get a slightly higher output of 3.9, but the positive voltage is 4.87. Why am I losing so much, and why am I getting a 2:1 gain instead of ~1.5:1 gain?
 
Check out this article, which was posted in a Jon's Imaginarium post.

The gain equations for inverting and non-interverting amps aren't the same.

**broken link removed**
 
Are you saying that the one in the original diagram, the LMC6484A is fundamentally different from my LM358 in how it operates? I just read through that article you linked to and given the equation, I should have about a 1.51:1 gain, Vout:Vin with how I have it wired. Yet I was seeing about 2:1. And regardless of that, the output is saturated at 3.51V when the secondary voltage (not sure what that's called) is 4.87V. So I'm still losing over a volt for some reason.
 
The old LM358 (it is not rail-to-rail) output cannot go higher than about 1.3V less than its power supply voltage (yours is 4.87V) so its max output is 4.87 - 1.3= 3.57V. If it has a load then its maximum output voltage is less. It is shown in its datasheet.

Your circuit's gain is 1 + (5.1k/10k)= 1.51 times. With a 5V supply, its maximum allowed input voltage is 3.5V.

The LM358 is fairly slow so it does not work at high audio frequencies. You said analog which might be audio. The LM358 produces hiss and crossover distortion.
 
Are you saying that the one in the original diagram, the LMC6484A is fundamentally different from my LM358 in how it operates?
Not fundamentally, but in its maximum output voltage, as AG noted.
Below is the LTspice simulation with your resistor values and op amp:
The gain is about 3.58/2.37 = 1.51.
I'm still losing over a volt for some reason.
The reason is shown in the data sheets for the op amps.


 
Thanks for all the help guys!

I'm not doing audio, it's to replace a 0-5V hall effect sensor as a throttle connecting to a motor controller. So the LMC6484 doesn't have the voltage drop that the LM358 does? Gotcha. I can use a higher supply voltage on the LM358 instead though right? Maybe like 12V, but because the gain is only 1.51 it still won't go above ~5V, right?
 
Although this is an extreme oversimplification, you can roughly break opamps into three types.
- Standard. These usually need bipolar supplies. The outputs cannot reach either of the supply rails.
- Single supply. The outputs of these can reach the negative rail, but not the positive rail. The LM358 is this type.
- Rail to rail. The outputs of these can reach both supply rails. The LMC6484 is this type,

Yes, the output of the LM358 with 12 Volt supply will go to 5 Volts. If the input voltage times the gain equals 5 Volts, then it won't go higher than that.
 
I can use a higher supply voltage on the LM358 instead though right? Maybe like 12V, but because the gain is only 1.51 it still won't go above ~5V, right?
Yes, that should work.
Simulation below:

 
The hiss from an LM358 might cause the throttle to fluctuate a little at any setting.
The crossover distortion produced by an LM358 might cause the throttle to make a "twitch" at a certain setting of when the voltage cross occurs.
 
You know I think then my best option will be to use that digital level shifter from my earlier post with PWM, then flatten it out with an RC low-pass filter.
 
You know I think then my best option will be to use that digital level shifter from my earlier post with PWM, then flatten it out with an RC low-pass filter.
I'm hoping there is not a confusion about what a digital level shifter does. If a 5v logic signal is sent from a sensor, the level shifter will convert it to 3.3v to send as a logic HIGH to a microcontroller running at 3.3v and requiring max 3.3v input. A zero volt signal will remain zero volt. Any signal in between zero and 5 Volts will require a check of the datasheet to see whether the level shifter output will be 0V or 3.3v. It will never be anything in between (except for a few hundredths of a microsecond).
alternatively, a level shifter can work in reverse or both - converting a 3.3v logic signal to 5v. Again, no levels in between 0 and 5v will be output.
 
Yes, that's why I said level shifter with an RC low-pass filter. I know the level shifter I have will handle at least 20kHz PWM signal (tested it, works great), but I didn't try the low-pass filter yet. My Seeeduino Xiao can do up to 47kHz PWM on all but 3 pins, so a 2k resistor and 33uf cap (or thereabouts) should give me a very fast settling time and good, smooth, analog output.
 
You're mixing up two ideas.

A PWM signal is DIGITAL – it's high or low, and a digital level shifter will shift the high level signal 3.3v from the Xiao to 5 volts.

The low pass filter converts the highs and lows of the PWM signal to DC.
 
You're mixing up two ideas.

A PWM signal is DIGITAL – it's high or low, and a digital level shifter will shift the high level signal 3.3v from the Xiao to 5 volts.

The low pass filter converts the highs and lows of the PWM signal to DC.
No, I'm not mixing up anything. I'll generate 3.3V PWM, then level shift it up to 5V (still PWM), then filter it to DC so I'll have 0-5VDC out (roughly, not exactly, but close enough).
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…