Introduction: Profibus-DP Communication Between Arduino and PLC

About: PLC, Arduino - Do it yourself project

Today, I would like to share how an Arduino communicates with PLC via Profibus-DP connection. With this result, we can carry out some projects with the combination of PLC and Arduino plus its extension shields at low cost, for examples:

  • Control and data acquisition to / from PLC with BLYNK on smart phone via Arduino Mega + Ethernet Shield + RS485 module. Normally, in order to connect Industrial Ethernet, the Siemens PLC must have built-in communication module, such as 6ES7315-2EH14-0AB0 ..., or be equipped with a separated communication module, like CP343, CP443.... With video below, Arduino will take over the roles of Ethernet connection and exchange data with PLC through Profibus protocol.

  • Turn sensors such as PIR Motion Sensor, SRF05 Ultrasonic Distance Sensor, MPU6050 Accelerometer and Gyroscope Sensors.... into Profibus devices that can be connected to industrial automation system. Video below shows that PLC can read value of ultrasonic distance sensor to switch on/off 24V relays.

  • D.I.Y a HMI touchscreen to control /monitor PLC system through Touch Screen TFT LCD Module. As video below, 3.2 inches touchscreen LCD can communicate with PLC via Profibus and control 4 x 24V relays as well as display temperature value collected from PLC.

In terms of cost, with some testings above, we will save a lot of money because the price of industrial communication module or industrial touchscreen HMI are very expensive. In addition, we can extend Input and Output of PLC through Profibus - DP interface. It means that Arduino can works similar to Siemens DP/DP Coupler Module to connect two Profibus - DP networks together. And this DP/DP Coupler’s price is also very expensive. We can refer to their prices as follows:

I hope this project will inspire you, especially the students who don't have much money, to come up with ideas for combining electronic and automation fields together, with low price.

Step 1: B.O.M

Step 2: PREPARATION BEFORE STARTING THIS PROJECT

I. SOFTWARES:

II. REFERENCE MANUALS:

  • Arduino's UART, Timer.
  • Profibus manuals:

§. https://www.felser.ch/profibus-manual/index.html

§. https://www.profibus.com/

  • Learn about * .GSD file to configure Arduino into Siemens PLC hardware system.

Step 3: PROFIBUS–DP

I. PROFIBUS-DP:

Profibus was created in 1989 by the German government in cooperation with several manufacturers of automation equipment. It is a messaging format specifically designed for high-speed serial I/O in factory and building automation applications. It is an open standard and is recognized as the fastest Fieldbus in operation today.

The PROFIBUS DP network is based on an RS485 physical layer and the European standard EN-50170. The DP suffix refers to “Decentralized Periphery”, which is used to describe distributed I/O devices connected via a fast serial data link with a central controller.

For more details about Profibus, you need to read the this documentation from Max Felser.

II. GSD FILE:

The GSD file is an electronic device datasheet or device database file that identifies the Profibus device. All Profibus devices (class 1 masters and slaves) have their own GSD files. GSD stands for "General Station Description". It is an ASCII text file that contains device-specific data, such as, vendor identification information, supported baud rates, supported message length, number of input/output data, meaning of diagnostic messages, timing information, plus options and features supported, data formats, and available I/O signals.

In order to commercialize Profibus devices, the manufacturers of automation devices have to registry the Ident Numbers for each device and it is also contained in this *.GSD file. You can check at: https://www.profibus.com/products/ident-numbers/

And refer to the *.GSD file of Siemens DP / DP coupler module at this address.

Step 4: SCHEMATICS

Arduino Mega 2560 can communicate with PLC S7-300 by RS-485 (MAX485) module through Profibus protocol as schematic below:

Here below are some schematics that I have tried for this project:

1. Schematic 1 - PLC read Ultrasonic Distance Sensor via Arduino Mega 2560 + RS485 Module.

    2. Schematic 2 - Smartphone Blynk PLC via Arduino Mega 2560 + Ethernet Shield + RS485 Module.

    Step 5: CIRCUIT ASSEMBLY

      This assembly work is for schematic 2 in previous step - Smartphone Blynk PLC via Arduino Mega 2560 + Ethernet Shield + RS485 Module.

      • Soldering adapter shield for Arduino Mega 2560 includes Ethernet Shield and RS-485 Module.

      • Installation Ethernet Shield and RS-485 Module on Adapter Shield. Plugging this Adapter Shield on top of Arduino Mega 2560.

      • Wiring PLC's outputs to 4x24V relays.

      • Connecting Profibus cable from PLC to Arduino. Take note about the GND of two systems, they must be connected together.

      Step 6: HARDWARE CONFIGURATION

      • In Simatic Step 7 program (HW CONFIG), we have to install *.GSD file and update your Hardware Catalog using the menu command "Options --> Update catalog".

      • Hardware configuration

      §. With Arduino Mega 2560 - 16MHz, Profibus works well at baudrate 45.45 Kbps.

      §. Define the number of bytes transmitted and received over the Profibus connection.

      Step 7: PROGRAMING

      I. PLC PROGRAM.

      II. ARDUINO PROGRAM.

      III. BLYNK HMI SCREEN.

      Blynk code is as follows:

      void myTimerEvent()
      
      {
        Blynk.virtualWrite(V8, temperature);
      }
      
      BLYNK_WRITE(0)
      {
        if (param.asInt())
          {       
            Control_State[0]=1;
          } 
        else 
          {
           Control_State[0]=0;
          }
      }
      
      BLYNK_WRITE(1)
      {
        if (param.asInt())
          {       
            Control_State[1]=1;
          } 
        else 
          {
           Control_State[1]=0;
          }
      }
      
      BLYNK_WRITE(2)
      {
        if (param.asInt())
          {       
            Control_State[2]=1;
          } 
        else 
          {
            Control_State[2]=0;
          }
      }
      
      BLYNK_WRITE(3)
      {
        if (param.asInt())
          {       
            Control_State[3]=1;
          }
        else 
          {
            Control_State[3]=0;
          }
      }
      
      BLYNK_WRITE(4)
      {
        if (param.asInt())
          {       
            Control_State[4]=1;
          } 
        else 
          {
            Control_State[4]=0;
          }
      }
      
      BLYNK_WRITE(5)
      {
        if (param.asInt())
          {       
            Control_State[5]=1;
          }
        else 
          {
            Control_State[5]=0;
          }
      }
      
      BLYNK_WRITE(6)
      {
        if (param.asInt())
          {       
            Control_State[6]=1;
          } 
        else 
          {
            Control_State[6]=0;
          }
      }
      
      BLYNK_WRITE(7)
      {
        if (param.asInt())
          {       
            Control_State[7]=1;
          }
        else 
          {
            Control_State[7]=0;
          }
      }

      NOTES:Description below shows how the project works:

      • PUSH BUTTONS COMMANDS ON BLYNK:

      §. I create on the Blynk app a panel with 8 push buttons V0 ~ V7.

      §. When push buttons are touched, the button statuses (ON / OFF) will be written to the Arduino Mega 2560 via Ethernet Shield and be stored in transmitted buffer.

      §. Arduino Mega 2560 will transmit these button statuses to PLC S7-300 via Profibus communication (RS-485 module). At PLC side, as hardware configuration in previous step, button statuses will be received at PLC's input I0.0 ~ I0.7.

      §. PLC's output Q124.0 ~ Q124.7 will switch ON or switch OFF 24V relays according to the status of I0.0 ~ I0.7.

      • COLLECT AND DISPLAY TEMPERATURE DATA RECEIVED FROM PLC USING BLYNK

      Since I do not have temperature sensors like Thermocouples, PT-100..., I have simulated the temperature data acquisition from the PLC by sending back status values of push buttons received from Blynk. Temperature value is sent at PLC's output PQB0 (Q0.0 ~ Q0.7) via Profibus protocol.

      Step 8: PICTURES

      The images above are results of 3 experiments that I have done for this project, including:

      • PLC read Ultrasonic Distance Sensor SRF05 via Arduino Mega 2560 + RS485 Module.
      • D.I.Y a HMI touchscreen to control /monitor PLC system via Arduino Mega 2560 + 3.2" Touch Screen TFT LCD + RS485 module.
      • Control and data acquisition to / from PLC with BLYNK on smart phone via Arduino Mega + Ethernet Shield + RS485 module.

      Step 9: FINISH

      As information from PROFIBUS & PROFINET International (PI) - a large automation community, it has about 1,700 manufacturer members and over 60 million PROFIBUS nodes installed worldwide.

      This is just an initial primitive experiment, but it’s great if we can implement a PROFIBUS network in an Industrial Internet of Things (IIoT) field by an Arduino. And once the Arduino can communicate with the PLC/ industrial automation system via Profibus - DP, we can do lots of cool things.

      THANK FOR YOUR WATCHING !!!