Monday, June 9, 2014

Toying with Gain - A Peek at the Differential Amplifier

Op Amps have many uses and functions, even more so than a massive wikipedia page can cover. Today I will introduce the Differential Amplifier; one such function. I will also offer some real-life instances in which to use it and then discuss some issues that I found in testing.

Differential Amplifier

With some simple algebra, one may calculate a wide range of gain to apply to an input signal. According to wikipedia, the differential amplifier amplifies the difference in voltage between its inputs. The two inputs are shown as minus (-) and plus (+) or inverting and non-inverting respectively. Depending on the location of Rf, or the feedback resistor the output signal will be inverted or not. With feedback from Vout to minus, the signal will not be inverted. With feedback from Vout to plus, the output will be inverted. I only have a use for a non-inverted signal right now, so Rf will remain from Vout to minus, as shown below:

The image is borrowed from wikipedia, and is how they show a non-inverting differential amplifier. Now for the math behind it.

Not a terrible equation by any means, and it can be reorganized to calculate any of the variables other than Vout if need be. It is probably in the user's best interest to do so since they most likely already know what Vout they want and what the input voltages are.

Applying your own 1/3 or 1/2 Gain

I do have one problem with this though and that is Rg which is connected to 0v. This voltage is not taken into consideration of the equation, but could potentially be any other voltage! Lets say I want to connect V1 to 0v so this functions like an ordinary gain amplifier. According to this guy:
If R4 (Rg) is connected to another voltage, that voltage becomes the reference voltage that the output signal centers on. His example illustrates a -5/+5v (10vpp) voltage being multiplied by a fractional gain to output a 0/3v3 siganl. (3.3 - 0)/2 = 1.65, which becomes his reference voltage. This is excellent news since I need to work with a 10vpp signal as well. I however need to apply a 1/2 gain to get 0/5v instead of 0/3v3. Since 33K/100K = 1/3, then 50K/100K - 1/2. All i have to do is replace the 33K resistors with 50K resistors and change the refrence voltage to (5-0)/2 = 2.5v.


Just a note that seems never to be shared is that the power supplies to your op amp must exceed the range of your gain. If you want to amplify (lets say) a 0/5v signal up to 0/10v, then you must have a power supply at or above +10v at the positive voltage input and at most a 0v signal at the negative power pin. If you do not use a supply higher than your what your output could potentially reach, then you will see "clipping" where the signal gets cut off at the levels of the supply.

Another note is that your power supply connections may be less than the input signal if in fact you are applying a fractional gain (1/2 gain, 1/3 gain, etc.). If you have a input signal of 0/5v and want an output of 0/3.3v, then you may happily use a 3.3v input as the positive supply voltage.

Clipping sounds like a bad thing, but at the same time you may exploit it in your advantage. I need to send Vout to a microcontroller, which has a 5v tolerance. If this tolerance is exceeded, then the mC could be damaged which we don't want! Since the 10vpp signal is coming from an outside source, I have no control of how precise it is. It coul be high than +5v or lower than -5v potentially. So I can use clipping to my advantage to protect the mC. How? By applying a voltage supply the same as my Vout limits: 0/5v.
With ground and +5v, any other voltages will be clipped off! Genius. :P

Applying a Gain of 2 - Problematic ...

Within the same project, I have the need to apply another gain to another signal. I need to boost a 0/5v signal into a 10vpp signal. Since this is the exact opposite of my calculation above, I can say with confidence taht we just swap the resistors values. 50K and 100K values are swapped to produce a 2 times gain. I also want my output to be centered on 0v, so I should connect my reference voltage to 0v. It all sounds correct and I set it all up on my breadboard:

Yes, its a mess but I have three voltage supplies (+12, -12, 0 and +5) and a pot (off screen) connected to 5v and 0 as a voltage divider for my input. I also have more resistors than I should because I don't have any 50K ohm resistors, so the 100Ks are in parallel to make 50K. At one point I even had a -5v regulator connected on the board...

The problem is that when I measure my Vout with an input signal of 0/5v I am reading a range from 0 to +10v. Now, this is perfect for my gain calculations, but bad because of my reference voltage. It is referenced at +5v. Clearly, this is wrong or I am wrong, or something...

I want to assume that the reference voltage works only if it is a positive value. 0 and negative do not work as references because of some multiplication in the equations that I am missing. Everyone knows what happens when you multiply by negative numbers or by 0. I believe the fix may be a second op amp, but with a different configuration. A configuration not to apply a gain, but to shift the level down by 5v. By changing the reference and not the gain, I should be able to get the voltages I want to see. I will get back to you all once I do some further reading and testing. Let me know if you have a solution before I find it.

Until then however, I designed a simple board in Eagle that allows the user to configure it in different ways. Gain can be calculated, reference(s) voltage can be chosen Vp and Vn and it even has the option to add some DC clocking capacitors if you are working with audio signals. I call it devGain. It too has the same problem as I am having, but any fractional gain should work accordingly. I designed it sort of as a daughter card to stand upright with 90 degree header pins and take up very little room on a breadboard. What do you think?

As you can see, there are many components not on my breadboard, but like I said it can be configured for multiple purposes. The two lower Ceramic caps can be bridged for non-audio as can the electrolytic caps on the sides. RC can be either a resistor or ceramic capacitor. As a resistors it is used to define a ground reference for the next device to accept the signal. As a cap, it is used to clean up random noise that you might see on the signal if it going to a microcontroller or similar. Ignore the values below each resistor on the schematic. They were set that way for each of the two op amps found in the 8-pin DIP. TL062, 072, 082 or similar may be used.

Let me know what you think or if you have a solution to my 2x gain-reference voltage problem.



No comments:

Post a Comment