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/05.pro-solutions/solutions-and-kits/opta/tutorials/getting-started/content.md
+37-41Lines changed: 37 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,8 @@ hardware:
18
18
19
19
Opta is a robust micro PLC solution with many engaging features. In this tutorial we will go through the setup of Opta with the Arduino IDE and explain how to use its basic features, showing through examples how to program the LEDs on the device, how to use the programmable button, as well as controlling its inputs and outputs.
20
20
21
+

22
+
21
23
## Goals
22
24
23
25
- Putting Opta to work with the Arduino IDE
@@ -49,20 +51,18 @@ Now you are ready to upload sketches to the Opta via the Arduino IDE.
49
51
50
52
Once the IDE and the core are installed, let's warm up by uploading a first sketch to your Opta. We will be using a modified version of the classical Arduino blink sketch to put your device to work and test if everything is set properly.
51
53
Let's create a simple blink sketch that will blink the four STATUS LEDs on the Opta, highlighted in the image below.
52
-
All the STATUS LEDs on the device are defined in the core of the PLC.
53
-
Hereafter you can see the correspondence between each of them as identified in the core and their labeling on the front panel of the product:
54
-
55
-
LED_D0 --> STATUS 1
56
54
57
-
LED_D1 --> STATUS 2
58
-
59
-
LED_D2 --> STATUS 3
60
-
61
-
LED_D3 --> STATUS 4
55
+

62
56
63
-
LED_RESET --> LED above the reset button
57
+
All the STATUS LEDs on the device are defined in the core of the PLC.
58
+
Hereafter you can see the correspondence between each of them as identified in the core and their labeling on the front panel of the product:
64
59
65
-
LED_USER --> LED above the user button (only available on Opta WiFi (AFX00002))
60
+
-`LED_D0`: STATUS 1
61
+
-`LED_D1`: STATUS 2
62
+
-`LED_D2`: STATUS 3
63
+
-`LED_D3`: STATUS 4
64
+
-`LED_RESET`: LED above the reset button
65
+
-`LED_USER`: LED above the user button (only available on Opta WiFi (AFX00002))
66
66
67
67
Select the correct **board** and **port** in the **Tools** section.
68
68
Copy the sketch below into the Arduino IDE sketch editor, then upload it to Opta.
@@ -97,16 +97,15 @@ void loop() {
97
97
digitalWrite(LED_D3, LOW);
98
98
delay(500);
99
99
}
100
-
101
-

100
+
```
102
101
103
102
### Configuring the Programmable Button on the Opta
104
103
105
-
Opta has a programmable button, shown on the image below and identified as USER. It can be programmed using the Arduino IDE to fit your needs.
106
-
To show how much simple is to use it, let's create a sketch and program the button as a trigger to modify the status of the STATUS LEDs.
107
-
The button is defined in the core as `BTN_USER`: 'HIGH' as default (not pressed), and 'LOW' when pressed.
108
-
The new sketch will turn on one by one the LEDs when the button is pressed, and then start over when all the lights have been turned on.
109
-
Below you can find the entire sketch, where a simple [Switch (case) Statement](https://www.arduino.cc/reference/en/language/structure/control-structure/switchcase/) is used, and an image highlighting where the USER button is located on the device.
104
+
Opta has a programmable button, shown on the image below and identified as USER. It can be programmed using the Arduino IDE to fit your needs. To show how much simple is to use it, let's create a sketch and program the button as a trigger to modify the status of the STATUS LEDs.
105
+
106
+

107
+
108
+
The button is defined in the core as `BTN_USER`: 'HIGH' as default (not pressed), and 'LOW' when pressed. The new sketch will turn on one by one the LEDs when the button is pressed, and then start over when all the lights have been turned on. Below you can find the entire sketch, where a simple [Switch (case) Statement](https://www.arduino.cc/reference/en/language/structure/control-structure/switchcase/) is used, and an image highlighting where the USER button is located on the device.
110
109
111
110
```arduino
112
111
int buttonState = 0;
@@ -159,40 +158,36 @@ void changeLights() {
159
158
}
160
159
delay(100);
161
160
}
162
-
163
-

161
+
```
164
162
165
163
Once the sketch is uploaded, you can see that an additional LED is turned on each time you press the button, following the sequence:
166
164
167
-
First press --> LED 1 ON.
168
-
169
-
Second press --> LEDs 1 and 2 ON.
170
-
171
-
Third press --> LEDS 1, 2 and 3 ON.
172
-
173
-
Fourth press --> LEDS 1, 2, 3 and 4 ON.
174
-
175
-
Fifth press --> All leds off and back.
165
+
| Interaction | Result |
166
+
| ------------ | ---------------------- |
167
+
| First press | LED 1 ON. |
168
+
| Second press | LEDs 1 and 2 ON. |
169
+
| Third press | LEDS 1, 2 and 3 ON. |
170
+
| Fourth press | LEDS 1, 2, 3 and 4 ON. |
171
+
| Fifth press | All leds off and back. |
176
172
177
173
178
174
### Using Out Relays
179
175
180
-
Opta has 4 outputs, consisting of 4 electromechanical relays NO (SPST) with a capacity of 10 A at 250 V AC (considering a resistive load). They are identified as OUTPUTS and located on the bottom of Opta as shown in the image. They correspond to pins D0 to D3 as follows:
181
-
The outputs correspond to pins D0 to D3 as follows:
182
-
OUTPUT 1 --> D0
176
+
Opta has 4 outputs, consisting of 4 electromechanical relays NO (SPST) with a capacity of 10A at 250V AC (considering a resistive load). They are identified as OUTPUTS and located on the bottom of Opta as shown in the image below.
183
177
184
-
OUTPUT 2 --> D1
185
-
186
-
OUTPUT 3 --> D3
178
+

187
179
188
-
OUTPUT 4 --> D4
180
+
The outputs correspond to pins D0 to D3 as follows:
189
181
190
-

182
+
| Output | Pin |
183
+
| -------- | --- |
184
+
| OUTPUT 1 | D0 |
185
+
| OUTPUT 2 | D1 |
186
+
| OUTPUT 3 | D3 |
187
+
| OUTPUT 4 | D4 |
191
188
192
189
The OPTA output contacts are "clean" contacts, which means they are contacts that are not alive in a "non-connection" situation. This type of contact can be used in any system and with any type of voltage. To properly function, the outputs must therefore be connected by bringing for example a power cable to one of the terminals and connecting the load to the exit of the other terminal.
193
190
194
-

195
-
196
191
This way, when the contact is closed by the logic set in the programming, the power supply signal will cross the contact carring the signal up to the reference load.
197
192
198
193
The “clean” contact also allows carrying a different power system or type of load for each output contact, being possible to control multiple devices or signals that use different voltage levels.
@@ -331,19 +326,20 @@ void loop() {
331
326
332
327
delay(1000);
333
328
}
329
+
```
334
330
335
331
Once you have uploaded the code, open the serial monitor to see the values read in each analog input. Ig you have connected a device with an analog voltage value in I1, I2, and/or I3 you will see the voltage or analog value of each of the signals. In case you did not connect anything to the analog inputs, you will see how the values oscillate between 0V and a very small value because the pins are floating.
336
332
337
333
You may notice from the output values that when the maximum value of 10V is reached, the corresponding numerical value is not 4095 as the maximum value with 12 bits resolution should be. The reason is that there is a precautional margin taken on the maximum voltage level applicable to the inputs to preserve the integrity of the microcontroller.
338
334
339
335
### Connecting Opta to the Cloud
340
336
341
-
It is possible to use the Opta with the Arduino Cloud. To set up the Opta to the cloud go to the [Arduino Cloud](https://cloud.arduino.cc/). For help with how to get started with the cloud, go to our [Getting started with the cloud tutorial](https://docs.arduino.cc/arduino-cloud/getting-started/iot-cloud-getting-started). We also have a number of other helpful tutorials for [the Arduino cloud](https://docs.arduino.cc/arduino-cloud/).
337
+
It is possible to use the Opta with the Arduino Cloud. To set up the Opta to the cloud go to the [Arduino Cloud](https://cloud.arduino.cc/). For help with how to get started with the cloud, go to our [Getting started with the cloud](https://docs.arduino.cc/arduino-cloud/getting-started/iot-cloud-getting-started) tutorial. We also have a number of other helpful tutorials for [the Arduino cloud](https://docs.arduino.cc/arduino-cloud/).
342
338
343
339
## Conclusion
344
340
345
341
This tutorial went through the basics of the Opta. Now you should know how to program the LEDs on the board. We also showed how to program the programmable button on the device. The analog inputs and the out relays were also covered. After going through this tutorial you should be ready to go into the other Opta tutorials and learn more about the device and its features.
346
342
347
343
### Next Steps
348
344
349
-
Now that you know the basics of the Opta it could be a good idea to combine these features with other features on the Opta. For example, if you want to add connectivity to your solution, take a look at the [Getting started with connectivity on the Opta tutorial]().
345
+
Now that you know the basics of the Opta it could be a good idea to combine these features with other features on the Opta. For example, if you want to add connectivity to your solution, take a look at the [Getting started with connectivity on the Opta tutorial](/tutorials/opta/getting-started-connectivity).
0 commit comments