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
+174-2Lines changed: 174 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3643,10 +3643,182 @@ This output mode lets you control voltage-driven actuators.
3643
3643
To set a voltage in an analog output terminal use the built-in function `pinVoltage()` as shown below:
3644
3644
3645
3645
```arduino
3646
-
float value = exp.getRtd(<input>); // this returns the resistive value measured in the input in ohms
3646
+
exp.pinVoltage(ch, <voltage>, true); // the first argument is to define the output channel, the second, the voltage
3647
3647
```
3648
+
You can also configure the output voltage using the `setDac()` function as follows:
3648
3649
3649
-
For the following example a 2 wires **PT1000** will be used connected to **I1**. The sketch below will let you measure the resistance and convert it to a temperature value. This sketch is based on the built-in example found in **File > Examples > Arduino_Opta_Blueprint > Analog > RTD**:
3650
+
```arduino
3651
+
exp.setDac(ch, <dac_value>); // the first argument is to define the output channel, the second, the DAC output in bits
3652
+
```
3653
+
3654
+
The following example will let you set an output voltage on every channel at once, increasing and decreasing it sequentially, this sketch is based on the built-in example found in **File > Examples > Arduino_Opta_Blueprint > Analog > DAC**:
Please take into account that `OptaController.update()` must be called cyclically to support the hot plug of new expansions. In other words, by calling the update() function cyclically, the controller will discover new expansions when they are plugged in while the controller is already running.
3789
+
3790
+
Thanks to this function, the action of plugging in a new expansion will cause the controller to start a completely new discovery process and a new I2C address assignment.
3791
+
3792
+
`OptaController.update()` function DOES NOT:
3793
+
* Check if an expansion has been removed and remove their objects
3794
+
* Update any data from or to the expansion
3795
+
3796
+
The expansion object in the example above is defined using the `OptaController.getExpansion(i);` function, as follows:
3797
+
3798
+
```arduino
3799
+
for(int i = 0; i < OptaController.getExpansionNum(); i++) { // check all the available expansion slots
The above method will check if there is an Ext A0602 expansion connected in the `i` index from the five admitted. This will ensure which expansion the read state belongs to.
3804
+
3805
+
The expansion channels are configured as **voltage output** using the function `beginChannelAsRtd` alongside the following parameters:
3806
+
3807
+
```arduino
3808
+
AnalogExpansion::beginChannelAsDac(OptaController, // object class
3809
+
device, // the device
3810
+
ch, // the output channel
3811
+
OA_VOLTAGE_DAC, // output mode
3812
+
true, // enable current limit
3813
+
false, // enable slew
3814
+
OA_SLEW_RATE_0); // set slew rate
3815
+
```
3816
+
3817
+
The function `optaAnalogTask()` increases sequentially the `dac_value` variable to set the voltage output on the expansion channels and decrease it back generating a swiping output.
3818
+
3819
+
After the Opta™ controller is programmed with the example sketch, you can measure the voltage on the expansion outputs and experience the following behavior:
3820
+
3821
+

0 commit comments