Skip to content

Commit af3a2be

Browse files
committed
led section
1 parent 97273d2 commit af3a2be

File tree

5 files changed

+14
-77
lines changed

5 files changed

+14
-77
lines changed
558 KB
Loading
1.3 MB
Loading
585 KB
Loading
526 KB
Loading

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

Lines changed: 14 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ I_IN1 := IN1*25.0/65535.0;
199199

200200
### Analog RTD Input Mode
201201

202-
To set up an input in RTD mode for termperature measurement, navigate to **Programmable Channels** under your desired expansion in the left **Resources** menu. Define a variable name to **I1**, `IN1` in this case and set the **IOType** to `Input - RTD 2 Wires` or `Input - RTD 3 Wires` .
202+
To set up an input in RTD mode for termperature measurement, navigate to **Programmable Channels** under your desired expansion in the left **Resources** menu. Define a variable name to **I1**, `IN1` in this case and set the **IOType** to `Input - RTD 2 Wires` or `Input - RTD 3 Wires`.
203203

204204
![Current Input Configuration](assets/plc-ide-13.png)
205205

@@ -248,7 +248,7 @@ The Opta™ Analog Expansion has **8x analog programmable outputs** accessible t
248248

249249
### Analog Voltage Output Mode
250250

251-
To set up an output in voltage mode, navigate to **Programmable Channels** under your desired expansion in the left **Resources** menu. Define a variable name to **O1**, `OUT1` in this case and set the **IOType** to `Input - RTD 2 Wires` or `Input - RTD 3 Wires` .
251+
To set up an output in voltage mode, navigate to **Programmable Channels** under your desired expansion in the left **Resources** menu. Define a variable name to **O1**, `OUT1` in this case and set the **IOType** to `Input - RTD 2 Wires` or `Input - RTD 3 Wires`.
252252

253253
### Analog Current Output Mode
254254

@@ -268,92 +268,29 @@ The Analog Expansion has 4x PWM output channels **(P1...P4)**. They are software
268268

269269
### Expansion Status LEDs
270270

271-
To set up the sensor input for the potentiometer, navigate to **Programmable Inputs** under your desired expansion in the left resources menu. Define a **variable** name, **sensor** in this case, and set the **IOType** to **Analog**.
271+
The Opta™ Analog Expansion has **8x status LEDs** on the front panel.
272272

273-
![Setting up the sensor input](assets/plc-ide-8.png)
273+
To control an LED, navigate to **LED Outputs** under your desired expansion in the left **Resources** menu and define a variable name to **L3**, `LED3` in this case.
274274

275-
To set up the Opta™ expansion outputs, proceed to **Relay Outputs** under your desired expansion in the left resources menu. In this instance, define **variable** names for each output, **out_1** to **out_8**.
275+
![LED output configuration](assets/plc-ide-16.png)
276276

277-
![Setting up the relay outputs](assets/plc-ide-9.png)
277+
Assign a variable to the Opta `USER` Button, `BTN_USR` in this case so we can use it to control the LED.
278278

279-
For the main code of our solution, navigate to the **Project** tab in the left panel, select **Main** in the project tree, and right-click on the **Local variables** window to insert some variables.
279+
![User button configuration](assets/plc-ide-17.png)
280280

281-
![Configuring the main project](assets/plc-ide-10.png)
281+
Now you can easily control the LED state by pressing the button with a simple program. For example in a **Ladder Diagram**:
282282

283-
Insert the following three variables with their respective _type_ and _attribute_:
283+
- Create a new program in Ladder (LD), name it as you want, `ledControl` in this case and set the scanning speed to `fast`.
284284

285-
| Name | Type | Init value | Attribute |
286-
|-------|------|------------|-----------|
287-
| VSTEP | REAL | - | - |
288-
| VCC | REAL | 12 | CONSTANT |
289-
| VIN | REAL | - | - |
285+
![Ladder Diagram program creation](assets/ladder-led.png)
290286

291-
![Defining the local variables](assets/plc-ide-11.png)
287+
- Assign the variable `BTN_USR` to your contact and the `LED3` to your coil as follows:
292288

293-
- **VSTEP** will store the voltage step threshold to activate the relay outputs sequentially.
294-
- **VCC** is a constant representing the 12 VDC used to power the Opta™ Digital Expansion.
295-
- **VIN** will store the voltage read at the sensor input.
289+
![Ladder variables assigning](assets/led-control.gif)
296290

297-
Copy and paste the following sketch to the **Main code** text editor:
298-
299-
```
300-
VSTEP := VCC/8;
301-
VIN := sensor*1.733E-3;
302-
IF VIN >= VSTEP*1 THEN
303-
out_1 := TRUE;
304-
ELSE
305-
out_1 := FALSE;
306-
END_IF;
307-
IF VIN >= VSTEP*2 THEN
308-
out_2 := TRUE;
309-
ELSE
310-
out_2 := FALSE;
311-
END_IF;
312-
IF VIN >= VSTEP*3 THEN
313-
out_3 := TRUE;
314-
ELSE
315-
out_3 := FALSE;
316-
END_IF;
317-
IF VIN >= VSTEP*4 THEN
318-
out_4 := TRUE;
319-
ELSE
320-
out_4 := FALSE;
321-
END_IF;
322-
IF VIN >= VSTEP*5 THEN
323-
out_5 := TRUE;
324-
ELSE
325-
out_5 := FALSE;
326-
END_IF;
327-
IF VIN >= VSTEP*6 THEN
328-
out_6 := TRUE;
329-
ELSE
330-
out_6 := FALSE;
331-
END_IF;
332-
IF VIN >= VSTEP*7 THEN
333-
out_7 := TRUE;
334-
ELSE
335-
out_7 := FALSE;
336-
END_IF;
337-
IF VIN >= VSTEP*8 THEN
338-
out_8 := TRUE;
339-
ELSE
340-
out_8 := FALSE;
341-
END_IF;
342-
```
343-
344-
Compile the project by clicking on the compilation button found in the upper left corner of the IDE. If no errors are shown, upload the program to the Opta™ controller by clicking the upload button highlighted next to it.
345-
346-
![Main program in Structured Text](assets/plc-ide-12.png)
347-
348-
You can monitor the project variables in real-time while the project is running by dragging and dropping the desired variables from the left project panel to the **Watch** window:
349-
350-
![Live variable monitoring](assets/demo.gif)
351-
352-
Finally, your solution is ready. The Opta™ expansion relay outputs will activate sequentially as the sensor output increases.
353-
354-
Turn the potentiometer and observe how the **VIN** variable displays the voltage being read. The outputs activate as their respective thresholds are reached:
291+
- Upload the program to your Opta and enable the **Live Debug Mode** to see the contacts and coils updating in real-time.
355292

356-
![Final application showcase](assets/animation.gif)
293+
![LED control demo](assets/digital-in-demo.gif)
357294

358295
### Conclusion
359296

0 commit comments

Comments
 (0)