PLC Acquiring data

Mondey, August 20, 2012 8:00 AM

Introduction

In industry, storing the number of items produced in the production line factory and consult it at any time is important.
This windows application allows communication to PLCs, storing data in DATABASE and consulting it in form of curve.



To count the number of item produced in each production line i use Programmable logic controller PLC which is responsible for the counting using differents kind of sensors.
These PLCs should be programmed to be able to count each items leaving the production line.

ModBus

The application can communicate with one or many PLCs through the MODBUS protocols.

MODBUS Protocol is a messaging structure created by MODICON company to connect PLC to programming tools. It is now widely used to establish master-slave communication between intelligent devices.
MODBUS is independent of the physical layer.  It can be implemented using RS232, RS422, or RS485 or over a variety  of media (e.g. fiber, radio, cellular, etc...).
The PLCs uses the RS485 or the TCP/IP with MODBUS protocol if available. This application use the RS485 for the communication. The RS485 can span relatively up to 4,000 feet (1,200 m) and can manage 255 slaves. The master device is the computer and the slaves are the PLCs.
This is how looks like The frame structure of the MODBUS:

The frame structure is the same for requests (master to slave messages)  and responses (slave to master messages).
When a message is sent from a master to a slave device the function code field tells the slave what kind of action to perform. Examples are to read the ON/OFF states of a group of discrete coils or inputs; to read the data contents of a group of
registers..
When the slave responds to the master, it uses the function code field to indicate either a normal (error–free) response or that some kind of error occurred (called an exception response). For a normal response, the slave simply echoes the original function code

Main program

Here's a simplified Flow Chart of the main program:

The application must read, each hour, the data from PLCs which represents the number of items produced during one hour. Then save these data to the DATABASE.

DataBase

I use Microsoft Access as DATABASE for storing the datas. for that i creat 3 tables :
- Reynolds_h : Store the number of items produced every hour.
- Reynolds_d : Store the number of items produced per day.
- Reynolds_m : Store the number of items produced per month.

Reynolds_h :


Reynolds_h store the data readed from the PLCs via the application. The other table determine their value from the Reynolds_h. they are updated every hour.

Reynolds_d:

Reynolds_m:



Curves

The data which are stored in the DATABASE can be consulted in forme of curve. This application offers several options for curves display.
The user can choose to display the curve:
- by day : display the production number during 24 hours for different machine. (X axis : 24 hours).
- by week : display the production number during a week. (X axis : 7 days).
- by month : display the production number during a month. (X axis : 30/31 days).
- by year : display the production number during a years. (X axis : 12 months).
- Customize : choose the number of day to display as user wish.



The user have to select the machine from the ComboBox and the date from the calendar then click to '+' icon to add it to the Curve table. One click on the curve icon next to calander and the curve will display.
The application can display 10 curve in the same time and the user can choose between line or column displaying curves.
Here's the line curve of the coloring (painting) and packaing machine for the week 01/09/2013:


Here's another curve with column display :

The curves are realized with vector drawing tools, so enlarge or shrink the curve window the image will conserve the same quality and no risk of a pixelated image. It would be perfect for printing in large format.
The curves can be saved into image file and then printed.

Here's another example of comparing the production of the packaging machine during september and october. the average option is checked from the main window.

As shown above the curve display the total number produced during a month and the average value per day. the discontinued line represents the average value.

Options

The application offers many options.

it's possible to choose the text size, font and the opacity of column.

Creat setup

Using Inno setup software, i creat a setup for application.

Installation script :



Here's the installation floder :



Video