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
+1-1
Original file line number
Diff line number
Diff line change
@@ -1194,7 +1194,7 @@ You should be able now to connect to your Opta™ using a central device. The Bl
1194
1194
1195
1195
Interrupts are particularly useful when reacting instantly to an external event, such as a button press or a sensor signal. Without interrupts, you would have to constantly poll the status of a button or a sensor in the main loop of your running sketch. With interrupts, you can let your Opta's microcontroller do other tasks and only react when a desired event occurs.
1196
1196
1197
-
***Due to Opta's microcontroller interrupt structure, interrupts in terminals `I1` and `I3`cannot be used simultaneously; you need to choose just one to avoid issues with them.***
1197
+
***Due to Opta's microcontroller interrupt structure, interrupts in terminals `I1`(`A0`) and `I4` (`A4`) cannot be used simultaneously to avoid operational issues. It is important to note that, despite this limitation, any other combination of inputs can be used for interrupt detection. However, this means that, at most, seven of the eight available inputs can be used simultaneously for interrupts, as combinations containing both `I1` and `I4` are excluded from viable configurations.***
1198
1198
1199
1199
Interrupts can be used through the built-in functions of the Arduino programming language. To enable interrupts in your Opta's analog/digital programmable inputs and user-programmable button:
Copy file name to clipboardExpand all lines: content/hardware/07.opta/opta-family/opta/tutorials/04.getting-started-with-interrupts/assets/opta_interrupt_overview.svg
Copy file name to clipboardExpand all lines: content/hardware/07.opta/opta-family/opta/tutorials/04.getting-started-with-interrupts/content.md
+22-14
Original file line number
Diff line number
Diff line change
@@ -17,9 +17,9 @@ hardware:
17
17
18
18
The Opta™ micro PLC is designed to operate in several industrial environments involving crucial processes. These processes require controllers to be responsive and precise to manage sensitive tasks and capable of handling large sets of conditions within defined parameters in real-time. Asynchronous operations or spontaneous events are the kind of process that requires immediate attention at a given moment. Therefore, interrupt management is critical to control and optimize these event classes.
19
19
20
-

20
+

21
21
22
-
The **Interrupt**, a basic yet vital feature, is available on Opta™ to handle time-sensitive and unexpected events based on state changes. This tutorial will help you to implement interrupts on Opta™ using the Arduino programming language and the [Arduino IDE](https://www.arduino.cc/en/software).
22
+
The **interrupt**, a basic yet vital feature, is available on Opta™ to handle time-sensitive and unexpected events based on state changes. This tutorial will help you to implement interrupts on Opta™ using the Arduino programming language and the [Arduino IDE](https://www.arduino.cc/en/software).
23
23
24
24
## Goals
25
25
@@ -30,9 +30,9 @@ The **Interrupt**, a basic yet vital feature, is available on Opta™ to handle
30
30
31
31
#### Hardware Requirements
32
32
33
-
- Opta™ PLC (x1)
33
+
-[Opta™ Lite](https://store.arduino.cc/products/opta-lite), [Opta™ RS485](https://store.arduino.cc/products/opta-rs485), or [Opta™ WiFi](https://store.arduino.cc/products/opta-wifi) (x1)
34
34
- USB-C® cable (x1)
35
-
- 12-24VDC/1A power supply (x1)
35
+
-+12-24 VDC/0.5 A power supply (x1)
36
36
37
37
#### Software Requirements
38
38
@@ -41,9 +41,9 @@ The **Interrupt**, a basic yet vital feature, is available on Opta™ to handle
41
41
42
42
## Interrupt Basics
43
43
44
-
**Interrupts** are execution requests triggered usually by a timed event or signal which will pause the active process if the interrupt request is accepted under certain conditions, executing new high-priority commands immediately and returning to the main process as soon as possible. The **Interrupt Service Routine**, or **ISR**, is the handler that performs a specific instruction set whenever an interrupt is raised.
44
+
**Interrupts** are execution requests triggered usually by a timed event or signal, which will pause the active process if the interrupt request is accepted under certain conditions, executing new high-priority commands immediately and returning to the main process as soon as possible. The **Interrupt Service Routine**, or **ISR**, is the handler that performs a specific instruction set whenever an interrupt is raised.
45
45
46
-
The handler can be defined to run particular instructions periodically, use external signals, or send an alert in case of a system failure. It is a function launched as a priority task among the other operations, whenever a specific high-awareness state change occurs respective to an assigned trigger.
46
+
The handler can be defined to run particular instructions periodically, use external signals, or send an alert in case of a system failure. It is a function launched as a priority task among the other operations whenever a specific high-awareness state change occurs relative to an assigned trigger.
47
47
48
48
### Interrupt Types
49
49
@@ -60,10 +60,18 @@ Interrupt signals must be set with appropriate triggers to create interrupt requ
60
60
***Level-Triggered:** This is when an interrupt has been requested with signals at a particular logic level, which can be either *HIGH* or *LOW*.
61
61
***Edge-Triggered:** This is when an interrupt has been requested due to a signal at a specific transition level, which can be either *RISING* or *FALLING* edge. It can also be configured with *CHANGE* to interrupt whenever either signal transition has occurred.
62
62
63
-

63
+

64
64
65
65
Now that you have a better knowledge about interrupts, let's see how to use interrupts with an Opta™ device.
66
66
67
+
## Interrupts on Opta™
68
+
69
+
**Opta's analog/digital programmable inputs and user-programmable button are interrupt-capable**; you can use them through the built-in functions of the Arduino programming language. To enable interrupts in your Opta's analog/digital programmable inputs and user-programmable button it is important to do the following:
70
+
71
+
- Add the `attachInterrupt(digitalPinToInterrupt(pin), ISR, mode)` instruction in your sketch's `setup()` function. Notice that the `pin` parameter can be `A0`, `A1`, `A2`, `A3`, `A4`, `A5`, `A6`, `A7`, or `BTN_USER`; the `ISR` parameter is the ISR function to call when the interrupt occurs, and the `mode` parameter defines when the interrupt should be triggered (`LOW`, `CHANGE`, `RISING`, or `FALLING`).
72
+
73
+
***Due to Opta's microcontroller interrupt structure, terminals `I1` (`A0`) and `I4` (`A4`) interrupts cannot be used simultaneously to avoid operational issues. It is important to note that, despite this limitation, any other combination of inputs can be used for interrupt detection. However, this means that, at most, seven of the eight available inputs can be used simultaneously for interrupts, as combinations containing `I1` and `I4` are excluded from viable configurations.***
74
+
67
75
## Instructions
68
76
69
77
### Setting up the Arduino IDE
@@ -72,17 +80,17 @@ This tutorial will need the latest version of the Arduino IDE. You can download
72
80
73
81
### Example Setup
74
82
75
-
The example will try to keep the setup as simple as possible while maintaining the scalability of the feature on Opta™. The setup will use the programmable user button (`BTN_USER`) and `A0-A1` inputs as interrupt pins. All available `D0-D3` relays will be configured as outputs and status LEDs will indicate the corresponding contact state.
83
+
The example will try to keep the setup as simple as possible while maintaining the scalability of the feature on Opta™. The setup will use the programmable user button (`BTN_USER`) and `A0-A1` inputs as interrupt pins. All available `D0-D3` relays will be configured as outputs, and status LEDs will indicate the corresponding contact state.
76
84
77
85
Please refer to the following diagram to have an overview of the inputs and outputs position of the example model.
78
86
79
-

87
+

80
88
81
89
### Example Overview
82
90
83
91
The example will showcase different interrupt routines for Opta™ using two scenarios:
84
92
85
-
1. The `BTN_USER` is the user-programmable button that will be used for the interrupt to simulate asynchronous events. The corresponding interrupt will make relay and corresponding status LED state switch in a sequence based on its present state.
93
+
1. The `BTN_USER` is the user-programmable button that will be used for the interrupt to simulate asynchronous events. The corresponding interrupt will make a relay and corresponding status LED state switch in a sequence based on its present state.
86
94
2. The `A0` and `A1` inputs will be open to external devices that send signals periodically, and it will make an interrupt on the signaled pin. The `A0` will be in charge of the `D0` and `D1` relays, while the `A1` will control the `D2` and `D3` relays.
87
95
88
96
These tasks will help you test multiple interrupt schemes combined with Opta™ PLC's onboard relays and status LEDs. The following section will highlight the details of interest of the example code to help you understand it with ease.
The relays and corresponding status LEDs are defined in an array including their status. Using the array provides the advantage to manage and call the data flexibly.
109
+
The relays and corresponding status LEDs are defined in an array, including their status. Using the array provides the advantage of managing and calling the data flexibly.
The `setup()` will define the relay and status LED outputs, and also the inputs that will be used to attach to interrupt cases. The `attachInterrupt()` function configures the inputs as interrupts with its trigger method and connects to the defined ISR functions that can be found later in the example description.
118
+
The `setup()` will define the relay and status LED outputs, as well the inputs that will be used to attach to interrupt cases. The `attachInterrupt()` function configures the inputs as interrupts with its trigger method and connects to the defined ISR functions that can be found later in the example description.
111
119
112
120
***For more information about `attachInterrupt()` function, please check [here](https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/). You will also be able to read briefly more information about interrupts.***
113
121
@@ -158,7 +166,7 @@ void loop(){
158
166
159
167
The `relayLinearCounter()` function runs a linear sequence for turning on and off the `D0` to `D3` relays with their corresponding status LEDs based on the interrupt triggered each time `BTN_USER` is pressed.
160
168
161
-
The `counter` and `relayLedState` variables are used to track the total number of `BTN_USER` triggered interrupts, which also represents the number of button presses, and currently shifted relay status. The `relCntState` is used as a gatekeeper instance based on the `BTN_USER` interrupt request since it is an active function inside the `loop()` function.
169
+
The `counter` and `relayLedState` variables are used to track the total number of `BTN_USER` triggered interrupts, which also represents the number of button presses and currently shifted relay status. The `relCntState` is used as a gatekeeper instance based on the `BTN_USER` interrupt request since it is an active function inside the `loop()` function.
162
170
163
171
```arduino
164
172
/**
@@ -274,7 +282,7 @@ You will be able to observe the following results when testing if you were able
274
282
* You will be able to observe that the `D0-D3` relays are turning on in sequence and turning off in the next succession linearly as you press the `BTN_USER` button. The sequence then will repeat, and the counter will keep a record of the number of interrupts caused by `BTN_USER` button press, and currently actuated relay via `relayLedState`.
275
283
* If you send feedback on either `A0` or `A1` input with a rising edge signal, it will apply state inversion on top of the actual relay states as a result of the interrupt. Thus, you will observe the `D0` and `D1` relays invert their states if the interrupt was triggered on `A0`; while `A1` will do the same job, but on `D2` and `D3` relays.
276
284
277
-
Hence, your Opta™ is processing based on asynchronous interrupt generated by `BTN_USER` button while `A0-A1` are in charge of the interrupts generated periodically by an external device.
285
+
Hence, your Opta™ is processing based on an asynchronous interrupt generated by `BTN_USER` button while `A0-A1` are in charge of the interrupts generated periodically by an external device.
0 commit comments