Skip to content

Commit e3d67f3

Browse files
ArduinoBotTaddyHCg-castronovo
authored
[PC-1814][PC-1933] Getting started Din Simul8 Content Update (#2144)
* Initial commit - Getting started Din Simul8 content update * Tutorial content resources update * Update content/hardware/08.edu/solution-and-kits/din-simul8/tutorials/getting-started/content.md Co-authored-by: Gaia Castronovo <[email protected]> * Update content/hardware/08.edu/solution-and-kits/din-simul8/tutorials/getting-started/content.md Co-authored-by: Gaia Castronovo <[email protected]> * Update content/hardware/08.edu/solution-and-kits/din-simul8/tutorials/getting-started/content.md Co-authored-by: Gaia Castronovo <[email protected]> --------- Co-authored-by: TaddyHC <[email protected]> Co-authored-by: TaddyHC <[email protected]> Co-authored-by: Gaia Castronovo <[email protected]>
1 parent 8250b01 commit e3d67f3

File tree

10 files changed

+59
-51
lines changed

10 files changed

+59
-51
lines changed

content/hardware/08.edu/solution-and-kits/din-simul8/tutorials/getting-started/content.md

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: 'Getting Started with DIN Simul8'
2+
title: 'Getting Started with Arduino® DIN Simul8'
33
difficulty: beginner
4-
description: 'This short guide helps you connecting the board to a PLC of the Opta® family and test some basic functionality.'
4+
description: 'This tutorial will help you connect the board to a PLC from the Opta® family and test some basic functionality.'
55
tags:
66
- Simul8
77
- DIN
@@ -13,20 +13,20 @@ software:
1313
- ide-v2
1414
---
1515

16-
![The board.](assets/title.png)
16+
![ ](assets/title.png)
1717

18-
In this tutorial you'll be guided in connecting the **Arduino® DIN Simul8** to the **Arduino Opta® WiFi**, and trigger some basic functions.
18+
In this tutorial, you will learn how to connect the **Arduino® DIN Simul8** to the **Arduino Opta® WiFi** and implement basic functions.
1919

2020
## Hardware & Software Requirements
2121

2222
### Hardware
2323

24-
- Arduino® DIN Simul8
2524
- [Arduino Opta® WiFi](https://store.arduino.cc/products/opta-wifi)
25+
- Arduino® DIN Simul8
2626
- USB-C® cable
27-
- 24 V power supply with barrel plug adapter
28-
- 8x wire for signal
29-
- 2x wire for power distribution
27+
- 24 V AC/DC power supply with barrel plug adapter
28+
- Wiring cable for signal (x8)
29+
- Wiring cable for power distribution (x2)
3030

3131
### Software
3232

@@ -36,31 +36,31 @@ In this tutorial you'll be guided in connecting the **Arduino® DIN Simul8** to
3636

3737
![Render front](assets/Simul-8-Top-with-Adaptor.png)
3838

39-
DIN Simul8 is a digital-input-simulator and power distribution board for the PLC of the Opta family. It provides eight toggle switches (0 - 10 V output) and four screw terminal for bringing the 24 V and the GROUND easily to the PLC or other boards.
39+
The **DIN Simul8** is a digital input simulator and power distribution board designed for the Opta PLC family. It features eight toggle switches (0 - 10 V output) and four screw terminals, making it easy to supply 24 VDC and GND to the PLC or other boards.
4040

41-
If you have any problems using the Opta WiFi you can read its [manual](https://docs.arduino.cc/tutorials/opta/user-manual/) before proceeding.
41+
***If you encounter any issues with the Opta WiFi, refer to its [user manual](https://docs.arduino.cc/tutorials/opta/user-manual/) before continuing.***
4242

4343
### Connections
4444

45-
To connect the DIN Simul8 to the PLC you'll need 8 wires for the signal and two for the power.
46-
47-
![connections scheme](assets/connections_scheme.png)
45+
To connect the DIN Simul8 to the PLC, you will need eight wiring cables for the signal connections and two for power.
4846

49-
Connections are super important in an industrial project, first of all **disconnect the power plug** and then connect all the pins using cable with lugs, or be careful that no copper part of the cable touch other pins.
47+
![Connection diagram](assets/wiring.png)
5048

51-
![Overall connections](assets/connections_all.png)
49+
1. Connect the power pins: +24V and GND.
50+
2. Connect all the signal pins.
5251

53-
1. Connect the power pins: +24V and GND
54-
2. Connect all the signal pins
52+
***It is recommended to use __AWG 17__ cables for all connections to ensure optimal performance and safety.***
5553

56-
![Detail connections](assets/connections.png)
54+
Proper connections are crucial in an industrial project. **Always disconnect the power source before making any connections.** Use cables with lugs, or ensure that no exposed copper parts of the cables come into contact with other pins.
5755

56+
![Wiring precaution](assets/wiring_caution.png)
5857

5958
## Upload Test Code
6059

61-
Firstly we have to test if the components and the connections works as excepted. Let's print on the [Serial Monitor](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-serial-monitor/) what arrives to the inputs.
60+
Before proceeding, it is necessary to test if the components and connections are working as expected. We can do this by printing the input values to the [Serial Monitor](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-serial-monitor/).
61+
62+
The Opta WiFi has eight input ports, labeled `I1` to `I8` at the top. These are mapped to pins `A0` through `A7`. To make it easier to reference each input, we can assign a variable to each port using the [`#define`](https://www.arduino.cc/reference/en/language/structure/further-syntax/define/) command, as shown below:
6263

63-
The Opta WiFi has eight inputs ports, at the top, named from `I1` to `I8`. They are mapped to pin `A0` to `A7`. Let's assign to each of them a variable with the name of the port on the Opta WiFi, easier to remember, we can use the [#define](https://www.arduino.cc/reference/en/language/structure/further-syntax/define/) function, like this:
6464

6565
```arduino
6666
#define pin_I1 A0
@@ -77,17 +77,15 @@ The Opta WiFi has eight inputs ports, at the top, named from `I1` to `I8`. They
7777
| `I7` | `A6`/`PIN_A6` | `pin_I7` |
7878
| `I8` | `A7`/`PIN_A7` | `pin_I8` |
7979

80-
From now on we can refer to the port `I1` of the Opta WiFi using the `pin_I1` variable.
81-
80+
Now, you can refer to the `I1` port on the Opta WiFi using the `pin_I1` variable.
8281

83-
To read what's arriving on each input port, we can use the [digitalRead](https://www.arduino.cc/reference/en/language/functions/digital-io/digitalread/) function, inside the `Serial.print` command:
82+
To read the received values at each input port, you can use the [`digitalRead`](https://www.arduino.cc/reference/en/language/functions/digital-io/digitalread/) function within the `Serial.print` command:
8483

8584
```arduino
8685
Serial.print(digitalRead(pin_I1));
8786
```
8887

89-
Now let's do this for each input port, dividing each value with a comma `,`.
90-
Here the full code:
88+
Next, lets do this for each input port, separating each value with a comma (`,`). Here is the complete code:
9189

9290
```arduino
9391
#define pin_I1 A0
@@ -127,28 +125,31 @@ void loop() {
127125
128126
delay(100);
129127
}
130-
131128
```
132129

133-
>**Don't forget to** initialize the Serial communication with the Serial.begin command in the setup.
130+
***Remember to initialize the Serial communication with the `Serial.begin` command in the `setup` function.***
134131

135-
>**Don't forget to** call the the last `Serial.print` as `Serial.println`, in order to print a new line and wrap the text to make readable.
132+
***Use `Serial.println` for the last `Serial.print` to ensure the output wraps to a new line, making it easier to read.***
136133

137-
>**Don't forget to** put some delay, like 100ms in order to have a stable communication over serial.
134+
***Add a `delay`, such as __100ms__, to ensure stable communication over Serial.***
138135

139-
Each switch in the DIN Simul8 outputs 0 V when OFF and 10 V when ON. The `digitalRead()` function will read 0 for 0 V and 1 for 10 V.
140-
If you switch on the toggle switches 1-3-5-7 and leave off the 2-4-6-8, like in the following image:
141136

142-
![Toggle switches 1-3-5-7](assets/step1_switches.png)
137+
Each switch on the DIN Simul8 outputs is 0 V when OFF and 10 V when ON. The `digitalRead()` function will read `0` for 0 V and `1` for 10 V.
143138

144-
The output should be like this:
145139

146-
![Serial Monitor output](assets/step1_serial-monitor.png)
140+
For example, if you turn on toggle switches 1, 3, 5, and 7 while leaving 2, 4, 6, and 8 off, as shown in the image below:
147141

142+
![Toggle switches 1-3-5-7](assets/led_toggles.png)
143+
144+
The output should look like this:
145+
146+
![Serial Monitor output](assets/step1_serial-monitor.png)
148147

149148
## Upload Function Trigger Code
150149

151-
If everything works we can move on and try to trigger a function when switch change state: a function that print `"Switch 1 ON"` when turned on and the inverse for the OFF state.
150+
If everything works correctly, we can trigger a function when the switch changes state.
151+
152+
For example, we can create a function that prints `"Switch 1 ON"` when the switch is turned on and `"Switch 1 OFF"` when it is turned off.
152153

153154
```arduino
154155
void ON_function() {
@@ -160,13 +161,13 @@ void OFF_function() {
160161
}
161162
```
162163

163-
In order to make every function runs once, only when the state changed, and not continuously, we can save the status of the switch in a variable:
164+
To ensure that the function only runs once when the state changes (and not continuously), we can store the current state of the switch in a variable:
164165

165166
```arduino
166167
bool stateSwitch = false;
167168
```
168169

169-
and call the function when it reads the opposite state: if the state is OFF (0) and it reads ON (1) it means that is just changed to ON, so call the `ON_function()` and update the `stateSwitch` variable.
170+
The function is called when the switch state changes. For instance, if the switch is currently OFF (`0`) and the state changes to ON (`1`), the `ON_function()` is triggered, and the `stateSwitch` variable is updated accordingly:
170171

171172
```arduino
172173
if (stateSwitch == 0) {
@@ -177,7 +178,7 @@ and call the function when it reads the opposite state: if the state is OFF (0)
177178
}
178179
```
179180

180-
The final code should like like this and it will works only for the toggle switch 1.
181+
Here is the complete code, which works for toggle switch 1:
181182

182183
```arduino
183184
#define pin_I1 A0
@@ -222,27 +223,31 @@ void ON_function() {
222223
void OFF_function() {
223224
Serial.println("Switch 1 OFF");
224225
}
225-
226226
```
227227

228+
This code will monitor the state of toggle switch 1 and trigger the appropriate function when the switch is turned *on* or *off*.
229+
228230
## Upload Final Code
229231

230-
In order to make it works for all the eight switches, you can repeat the `stateSwitch` variable and the `if-else` conditions eight times... but that would be boring. What about using [arrays](https://www.arduino.cc/reference/en/language/variables/data-types/array/) and a [for-loop](https://www.arduino.cc/reference/en/language/structure/control-structure/for/)?
232+
To make this work for all eight switches, you could repeat the `stateSwitch` variable and the `if-else` conditions eight times, but that would be a nonoptimal approach.
231233

232-
The idea is to replace all the variables used in the loop with arrays that stores eight values, one for each switch, and put it inside a `for loop` that will cycle through all the eight inputs. Let's see how to do it:
234+
Instead, let's use [`arrays`](https://www.arduino.cc/reference/en/language/variables/data-types/array/) and a [`for-loop`](https://www.arduino.cc/reference/en/language/structure/control-structure/for/).
233235

234-
First of all we need an array for all the pins definition of the inputs:
236+
The idea is to replace the variables in the loop with arrays that store values for each switch and then use a `for-loop` to cycle through all eight inputs.
237+
238+
First, define an array for all the input pin definitions:
235239

236240
```arduino
237241
int pins[] = { pin_I1, pin_I2, pin_I3, pin_I4, pin_I5, pin_I6, pin_I7, pin_I8 };
238242
```
239-
Then we need one for the `stateSwitch` variable:
243+
244+
Next, create an array for the `stateSwitch` variable:
240245

241246
```arduino
242247
bool stateSwitch[] = { false, false, false, false, false, false, false, false };
243248
```
244249

245-
And then we can substitute them:
250+
Then, you can substitute these arrays into your code:
246251

247252
```arduino
248253
if (stateSwitch[ ] == 0) {
@@ -258,8 +263,9 @@ if (stateSwitch[ ] == 0) {
258263
}
259264
```
260265

261-
Now we need to tell to each array-variable which values to use, you can do it by putting a number from 0 to 7 inside the `[]`, i.e. `pins[0] = pin_I1 // pins[1] = pin_I2 // etc..`.
262-
One way of doing it is with the [`for-loop`](https://www.arduino.cc/reference/en/language/structure/control-structure/for/). We can assign a variable, like `int i`, to change from 0 to 7, and then assign it to each array-variable:
266+
To specify which array values to use, you can use a number from 0 to 7 inside the brackets `[]`. For example, `pins[0] = pin_I1`, `pins[1] = pin_I2`, and so on.
267+
268+
One way to implement this is with a [`for-loop`](https://www.arduino.cc/reference/en/language/structure/control-structure/for/). Assign a variable, like `int i`, to iterate from 0 to 7, and then use it to access each array value:
263269

264270
```arduino
265271
for (int i = 0; i <= 7; i++) {
@@ -277,9 +283,9 @@ for (int i = 0; i <= 7; i++) {
277283
}
278284
```
279285

280-
Ok, that would work, but the `ON_function()` and the `OFF_function()` will print only the state of the Switch 1, unless we make the `i` variable as an [argument](https://docs.arduino.cc/learn/programming/functions/), and so we can print the number related to the switch we are switching.
286+
This approach will work, but the `ON_function()` and `OFF_function()` will only print the state of Switch 1 unless we pass the `i` variable as an [argument](https://docs.arduino.cc/learn/programming/functions/). This way, we can print the switch number that is being toggled.
281287

282-
Here the full code:
288+
Here is the full code:
283289

284290
```arduino
285291
#define pin_I1 A0
@@ -332,14 +338,16 @@ void OFF_function(int n) {
332338
}
333339
```
334340

335-
And here you can see what's goes on the serial monitor when you turn on all the switch from 1 to 8 and then off from 8 to 1:
341+
And here is what you should see on the Serial Monitor when you turn on all the switches from 1 to 8 and then off from 8 to 1:
336342

337343
![Serial Monitor with switches](assets/step3_serial-monitor.png)
338344

345+
This code will monitor the state of all eight switches and print the corresponding message whenever a switch is toggled *on* or *off*.
346+
339347
## Considerations
340348

341-
If something strange happens when you turn a switch on or off, like if the switch was triggered on and off super rapidly, don't panic! That's normal, and it is related to something called "debounce". You can have a look [here](https://docs.arduino.cc/built-in-examples/digital/Debounce/) to understand what's going on.
349+
If you notice any unexpected behavior when turning a switch on or off, such as the switch appearing to toggle on and off rapidly, don't worry! This is normal and is related to a phenomenon called "debounce." To understand further, you can learn more about it [here](https://docs.arduino.cc/built-in-examples/digital/Debounce/).
342350

343351
## Conclusions
344352

345-
The Arduino DIN Simul8 is the perfect playground to start experiment your coding skill in the PLC world. Try creating more functions that could be triggered by some combination of switch position, or whatever you like, have fun!
353+
The Arduino DIN Simul8 provides an excellent platform to start experimenting with your coding skills in the PLC world. Try creating more functions that different combinations of switch positions can trigger, or explore any other ideas you have. Have fun!

0 commit comments

Comments
 (0)