plcLib (Arduino): Configuring the Hardware

A basic set of inputs and outputs is enabled by default. This default configuration is selected by firstly 'including' the plc library file (#include <plcLib.h>) and secondly by calling the setupPLC() function from within the setup() section of your sketch, as was seen in the example sketch on the previous page.

At a minimum, the software defines four inputs X0, X1, X2 and X3 (analogue inputs A0A3) and four outputs Y0, Y1, Y2 and Y3 (pins 3, 5, 6, and 9).

Additional pins are allocated for larger Arduino boards (Mega, Mega 2560 or Due), giving 8 inputs and 8 outputs in total.

The main features of this hardware layout are explained below:

  • Inputs are capable of reading either digital or analogue values.
  • Outputs can produce either digital, PWM or servo values.
  • Arduino pins with duplicate functions have been avoided wherever possible, to minimise hardware conflicts.
  • Data directions of inputs and outputs are automatically configured and outputs are initially disabled (based on the assumption that 0='off' and 1 = 'on')
Most of the supplied example files make use of the standard I/O configuration.

If this default arrangement proves unsuitable, then a number of alternative custom hardware setups are available – or you may prefer to create your own. Please see the Defining Custom IO Allocations section for more details.

The next page introduces the use of a ladder diagram to describe the arrangement and operation of a simple system, and its conversion into ladder logic based program. Ladder logic concepts are further developed in subsequent sections of the plcLib User Guide.

Related Topics