You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/07.opta/opta-family/opta/tutorials/01.user-manual/content.md
+71-69Lines changed: 71 additions & 69 deletions
Original file line number
Diff line number
Diff line change
@@ -201,11 +201,11 @@ Opta's maximum power consumption at +12 VDC is 2 W, and at +24 VDC is 2.2 W.
201
201
202
202
### Programmable Inputs
203
203
204
-
The image below shows Opta™ devices have **eight analog/digital programmable inputs** accessible through terminals `I1`, `I2`, `I3`, `I4`, `I5`, `I6`, `I7`, and `I8`.
204
+
The image below shows Opta™ devices have **eight digital/analog programmable inputs** accessible through terminals `I1`, `I2`, `I3`, `I4`, `I5`, `I6`, `I7`, and `I8`.
205
205
206
206

207
207
208
-
Analog/digital input terminals are mapped as described in the following table:
208
+
Digital/analog input terminals are mapped as described in the following table:
209
209
210
210
|**Opta™ Terminal**|**Arduino Pin Mapping**|
211
211
|:------------------:|:-----------------------:|
@@ -218,35 +218,32 @@ Analog/digital input terminals are mapped as described in the following table:
218
218
|`I7`|`A6`/`PIN_A6`|
219
219
|`I8`|`A7`/`PIN_A7`|
220
220
221
-
#### Analog Inputs
221
+
#### Digital Inputs
222
222
<br></br>
223
223
224
-
The input voltage range for each analog input terminal is the following:
224
+
The input voltage range for each digital input terminal is the following:
225
225
226
-
-**Input voltage range**: 0 to +10 VDC
226
+
-**Input voltage range**: 0 to +24 VDC
227
227
228
-
The analog input terminals can be used through the built-in functions of the [Arduino programming language](https://www.arduino.cc/reference/en/). To use the input terminals as analog inputs:
228
+
***The Opta™ digital inputs also support the 0 to +10 VDC logic level.***
229
229
230
-
- Add the `analogReadResolution()` instruction in your sketch's `setup()` function.
230
+
The input terminals can be used through the built-in functions of the [Arduino programming language](https://www.arduino.cc/reference/en/). To use the input terminals as digital inputs:
231
231
232
-
The sketch below shows how to monitor analog voltages on Opta's input terminals `I1`, `I2`, and `I3`. It initializes a serial connection, takes readings from each defined terminal, converts those readings into voltage based on a 12-bit resolution, and outputs these voltage values through the Arduino IDE's Serial Monitor. The readings are looped every second, allowing you to monitor changes real-time changes.
232
+
- Add the `pinMode(pinName, INPUT)` instruction in your sketch's `setup()` function.
233
+
234
+
The sketch below shows how to monitor digital states on Opta's input terminals `I1`, `I2`, and `I3`. It initializes a serial connection, takes readings from each defined terminal, and interprets them as either `HIGH` or `LOW` digital states. These states are then output through the Arduino IDE's Serial Monitor. The state readings are looped every second, allowing you to monitor real-time changes.
233
235
234
236
```arduino
235
237
/**
236
-
Opta's Analog Input Terminals
237
-
Name: opta_analog_inputs_example.ino
238
-
Purpose: This sketch demonstrates the use of I1, I2, and I3 input
239
-
terminals as analog inputs on Opta.
238
+
Opta's Digital Input Terminals
239
+
Name: opta_digital_inputs_example.ino
240
+
Purpose: This sketch demonstrates the use of I1, I2, and I3 input
241
+
terminals as digital inputs on Opta.
240
242
241
243
@author Arduino PRO Content Team
242
-
@version 2.0 22/07/23
244
+
@version 2.0 23/07/23
243
245
*/
244
246
245
-
// Define constants for voltage, resolution, and divider.
246
-
const float VOLTAGE_MAX = 3.3; // Maximum voltage that can be read
// Initialize serial communication at 9600 bits per second.
258
255
Serial.begin(9600);
259
256
260
-
// Enable analog inputs on Opta
261
-
// Set the resolution of the ADC to 12 bits.
262
-
analogReadResolution(12);
257
+
// Set the mode of the pins as digital inputs.
258
+
for (int i = 0; i < NUM_PINS; i++) {
259
+
pinMode(TERMINALS[i], INPUT);
260
+
}
263
261
}
264
262
265
263
void loop() {
266
-
// Loop through each of the terminal, read the terminal analog value, convert it to voltage, and print the result.
264
+
// Loop through each of the terminal, read the terminal digital value, and print the result.
267
265
for (int i = 0; i < NUM_PINS; i++) {
268
266
readAndPrint(TERMINALS[i], i + 1);
269
267
}
@@ -272,49 +270,48 @@ void loop() {
272
270
delay(1000);
273
271
}
274
272
275
-
// This function reads the value from the specified pin, converts it to voltage, and prints the result.
273
+
// This function reads the digital value from the specified pin and prints the result.
276
274
void readAndPrint(int terminal, int terminalNumber) {
277
-
// Read the input value from the analog pin.
278
-
int terminalValue = analogRead(terminal);
279
-
280
-
// Convert the terminal value to its corresponding voltage.
281
-
float voltage = terminalValue * (VOLTAGE_MAX / RESOLUTION) / DIVIDER;
282
-
283
-
// Print the terminal value and its corresponding voltage.
275
+
// Read the input value from the digital pin.
276
+
int terminalValue = digitalRead(terminal);
277
+
278
+
// Print the terminal value.
284
279
Serial.print("I");
285
280
Serial.print(terminalNumber);
286
281
Serial.print(" value: ");
287
-
Serial.print(terminalValue);
288
-
Serial.print(" corresponding to ");
289
-
Serial.print(voltage, 5);
290
-
Serial.println(" VDC");
282
+
Serial.println(terminalValue);
291
283
}
292
284
```
293
285
294
-
#### Digital Inputs
286
+
#### Analog Inputs
295
287
<br></br>
296
288
297
-
The input voltage range for each digital input terminal is the following:
289
+
The input voltage range for each analog input terminal is the following:
298
290
299
-
-**Input voltage range**: 0 to +24 VDC
291
+
-**Input voltage range**: 0 to +10 VDC
300
292
301
-
The input terminals can be used through the built-in functions of the [Arduino programming language](https://www.arduino.cc/reference/en/). To use the input terminals as digital inputs:
293
+
The analog input terminals can be used through the built-in functions of the [Arduino programming language](https://www.arduino.cc/reference/en/). To use the input terminals as analog inputs:
302
294
303
-
- Add the `pinMode(pinName, INPUT)` instruction in your sketch's `setup()` function.
295
+
- Add the `analogReadResolution()` instruction in your sketch's `setup()` function.
304
296
305
-
The sketch below shows how to monitor digital states on Opta's input terminals `I1`, `I2`, and `I3`. It initializes a serial connection, takes readings from each defined terminal, and interprets them as either `HIGH` or `LOW` digital states. These states are then output through the Arduino IDE's Serial Monitor. The state readings are looped every second, allowing you to monitor real-time changes.
297
+
The sketch below shows how to monitor analog voltages on Opta's input terminals `I1`, `I2`, and `I3`. It initializes a serial connection, takes readings from each defined terminal, converts those readings into voltage based on a 12-bit resolution, and outputs these voltage values through the Arduino IDE's Serial Monitor. The readings are looped every second, allowing you to monitor changes real-time changes.
306
298
307
299
```arduino
308
300
/**
309
-
Opta's Digital Input Terminals
310
-
Name: opta_digital_inputs_example.ino
311
-
Purpose: This sketch demonstrates the use of I1, I2, and I3 input
312
-
terminals as digital inputs on Opta.
301
+
Opta's Analog Input Terminals
302
+
Name: opta_analog_inputs_example.ino
303
+
Purpose: This sketch demonstrates the use of I1, I2, and I3 input
304
+
terminals as analog inputs on Opta.
313
305
314
306
@author Arduino PRO Content Team
315
-
@version 2.0 23/07/23
307
+
@version 2.0 22/07/23
316
308
*/
317
309
310
+
// Define constants for voltage, resolution, and divider.
311
+
const float VOLTAGE_MAX = 3.3; // Maximum voltage that can be read
// Initialize serial communication at 9600 bits per second.
326
323
Serial.begin(9600);
327
324
328
-
// Set the mode of the pins as digital inputs.
329
-
for (int i = 0; i < NUM_PINS; i++) {
330
-
pinMode(TERMINALS[i], INPUT);
331
-
}
325
+
// Enable analog inputs on Opta
326
+
// Set the resolution of the ADC to 12 bits.
327
+
analogReadResolution(12);
332
328
}
333
329
334
330
void loop() {
335
-
// Loop through each of the terminal, read the terminal digital value, and print the result.
331
+
// Loop through each of the terminal, read the terminal analog value, convert it to voltage, and print the result.
336
332
for (int i = 0; i < NUM_PINS; i++) {
337
333
readAndPrint(TERMINALS[i], i + 1);
338
334
}
@@ -341,16 +337,22 @@ void loop() {
341
337
delay(1000);
342
338
}
343
339
344
-
// This function reads the digital value from the specified pin and prints the result.
340
+
// This function reads the value from the specified pin, converts it to voltage, and prints the result.
345
341
void readAndPrint(int terminal, int terminalNumber) {
346
-
// Read the input value from the digital pin.
347
-
int terminalValue = digitalRead(terminal);
348
-
349
-
// Print the terminal value.
342
+
// Read the input value from the analog pin.
343
+
int terminalValue = analogRead(terminal);
344
+
345
+
// Convert the terminal value to its corresponding voltage.
346
+
float voltage = terminalValue * (VOLTAGE_MAX / RESOLUTION) / DIVIDER;
347
+
348
+
// Print the terminal value and its corresponding voltage.
350
349
Serial.print("I");
351
350
Serial.print(terminalNumber);
352
351
Serial.print(" value: ");
353
-
Serial.println(terminalValue);
352
+
Serial.print(terminalValue);
353
+
Serial.print(" corresponding to ");
354
+
Serial.print(voltage, 5);
355
+
Serial.println(" VDC");
354
356
}
355
357
```
356
358
@@ -1775,7 +1777,7 @@ Finally, your Opta™ expansion will be updated with the latest firmware version
1775
1777
1776
1778
The Opta™ Expansions have **16 analog/digital programmable inputs** accessible through terminals `I1` to `I16`.
1777
1779
1778
-
Both Ext D1608E and Ext D1608S variant inputs can be used as **digital** with a 0-24 VDC range or as **analog** inputs with a 0-24 VDC range. The inputs are capable of operating with 0-10V analog sensors as well as 0-24V sensors.
1780
+
Both Ext D1608E and Ext D1608S variant inputs can be used as **digital** with a 0-24 VDC or 0-10 VDC range or as **analog** inputs with a 0-24 VDC range. The analog inputs are capable of operating with 0-10 VDC analog sensors as well as 0-24 VDC sensors.
1779
1781
1780
1782
***The inputs are marked on plastic as DGT/0-10 V to maintain uniformity with the main Opta module and as conventionally the majority of industrial analog sensors work in the 0-10 V range.***
1781
1783
@@ -1795,11 +1797,11 @@ Both Ext D1608E and Ext D1608S variant inputs can be used as **digital** with a
***General note: The library supports the OptaController.getExpansionNum(). This function always returns the number of expansions discovered during the last discovery / assign I2C address process. Since the discovery process is NOT performed if an expansion is removed or powered down, the value returned by this function DOES NOT change in case of the removal of one Expansion. To know if an expansion is missing, register a callback using setFailedCommCb(cb) (available on all the Expansion classes). The callback will be called any time an I2C expected answer is not received by the controller, allowing the user to know that expansion is missing. No "heartbeat" function is provided to understand if an expansion is missing since having an expansion and not regularly communicating with it is not a behavior meant by design.***
2025
+
***The library supports the OptaController.getExpansionNum(). This function always returns the number of expansions discovered during the last discovery / assign I2C address process. Since the discovery process is NOT performed if an expansion is removed or powered down, the value returned by this function DOES NOT change in case of the removal of one Expansion. To know if an expansion is missing, register a callback using setFailedCommCb(cb) (available on all the Expansion classes). The callback will be called any time an I2C expected answer is not received by the controller, allowing the user to know that expansion is missing. No "heartbeat" function is provided to understand if an expansion is missing since having an expansion and not regularly communicating with it is not a behavior meant by design.***
0 commit comments