Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Voltage level shift

Status
Not open for further replies.

augustinetez

Active Member
I need to level shift a voltage that has a range of ~3V and sits between ~2 & 5V, to a non-inverted 0 - ~3V to feed to a PIC ADC input (PIC is running on 5V).

And it of course needs to done simply and cheaply (when doesn't it).

Idea #1 (ignore the resistor values for the moment, they are placeholders) open to other ideas but pcb real estate is limited.
The cap is to try and keep out any rubbish that might be on the incoming voltage and the op-amp is a rail-to-rail device TLV2371.
level_shift.jpg
 
Nope. You want to shift the input signal range downward. But an attenuator referenced to a voltage that is greater than the average value of the input signal will shift that signal upward.

ak
 
Why not do it in software? Simply subtract 2/5x1023 from the result.

Mike.
Edit. Unless you intend to use the internal 4.096V reference.
 
You have roughly the right idea, a "differential amp" - but the input reference should be the 2V offset and the output reference zero.

The 20K that connects to 5V should be grounded (output reference), and the 20K grounded should be at 2V (input reference)
And the Vin 10K & 20K should be opposite values.
 
Since the slope of your curve is a fixed G, all you need is an offset.

You can get a +/- 2% zener, 2V, and a R, say 1K, and that will do the offset.

Or use a 3 term adjustable Vref (the LM385 is functioning as an adjustable zener)

1639493501694.png



Note the symbol is screwy because I could not find a standard spice model for the part.
Also the 385 may be obsolete but there are replacements for it, TI, Analog Devices.....

This particular model was 2.4V I think, but you get the idea. The zener / Vref gives you a fixed
Voffset which is all you need. 2V and 2.048 V seem common as references.


There is a consideration for Vref settling time if your input signals
are transient large signal rich, otherwise can be ignored.


Regards, Dana.
 
Last edited:
Thanks Dana.

The incoming voltage of interest is a user adjustable DC voltage, so slow moving at best, but it is in an RF environment so likely to have some artifacts impressed on it.

Left side of attached diagram is the bit of interest (right side is a preset - not user adjustable).

Marked voltages are assuming components are 'ideal' and 8V line is actually 8V, something we know is unlikely to happen in the real world, hence the use of ~ above.
clarifier.png
 
Is it possible to change the pot to a dual gang? One with the existing components and one that goes from 0 to 5v.

MIke.
 
Trying to avoid that if possible - lot of disassembly work to get to it and possibly not enough room anyway - unfortunately, I don't have the piece of equipment in front of me, it's on the opposite side of the globe.

There is an easily accessible connector that carries the voltage to tap in to.
 
What is your goal in accuracy of A/D reading ?

Do you care about absolute accuracy or relative
accuracy ?

What A/D reference is being used, internal to chip or external ? Part number of chip ?


Regards, Dana.
 
I don't need absolute accuracy, it is a piece of (old) equipment still much in use, but I can't say much more about that until I know if this is going anywhere or not (it may be a one off or it may be a reasonable volume bit of kit).

I still need to do the numbers re the ADC reference but I would like as far as possible to have at least 1000 of the 1024 bits of the ADC available to cover the 3V, allowing for a few bits at each end and center of the range for a bit of dead band.

I'm poking this in to a 16F1827 (with software being moved across - with some additions - from an older chip)

And looking at the schematic, the Vref+ pin is being used for something else :banghead: so it will have to be the internal 4.096V Ref and probably a little bit of up-scaling of the range via the op-amp.

I'll see what happens and move pin functions around if needed (I've got a couple spare).
 
Doing it completely in software will give a range of ~600. That is 0.16% per bit. Surely that is accurate enough as I can't position a dial to that accuracy. Note, that would be using Vdd as the reference. Is your Vdd a stable 5V supply?

Mike.
 
Finally got the chance to build this and test it - and of course it doesn't do what I want :banghead: - can anybody see a flaw in the implementation.

I would have expected the output voltage to run between ~0 and 2.65V with the given input voltage range.
level_shift2.jpg
 
I would have expected the output voltage to run between ~0 and 2.65V with the given input voltage range.
No, because you have a differential amp with a gain of 1/2, thus your output offset is -1V, and the output swing is 1/2 the input swing.

Below is the LTspice simulation of your circuit adjusted for your original requirements and using a stable reference:

First I calculated the value of R1 to give an inverting gain that generates -2V output offset from the TL431 2.5V shunt reference voltage.

Then I determined the R4 and R5 input resistor values to give the desired non-inverting gain (+1 here) at the output.
In this case it can be just the same values as R1 and R2.

From that, the simulation shows the output (yellow trace) going from ≈ 0V to 3V for an input of ≈ 2V to 5V (green trace) as calculated.

1642747419026.png
 
Last edited:
I would have expected the output voltage to run between ~0 and 2.65V with the given input voltage range.
Just change the 20K resistors to 10K, so it's a unity gain differential amp.

You may have to tweak the bias slightly to get the best range.
 
No, because you have a differential amp with a gain of 1/2,
Yep, helps if you use the right calculations, using the right one gives me the same number - Vout = (V2-V1)*Rf/Rs :oops:

Will have another go with amended values, thanks.
Just change the 20K resistors to 10K, so it's a unity gain differential amp.
Did actually try that and the output dropped from 1.2V to 1V - but it is possible I had a bad connection - been too hot and sticky in the back room today.
 
Just change the 20K resistors to 10K, so it's a unity gain differential amp.

Did actually try that and the output dropped from 1.2V to 1V
Turns out I had shorted a wrong resistor (In the test bed I had 2 x 10k in series for the 20k) - correcting that now gives me 0 - 2.53V output for 1.82 - 4.35V input.

I'm going to try using 100k resistors to (hopefully) lighten the load on the incoming line to restore it back to it's original 2 - 5V range.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top