Now You Can Have Robust Data Logging for Free – Part 6

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
Now You Can Have Robust Data Logging for Free – Part 6

Computer Program Visual Basic (VB6)

We have looked at VB and discussed what we need to do to get the information out of the Do-More PLC and into an Access 2007 (*.accdb) database.


We will start by setting up the database. It will have the following two tables, Production_Log and Minute_Log. Please refer to the data we are storing in the PLC in Part 5.
Using Access, create the two tables (Production_Log / Minute_Log). Name each record in the logs according to the data we will retrieve from the PLC.
See the tables below.
The database will be named AccRL.accdb. This is an access 2007/2010 database.
We will store the database in the following directory:
C:AccRLDataAccRL.accdb
The visual basic program file will be in the C:AccRL directory.

Now let’s start the basic visual programming:
Please start and save a new project as AccRL in the above directory.

Add the Microsoft Winsock Control 6.0 component to the project. This will be needed to communicate through Ethernet to our PLC on the network.

Add the Microsoft ADO Data Control 6.0 (OLEDB) component to the project. This is required to communicate to the AccRL.accdb file created above.

This is what our program form looks like now.

We can now draw labels on our form for all the data we wish to display. Fonts, sizes, etc., can change based on how you want them to appear.
Note: Everything shown on the form is labeled for the data. This program will display the information that is being retrieved from the PLC.

Along the bottom of the form, you will notice that the Winsock control, two Adodc controls, and a timer have been added.
The Winsock control will be set up during the running of the program. The form will add a variable to tell the IP address of the PLC. We will deal with it after the database information has been set up.
Each of the Adodc controls represents the two tables set up earlier. Adodc1 is for the Production_Log table, and Adodc2 is for the Minute_Log.
Let’s now set up Adodc1.
Right-click the control and select properties.

Select the ‘Use Connection String’ and click on Build.
Select ‘Microsoft Office 12.0 Access Database Engine OLE DB Provider’ and click Next.

We will now enter where the data source is located. C:AccRLDataAccRL.accdb
Click ‘Test Connection

If the connection is good, you will receive the following message. If not, please check the location of the data source and provider information mentioned earlier.

The last step is to set the table in the database.

Go back to the Property Page and select the RecordSource tab. The command type will be set for ‘2 – adCmdTable’, and the Table or Stored Procedure Name will be ‘Production_Log.’ You will notice that you can only choose between the Production_Log and Minute_Log because they are the only two tables in the database file.
Now repeat the same steps and set up the Adodc2 for the Minute_Log table of the database.

In part 7, we will continue with writing the VB6 program.
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