3

I want to invert, difference, and amplify the 11.3-12V decaying (upwards to 12V) signal from the metal detector coil in the circuit at https://www.lammertbies.nl/electronics/pi-metal-detector into a 0-5v range signal compatible with microcontroller ADCs.

I looked at Level shifting a +/- 2.5V signal to 0 - 5V and the answers there, especially the https://electronics.stackexchange.com/a/37096/30711 which contains the only example of an inverting level shifter I've found, but since I want amplification and the input signal is not centered on zero, my use-case seems a couple steps more complicated.

schematic

simulate this circuit – Schematic created using CircuitLab

I figure that this will clip with 0+-2.5V on the output, but I'm not quite sure how to inject an offset to push it up an additional 2.5v.

Do I sum in another voltage on the negative input?

Or would I adjust the positive input to something else?

===

For clarity, I'd like for the circuit to do approximately V_out = (12-V_in) * 7. I make plenty of sign and order of operations errors in my day job, and I'm curious how to translate this operation into an opamp. My attempt above seems like it would do V_out=(12-Vin)*7+(12V+0V)/2

Some completely fabricated curves of simulated input and desired output are below.

# R code:
x=0:30/1000
y1= 12-0.7* ifelse(x < 0.010,1,exp(-200*(x-0.010))); plot(x,y1,'l',col='black')
y2= 12-0.7* ifelse(x < 0.008,1,exp(-250*(x-0.008))); lines(x,y2,'l',col='red')
y3= 12-0.7* ifelse(x < 0.012,1,exp(-150*(x-0.012))); lines(x,y3,'l',col='blue')
y1= 7*0.7* ifelse(x < 0.010,1,exp(-200*(x-0.010))); plot(x,y1,'l',col='black')
y2= 7*0.7* ifelse(x < 0.008,1,exp(-250*(x-0.008))); lines(x,y2,'l',col='red')
y3= 7*0.7* ifelse(x < 0.012,1,exp(-150*(x-0.012))); lines(x,y3,'l',col='blue')

Simulated sample transient input voltages:

enter image description here

Simulated sample transient output voltages:

enter image description here

Dave X
  • 372
  • 5
  • 12
  • It's unclear to me when you say "invert". Do you want 11.3 V to go to 0 V and 12 V to go to 5 V or 11.3 V to go to 5 V and 12 V to go to 0 V? –  Nov 18 '21 at 22:56
  • Are you interested in the DC component or is it possible to AC-couple the signal to get rid of DC? – bobflux Nov 18 '21 at 23:10
  • _would I adjust the positive input to something else?_ That's the way to do it. – Davide Andrea Nov 18 '21 at 23:21
  • @james -- by invert I mean multiply by -1 -- the metal detector circuit has a low-side switch om the coil and is emitting a signal tat decays back to +12v. I would like it to decay from near 5v towards zero for the ADC. – Dave X Nov 18 '21 at 23:32
  • AC couple it - if you attempt to just do a DC offset it will require constant adjustment when the 12v power drifts. – Kevin White Nov 18 '21 at 23:44
  • So is 11.3 V to be translated to 0 V and 12 V to be translated to 5 V? –  Nov 19 '21 at 00:11
  • @Davide Andrea: so one shouldn't think of the math as `V_out=(12-V_in)* 7` but maybe like `V_out= (-V_in)*7+C` or maybe `V_out= (-V_in)*7+C+(12V+0V)/2`? – Dave X Nov 19 '21 at 00:45
  • You've answered "yes" to my question but the equation which you've added to your question suggests that you require 12 V to be translated to 0 v and 11.3 V to be translated to +5 V. Getting more confusing by the minute! –  Nov 19 '21 at 00:54
  • @James: My comment was mistaken-- I will delete it. I should have said: No. I instead want the curve inverted, with 12V to produce zero, and 11.3V to produce a value near 5V. I've added input-output curves to my Q. – Dave X Nov 19 '21 at 01:01
  • @Kevin White: I'd think that AC coupling might make the output dependent on changing frequency and amplitude. Also, the curve between 12 and 11.7 is clamped by a diode pair, so it should drift with the 12v as the power drifts, and if I reference the offset to the 12V Vcc with a voltage divider, it should drift with the power. – Dave X Nov 19 '21 at 01:04
  • The TI design guide https://www.ti.com/lit/an/sloa097/sloa097.pdf SLOA097 -- "Designing Gain and Offset in Thirty Seconds" classes this as a "negative m and negative b" problem per y = -mx - b. – Dave X Dec 02 '21 at 18:51

2 Answers2

5

ok:

$$ output = ( 12V - input ) * ( 5/0.7 ) $$

schematic

simulate this circuit – Schematic created using CircuitLab

R1,R2 gives the needed -7.14 gain

R3,R4 gives the needed bias to give 0V out when in is 12V (by symmetry)

use 1.1K in series with 300 ohms for R1 and R3

a good thing about ther LM358 is that its output goes to the negative supply, but unfortunately the input can only go to withing 2v of the positive supply.

there;s also a problem in that the output is not limited to 5V if the input goes out of range. but ther LM358's waek output stage is unlikely to be able to do any damage.

That power supply requirement is a pain. So, can better be done?

Yes!

schematic

simulate this circuit

Here I've added 2k resistors pulling fown on the inverting and non inverting inputs.

This reduces the input votlage to the op-amp to arounnd 7V (I have not done the arithmetic) allowing it to operate off a 12V supply. or even lower.

Because it's symmetical this change does not alter the operating point of the amplifier output.

  • 4
    Specify the rails for the LM358 (it's not a great opamp) and the error bounds given a specified resistor tolerance and bias and offset currents and I think this answer is worth lots of +1 from everyone. Nice topology. I'm +1, anyway. But I'd like to see more written about it. – jonk Nov 19 '21 at 04:58
  • 1
    true, that naiive circuit is not as simple as it first appearsed – Jasen Слава Україні Nov 19 '21 at 09:14
  • To keep the single 12V supply, and accommodate the LM358's `Vin < Vcc-2V` constraint, I suppose I could run the input through a 10/12 voltage divider, increase the gain to `G=5/0.7*12/10=-8.57... // Ah, I see--the "(by symmetry)" is that at 0V, Vin- = Vin+, so you design the V+ bias voltage to match the desired 0V output. – Dave X Nov 19 '21 at 16:44
  • For high-side operations like this, maybe the TL081 would be good with it's input range of (Vcc-+1.5V to Vcc+) as compared to the LM358's range of (Vcc- to Vcc-1.5C) https://www.ti.com/lit/ds/symlink/tl081.pdf vs https://www.ti.com/lit/ds/symlink/lm158-n.pdf – Dave X Nov 20 '21 at 03:36
  • 1
    by addign two resistors the output can be brought into the acceptable range for the op-amp (see edit) – Jasen Слава Україні Nov 20 '21 at 04:53
  • I understand you selected R3 and R4 for symmetry to give 0V when the input is 12V. Can you explain that a little more? How do you select R3 and R4? – F. Heisenberg Oct 29 '22 at 21:00
1

Level Translator

If input signal drifts with the power rail then output accuracy should be maintained.

  • Why does it take eight (8) resistors to bias the non-inverting input? – AnalogKid Nov 19 '21 at 02:06
  • @AnalogKid To get the accuracy. Thevenin equiv cct of R7/R9/R1/R8 is 11.65 V voltage source in series with 9k1 resistor. This Thevenin voltage must be equal to the mid-voltage of the input range. Thevenin equiv cct of R4/R5/R10/R11 is 2.5 V voltage source in series with 65k resistor. This Thevenin voltage must be equal to the mid-voltage of the output range. The two Thevenin resistances must be equal to the two resistances connected to the inverting input and there ratios are equal to 5V/0.7V. –  Nov 19 '21 at 02:23
  • So the feedback gives a 65K/9.1K=7.14 gain, and on the + terminal, the 12V* (312k)/(312k+9370) voltage divider gives a 11.65V reference which is the center of the range of interest, and the (82100)/(82100+312e3)*12 voltage divider gives a 2.5V reference, which is the center of the output range. How do you choose the particular voltage dividers? // I'm reading your comment about matching the Thevenin resistances of the input and feedback resistors, but could you point me at why? – Dave X Nov 19 '21 at 02:56
  • you're not getting 4 figures of voltage accuracy by using 8 5% resistors. or even 1% resistors. – Jasen Слава Україні Nov 19 '21 at 04:04
  • @Jasen Yes, I agree. Yours is a better solution. –  Nov 19 '21 at 04:51
  • I was going to point out the false accuracy, but Jasen beat me to it. You will get better accuracy and stability with just two resistors and a trimpot, all of the same construction and tempco. Also, you will be able to trim out the LM358's relatively large input stage errors. – AnalogKid Nov 19 '21 at 05:08
  • @AnalogKid Yes, I too was converging on the pot and series resistors solution. Also if an op amp with a higher common mode input range than the LM358 has is used then the op amp can be powered from +12V making life easier if a +12V rail is all that is available. –  Nov 19 '21 at 11:56