Skip to content

Commit c69608f

Browse files
committed
finished
1 parent 948747c commit c69608f

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed
479 KB
Loading
654 KB
Loading
875 KB
Loading

content/hardware/07.opta/opta-family/opta/tutorials/18.opta-analog-expansion-plc-ide/content.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ END_IF;
296296

297297
***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.***
298298

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

301301
![Current Output Demo](assets/analog-current.png)
302302

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

315-
![Example of wiring to use the PWM outputs using Opta power voltage as **V<sub>PWM</sub>** as voltage reference](assets/pwm-setup.png)
315+
![Example of wiring to use the PWM outputs](assets/pwm-setup.png)
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.
318+
319+
![PWM output configuration](assets/plc-ide-18.png)
320+
321+
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+
![Insert a local variable](assets/local-var.png)
326+
327+
Insert the following variable with its respective _type_ and _attribute_:
328+
329+
| **Name** | **Type** | **Init value** | **Attribute** |
330+
| :------: | :------: | :------------: | :-----------: |
331+
| PERIOD | INT | 1000 | CONSTANT |
332+
333+
![Set up local variable](assets/local-var-5.png)
334+
335+
***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**.
352+
353+
![PWM Output Demo](assets/pwm-out.png)
316354

317355
### Expansion Status LEDs
318356

0 commit comments

Comments
 (0)