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
+145-1Lines changed: 145 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3026,6 +3026,12 @@ AnalogExpansion::beginChannelAsAdc(OptaController, // the expansion object
3026
3026
false, // disable diagnostic
3027
3027
0); // disable averaging
3028
3028
```
3029
+
3030
+
You can also use the simplified dedicated method using the function `beginChannelAsVoltageAdc` as follows:
3031
+
3032
+
```arduino
3033
+
exp.beginChannelAsVoltageAdc(<exp channel>); // pass the desired input as argument
3034
+
```
3029
3035
The function `optaAnalogTask()` reads all the analog input raw ADC values and prints out them. If you want to show the voltage reading instead use the following function:
3030
3036
3031
3037
```arduino
@@ -3220,6 +3226,13 @@ AnalogExpansion::beginChannelAsAdc(OptaController, // the expansion object
3220
3226
false, // disable diagnostic
3221
3227
0); // disable averaging
3222
3228
```
3229
+
3230
+
You can also use the simplified dedicated method using the function `beginChannelAsCurrentAdc` as follows:
3231
+
3232
+
```arduino
3233
+
exp.beginChannelAsCurrentAdc(<exp channel>); // pass the desired input as argument
3234
+
```
3235
+
3223
3236
The function `optaAnalogTask()` reads all the analog input current values and prints out them.
3224
3237
3225
3238
After the Opta™ controller is programmed with the example sketch, open the Arduino IDE Serial Monitor and you will see each input reading as follows:
@@ -3237,11 +3250,142 @@ Analog Expansion n. 0
3237
3250
```
3238
3251

3239
3252
3240
-
There is another approach for interfacing 4-20 mA sensors that consists of defining the channel as a voltage output, connecting the sensor to the channel and measuring the current of the loop. Use the following example sketch instead:
3253
+
There is another approach for interfacing 4-20 mA sensors that consists of defining the channel as a **voltage DAC** and adding a **current ADC** to the same channel, connecting the sensor to the channel and measuring the current of the loop. Use the following example sketch instead:
The key section of the example from above is in the `setup()` function, specifically in the way we initialize the channel to be used for the measurement:
3241
3370
3242
3371
```arduino
3372
+
// start the channel as a voltage DAC
3373
+
exp.beginChannelAsDac(SENSOR_CH, //channel index
3374
+
OA_VOLTAGE_DAC, //DAC type
3375
+
false, //limit current (set to false so it can power the sensor current loop)
3376
+
false, //No slew rate
3377
+
OA_SLEW_RATE_0); //Slew rate setting.
3378
+
3379
+
Serial.println("Setting DAC output to 11 V on expansion n. " + String(exp.getIndex()));
3380
+
exp.pinVoltage(SENSOR_CH, 11.0, true); // set channel 0 output to 11 V (Max voltage output)
3381
+
delay(200); // give time for the channel to be set up
3382
+
// add a current ADC to the same channel
3383
+
exp.addCurrentAdcOnChannel(SENSOR_CH);
3243
3384
```
3244
3385
3386
+
First, the channel is initialized as a voltage DAC with the "limit current" parameter disabled, a voltage is set in the output that will power the current loop and then a current ADC is added to the same channel, this way we can use the `pinCurrent()` function to measure the current output of the sensor.
0 commit comments