OPERATIONAL AMPLIFIER
1. AIM
To design a comparator circuit, Non-inverting and Inverting amplifier with OPAMP’s, an Analog to Digital (ADC),
using comparators and Digital to Analog Converter (DAC) circuit also to verify using Arduino Uno and with LEDs’.
2. THEORY
An operational amplifier, or op-amp, is a very high gain differential amplifier with high input impedance and low
output impedance. Typical uses of the operational amplifier are to provide voltage amplitude changes (amplitude
and polarity), oscillators, filter circuits, and many types of instrumentation circuits. An op-amp contains a number of
differential amplifier stages to achieve a very high voltage gain.
An operational amplifier is a very high gain amplifier having very high input impedance (typically a few megohms)
and low output impedance (less than 100 ohm). The basic circuit is made using a difference amplifier having two
inputs (plus and minus) and at least one output. Figure 1 shows a basic op-amp unit. The plus (+) input produces an
output that is in phase with the signal applied, whereas an input to the minus (-) input results in an opposite-polarity
output[1].
Figure-1 Basic Op-amp circuit Pin diagram of ic 741 op amp
Inverting Amplifier: The most widely used constant-gain amplifier circuit is the inverting amplifier, as shown in
Fig. 2 The output is obtained by multiplying the input by a fixed or constant gain, set by the input resistor (R 1) and
feedback resistor (Rf)—this output also being inverted from the input. Using Equation
Figure-2 Inverting Op-amp circuit
Non-inverting Amplifier: The connection of Fig. 3 shows an op-amp circuit that works as a noninverting amplifier
or constant-gain multiplier. It should be noted that the inverting amplifier connection is more widely used because it
has better frequency stability.
The output voltage of a non-inverting amplifier is Vout = Vin + (Vin/R1)R2 and the closed loop voltage gain of
a Non-inverting Operational Amplifier will be given as:
1
OPERATIONAL AMPLIFIER
Figure-3 Non- inverting Op-amp circuit
Comparator: The comparator is a circuit which compares an input signal Vi(t) with a reference voltage VR. We
verified that the circuit is behaving as a zero-crossing detector. The output responds almost discontinuously every
time the input passes through zero. Due to slew rate limitations of the Op-amp the output would no longer be a
square wave; with increasing frequency it converts to trapezoidal wave and to a triangular wave also. In electronics
community sometimes it is necessary to have an electronic circuit which can convert between the two different
domains of continuously changing analog signals and discrete digital signals. Making an ADC with Op-amp
comparators also required voltage divider and a reference voltage[2].
Figure-4 shows Comparator circuit
Analog-to-Digital Converters (ADCs) are essential components in Arduino boards, allowing them to read analog
signals and convert them into digital values.
Figure-5 Analog-to-Digital Converter Op-amp circuit
2
OPERATIONAL AMPLIFIER
3. EXPERIMENTAL SETUP
To verify the circuits, we need the following apparatus
1. Breadboard, Jumping wires
2. OPAMP chips (741)
3. Resistors
4. Light Emitting Diodes (LEDs)
5. Power Supply -3
6. Oscilloscope (Digital) and Probes
7. USB to extended type-B cable
8. Digital Multimeter with Probes
9. Laptop, Arduino Uno and Arduino IDE application
4. OBSERVATIONS
Using the OPAMP chips we first design the basics of OPAMP’s like comparator, Inverting and non-inverting
amplifier then we switch to a more complex form i.e. ADC and compile with Arduino and finally we did same for
DAC.
Figure-6 Op-amp as adder circuit
Figure-7 Analog-to-Digital Converters Op-amp circuit
3
OPERATIONAL AMPLIFIER
Figure-8 Op-amp as Comparator circuit
4
OPERATIONAL AMPLIFIER
Figure-9 Op-amp as Comparator circuit
5
OPERATIONAL AMPLIFIER
5. RESULTS AND DISCUSSIONS
https://photos.app.goo.gl/KDAgARXNqXbL5uEf8
Figure-10 Video shows glowing of LEDs bulbs by changing the resistance
Code
const int outputPins[3] = {2, 3, 4}; // Digital output pins to DAC
const int analogPin = A0; // Analog input pin (from DAC output)
void setup() {
Serial.begin(9600); // Start serial communication
for (int i = 0; i < 3; i++) {
pinMode(outputPins[i], OUTPUT); // Set output pins
}
}
void loop() {
for (int value = 0; value < 8; value++) { // Iterate through all binary
combinations
// Set binary output to DAC
for (int i = 0; i < 3; i++) {
digitalWrite(outputPins[i], (value >> i) & 1);
}
// Read analog output from DAC
int analogValue = analogRead(analogPin);
// Print values to Serial Monitor
Serial.print("Binary Output to DAC: ");
Serial.print(value, BIN);
Serial.print(" | Analog Output from DAC: ");
Serial.println(analogValue*(5.0/1023));
6
OPERATIONAL AMPLIFIER
delay(500); // Small delay for stability
}
}
Code
const int analogOutPins[3] = {9, 10, 11}; // PWM output pins to DAC
const int analogInPin = A0; // Analog input pin (from DAC output)
int analogValues[3] = {0, 60, 60}; // Manually set analog output values
void setup() {
Serial.begin(9600); // Start serial communication
for (int i = 0; i < 3; i++) {
pinMode(analogOutPins[i], OUTPUT); // Set analog output pins
}
}
void loop() {
// Set predefined analog values to DAC
for (int i = 0; i < 3; i++) {
analogWrite(analogOutPins[i], analogValues[i]);
}
// Read analog output from DAC
int analogValue = analogRead(analogInPin);
// Print values to Serial Monitor
Serial.print("Analog Outputs to DAC: ");
for (int i = 0; i < 3; i++) {
Serial.print(analogValues[i]);
Serial.print(" ");
}
Serial.print(" | Analog Output from DAC: ");
Serial.println(analogValue*(5.0/1023));
delay(1000); // Small delay for stability
}
6. CONCLUSION
This lab experiment successfully demonstrated the implementation of a comparator using an operational amplifier
(op-amp) and the control of an LED using an Analog-to-Digital Converter (ADC) with an Arduino board. The key
findings and outcomes of this experiment are as follows: Op-amp as Comparator: We effectively utilized an op-amp
(such as the LM358) as a voltage comparator without a feedback resistor, allowing it to swing between full on and
full off states5. This configuration proved useful for comparing input voltages and triggering the LED based on
predefined thresholds. ADC Implementation: The Arduino's built-in ADC was successfully employed to convert
analog input signals to digital values. The analogRead() function converted the 0-5V input range to digital values
between 0 and 1023, providing a resolution of approximately 4.9mV per unit4. LED Control: We demonstrated the
ability to control an LED using the digital output from the ADC. The LED's brightness could be varied based on the
analog input, with the option to use either the built-in LED on pin 13 or an external LED4. Code Functionality: The
7
OPERATIONAL AMPLIFIER
Arduino code effectively read analog values, converted them to voltages, and controlled the LED accordingly. The
implementation allowed for real-time monitoring of both digital and analog values through serial communication.
Future Work:
Future Arduino boards are likely to incorporate more advanced built-in Op-Amps, ADCs, and DACs, enabling more
sophisticated signal processing capabilities. This will allow for:
Higher resolution: Future ADCs and DACs may offer increased bit depth, improving the accuracy of analog-to-
digital and digital-to-analog conversions.
Faster sampling rates: Upcoming Arduino models might feature ADCs and DACs capable of higher sampling
frequencies, enabling the processing of higher bandwidth signals.
High-fidelity sound generation: Future Arduino-based systems might be capable of producing studio-quality audio
output6. Real-time audio effects: Improved processing power combined with fast ADCs and DACs could enable
complex audio manipulation in real-time[3].
7. REFERENCES
1. https://www.electronics-tutorials.ws
2. https://www.renesas.cn/zh/document/tra/r13tb0001-op-amp-crash-course-part-1-
basics-tutorial
3. "Getting Started: FOUNDATION > Introduction". arduino.cc. Archived from the
original on 2017-08-29. Retrieved 2017-05-23.