plcLib (Arduino): Installing the Software

Please follow the appropriate instructions below, depending on whether you are installing the software for the first time, or upgrading an existing version.

First Time Installation

The plcLib software is supplied as a ZIP file which can be downloaded and then added into your Arduino IDE in the normal way. With the software installed you'll be able to browse through the example programs, and create ladder logic programs of your own.

The first step is to download the Zip file to a convenient location:

Download: plcLib Version 1.2, released 21st Dec, 2015. (See the Revision History for all published versions.)

Exact details of the installation process depends on the version of Arduino IDE installed. For Aduino 1.6.4 or later, select the Sketch > Include Library > Add .Zip Library option and browse to the Zip file downloaded earlier.

If you're using Version 1.0.5 of the Arduino IDE, then select Sketch > Import Library... > Add Library... from the pull-down menu, browse to find the previously downloaded Zip file.

The installation process is explained fully in this Arduino guide.

Your First Program

With the software installed, browse to the examples section and load the Bare Minimum program.

#include <plcLib.h>

/* Programmable Logic Controller Library for the Arduino and Compatibles

   Bare Minimum - Single bit digital input and output

   Connections:
   Input - switch connected to input X0 (Arduino pin A0)
   Output - LED connected to output Y0 (Arduino pin 3)

   Software and Documentation:
   http://www.electronics-micros.com/software-hardware/plclib-arduino/

*/

void setup() {
  setupPLC();  // Setup inputs and outputs
}

void loop() {
  in(X0);      // Read Input 0
  out(Y0);     // Send to Output 0
}
Source location: File > Examples > plcLib > InputOutput > BareMinimum
All examples shown in this guide are available from the File > Examples section of the Arduino IDE.

This sketch reads a switch connected to input X0 (pin A0 on the Arduino) and sends the switch state to output Y0 (pin 3 on the Arduino). To see it working, you can either wire up a prototype board circuit, or use any of the range of supported hardware, as explained in the Configuring the Hardware page.

New versions of the plcLib software are released periodically. The recommended upgrade procedure is to firstly remove the existing version of the library and then install the new one, as described below.

  1. Identify the location of the library files on your computer, which will be in a libraries folder beneath the Arduino Sketchbook location. Exact details may vary but it will typically be something like [My Documents]/Arduino/libraries, with a plcLib folder existing beneath this if the software has been previously installed. You can check the path to the Sketchbook folder by selecting File > Preferences from the Arduino IDE.
  2. Close the Arduino IDE, and then delete the plcLib folder identified above. (It is a good idea to make a backup copy of any existing files before deleting them – just in case you make a mistake.)
  3. Reinstall the library as explained earlier.

The next section introduces the hardware arrangement used by the software.

Related Topics

top