Saturday, November 8, 2014

Now You Can Have Robust Data Logging for Free - Part 5

Now You Can Have Robust Data Logging for Free - Part 1
Now You Can Have Robust Data Logging for Free - Part 2
Now You Can Have Robust Data Logging for Free - Part 3
Now You Can Have Robust Data Logging for Free - Part 4
Now You Can Have Robust Data Logging for Free - Part 5

Computer Program

We will now start to write a program in visual basic. (VB) Visual Basic is a product by Microsoft. It was developed to allow programs to be easily written. It is the most widely used computer programming language. Visual Basic was developed after Basic. Basic was used before the world was introduced to Windows.
There are several versions of Visual Basic. Visual Basic was always backward compatible. This means that code written in it can be easily used in the new version. In 2005, VB.net was introduced which was not compatible with previous versions but opened up a whole new computer architect for programmers. We will use VB6 for our Robust Data Logging to the Do-More Controller.

The following links can be used for training on VB6:
http://www.vbtutor.net/vb6/vbtutor.html
http://www.vb6.us/guides/visual-basic-6-beginners-guide
Learning Visual Basic 6 Programming: Lesson 1
YouTube is also a great resource for learning how to program in VB.



Data Collection
Visual Basic 6 will be used to log the data into a database. The information will be collected using Modbus TCP communication to the Do-More PLC and/or Simulator of the Do-more Designer. This will use an Ethernet communication cable to the PLC. The program will read the indirect address pointers in the PLC. It will then read the information collected and store the information into an Access Database. The indirect address pointers will then be reset by the program.

The access database is 2007 and has an extension of '.accdb'. Here are two videos that show how we connect to a database, read, write, and delete records.
VB6 - How to connect ADO with MSAcess 2007 (*.accdb) Database - Tutorial 1
VB6 - How to connect ADO with MSAcess 2007 (*.accdb) Database - Tutorial 2

Here is a link on the Modbus TCP protocol with a good overall introduction and explanation. A video is also included on the page.
http://www.rtaautomation.com/wp-content/cache/supercache/www.rtaautomation.com/technologies/modbus-tcpip/

Here are the locations for the information in the programmable logic controller:

Daily Production Log Pointer
MHR1 is the porinter for the daily production log. It will point to the location to store the next series. (Next Day of Data)
MHR1 = 30 means that we are all data has been retrieved.
MHR1 = 650 means that we have 31 days of data to be retrieved.
A visual basic program will read MHR1. If it is greater than 30 then the data will be read and then written into a database. It will then write the value of 30 back into MHR1 to reset the pointer.
Current values are located here:
MHR10 - Year (XXXX)
MHR11 - Month (XX)
MHR12 - Day (XX)
MHR13 - Weekend 12am Meters MSW (Most significant word)
MHR14 - Weekend 12am Meters LSW (Least significant word)
MHR15 - Weekend 12pm Meters MSW
MHR16 - Weekend 12pm Meters LSW
MHR17 - Weekday 12-8am Meters MSW
MHR18 - Weekday 12-8am Meters LSW
MHR19 - Weekday 8-4pm Meters MSW
MHR20 - Weekday 8-4pm Meters LSW
MHR21 - Weekday 4-12pm Meters MSW
MHR22 - Weekday 4-12pm Meters LSW
MHR23 - Weekend 12am Utilization % (xxx.x)
MHR24 - Weekend 12pm Utilization % (xxx.x)
MHR25 - Weekday 12-8am Utilization % (xxx.x)
MHR26 - Weekday 8-4pm Utilization % (xxx.x)
MHR27 - Weekday 4-12pm Utilization % (xxx.x)

Run Minute_Logger
MHR2 - Pointer - Value 670 to 2000
MHR660 - MHR669 - Current logged values
MHR660 - Year - xxxx   MHR661 - Month - xx   MHR662- Day - xx
MHR663 - Hour - xx   MHR664 - Minute - xx   MHR665- Second - xx
MHR666 - MHR667 - Current Meters - xxxxxxxx
MHR668 - Current Rate - xxxxx mpm

In part 6 we will continue with the VB6 program of getting the information out of the PLC and putting it into a database.
If you have any questions or need further information, please contact me.
Regards,
Garry

No comments:

Post a Comment