OT 102: Ladder Logic (15 pts)

What You Need

Installing OpenPLC Editor

In a Web browser, go to
https://autonomylogic.com/download/
Download the Windows version and install the software.

If a box opens, saying "Windows protected your PC", click "More info" to run it anyway.

Creating a Project

Launch OpenPLC Editor, as shown below.

In OpenPLC Editor, at the top left, click the New icon, outlined in blue in the image below.

Create a new empty folder to save your project, with a name such as OT102

A "Create a new POU" (Program Organization Unit) box appears.

Enter a POU Name of OT102_Program and select a Language of LD (Ladder Logic), as shown below.

In the "Create a new POU" box, click OK.

Adding Power Rails

In OpenPLC Editor, at the top right, click the "Create a new power rail" button, outlined in blue in the image below.

Then click the central white area.

A "Power Rail Properties" box pops up, as shown below.

In the "Power Rail Properties" box, accept the default option of "Left PowerRail" and click OK.

A PowerRail icon appears in the central white area. Drag it to the left side, as shown below.

Repeat the process to add a Right PowerRail on the right side, as shown below.

Adding a Variable

A Contact can be open or closed, so it requires a variable to store its current state.

In the top right, click the green plus-sign, outlined in blue in the image below.

A row appears to enter values. Enter these values, as shown below:

Adding a Contact

A Contact represents input of a single bit to the program. You can think of it as an electrical switch that can be open or closed.

In OpenPLC Editor, at the top right, click the "Create a new contact" button, outlined in blue in the image below.

Then click the central white area.

A "Edit Contact Values" box pops up, as shown below.

In the "Edit Contact Values" box, accept the default Modifier of Normal, select a Variable of ToggleSwitch, and click OK.

Drag the Contact to the left side, between the power rails. Drag the line from the left power rail to connct it to the Contact, as shown below.

Adding a Coil

A Coil represents output of a single bit to the program. You can think of it as an electrical relay.

Add another variable named Coil, of type BOOL.

At the top right, click the "Create a new coil" button, outlined in blue in the image below.

Then click the central white area.

A "Edit Coil Values" box pops up, as shown below.

In the "Edit Coil Values" box, accept the default Modifier of Normal, select a Variable of Coil, and click OK.

Drag the Coil to the right side, between the power rails. Drag the lines to connect the circuit, as shown below.

Saving the Program

From the menu bar, click File, Save.

Running a Simulation

At the top center, click the "Start PLC simulation" button, outlined in blue in the image above.

In the lower right pane, messages scroll by, ending with two green icons, as shown below.

Debugging the Program

At the lower left, next to "Config0.Res0.instance0", click the eyeglass icon, outlined in blue in the image below.

The right pane shows a Debugger pane, with a Tick counter increasing.

At the lower left, click the eyeglass icon next to the ToggleSwitch counter.

The ToggleSwitch variable's value appears in the rightmost pane. Currently it's "False".

Repeat the process to display the Coil value in the rightmost pane.

You should see both variables in the rightmost pane, both currently False, as shown below.

Displaying Time Charts

In the rightmost pane, double-click ToggleSwitch. The display shows a moving graph, as shown below.

Double-click Coil to display its moving graph also.

Changing the ToggleSwitch Value

In the central pane, right-click the ToggleSwitch.

Click "Force True", as shown below.

You see both variables change state from False to True, as shown below.

Flag OT 102.1: Stopping the Simulation (15 pts)

At the top center, click the Stop icon, outlined in blue in the image above.

The flag is covered by a green rectangle in the image below.

Saving the Program

From the menu bar, click File, Save.

Close OpenPLC Editor.

References

Introduction to Open PLC - Download OpenPLC Software
OpenPLC Programming Reference
Error Code on MacOS

Posted 1-24-23