Skip to content

Commit 1ff6f40

Browse files
Added Reference for OPAMP
1 parent 2da5715 commit 1ff6f40

File tree

1 file changed

+96
-0
lines changed
  • content/hardware/02.hero/boards/uno-r4-wifi/tutorials/opamp-library-reference

1 file changed

+96
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: OPAMP Library API Documentation
3+
description: 'Learn how to use the on-board OPAMP on the Arduino R4 boards.'
4+
author: Pedro Sousa Lima
5+
hardware:
6+
- hardware/10.mega/boards/giga-r1-wifi
7+
software:
8+
- ide-v1
9+
- ide-v2
10+
- web-editor
11+
tags: [AMPOP, OPAMP]
12+
---
13+
14+
## Overview
15+
16+
The OPAMP library provides an interface to initialize and manage operational amplifiers (op-amps) on supported Arduino boards. This documentation details the public functions available for user interaction.
17+
18+
## Accessing the Library
19+
20+
The library provides an instance of the `OpampClass`, which represents the operational amplifier controller:
21+
```cpp
22+
OpampClass OPAMP;
23+
```
24+
This instance is used to call the library's methods.
25+
26+
## Supported Boards
27+
28+
- Arduino UNO R4 WiFi
29+
- Arduino UNO R4 Minima
30+
31+
## Functions
32+
33+
### `bool begin(OpampSpeedMode)`
34+
35+
Initializes the default op-amp channel. You can specify the speed mode as either high-speed or low-speed. If no speed mode is specified, the op-amp will default to high-speed mode.
36+
37+
#### Parameters
38+
39+
- `speed` (optional): The speed mode of the op-amp. Options are:
40+
- `OPAMP_SPEED_LOWSPEED`
41+
- `OPAMP_SPEED_HIGHSPEED` (default)
42+
43+
#### Returns
44+
45+
- `true` if initialization was successful.
46+
- `false` if initialization failed.
47+
48+
### `bool isRunning(uint8_t channel)`
49+
Checks whether a specific op-amp channel is currently running.
50+
51+
#### Parameters
52+
- `channel`: The channel number to check (0 to 3).
53+
54+
#### Returns
55+
- `true` if the channel is active.
56+
- `false` if the channel is inactive.
57+
58+
### `void end()`
59+
Deactivates all op-amp channels.
60+
61+
### `void end(uint8_t channel_mask)`
62+
Deactivates specified op-amp channels.
63+
64+
#### Parameters
65+
- `channel_mask`: A bitmask specifying which channels to deactivate.
66+
67+
## Example Usage
68+
Here is an example demonstrating how to initialize and check the status of the op-amp:
69+
70+
```cpp
71+
#include <OPAMP.h>
72+
73+
void setup() {
74+
Serial.begin(9600);
75+
delay(2000); // serial monitor delay
76+
77+
// Activate OPAMP on the default channel (channel 0)
78+
// Plus: Analog A1
79+
// Minus: Analog A2
80+
// Output: Analog A3
81+
if (!OPAMP.begin(OPAMP_SPEED_HIGHSPEED)) {
82+
Serial.println("Failed to start OPAMP!");
83+
}
84+
85+
bool const isRunning = OPAMP.isRunning(0);
86+
if (isRunning) {
87+
Serial.println("OPAMP running on channel 0!");
88+
} else {
89+
Serial.println("OPAMP channel 0 is not running!");
90+
}
91+
}
92+
93+
void loop() {
94+
delay(1000); // do nothing
95+
}
96+
```

0 commit comments

Comments
 (0)