Skip to main content

Adding IoT capability to existing systems part 2

View Part 1 here

In part 2 of our focus on adding IoT capability to exisiting systems we show how device data can be placed on local corporate networks, this highlights perfectly Brainboxes solutions for Industry 4.0 Monitoring and Control :

Brainboxes technology integrating: the Power of a PC, the precision of a PLC and the price of a Raspberry Pi.  

 

Overview

This demonstration shows how by connecting Brainboxes remote IO modules to everyday inputs and outputs found on factory production lines, in building security systems or control rooms, allowing the data generated by these devices to be shared across the corporate network. The data is no longer only trapped at the local machine; now it can be viewed from anywhere within the network and integrated with other business data sources and processes.

The demo also shows how easy it is to retrofit existing equipment controlled by PLCs with state of the art monitoring technology. The idea is not to replace the PLC, as often they have been running equipment flawlessly for many years, but instead to work alongside the PLC. Often PLC programs are only available to the authorised engineer who installed the device many years ago, making further access to the system very difficult.

Finally, the demo shows how brainboxes software APIs can reside on low cost hardware such as a Raspberry Pi. The software can then collect and distribute data from the factory floor to the corporate network. This takes advantage of Brainboxes Industrial hardware which is designed to cope in the toughest industrial environments, where the temperature may range from -40°C to +80°C (-40°F to +176°F) , electrical power available may range from 5VDC to 30VDC and Machine Inputs or Outputs may be switching up to 30V and 1 Amp. Raspberry Pi’s make for fantastic controllers, however they are not designed to withstand these extremes; Brainboxes hardware collects the data on the factory floor and sends it back to the Raspberry Pi for processing. The Pi can be conveniently located in the controlled environment of a server room.

How it was done

System overview

title

Industrial meets Internet Communication Protocols

The Brainboxes Industrial IO modules can communicate using the Industrial standard communication protocol Modbus TCP. This makes them ideal to communicate with PLCs and other industrial equipment. The Brainboxes modules also have an RS-422/485 port or an RS-232 port for interfacing to other industrial equipment with make use a number of standard protocols such as Module RTU or application specific bespoke protocols.

Disadvantages of Industrial protocols such as Modbus TCP
Despite the ubiquity there are a number of limitations to industrial protocols:

  • Security: Modbus TCP is an inherently insecure protocol, anyone on the network can listen to data sent and received over the network as Modbus TCP
  • Authentication: Modbus TCP has no concept of authentication, anyone on the network can communicate with a Modbus TCP device
  • Command Response Protocol: Modbus TCP communication occurs using the command response model where a client makes a request of the server and the server sends an answer. This means that the client has to constantly poll the server to get the latest information. This process is highly inefficient and the clients’ data is old the second it arrives.
  • Max number of connections: Modbus TCP devices have a maximum number of simultaneous connections which makes them inadequate for system where many clients wish to view the data

That’s where modern internet communication protocols come in such as the combination of TLS (Transport Layer Security), JSON (JavaScript Simple Object Notation) and WebSockets come in. Industrial devices on the factory floor do not speak this protocol, so brainboxes have developed a suite of APIs which bridge this gap.

Advantages of Modern Web Protocols such as JSON over Secure Websockets
Modern web protocols have the following advantages:

  • Security: TLS 1.2 is the current most secure encryption protocol (as of July 2016) used for communication on the open internet. It is used to secure everything from bank transactions to Facebook logins
  • Authentication: there are many standards for authentication which allow a client to uniquely identification themselves with a server, so that both the client and server can be sure they are talking with an authorised peer.
  • Bi-directional real-time communication: using WebSockets once a connection has been established between client and server it remains open, allowing either client or server to instantly send data or commands to the other.
  • Max number of connections: WebSockets is a lightweight protocol allowing a controller such as a Raspberry Pi to maintain many hundreds of connections simultaneously.

The Demo

The demonstration shows how to bridge the gap between industrial protocols and modern web protocols, allowing you to simple retrofit existing machines with remote monitoring/control or create new machine panels using the latest technology while maintaining interoperability with existing industrial infrastructure.

title

Skills Required
To reproduce this demo the following basic understanding is required

  • Software programming
  • Electrical wiring to sensors
  • Network installation

Hardware required:

Part Description Man part no RS part no
Brainboxes Industrial 8 port Ethernet switch SW-508 (111-3758)
Brainboxes Industrial Remote IO: Ethernet to 16 Digital Outputs + RS485 Gateway ED-527 (789-8122)
Brainboxes Remote IO: Ethernet to 4 Digital IO and RS232 Serial Port with Ethernet Switch ED-204 (789-8141)
Raspberry Pi 3 Raspberry Pi 3 Model B (182-2098)
Pi DIN Rail Case 2202874 (122-4299)
0.5m Cat 5 Ethernet Cable CR503B05CJN (294-8190)
MicroSD Card 16GB NOOBS 16GB (136-0148)
Power supply for Pi T5989DV (909-8135)
FAN   (042-6326)
12 V power supply   (721-0920)
Green push button   (609-2847)
Red push button   (656-7234)
Buzzer   (771-6894)
Proximity Sensor BES M08MI-NSC40B-S49G (413-9714)
7 Segment Display   (719-2513)
Cable single core 4510021 (724-4311)
RS Pro Cable Ferrule E7508-BLUE-L (045-8695)

title

Setting Up the Demo

Brainboxes ED-527 (789-8122) :

1. Connect power (input is from 5-30VDC), connect network to Brainboxes Switch

2. Connect to the ED-527 (789-8122) on its default ip address (192.168.127.254), click on the network tab and configure the device to have a static IP of 192.168.0.178

3. Wire the LCD, Fan and buzzer to the outputs of the (789-8122) as in system overview diagram above

title

Brainboxes ED-204  (789-8141) :

1. Connect power (input is from 5-30VDC), connect network to Brainboxes Switch

2. Connect to the ED-204 (789-8141) on its default ip address (192.168.127.254), click on the network tab and configure the device to have a static IP of 192.168.0.177

3. Wire the proximity sensor, buttons and switch to the inputs of the ED-204 as in system overview diagram above

Raspberry Pi:

1. Get a Pi (182-2098) :

2. Put into Phoenix Din Rail case (122-4299) :

3. Preload 8GB xd card with windows 10 IoT core, by following instructions: https://developer.microsoft.com/en-us/windows/iot

4. Install the xd card

5. Use Windows IoT Dashboard to scan the network and locate your raspberry Pi

title

6. Log into the Pi’s Portal page page and typing in the default username (Administrator) and password (p@ssw0rd )

title

7. Install Brainboxes-Remote-IO-Demo App on the device by clicking on “Apps” then “Install App” on the app is installed set it as the “Default App”. Whenever the Pi boots up the Brainboxes demo app will now automatically start

title

8. Connect the pi to the same demo network as the brainboxes ED-527 (789-8122)  and ED-204 (789-8141) and Reboot the Pi. On boot up it will connect to the the brainboxes devices and begin the demo.

Connect to the demo application

title

There are 2 ways to view the demo application:

1. Through the raspberry Pi HDMI connection.
2. Over the network by connecting to the raspberry pi’s IP address in a web browser of your choosing.

Simply confirm that the display is reflecting the current state of the IO connected to the brainboxes devices. Click on the fan in the browser, the fan connected to the ED-527 (789-8122) should come on. Click on the number in the browser the number of the LCD display and browser should increment. Likewise inputs pressed on the buttons and sensors connected to the ED-204 (789-8141) should cause the outputs of the ED-527 (789-8122) and browser display to update. Note the Brainboxes demo application on the Pi should function regardless of whether the Schneider PLC and HMI are in the system

title

 Output displays overview

title

Brainboxes software

Software Technologies Used
Brainboxes demo relies on a number of free and open source technologies including:

  • Microsoft C#: running on Universal Windows Platform (UWP): used on the server side to run the application
  • Brainboxes.IO : Brainboxes suite of APIs to simply monitor and control Brainboxes Ethernet IO and Ethernet to Serial devices in C#
  • Angular.JS : Google’s open source JavaScript framework used to control the webpage and WebSocket connection to the server
  • Bootstrap: Twitter’s open source CSS framework used to style the webpage
  •  Microsoft Visual Studio: Microsoft’s software development platform to create applications for many different platforms
  • HTML5: set of web software technologies available in modern web browsers such as WebSockets, Javascript 5.0 and css3

Editing the Brainboxes Software

Download the Brainboxes sample app from Microsoft Code Samples website: https;//code.msdn.microsoft.com/Brainboxes-Remote-for-7c60fbdb 

To edit the brainboxes software you need to download the latest version of Microsoft Visual Studio Community Edition (free) or Visual Studio Enterprise (requires license) which can be downloaded from here: https://www.visualstudio.com/downloads/download-visual-studio-vs

Once Visual Studio is installed open the Brainboxes IO Universal Windows Platform (BB.IO.UWP) demo app source code available from www.brainboxes.com

Running the Application in Visual Studio

To run the application, select Debug, x86, Brainboxes.IO.UWP.Demo, Local Machine. And click on the green play icon.

title

The demo app should start up in its on Window.

title

Note without the brainboxes devices on the network the application may show an error.

Editing the code

From within Visual Studio open App.xaml.cs.
The enter point into the software is in the file App.xaml.cs in the function App()

title

The demo relies upon Brainboxes.IO apis which are automatically downloaded from Nuget (Microsoft’s software package repository).

Other files to look at to start editing the code include:

  • RemoteIO.cs : C# file which determines Brainboxes device functionality
  • Index.html: the webpage which is loaded onto the client devices
  • BBDemo.js: JavaScript file which handles websockets and web page functionality using Angular.JS

RemoteIO.cs
This file defines what happens when the Brainboxes Remote IO devices inputs and outputs change, for example to configure which functions are called when IO lines change view the _configureHandlers function:

title

Index.html
This file contains the structure of the webpage shown to the clients’ web browser. The file reference all the other resources downloaded to the page and contains Angular.Js markup

title

BBDemo.JS
This file contains the functionality which controls the structure of the webpage, for example initiating the WebSocket connection and updating the page when the websocket sends new JSON data

title 

As with all Brainboxes hardware, we are always happy to provide telephone and email support. Please get in touch if you have any questions. Happy coding!     

See more from

title

title

Stay tuned for our 3rd and final piece in this series, where we focus on internet integration.

VIEW PART 1

Favourite things are Family, Music and Judo. Also, I have the ability to retain and quote useless facts, something that pleases me but can annoy others. My engineering hero - Isambard Kingdom Brunel
DesignSpark Electrical Logolinkedin