Skip to content

Commit c87aa80

Browse files
authored
[PC-1632] - Opta's interrupts information update (#1780)
* Content update (Opta's user manual IRQ information update) * Content update (Opta's IRQ tutorial information update) * Content update (grammar check, graphics update)
1 parent 10cf7b2 commit c87aa80

File tree

4 files changed

+23
-44
lines changed

4 files changed

+23
-44
lines changed

Diff for: content/hardware/07.opta/opta-family/opta/tutorials/01.user-manual/content.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ You should be able now to connect to your Opta™ using a central device. The Bl
11941194

11951195
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.
11961196

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.***
11981198

11991199
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:
12001200

Diff for: content/hardware/07.opta/opta-family/opta/tutorials/04.getting-started-with-interrupts/assets/opta_interrupt_overview.svg

-29
This file was deleted.

Diff for: content/hardware/07.opta/opta-family/opta/tutorials/04.getting-started-with-interrupts/content.md

+22-14
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ hardware:
1717

1818
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.
1919

20-
![General Overview of Interrupt on Opta](assets/opta_interrupt_overview.svg)
20+
![General overview of Opta's interrupts](assets/opta_interrupt_overview.png)
2121

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).
2323

2424
## Goals
2525

@@ -30,9 +30,9 @@ The **Interrupt**, a basic yet vital feature, is available on Opta™ to handle
3030

3131
#### Hardware Requirements
3232

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)
3434
- USB-C® cable (x1)
35-
- 12-24VDC/1A power supply (x1)
35+
- +12-24 VDC/0.5 A power supply (x1)
3636

3737
#### Software Requirements
3838

@@ -41,9 +41,9 @@ The **Interrupt**, a basic yet vital feature, is available on Opta™ to handle
4141

4242
## Interrupt Basics
4343

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.
4545

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.
4747

4848
### Interrupt Types
4949

@@ -60,10 +60,18 @@ Interrupt signals must be set with appropriate triggers to create interrupt requ
6060
* **Level-Triggered:** This is when an interrupt has been requested with signals at a particular logic level, which can be either *HIGH* or *LOW*.
6161
* **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.
6262

63-
![Interrupt Triggers with Opta™](assets/opta_interrupt_signals.svg)
63+
![Interrupt triggers in Opta™](assets/opta_interrupt_signals.svg)
6464

6565
Now that you have a better knowledge about interrupts, let's see how to use interrupts with an Opta™ device.
6666

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+
6775
## Instructions
6876

6977
### Setting up the Arduino IDE
@@ -72,17 +80,17 @@ This tutorial will need the latest version of the Arduino IDE. You can download
7280

7381
### Example Setup
7482

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.
7684

7785
Please refer to the following diagram to have an overview of the inputs and outputs position of the example model.
7886

79-
![Interrupt Example Setup for Opta™](assets/opta_interrupt_model.svg)
87+
![Interrupt example setup](assets/opta_interrupt_model.svg)
8088

8189
### Example Overview
8290

8391
The example will showcase different interrupt routines for Opta™ using two scenarios:
8492

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.
8694
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.
8795

8896
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.
@@ -98,7 +106,7 @@ volatile bool batchState01 = false;
98106
volatile bool batchState23 = false;
99107
```
100108

101-
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.
102110

103111
```arduino
104112
int idx{ 0 };
@@ -107,7 +115,7 @@ int leds[]{ LED_D0, LED_D1, LED_D2, LED_D3 };
107115
bool statuses[]{ true, true, true, true };
108116
```
109117

110-
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.
111119

112120
***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.***
113121

@@ -158,7 +166,7 @@ void loop(){
158166

159167
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.
160168

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.
162170

163171
```arduino
164172
/**
@@ -274,7 +282,7 @@ You will be able to observe the following results when testing if you were able
274282
* 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`.
275283
* 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.
276284

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.
278286

279287
## Conclusion
280288

0 commit comments

Comments
 (0)