This is a Windows Forms application that provides a simple interface that allows users to read/write to a PLC and/or a SQL Database.
This project uses the libplctag library, which can be found here and the c# wrapper for this library can be found here.
If you do not have visual studio downloaded onto your computer, you can download it here.
- Download the repository
- Open
PDC.sln
as a solution in Visual Studio - Add the corresponding reference(s)
This is all you need to do to start developing. In order to build the program and run it on other computers, you can follow the steps listed below.
- To run the program with debug mode, simply hit the
F5
key.
- Build a 'release' version (no debug) of application
- Run the application using
PDC.exe
.
When you start the application, this window should open:
*From here you can decide if you want to communicate to a PLC or a SQL Database. Use the tabs on the top left of the form to make a selection.
To read or write to the PLC you need to fill out the fields in the form. Below are descriptions for each field.
IP Address: The IP Address of the PLC.
Path: The path to access the PLC from the gateway. The path is required for an LGX cpu but optional for other types.
Slot: The slot is a continuation of the path. For example if the PLC is located on the Backplane on slot 0, you would choose 'Backplane' for Path and '0' for Slot.
Cpu Type: Type of PLC. This library supports: compactlogix, clgx, lgx, controllogix, flexlogix, and flgx.
Tag Name: The name of the tag to access.
- If the tag is located inside of another tag:
OutsideTag.InnerTag
- If the tag is an array:
myTag[3]
Data Type: The type of data the tag is storing. This library supports: Int8, Int16, Int32, Float32, and String.
Element Count: The number of elements in array. Default value is 1.
Write to PLC: Select this checkbox to write to the PLC instead of reading from the PLC.
Value to Write: When 'Write to PLC' is selected, a textbox to enter the value to write to the PLC appears. This value should match the format of the Data Type that was selected.
Once the fields are filled in, click the 'Connect' button to get the results.
To read or write to the SQL Database you need to fill out the fields in the form. Below are descriptions for each field.
Server Name: The server that the SQL Database is located on.
Database Name: The name of the database to access.
Username: The username of the login credentials to access the database.
Password: The password of the login credentials to access the database.
Once the fields are filled in, click the 'Load' button to reveal a drop-down list of tables within the database.
Choose a table to view/edit, then click the 'View' button to view the table. A new form will pop up that displays all of the records in the selected table.
In order to edit the data, simply click in the desired cell, modify the data, and click 'Save'.
Note: primary keys are not editable.