Skip to content

Arduino IDE

Here you will find the necessary steps to program our Arduino based PLC using the Arduino IDE, from setting up your PC to completing the first program upload.

Requirements

  • Arduino or ESP32 based Industrial Shields PLC.
  • USB B or Micro USB cable (depending on the PLC).
  • Computer running GNU/Linux, windows or macOS.

IDE Installation

First, you need to install the Arduino IDE on your PC. There are 2 different versions:

  • Arduino IDE 2.X.X
  • Legacy IDE (1.8.X)

Both can be used with the same functionality, but we recommend the latest Arduino IDE 2 version. It can be downloaded at Arduino IDE Download Software. Follow the installation instructions and complete the installation according to your operative system.

Warning

Make sure that the installed IDE version is at least 1.8.13 or above.

Boards Package Installation

After the IDE is properly installed in the OS, install the Industrial Shields boards package, which provides the support for our PLCs needs to be installed.

To do so, follow the steps:

  1. Open the IDE, and on the top left corner, select: Files > Preferences, or press: Ctrl+, .
  2. Scroll down until you see the Additional boards manager URLs field. Insert the following link in it:
    http://apps.industrialshields.com/main/arduino/boards/package_industrialshields_index.json
    
    Capture: Arduino IDE settings
  3. Close the menu pressing the OK button.
  4. On the top left corner, select: Tools > Board > Boards manager.
  5. Use the search bar to look for the Industrial Shields package and install it. There are several Industrial Shields packages, choose the correct package according to your device:

    Device family Package name
    Ardbox, M-Duino industrialshields-avr
    ESP32, ESP32 14 industrialshields-esp32
    WIS (ESP32) industrialshields-wis-esp32
    WIS (MKR): industrialshields-wis-samd
  6. Finally, close the boards manager by clicking the icon on the left bar. With this simple steps the boards package is already installed, and the environment ready to program the PLC.

PLC Programming

Preparing the PLC and the IDE

Let's see how to program the PLC for the first time. Before doing, so, the IDE needs to be configured with the board model being used. In this example we will use an M-Duino 21+ as reference, as the procedure is the same for all the models. Follow the steps:

  1. Power on the PLC.

    Warning

    Make sure that the PLC is properly powered by a 12-24 Vdc power supply. The devices are not properly powered by the USB cable.

  2. Connect the PLC to the PC using a USB cable.

    Info

    Depending on the model, a USB Type-B or USB Micro-B is used. Check the Hardware Setup section for more details.

  3. In the IDE, on the top left corner, select the device family: Tools > Board > Industrial Shields AVR Boards > M-Duino Family.

  4. Choose the PLC variant: Tools > Board > Model > M-Duino 21+.
  5. Select the appropriate serial port corresponding to the PLC in Tools > Port.

    Info

    The port nomenclature depends on the operating system. Typical ports are:

    • GNU/Linux: /dev/ttyACM0, /dev/ttyUSB0
    • Windows: COM11, COM23
    • macOS: /dev/cu.usbmodem14101, /dev/cu.usbserial-1420

Uploading the Program

At this point the program can be uploaded to the PLC. Write a program or open an example (in the IDE, go to: File > Examples), then use the two buttons on the top left corner:

  • Verify
  button Verify: compile the sketch and check for errors.

  • upload
  button Upload: compile and upload the program.

After uploading, the PLC will start running the program.

Example

Let's upload the RTC example (Files > Examples > RTC > RTC). This example, included with the libraries, reads the time from the RTC chip and prints it through the serial port.

Capture: Arduino IDE sketch

Once uploaded, the serial monitor can be used to see what the PLC is outputting through the serial port. To open it, press the Serial Monitor button located on the top right corner of the IDE. A new tab will open in place of the console containing the monitor, with a few options that can be configured. In this case, change the baud rate according to the one being used by the PLC, 9600 (the baud rate for the PLC is set in the program).

The output of this example program is the time measured by the RTC:

Capture: Arduino IDE serial monitor