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/18.opta-analog-expansion-plc-ide/content.md
+40-2Lines changed: 40 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -296,7 +296,7 @@ END_IF;
296
296
297
297
***The analog channel in current mode can generate up to 25 mA and the DAC resolution is 13 bit, this is why we use the 8191 constant that corresponds to 2<sup>13</sup>-1.***
298
298
299
-
- Upload the program to your Opta and enable the **Live Debug Mode** to see the output updating in real-time and use an ampmeter to measure the output.
299
+
- Upload the program to your Opta and enable the **Live Debug Mode** to see the output updating in real-time and use an ampmeter to measure the output on **O1**.
300
300
301
301

302
302
@@ -312,7 +312,45 @@ The Analog Expansion has 4x PWM output channels **(P1...P4)**. They are software
312
312
| Max current draw (per channel) | 100 mA |
313
313
| Max frequency | 10kHz |
314
314
315
-

315
+

316
+
317
+
To configure a PWM output, navigate to **PWM Outputs** under your desired expansion in the left **Resources** menu. Define a variable name to **P1 PERIOD** and **P1 PULSE**, `P1_PERIOD` and `P1_PULSE` respectively in this case.
Now you can easily control this output PWM period and pulse in your program. For example in a **Structured Text** program:
322
+
323
+
- Open your project main program navigating to the **Project** tab in the left panel, select **Main** in the project tree, and right-click on the **Local variables** window to insert a variable.
324
+
325
+

326
+
327
+
Insert the following variable with its respective _type_ and _attribute_:
***PERIOD and PULSE values are in microseconds.***
336
+
337
+
- In the main code editor use the following sketch to set the PWM signal period and pulse times.
338
+
339
+
```
340
+
P1_PERIOD := PERIOD; // 1000 us period = 1 kHz
341
+
342
+
P1_PULSE := P1_PULSE + 10;
343
+
344
+
IF P1_PULSE >= 1000 then
345
+
P1_PULSE := 0;
346
+
END_IF;
347
+
```
348
+
349
+
***The PWM output voltage is defined by the voltage applied to __V<sub>PWM</sub>__ from 8 to 24 V.***
350
+
351
+
- Upload the program to your Opta and enable the **Live Debug Mode** to see the output updating in real-time and use an oscilloscope to measure the output on **P1**.
0 commit comments