Author Topic: Need assistance in calculating resistors in a differential amplifier  (Read 1805 times)

0 Members and 1 Guest are viewing this topic.

Offline mitrynicolaeTopic starter

  • Contributor
  • Posts: 45
  • Country: ro
Hello guys

I need your assistance in calculating R1 R2 R3 and R4 resistors from the attached schematic. The requirements are that at 25V the opamp should output 2V and the opamp should be powered from a single 5V supply.

Also please let me know if what I am trying to achieve is correct.
- if the base of the transistor is off and no battery is connected then the opamp should output 0V
- if the base of the transistor is on but  no battery is connected then the opamp should output 2V
- if the base of the transistor is on and the battery is connected then the opamp should output a value between 0 and 2 volts depending on the battery resistance (RL is used to simulate this resistance)
- if the base of the transistor is off but a 12V battery is connected then the opamp should output 0.96V
- if the battery is placed by mistake in reverse and the base of the transistor is off then the output should be 0.

Also please let me know the following:
1. is what I am trying to achieve correct or not?
2. in case of the reverse voltage on the opamp (+ and - not the supply), will the opamp survive?
3. what resistors I should change with potentiometer (only one if possible) in order to have possibility to adjust the output in case the resistors are not precise
4. is there any other method to measure the voltage between the specified points
5. regarding my schematic, could you also post the equations that lead to the calculated values or at least how you deduce them?

P.S. Please note that RL only simulates the battery internal resistance.
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 3430
  • Country: ua
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #1 on: April 06, 2019, 11:15:15 pm »
Here is very nice video from Dave which explains how it works:

 
The following users thanked this post: mitrynicolae

Offline alex.martinez

  • Contributor
  • Posts: 44
  • Country: es
  • Happiness is fixing electronics by hitting them.
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #2 on: April 07, 2019, 12:31:56 am »
Also please let me know if what I am trying to achieve is correct.
- if the base of the transistor is off and no battery is connected then the opamp should output 0V
- if the base of the transistor is on but  no battery is connected then the opamp should output 2V
- if the base of the transistor is on and the battery is connected then the opamp should output a value between 0 and 2 volts depending on the battery resistance (RL is used to simulate this resistance)
- if the base of the transistor is off but a 12V battery is connected then the opamp should output 0.96V
- if the battery is placed by mistake in reverse and the base of the transistor is off then the output should be 0.


You have two batteries in the system...I have no clue of which one you are talking about...

2. in case of the reverse voltage on the opamp (+ and - not the supply), will the opamp survive?
It should, +-32 V of input common mode, you can check the datasheet of the LM324AD

3. what resistors I should change with potentiometer (only one if possible) in order to have possibility to adjust the output in case the resistors are not precise

By a resistor being not precise, you mean if their tolerance is too large? What it is done to avoid this is to use high component values (100 k for instance) so that the tolerance is not so critical in general. But if you worry about acurracy, grab a decent multimeter and measure the components, adding pots all over the place ends up being messy. If you want tunability, add pots on small resistors (1 k, 5 k...)

4. is there any other method to measure the voltage between the specified points
I do not know whether you refer to mesuring the voltage in the simulator or in a physical sense...but I would suggers you that you post more info...

5. regarding my schematic, could you also post the equations that lead to the calculated values or at least how you deduce them?
They have posted an opamp tutorial prepared by Dave, I strongly advice that you watch it and try to understand the system, rather than guessing values from a simulator.
 
The following users thanked this post: mitrynicolae

Offline mitrynicolaeTopic starter

  • Contributor
  • Posts: 45
  • Country: ro
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #3 on: April 07, 2019, 07:14:23 am »
Thank you Martinez for your time!

Meanwhile I figured out the solution. The issue was in my logic. For the sake of simplicity let's consider that the supply voltage is 20 volts. I then divided this voltage to 10 and got 2V on the positive input of the opamp. Then I have set the R3 and R1 in order to match the R2 and R4. The issue was that the output voltage excedeed 2V. Which if you think about it is absolutely normal. The opamp tries to match positive input with the negative input by compensating with the output. In my case R1 and R3 acts as a voltage divider. The maximum voltage that the opamp can measure is when the positive input of the opamp is 2V and the R1 is conected "ground". This can be achieved by turning on the transistor and disconnect the load. Since the opamp will try to match the positive input with the negative input (at 2V) and since the R1 and R3 act as a voltage divider, and since R1 is connected to ground (we already demonstrated that) then we can calculate the required output.
(Vout-V2)/R3 = V2/R1
R1Vout - R1V2 = R3V2
Vout = (R1+R3)V2/R1
After applying the actual values we can determine that the Vout is aprox 2.2V which also the simulation suggested.

Thank you all for the answers. Sometimes even if you know the theory you just think that it will be easier to play around with the values. It turned out that with electronics is different and you can get quickly very frustrated when in fact the solution was to take a paper and a pencil and calculate the values. After a night of sleep I found the logical gap in the design and I have recalculated the values. I have attached a schematic of the actual (working) design. I know that I should use greater resistor values in order to not waste the current but I have a lot of 1k and 10k resistors and I don't want to buy other resistors.

For others who might face the same issue I also suggest this site: "https://www.electronics-tutorials.ws/opamp/opamp_5.html".

@martinez the external battery is marked on the schematic with a rectangle with + and - signs having the text "ExternalBattery". (You did not see this coming  :-DD :-DD :-DD)
 

Offline mitrynicolaeTopic starter

  • Contributor
  • Posts: 45
  • Country: ro
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #4 on: April 07, 2019, 07:24:56 am »
P.S. The fine tuning potentiometer should be placed in series with R3. We all know that resistors (even at 1% tolerance) will not be spot on and we need a way to fine tune the output. In this case R3 should be 9.5k (9.53k is the closest that you can buy) and a potentiometer of 1K. This will allow a correction of 5% up or down.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19562
  • Country: gb
  • 0999
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #5 on: April 07, 2019, 06:30:02 pm »
In what way do you want to change the output? Are you talking about the gain or offset? In this circuit, it's difficult to alter one, without affecting the other, with just one potentiometer.

What are the other sections of the LM324 being used for? Are any of them spare? If so, that would make it easier to adjust the offset voltage.
 

Offline mitrynicolaeTopic starter

  • Contributor
  • Posts: 45
  • Country: ro
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #6 on: April 08, 2019, 03:40:36 pm »
My intention is to have a way to adjust the amplifier in case the resistors are not spot on (which most certainly won't be). Could you please let me know where to put the potentiometer in order to solve this issue? It seems that my sugestion of putting it in series with R3 is not a good solution since it affects also the gain. My intention is to have always the gain of 0.1 regardless of the resistors tolerance. Ideally the output value of the opamp should be 2 volts (when measuring 20V) but if it is 1.995 then it is no issue since the measurement error will be compensated in software. It is always easier to compensate a constant error than to compensate an unknown gain (thats way I really need an exact gain of 0.1 regardless of the input value).
 

Offline mitrynicolaeTopic starter

  • Contributor
  • Posts: 45
  • Country: ro
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #7 on: April 08, 2019, 04:09:09 pm »
It seems that trying to compensate the opamp in order to do what I want is harder than I thought. Maybe as someone already suggested on this site, buying very low tolerance resistors is the best bet I have so far. Could you please suggest me a good store (that can deliver to Romania) and also some very low tolerance resistors (SMD package 1206) (preferably under 0.01%)?
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19562
  • Country: gb
  • 0999
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #8 on: April 08, 2019, 04:19:29 pm »
Mouser, RS Components, Digi-Key and Farnell are the  suppliers I use most often, but 0.01% tolerance will be expensive. At that tolerance, the drift also becomes significant. You can trim with a potentiometer, but when the temperature changes, the resistance will, causing the gain to drift.
 

Offline mitrynicolaeTopic starter

  • Contributor
  • Posts: 45
  • Country: ro
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #9 on: April 08, 2019, 04:28:40 pm »
Thank you for the replay Zero999, but where to put the adjustment potentiometer. The issue is that I want to have only one adjustment potentiometer and not two or more.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21729
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #10 on: April 08, 2019, 05:08:32 pm »
The transistor is always on, I fail to see what should happen here? ???

The traditional method to measure internal resistance is to apply an AC current, and measure the resulting AC voltage.  The circuit looks very different.  A typical implementation will be simultaneously more complicated (more components required), and simpler (consisting of only a current source and a voltmeter).  The source can be an oscillator and buffer amplifier or switch, and the voltmeter can be an AC coupled amplifier and precision rectifier, or a synchronous rectifier (analog switch), or...

Note that a SPICE "battery" is actually an ideal voltage source, i.e., Rs = 0 by definition.  You will need to find a model that describes a battery, to be able to test your circuit with something realistic.

Note also that, in general, the internal resistance varies with frequency, typically in a sqrt(f) manner (this is due to ionic diffusion within the battery).  This gives an impedance which is equal parts capacitive and resistive, so that it is difficult to speak in terms of resistance as such, even at very long time scales (which implies a large change in charge state, for which we of course expect a change in terminal voltage).  At shorter time scales (~kHz), it is capacitive (the capacitance of the battery plates themselves), and at still shorter times (~MHz), inductive, and so on (wiring stray inductance, radiation losses for the wiring as random antennas, etc.).

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline mitrynicolaeTopic starter

  • Contributor
  • Posts: 45
  • Country: ro
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #11 on: April 08, 2019, 06:04:00 pm »
Regarding the schematic, you can completely ignore the transistor and the battery. In fact let me add another simplified schematic. Now on this schematic, considering that the load resistor is disconnected and that the other resistors are not perfect (let's say 5% tolerance) where should I put the potentiometer in order fine tune the circuit and to obtain 2 volts on the output. I have tried several configurations (with the potentiometer in series with R3 or R1 but the output is not proportional with the input anymore.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9893
  • Country: us
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #12 on: April 08, 2019, 06:45:30 pm »
That schematic looks a lot like a non-inverting amplifier.  Does this calculator help?

https://www.allaboutcircuits.com/tools/non-inverting-op-amp-resistor-calculator/

Without checking the datasheet, I don't know that the op amp can get within 2 volts of ground.
 

Offline mitrynicolaeTopic starter

  • Contributor
  • Posts: 45
  • Country: ro
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #13 on: April 08, 2019, 07:16:28 pm »
Thanks for your help, but also the online calculator showed that the R1 should exactly match the R2 (according to their schematic). Basically if the resistors are not perfect then weird voltages will appear on the opamp output.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19562
  • Country: gb
  • 0999
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #14 on: April 09, 2019, 01:48:22 pm »
Don't use 5% tolerance resistors, when 1% is widely available and isn't expensive.

The only way to trim the gain, without adding another op-amp or affecting the offset is to set the gain slightly higher than required and add a potential divider to the input.
 

Offline RandallMcRee

  • Frequent Contributor
  • **
  • Posts: 541
  • Country: us
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #15 on: April 09, 2019, 03:18:33 pm »
Thanks for your help, but also the online calculator showed that the R1 should exactly match the R2 (according to their schematic). Basically if the resistors are not perfect then weird voltages will appear on the opamp output.

Right. This is why you should consider an integrated difference or instrumentation amplifier. The resistors are built in and trimmed to precisely match. All kinds of benefits, go to Analog Devices site and read some app notes.
 

Offline mitrynicolaeTopic starter

  • Contributor
  • Posts: 45
  • Country: ro
Re: Need assistance in calculating resistors in a differential amplifier
« Reply #16 on: April 09, 2019, 05:17:08 pm »
Thank you RandallMcRee. I will open another thread starting by your idea.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf