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:
https://www.vbtutor.net/vbtutor.html
https://www.vbtutor.net/vbtutor.html
Learning Visual Basic 6 Programming: Lesson 1
YouTube is also an excellent 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 the 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. The program will then reset the indirect address pointers. It will then read the information collected and store it in an Access Database.

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 to the Modbus TCP protocol with a good introduction and explanation. A video is also included on the page.
https://www.youtube.com/watch?v=E1nsgukeKKA

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

Daily Production Log Pointer

MHR1 is the pointer 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 12 am Meters MSW (Most significant word)
MHR14 – Weekend 12 am Meters LSW (Least significant word)
MHR15 – Weekend 12pm Meters MSW
MHR16 – Weekend 12pm Meters LSW
MHR17 – Weekday 12-8 am Meters MSW
MHR18 – Weekday 12-8 am Meters LSW
MHR19 – Weekday 8-4 pm Meters MSW
MHR20 – Weekday 8-4 pm Meters LSW
MHR21 – Weekday 4-12 pm Meters MSW
MHR22 – Weekday 4-12 pm 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 get in touch with me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLCs are not challenging to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimals, Hexadecimal, ASCII, and Floating Points.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.


Leave a Comment