Arduino Nano R4 Built in Operational Amplifier – How to Use

by kevinjpower in Circuits > Arduino

23 Views, 0 Favorites, 0 Comments

Arduino Nano R4 Built in Operational Amplifier – How to Use

The Arduino Nano R4 includes a built in Operational Amplifier (Op Amp) which can be used for various purposes. Ever wondered how to use this built in Op Amp?

This project describes a simple application of the Op Amp

Supplies

Arduino Nano R4

10 kOhm variable resistor

Breadboard and wires

Arduino Nano R4 Operational Amplifier

The Op Amp can provide signal conditioning and amplification capabilities directly on the Nano board without the need for external circuits.

The Op Amp is connected to the following analog pins:

A1 Op Amp + Non-inverting input (+)

A2 Op Amp - Inverting input (-)

A3 Op Amp Out Amplifier output

The complete pin-out for the Nano R4 is included for completeness

When using the Op Amp function in the Nano R4, pins A1, A2 and A3 cannot simultaneously be used as analog inputs. The Op Amp positive supply (Vs+) is connected the 5V DC supply of the Nano R4 and the negative supply (Vs-) is connected to GND.

The OP Amp can be configured as a high speed or low speed version. Specs for the two versions are included in the official documentation for the Nano R4.

The low speed version will use less power.

In the low speed mode, a slew rate of 0.12 V/µs puts the Op Amp behind the classic 741 operational amplifier which has a typical slew rate of 0.5 V/µs. This means that it should not be used for medium to high speed applications.

In high speed mode, the gain-bandwidth product of 1.7 MHz would put the Op Amp in the category of a general operational amplifier, which typically have a gain-bandwidth product of between 1 and 3.

Building a Unity Gain Amplifier As a Incoming Signal Buffer

In the case of a signal that could be influenced by the input impedance of a ADC, it is usual to buffer the signal with a unity gain operational amplifier circuit. This simple circuit is shown, along with the breadboard implementation

Arduino Code

To startup the Op Amp, include the library OPAMP.h and call

OPAMP.begin(speed)

where (speed) can be OPAMP_SPEED_LOWSPEED for lower power consumption or OPAMP_SPEED_HIGHSPEED for better performance.

The output from the Op Amp can be read directly from A3 using the analogRead(A3) command. This will convert the voltage at the Op Amp output via the ADC to a binary value dependent on the defined precision.

/*
OPAMP Example for the Arduino Nano R4 Board
Purpose: This sketch demonstrates how to initialize the built-in Op Amp
Configured as a unity gain follower
*/

// Op Amp library included in Nano distribution
#include <OPAMP.h>

float val = 0;

void setup() {
// Initialize serial communication
Serial.begin(115200);
Serial.println("Arduino Nano R4 - OPAMP Example started...");
Serial.println("Initializing Op Amp in high-speed mode...");

// Initialize Op Amp in high-speed mode as opposed to low-speed mode
OPAMP.begin(OPAMP_SPEED_HIGHSPEED);
Serial.println("Op Amp initialized successfully!");

// Set resolution of Arduino ADC to 12 bits (default is 10)
analogReadResolution(12);
}

void loop() {
// Read in the value of the Op Amp output
// Print out the result
Serial.println("- Op Amp running...");

//Output of Op Amp can be accessed directly on A3
// 2 ^^ 12 is 4095. Convert input from A3 to voltage reading
val = analogRead(A3)*(5.0/4095.0);

// Print out voltage value
Serial.println(val,3);
delay(4000);
}

Downloads

Results

After setting up the circuit and uploading the code to the Nano R4, the serial monitor will display the voltage across the variable resistor RV1. The output will update as you change the variable resistor.