Amplifiers
Copyright (C) 2022 Miodrag Bolic
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details <https://www.gnu.org/licenses/>.
% Changing the path from main_folder to a particular chapter
main_path=fileparts(which('Main_Content.mlx'));
%addpath(append(main_path,'/Chapter2'))
cd (append(main_path,'/CChapter3/Amplifiers'))
addpath(append(main_path,'/Service'))
SAVE_FLAG=0; % saving the figures in a file
Introduction
This notebook provides an introduction to operational amplifiers and models for a:
- Differential Amplifier
- Instrumentation Amplifier
- Charge Amplifier
- Transimpedance Amplifier
- Programmable Gain Amplifier
Differentiator
Differential Amplifier
A simple model for a differential amplifier is created and shown in figure below. The amplifier is extremely sensitive to the imbalance of the resistor values and therefore it is critical that R3/R1=R4/R2 in both branches of the amplifier is equal.
Differential amplifiers amplifies the difference between the input voltages. For the selected values of resistors, the output of this circuit is 10 times larger than the difference between inputs. Resistors have the following values : R1=10 kΩ, R2=100 kΩ, R3=10 kΩ and R4=100 kΩ. For the input voltage difference of 0.2 V, the output is 2 V.
The differential amplifier equation is as follows when R1=R3 and R2=R4:
For the example, if Vin =0.2 V and for the other parameters of the model belo we get:
The simulation input and output can be seen in a graph as well:
model_name = 'Differential_amplfier';
set_param('Differential_amplfier/R1','R','10');
set_param('Differential_amplfier/R2','R','10');
set_param('Differential_amplfier/R3','R','100');
set_param('Differential_amplfier/R4','R','100');
set_param('Differential_amplfier/R3','enable_R_tol','0');
model_name = 'Differential_amplfier';
temp_vin = simout.Data(:,1);
temp_vout = simout.Data(:,2);
plot(simout.Time,temp_vin,'LineWidth',1);
plot(simout.Time,temp_vout,'LineWidth',1);
title('Differential amplifier signals');
annonation_save('a)',"Fig4.5a.jpg", SAVE_FLAG);
set_param('Differential_amplfier/R3','enable_R_tol','2');
set_param('Differential_amplfier/R3','R_tol','0.5'); % 0.5 was used for 1% tolerance. Please use 0.05 and 0.005 for Table 1
set_param('Differential_amplfier/Vd//2','amp','0');
set_param('Differential_amplfier/-Vd//2','amp','0');
temp_vin = simout.Data(:,1);
temp_vout = simout.Data(:,2);
%plot(simout.Time,temp_vin,'LineWidth',1);
plot(simout.Time,temp_vout,'LineWidth',1);
title('Differential amplifier common mode signal');
ampl_CM=max(simout.Data(500:end,2));
disp ('CMRR for 1% tolerance from Ad=10 is:') % Please note that the values in Table 2 are computed for Ad=1;
CMRR for 1% tolerance from Ad=10 is:
set_param('Differential_amplfier/R3','enable_R_tol','2');
set_param('Differential_amplfier/R3','R_tol','0.5'); % 0.5 was used for 1% tolerance. Please use 0.05 and 0.005 for Table 1
set_param('Differential_amplfier/Vd//2','amp','0.02');
set_param('Differential_amplfier/-Vd//2','amp','0.02');
temp_vin = simout.Data(:,1);
temp_vout = simout.Data(:,2);
%plot(simout.Time,temp_vin,'LineWidth',1);
plot(simout.Time,temp_vout,'LineWidth',1);
title('Differential amplifier output with common mode signal');
annonation_save('b)',"Fig4.5b.jpg", SAVE_FLAG);
%legend({'Input','Output'},'Location','Best');
Both obtained and expected outputs are same.
Bonus example: Derive the differential amplifier equation
Instrumentation Amplifier
The most basic and wide-use instrumentation amplifier is usually developed by using three op amps, the model created can be seen below.
For the selected values of resistors, the output of this circuit is 3 times larger than the difference between inputs. Resistors have the following values : R1=1 kΩ, R2=1 kΩ, R3=1 kΩ, R4=1 kΩ R5=1 kΩ, R6=1 kΩ, R7=1 kΩ. For the input voltage difference of 10 V, the output is 30V.
The instrumentation amplifier equation is as follows when R1=R2, R2=R4, and R6=R7:
For the example model:
The simulation input and output can be seen in a graph as well:
model_name = 'instrumentation_amplifier';
sim(model_name)
Warning: Model 'instrumentation_amplifier' is using a default value of 0.08 for maximum step size. You can disable this diagnostic by setting Automatic solver parameter selection to 'none'
temp_vin = simout.Data(:,1);
temp_vout = simout.Data(:,2);
plot(simout.Time,temp_vin,'LineWidth',1);
plot(simout.Time,temp_vout,'LineWidth',1);
title('Instrumentation amplifier');
legend({'Input','Output'},'Location','Best');
Both obtained and expected outputs are same.
In general, the three-op instrumentation amplifier has a potential for a large gain for input differential signals, while the gain for common-mode signals is always 1. The CMRR is equal to Differential Gain, which can be adjusted by changing the gain resistor (R6). Therefore, this kind of circuit can efficiently reject 60Hz noise in measurement, and has been widely used in biopotential instrumentation.
Demodulator
The simulation does not work at the moment.
open_system('demodulator')
simOut = sim('demodulator', 'CaptureErrors', 'on');
plot(out.simout.Data(:,3))
Charge Amplifier
open_system('ChargeAmpl1')
simout = sim('ChargeAmpl1', 'CaptureErrors', 'on');
Warning: 'Input Port 2' of 'ChargeAmpl1/Scope' is not connected.
Warning: 'Input Port 3' of 'ChargeAmpl1/Scope' is not connected.
Warning: Unconnected output line found on 'ChargeAmpl1/Signal Builder' (output port: 3)
Warning: Unconnected output line found on 'ChargeAmpl1/Signal Builder' (output port: 1)
Warning: Unconnected output line found on 'ChargeAmpl1/Signal Builder' (output port: 5)
Warning: Unconnected output line found on 'ChargeAmpl1/Signal Builder' (output port: 2)
Warning: Unconnected output line found on 'ChargeAmpl1/Signal Builder' (output port: 4)
Plotting results:
plot(simout.VCf.Time(start_time:end_time), simout.VCf.Data(start_time:end_time))
title("Signal over the capacitor C_f")
%plot(i.Time(start_time:end_time), i.Data(start_time:end_time))
annonation_save('a)',"Fig4.13a.jpg", SAVE_FLAG);
hold on, plot(simout.VCf.Time(start_time:end_time), 1.65*ones(1,end_time-start_time+1))
plot(simout.Vo1.Time(start_time:end_time), simout.Vo1.Data(start_time:end_time))
plot(simout.Vo2.Time(start_time:end_time), simout.Vo2.Data(start_time:end_time))
legend("Vcc/2","Vo1","Vo");
title("Output signals of the charge amplifier and amplifier stages")
annonation_save('b)',"Fig4.13b.jpg", SAVE_FLAG);
Transimpedance Amplifier
open_system('Transimpedance')
simout = sim('Transimpedance', 'CaptureErrors', 'on');
plot(simout.Vo.Time, simout.Vo.Data)
title("The signal at the output of the transimpedance amplifier")
annonation_save('b)',"Fig4.14b.jpg", SAVE_FLAG);
Programmable Gain Amplifier
Programmable gain amplifiers (PGA) commonly have a set of values of gains that can be digitally programmed or set by a microcontroller or a microprocessor. PGAs are used nowadays in biomedical instrumentation in general, as a photodiode amplifier circuits, as ultrasound and sonar preamplifiers and so on.
PGAs are very important in applications where the signal level can vary significantly and can cause the signal at the output of the amplifier to be either too small or to saturate. They are often used as a part of signal conditioning circuit before A/D converter to make sure that the full range of A/D/ converter is covered.
A simple model for a PGA is created and shown in figure below.
The PGA has only one control input that can be set to either 0 V or 5 V. When it is set to 0 V, the switch is up as shown in the figure and the gain is 1. When the control input is set to 5V, the amplifier is acting as non-inverting amplifier and the gain is 1+R3/R1=2. This setup of the PGA is used in order to remove the effect of the finite resistance of the switch when the switch is ON [AD08].
The simulation input and output can be seen in a graph as well:
%Set control input to either 0V or 5V
set_param('pga/Control input/Constant','Value','0')
plot(ScopeData1.time,ScopeData1.signals.values)
title('Programmable Gain Amplifier')
legend({'Output Voltage', 'Input Voltage'},'Location','Best');
It can be seen that when it is set to 0 V, the switch is up and the gain is 1.
%Set control input to either 0V or 5V
set_param('pga/Control input/Constant','Value','5')
plot(ScopeData1.time,ScopeData1.signals.values)
title('Programmable Gain Amplifier')
legend({'Output Voltage', 'Input Voltage'},'Location','Best');
It can be seen that when it is set to 5 V, the switch is up and the gain is 2.