Skip to content

Commit 4c19a13

Browse files
Merge pull request #1596 from arduino/Hannes7eicher/OPAMP
[MKC-1351] OPAMP Docs
2 parents 85644b0 + 92a761e commit 4c19a13

File tree

12 files changed

+214
-0
lines changed

12 files changed

+214
-0
lines changed
Loading
Loading
Loading
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
title: 'Arduino UNO R4 Minima OPAMP'
3+
description: 'Learn how to use the built-in Operational Amplifier in the UNO R4 Minima'
4+
tags:
5+
- OPAMP
6+
author: 'Maximilian Gerhardt, Hannes Siebeneicher'
7+
hardware:
8+
- hardware/02.hero/boards/uno-r4-minima
9+
software:
10+
- web-editor
11+
- ide-v1
12+
- ide-v2
13+
---
14+
15+
In this tutorial, you will learn how to use the built-in operational amplifier (OPAMP) featured on the [Arduino UNO R4 Minima](https://store.arduino.cc/products/uno-r4-minima). Operational amplifiers are very versatile and can be used to e.g. mirror an electrical signal or amplify it.
16+
17+
## Goals
18+
19+
In this article, you will learn:
20+
- about the OPAMP feature onboard the UNO R4 Minima,
21+
- about the basics of the OPAMP library,
22+
- how to mirror a voltage signal,
23+
- how to amplify a voltage signal.
24+
25+
## Hardware & Software Needed
26+
To follow along with this article, you will need the following hardware:
27+
28+
- [Arduino UNO R4 Minima](https://store.arduino.cc/uno-r4-minima)
29+
- resistors
30+
- Jumper wires
31+
32+
33+
## Operational Amplifier (OPAMP)
34+
35+
An OPAMP is a versatile and widely used electronic component that belongs to the class of analog integrated circuits. Its primary function is to amplify voltage signals but they are very versatile and can be used to:
36+
37+
- mirror an input voltage to its output,
38+
- amplify a small analog voltage to its output pin, the UNO R4's output voltage range is 0 to ~4.7 V,
39+
- compare two input voltages and give a binary "higher" or "lower" output,
40+
- integrate and differentiate signals.
41+
42+
## Voltage Follower
43+
44+
The simplest way to test the OPAMP is to configure it as a voltage follower by connecting A2 to A3. In this setup, the voltage at A3 should mimic the voltage applied to A1. For instance, if you connect A1 to the ground (GND), the OPAMP output at A3 should also be at the ground potential. Similarly, if you connect A1 to 3.3 V, the output at A3 should be approximately 3.3 V.
45+
46+
## Circuit
47+
48+
![Voltage Follower Circuit](./assets/circuitFollowerMinima.png)
49+
50+
## Voltage Amplifier
51+
52+
***Caution: When amplifying the voltage of a battery using an operational amplifier, you should be aware of potential risks. The amplification process can lead to a high current draw, essentially placing a significant load on the battery, which may result in overheating, damage, or even pose a security risk. To mitigate this risk, you may for example add a resistor in series with the battery.***
53+
54+
A voltage amplifier, as the name suggests, amplifies the voltage. A simple 2x amplifier can be built using e.g. two `10k` resistors. Connect one resistor between "minus" and GND. Then use the second resistor to connect the output and "minus" together. A circuit diagram [can be seen below](#circuit). Any signal input at "plus" will now appear with double the amplitude at the output pin. Of course, the input signal and the Arduino board should share the same `GND`.
55+
56+
***The amplified output signal should not go above ~4.7 V, otherwise clipping will appear and you can damage the board***
57+
58+
Below is a capture of an oscilloscope in which an approx. 2 V square wave (green, channel 2) is amplified to a 4 V square wave (yellow, channel 1) with the circuit shown below. The input signal was generated by a function generation (and shared GND was connected).
59+
60+
![Oscilloscope measurements](./assets/amp_screenshot.png)
61+
62+
But let's say you want to amplify the voltage signal 4x instead of 2x. The amplification of an OPAMP mainly depends on the chosen resistor values. Take a look at the formula below:
63+
64+
![Calculate resistor value](./assets/calc.png)
65+
66+
**Av** = Amplified Voltage (V)
67+
68+
**R1** = Resistor connected to Ground (Ω)
69+
70+
**R2** = Feedback resistor (Ω)
71+
72+
We know we want to amplify the voltage times four so:
73+
74+
**Av** = 4 V
75+
76+
Now, we need to figure out what resistors to choose. Because we only can solve for one unknown value we choose a predefined value for one of the resistors, e.g. 10k Ω for R1.
77+
78+
**R1** = 10k Ω
79+
80+
Your formula should now look like this:
81+
82+
![Add values to the formula](./assets/numCalc.png)
83+
84+
That leaves R2 as the only unknown variable. Now, Subtract one from both sides and multiply by ten, which leaves us with:
85+
86+
**R2 = 30k Ω**
87+
88+
## Circuit
89+
90+
![Voltage 2x Amplifier Circuit](./assets/circuitAmplifierMinima.png)
91+
92+
***Read more about an amplifier circuit [here](https://www.electronics-tutorials.ws/opamp/opamp_3.html).***
93+
94+
## Code
95+
96+
To start up the opamp, simply include the library and call `OPAMP.begin(speed)`. As the optional `speed` argument to this function, can choose either `OPAMP_SPEED_LOWSPEED` as the low-speed (lower power) mode or `OPAMP_SPEED_HIGHSPEED` as the high-speed, high-power mode.
97+
98+
```arduino
99+
#include <OPAMP.h>
100+
101+
void setup () {
102+
OPAMP.begin(OPAMP_SPEED_HIGHSPEED);
103+
}
104+
105+
void loop() {}
106+
107+
```
Loading
Loading
Loading
Loading
Loading
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
title: 'Arduino UNO R4 WiFi OPAMP'
3+
description: 'Learn how to use the built-in Operational Amplifier in the UNO R4 WiFi'
4+
tags:
5+
- OPAMP
6+
author: 'Maximilian Gerhardt, Hannes Siebeneicher'
7+
hardware:
8+
- hardware/02.hero/boards/uno-r4-wifi
9+
software:
10+
- web-editor
11+
- ide-v1
12+
- ide-v2
13+
---
14+
15+
In this tutorial, you will learn how to use the built-in operational amplifier (OPAMP) featured on the [Arduino UNO R4 WiFi](https://store.arduino.cc/products/uno-r4-wifi). Operational amplifiers are very versatile and can be used to e.g. mirror an electrical signal or amplify it.
16+
17+
## Goals
18+
19+
In this article, you will learn:
20+
- about the OPAMP feature onboard the UNO R4 WiFi,
21+
- about the basics of the OPAMP library,
22+
- how to mirror a voltage signal,
23+
- how to amplify a voltage signal.
24+
25+
## Hardware & Software Needed
26+
To follow along with this article, you will need the following hardware:
27+
28+
- [Arduino UNO R4 WiFi](https://store.arduino.cc/uno-r4-wifi)
29+
- resistors
30+
- Jumper wires
31+
32+
33+
## Operational Amplifier (OPAMP)
34+
35+
An OPAMP is a versatile and widely used electronic component that belongs to the class of analog integrated circuits. Its primary function is to amplify voltage signals but they are very versatile and can be used to:
36+
37+
- mirror an input voltage to its output,
38+
- amplify a small analog voltage to its output pin, the UNO R4's output voltage range is 0 to ~4.7 V,
39+
- compare two input voltages and give a binary "higher" or "lower" output,
40+
- integrate and differentiate signals.
41+
42+
## Voltage Follower
43+
44+
The simplest way to test the OPAMP is to configure it as a voltage follower by connecting A2 to A3. In this setup, the voltage at A3 should mimic the voltage applied to A1. For instance, if you connect A1 to the ground (GND), the OPAMP output at A3 should also be at the ground potential. Similarly, if you connect A1 to 3.3 V, the output at A3 should be approximately 3.3 V.
45+
46+
## Circuit
47+
48+
![Voltage Follower Circuit](./assets/circuitFollowerWiFi.png)
49+
50+
## Voltage Amplifier
51+
52+
***Caution: When amplifying the voltage of a battery using an operational amplifier, you should be aware of potential risks. The amplification process can lead to a high current draw, essentially placing a significant load on the battery, which may result in overheating, damage, or even pose a security risk. To mitigate this risk, you may for example add a resistor in series with the battery.***
53+
54+
A voltage amplifier, as the name suggests, amplifies the voltage. A simple 2x amplifier can be built using e.g. two `10k` resistors. Connect one resistor between "minus" and GND. Then use the second resistor to connect the output and "minus" together. A circuit diagram [can be seen below](#circuit). Any signal input at "plus" will now appear with double the amplitude at the output pin. Of course, the input signal and the Arduino board should share the same `GND`.
55+
56+
***The amplified output signal should not go above ~4.7 V, otherwise clipping will appear and you can damage the board***
57+
58+
Below is a capture of an oscilloscope in which an approx. 2 V square wave (green, channel 2) is amplified to a 4 V square wave (yellow, channel 1) with the circuit shown below. The input signal was generated by a function generation (and shared GND was connected).
59+
60+
![Oscilloscope measurements](./assets/amp_screenshot.png)
61+
62+
But let's say you want to amplify the voltage signal 4x instead of 2x. The amplification of an OPAMP mainly depends on the chosen resistor values. Take a look at the formula below:
63+
64+
![Calculate resistor value](./assets/calc.png)
65+
66+
**Av** = Amplified Voltage (V)
67+
68+
**R1** = Resistor connected to Ground (Ω)
69+
70+
**R2** = Feedback resistor (Ω)
71+
72+
We know we want to amplify the voltage times four so:
73+
74+
**Av** = 4 V
75+
76+
Now, we need to figure out what resistors to choose. Because we only can solve for one unknown value we choose a predefined value for one of the resistors, e.g. 10k Ω for R1.
77+
78+
**R1** = 10k Ω
79+
80+
Your formula should now look like this:
81+
82+
![Add values to the formula](./assets/numCalc.png)
83+
84+
That leaves R2 as the only unknown variable. Now, Subtract one from both sides and multiply by ten, which leaves us with:
85+
86+
**R2 = 30k Ω**
87+
88+
## Circuit
89+
90+
![Voltage 2x Amplifier Circuit](./assets/circuitAmplifierWiFi.png)
91+
92+
***Read more about an amplifier circuit [here](https://www.electronics-tutorials.ws/opamp/opamp_3.html).***
93+
94+
## Code
95+
96+
To start up the opamp, simply include the library and call `OPAMP.begin(speed)`. As the optional `speed` argument to this function, can choose either `OPAMP_SPEED_LOWSPEED` as the low-speed (lower power) mode or `OPAMP_SPEED_HIGHSPEED` as the high-speed, high-power mode.
97+
98+
```arduino
99+
#include <OPAMP.h>
100+
101+
void setup () {
102+
OPAMP.begin(OPAMP_SPEED_HIGHSPEED);
103+
}
104+
105+
void loop() {}
106+
107+
```

0 commit comments

Comments
 (0)