Page 18 - HTN_MarApr23
P. 18

Number 2 in a Series
Written by: Dr. Don Wilcher, CETa, EE, MSEIT
  In the previous issue, we talked about the different versions of OpenPLC and created our first project, Hello World PLC. We left off on wiring and testing the digital logic switches of your prototype Arduino Uno PLC. Before proceeding to the final step of the OpenPLC project, insert the USB cable into your PLC development machine’s USB port.
Building a Basic LD Program in OpenPLC
Figure 10. HelloWorld I/O Tags Listing
You will notice the columns Type and Location in the I/O tags listing. Click in the HelloWorld_PB’s Type cell and select BOOL. Repeat the selection process for the HelloWorld_LED. With the tactile pushbutton switch providing digital information (ON/OFF) and the output LED indicator being commanded to turn ON and OFF, the data type is Boolean, thus the selection of BOOL. The location column is the PLC address for the specified I/O pins of the Arduino Uno ATMEGA328 microcontroller. Type the addresses as shown in Figure 10. With the I/O tags listing completed, you will create an LD program. The two primary PLC bit instructions you will use for the Hello World project are the Examine If Closed (XIC) and Output Energized (OTE). The location of these bit instructions is in the programming toolbar.
Figure 11. PLC Bit Instructions
You will build the Hello World LD program by selecting the XIC and OTE bit instructions and placing them in the LD program build section of the OpenPLC editor. The tags you created will be associated by selecting the correct bit instructions. Alternatively, OpenPLC uses a contact for XIC and a coil for OTE bit instructions. Figure 12 shows the tags associated with the correct bit instructions.
Figure 12. Placing and Configuring the XIC and OTE Bit Instructions
You will connect the XIC and OTE bit instructions to the left and right power rails. With the mouse, select the power rail and configure the number of pins. The pins are the rungs for the LD program. Figure 13 illustrates the selection and configuration process of the power rails.
 You will
a project directory folder on your PLC development machine.
Next, create a project folder in which the OpenPLC-generated files are stored with the LD program. You will name the project folder “HelloWorld”. With the project folder created, open the OpenPLC software by clicking its icon with your mouse. The OpenPLC will direct you to your project directory folder. With your mouse, select the HelloWorld project folder. Once the HelloWorld project folder has been selected, the OpenPLC editor will appear on the screen.
Figure 8. The OpenPLC Editor
You will create the HelloWorld LD program by selecting File>New with your mouse. A small box will appear on the PLC development screen. Fill in the textbox labeled POU Name with “HelloWorld” as shown in Figure 9. For the Language dropdown list, select LD with the mouse. Click the OK button to finalize creating a new LD program.
Figure 9. Completing the Project Box Information With the project box completed, you are ready to create I/O tags. There are two tags for the Hello World LD: HelloWorld_PB and HelloWorld_LED. Click the plus sign with your mouse to create the two I/O tags. Your I/O tags listing should look
like Figure 10.
    18 | highTECH NEWS | MARCH/APRIL 2023

   16   17   18   19   20