Browsed by
Category: Software

Software available to use Arduino Based PLC

SimpleComm library to send data through any Arduino Stream

SimpleComm library to send data through any Arduino Stream

This is Industrial Shields library for different PLCs.

With the SimpleComm library you can send data through any Arduino Stream: RS-485, RS-232, Ethernet… It is enough flexible to support different kind of communication typologies: Ad-hoc, Master-Slave, Client-Server… Using an easy to use API.

Reference:

SimplePacket encapsulates the data into a packet and provides these functions:

setData(data)

Fill up the packet with the desired data to send or the received data from a remote device. It is possible to fill up the packet with different types of data: bool, char, unsigned char, int, unsigned int, long, unsigned long, double, const, const char, const void.

Read More Read More

How to create a web server to read a SD card in our PLC

How to create a web server to read a SD card in our PLC

This is an example it is explain how to read a SD card into the PLC through Ethernet connection. In this post we will see how create a server that when there is a request through a browser, you can see the directories and the files of the SD card in your browser.

The PLC has to be connected the Ethernet connection and the SD card correctly, check this post how to do it.

Once it is all connected correctly the next step is make the right configuration of the Ethernet port and create the server:

 

/*
   Copyright (c) 2017 Boot&Work Corp., S.L. All rights reserved

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <MDUINO.h>
#include <SPI.h>
#include <SD.h>
#include <Ethernet.h>


#define SD_SS_PIN 3


File root;

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
EthernetServer server(80);

/////////////////////////////////////////////////////////////////////////////////
void setup() {
	Serial.begin(115200L);

  // Init Ethernet and TCP server
  Serial.println("Starting Ethernet ...");
  Ethernet.begin(mac);
  server.begin();

  // Init SD card
  Serial.println("Starting SD card ...");
  if (!SD.begin(SD_SS_PIN)) {
    Serial.println("initialization failed!");
    return;
  }

  Serial.print("IP address: ");
  Serial.println(Ethernet.localIP());
}

///////////////////////////////////////////////////////////////////////////////
void loop() {
  EthernetClient client = server.available();
  if (client) {
    char lastC = 0;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if ((c == '\n') && (lastC == '\n')) {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/plain");
          client.println("Connection: close");
          client.println();
          client.println("SD card files:");

          root = SD.open("/");
          printDirectory(root, client);

          break;
        }
        if (c != '\r') {
          lastC = c;
        }
      }
    }
    delay(50);
    client.stop();
  }
}

////////////////////////////////////////////////////////////////////////////////
void printDirectory(File dir, Stream &stream) {
  while (true) {
    File entry = dir.openNextFile();
    if (!entry) {
      // no more files
      break;
    }

    stream.print(entry.name());
    if (entry.isDirectory()) {
      stream.println("/");
    } else {
      // files have sizes, directories do not
      stream.print(" [");
      stream.print(entry.size(), DEC);
      stream.println("]");
    }
    entry.close();
  }
}

See also:

How to connect a SD card to a PLC, How to connect the Ethernet port using W5100 library

 

How to connect a SD card to a PLC

How to connect a SD card to a PLC

 

In this example we will see how to connect a SD card to each of our PLCs.

Hardware required:

  • One of our PLCs
  • A SD card

How to connect the SD card to our PLC?

First we start with the connections; as follows you have a table and circuit diagram where you can see how to connect the SD card to the PLC.

 

 

 

PLC SD CARD
MOSI MOSI
SCK SCK
PIN3 CS
CD
MISO DO
GND

 

Next there is an example code to how to configured our PLC to read the SD card.        

Read More Read More

Installing Industrial Shields equipment to the Arduino IDE

Installing Industrial Shields equipment to the Arduino IDE

In order to be able to program our equipment even more easily, it is possible to install to Arduino IDE. Once installed will not be necessary to know witch Arduino board that includes each equipment, neither to consult the mapping between the pins of Arduino board and INs and OUTs of the PLCs, not even will be necessary to use our libraries: now all this information will be included in the Arduino IDE. When you select one of our PLCs, INs and OUTs will be already available with their names, moreover as libraries that will facilitate the use of different communication ports (RS-232, RS-485, …).

Read More Read More

How to Upload a Bootloader on an Arduino Board

How to Upload a Bootloader on an Arduino Board

To install a Bootloader on an Arduino Board it is necessary to have:

  • Original Arduino board (configurated as Bootloader burner).

Steps to configurate an Arduino Board as Bootloader burner:

  • Open The Arduino ISP Example on the Arduino IDE from: File >> Examples >> 11.ArduinoISP

arduino as ISP

  • Select the right board which will work as a Bootloader burner
  • Select the right port where the Arduino is connected.
  • Change the standard pin configuration. At “#define RESET 10” and “#define RESET  4” change both with the pin 2.  As illustrated here below.

 

  • UPLOAD!!!!

Once the Arduino board is configurated as Bootloader burner it is necessary to connect via SPI ports the Bootloader burner Arduino to the Original Arduino board where it is necessary to replace the bootloader…

Connect:

Bootloader burner (Arduino “A”) Arduino “B”
MISO MISO
MOSI MOSI
SCK SCK
PIN 2 RESET
GND GDN

 

After connect the Arduino “B” to the Bootloader burner (Arduino “A”) It is necessary to connect the USB cable between the Arduino “A” and the laptop.

Then you can continue doing:

  • Select the Arduino “B” board on the Arduino IDE (remember that you have connected The Arduino “A” to the Laptop) . ( Tools >> Board)
  • Select the right port (From the Arduino “A”). (Tools >> Port).
  • Select the Programmer type: Arduino as ISP  (Tools >> Programmer)

arduino as ISP_2

  • Click on BURN BOOTLOADER on the Tools menú.

burn bootloader

That’s all. Now you can upload a new file on the Arduino “A” 

And use the Arduino “B” as a new Board!!!!!

Using the original Arduino IDE

Using the original Arduino IDE

The Industrial Shields PLCs use original Arduino boards. Then the PLCs can be used as individually Arduino boards by The Arduino IDE. To use the original boards let the users to programm the PLCs by others programs which can program Arduino boards too. 

To start using this devices it is necessary:

  • Download the Arduino IDE from www.arduino.org

Arduino Ide let to use these devices as a individually Arduino boards. It is necessary to see the diferent technical details from each product user guide and see the pinout details about the pin configuration because each pin can be configurated as:

Read More Read More

Industrial Shields library in Arduino IDE.

Industrial Shields library in Arduino IDE.

There is two ways to include the Industrial Shields library in the Arduino IDE.

(1) Automatically: USING the Arduino IDE

Open The Arduino IDE.

Click on: Sketch – > Import library…  

Then Search Industrial Shields  on the Library Manager

gestordelibreria

and click on Install

To verify the installation you can go at: 

File -> Examples -> Industrial Shields

industrial_shields_library_link

 

(2) Manually:

How to use the Industrial Shields library in the Arduino IDE: (NOTE: This example also works for any other library you want to charge on the Arduino IDE).

1. Download the original IndustrialShields library from GitHub.

github_industrialshields 

Click on: “Clone or download”

Read More Read More

Software available to use Arduino based PLC

Software available to use Arduino based PLC

Software available to use Arduino based PLC:

All PLCs use an original Arduino board inside.

For this reason it is possible to use several softwares to develop your project. See below a list of some of availables software you can use on Arduino based PLCs:

Resultado de imagen de arduino ide

The original one. This is the most used platform to use Arduino boards.  It is not necessary to modify any libraries to use Industrial Shields PLCs with this software. Anyway there is available an open Industrial Shields library available in GitHub.

Read More Read More