Tag Archives: plc example

PLC Programming Example – Pick and Place

We will apply the five steps to PLC program development to a pick and place robot example. The example will use a BRX PLC communicating to Factory IO (3D Software Simulator). Developing the PLC program is a process that can be clearly defined. In our series on the five steps to PLC program development we have done some similar practical examples.
Five Steps to PLC Program Development – Press
PLC Programming Examples:
Process Mixer
Shift Register (Conveyor Reject)
Paint Spraying
Delay Starting of 7 Motors

Define the task: (1)
Watch the sequence of operation video below.
Watch on YouTube : PLC Programming Example – Pick and Place Testing
Continue Reading!

PLC Programming Example – Delay Starting of 7 Motors

We will look at a PLC programming example of delaying the start of 7 motors. Each motor will be on a switch that the operator can select at any time. The motor outputs should have a 5 second delay between the outputs coming on.

This question originally came from PLCTalk.net. An original solution to the problem came from Peter Steinhoff. His solution is what we will be presenting. It is simple and straight forward.

We will be using the Do-more Designer software which comes with a simulator. This fully functional program is offered free of charge at automation directKeep on Reading!

Building a PLC Program That You Can Be Proud Of – Part 6

We will continue the series by looking at a sequencer controlling seven cylinders that can be taught. The cylinders can be operator programmed from the AdvancedHMI screen. You will be able to select what cylinders to activate at each step and program in 500 steps. Our PLC will be the Do-More from Automation Direct.
Cylinder Teach HMI 110-min

Here is a quick review of the programming series so far. If you are new to the site, we recommend reviewing the other parts in the series first.
In part 1 we looked at writing PLC programs to control a traffic light using discrete bits and then using timed sequencing using indirect addressing.
Part 2 used indirect addressing for inputs as well as output to control the sequence of pneumatic (air) cylinders in the program. Part 3 and 4 we returned to the traffic light application and expand our program significantly. We looked at the sequence of operation using Input, output and mask tables.
In part 5 we used the AdvancedHMI software to create the game of Simon. A round in the game consists of the device lighting up one or more buttons in a random order, after which the player must reproduce that order by pressing the buttons. As the game progresses, the number of buttons to be pressed increases.

We will be using AdvancedHMI to communicate Modbus TCP to the Automation Direct Do-More Designer Software Simulator. The following is the sequence of operation:
Watch on YouTube : Running the Cylinder Sequence (PLC / HMI)
Note: All of the  programs used are provided free of charge and are an excellent way to learn PLC / HMI programming.

The following table is the Modbus TCP memory map to the Do-More PLC:

Coil/Register Numbers Data Addresses Type Do-More PLC Table Name
00001-09999 0000 to 270E Read-Write MC1 to MC1023 Discrete Output Coils
10001-19999 0000 to 270E Read-Only MI1 to MI1023 Discrete Input Contacts
30001-39999 0000 to 270E Read-Only MIR1 to MIR2047 Analog Input Registers
40001-49999 0000 to 270E Read-Write MHR1 to MHR2047 Analog Output Holding Registers

Cylinder Teach HMI 100-min
Here are the inputs and outputs we will be using for our program:

Device Data Addresses Type Do-More PLC Description
Start Pushbutton 00011 Input MC11
Stop Pushbutton 00012 Input MC12
Jog Pushbutton 00013 Input MC13
Reset Pushbutton 00014 Input MC14
Run/ Jog Selector 00008 / 00015 Input/ Output MC8 / MC15  MC8 is the value and MC15 is the click
Light Stack 00010 / 00009 / 00008 Output MC10 / MC9 / MC8  Red / Green / Amber
Set Pushbutton 00071 Input MC71
Jog / Teach Selector 00070 Input MC70  MC70 on is teach mode
Sequence Step (Panel Meter) 40001 Output MHR1  Current step in the sequence
Inputs Actual 40002 Input MHR2  Show the actual inputs in binary format
Output Sequence 40003 Output MHR3  Show the actual outputs in a binary format
Input Sequence 40004 Input MHR4  Show the input sequence bits in a binary format
Cylinder 1 to 7 – value 00001 to 00007 Output MC1 to MC7  Determine if cylinder is on/off
Cylinder 1 to 7 – set (click) 00041 to 00047 Input MC41 to MC47  Set the cylinder button
Cylinder 1 to 7 – retract indicators 00021 to 00027 Input MC21 to MC27 Indicate cylinder has retracted
Cylinder 1 to 7 – extend indicators 00031 to 00037 Input MC31 to MC37 Indicate cylinder has extended
Cylinder 1 to 7 – extend / retract error indicators 00050 to 00063 Output MC50 to MC63 Indicate cylinder input error when jogging

The first thing we will do is design the HMI. We have three main areas on the screen. Basic Controls, Cylinder Visualization and the Sequence Step/Teach area. Please refer to the above reference chart for the inputs and outputs programmed on the screen.
Cylinder Teach HMI 130-min

Basic Controls:
This area will allow us to see what mode we are in via the stack light. Red – Stop
Yellow – Jog / Teach Mode – Troubleshooting
Green – Run
Cylinder Teach HMI 101-min

Cylinder Visualization:
Each cylinder will have indication lights to determine status of the cylinder. (Extended / Retracted)
The cylinder will also have red indication lights to reflect the differences between the current sequence and the next sequence step. This is visible when we are in jog mode.
Cylinder Teach HMI 102-min

Sequence Step/Teach:
When in jog or teach mode the sequence step is visible, which indicates the current step that we are on. The inputs and outputs are displayed as a binary value which represents the actual inputs and outputs. This is valuable when troubleshooting and finding errors in the system. The set button is visible when in teach mode. When pushed the outputs and inputs are set for that step and the sequence will then increment.
Cylinder Teach HMI 103-min

The following is the code for each of the words that the DataScribers are reading. This includes the code to change the word into a 16 bit binary value.

Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
'Label1.Text = Hex(DataSubscriber1.Value)Dim i As Integer = DataSubscriber1.Value
Label1.Text = Convert.ToString(i, 2).PadLeft(16, "0") '16 bits
End Sub
Private Sub DataSubscriber2_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber2.DataChanged
'Label2.Text = Hex(DataSubscriber2.Value)
Dim i As Integer = DataSubscriber2.Value
Label2.Text = Convert.ToString(i, 2).PadLeft(16, "0") '16 bits
End Sub
Private Sub DataSubscriber3_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber3.DataChanged
Dim i As Integer = DataSubscriber3.Value
Label3.Text = Convert.ToString(i, 2).PadLeft(16, "0") '16 bits
End Sub
Private Sub DataSubscriber4_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber4.DataChanged
If DataSubscriber4.Value = True Then
     Label1.Visible = True
     Label2.Visible = True
     Label3.Visible = True
     Label4.Visible = True
     Label5.Visible = True
Else
     Label1.Visible = False
     Label2.Visible = False
     Label3.Visible = False
     Label4.Visible = False
     Label5.Visible = False
End If
End Sub

We will now look at the PLC ladder program. The program is broken down into several parts as follows:

ACC Automation
This is the main start / stop circuit of the program.
If we are in run mode the green light will be on. (MC9)
If we are not in jog mode (MC8) this circuit will be functional.
Cylinder Teach PLC 100-min

If we are not run mode (MC9) or in jog mode (MC8) then the stop mode is active.
This will turn on the red light. (MC10)
Cylinder Teach PLC 110-min

Run / Jog – Toggle Circuit
Flip Flop circuit to set the jog function
Cylinder Teach PLC 120-min

Move the outputs to the physical outputs when we go to run mode.
Cylinder Teach PLC 130-min

Indirect Addresses for the Program
V0 – Input pointer – 100 – 499
V1 – Output pointer – 500 – 999
V2 – Input pointer last step in sequence
V3 – Output pointer last step in sequence
V10 – Inputs to the sequencer
V20 – Outputs from the sequencer
Cylinder Teach PLC 140-min

Jog Mode – Jog Pushbutton
Cylinder Teach PLC 150-min

Reset the sequencer pointers. This will happen automatically in run mode or by hitting the reset button in jog or stop mode.
Cylinder Teach PLC 160-min

Teach Function
This first rung will activate the values so we can manually turn them off/on with the HMI screen.
Cylinder Teach PLC 170-min

This will reset the pointers when going into teach mode.
Cylinder Teach PLC 180-min

This will set the teach point and increment to the next step.
Cylinder Teach PLC 190-min

Show the current step of the sequence.
Note: 0 is the first step
Cylinder Teach PLC 200-min

Set the inputs for cylinders.
The actural physical input points would be inserted here.
HMI inputs from the cylinders have a 500ms delay to simulate the movement of the actual cylinder.
Cylinder Teach PLC 210-min Cylinder Teach PLC 220-min

Set the actual inputs / sequencer inputs / sequencer outputs so we can monitor this on the HMI.
Cylinder Teach PLC 230-min

Set the outputs for cylinders.
This will set the physical output points Y1 to Y7.
This will also set the HMI cylinders MC1 to MC7 (00001 to 00007)
Cylinder Teach PLC 240-min Cylinder Teach PLC 250-min Cylinder Teach PLC 260-min

Diagnostic Bits for indicating the difference for the inputs to the PLC. This will show up as a red indication light on the cyclinder represented on the HMI.
Cylinder Teach PLC 270-min Cylinder Teach PLC 280-min

This section of PLC logic will mimic the inputs from the cylinders.
Cylinder 1 – Retract MC21 (00021) – Extend MC31 (00031)
Cylinder 2 – Retract MC22 (00022) – Extend MC32 (00032)
Cylinder 3 – Retract MC23 (00023) – Extend MC33 (00033)
Cylinder 4 – Retract MC24 (00024) – Extend MC34 (00034)
Cylinder 5 – Retract MC25 (00025) – Extend MC35 (00035)
Cylinder 6 – Retract MC26 (00026) – Extend MC36 (00036)
Cylinder 7 – Retract MC27 (00027) – Extend MC37 (00037)

Between each funtion of the cylinder there is a time delay for the input to turn on and off of 500msec.
Cylinder Teach PLC 290-min

Cylinder 2 – Retract MC22 (00022) – Extend MC32 (00032)
Cylinder Teach PLC 300-min

Cylinder 3 – Retract MC23 (00023) – Extend MC33 (00033)
Cylinder Teach PLC 310-min

Cylinder 4 – Retract MC24 (00024) – Extend MC34 (00034)
Cylinder Teach PLC 320-min

Cylinder 5 – Retract MC25 (00025) – Extend MC35 (00035)
Cylinder Teach PLC 330-min

Cylinder 6 – Retract MC26 (00026) – Extend MC36 (00036)
Cylinder Teach PLC 340-min

Cylinder 7 – Retract MC27 (00027) – Extend MC37 (00037)
Cylinder Teach PLC 350-min

This is the end of the PLC program. You can see that the program is not very complicated once you break down the individual steps.

Download the PLC program and the Bin directory for the AdvancedHMI screen.

Watch on YouTube : Building a PLC Program that You can be Proud Of – Part 6b – Explaining the Program
If you have any questions or need further information please contact me.
Thank you,
Garry



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

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.

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

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

HTML and Scripting Languages

 We have the following accomplished:
  • PLC program
  • Visual Basic Program
  • Data collected in a Database
  • IIS web service established
  • ASP Script Written
iis106
Lets take a closer look at the ASP Script ( AccRL.asp) that was written in part 11:
The <html> is at the start of the file and the </head> is at the end of the file. These tags all have to have a start and end.  The ‘/’ indicates the end of the tag.
The <head> is used to place the information for the web page. The refresh will load the page after 300 seconds (5 minutes). This way the information will always be the latest. Title is used to label the page. This is the information at the top of the browser. The SHORTCUT ICON is used for the icon at the top of the browser near the page address.
<html>

<head>
<meta HTTP-EQUIV=”Refresh” CONTENT=”300″>
<title>ACC Automation – Robust Logger</title>
<LINK REL=”SHORTCUT ICON” HREF=”http://192.168.1.3/ACC_Do.ico”/></head>

ActiveX Data Objects (ADO) is used to access databases from your web pages. ADOVBS.inc is a file that has all of the ADO constants defined.  Be sure to add this file in your root web application directory.
<!– #include virtual=”/adovbs.inc” –>

The <% and %> symbols indicate the start and finish of VBScript in the page. We dimension our variables for StartTime and EndTime. These will be used to determine how long our script took to execute.
<%
Dim StartTime, EndTime
StartTime = Timer

We dimension the variables that are used for the connection to the database file.
Dim OBJdbConnection
Dim rs1
Dim objCmd

We set up the connection to the database and determine what information we need to retrieve.
Set OBJdbConnection = Server.CreateObject(“ADODB.Connection”)

OBJdbConnection.Open “Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=C:\AccRL\data\AccRL.accdb;Persist Security Info=False;”
set rs1 = Server.CreateObject(“ADODB.recordset”)
with rs1
 .CursorType = adOpenForwardOnly
 .LockType = adLockReadOnly
 .CursorLocation = adUseServer
 .ActiveConnection = OBJdbConnection
 .Source = “SELECT * FROM Minute_Log;”
end with

Using getrows will allow us to execute the Select command and retrieve all of the information in one pass from the database.  This is the quickest method to get the information out quickly.
rs1.Open

arraytime = rs1.getrows()
rs1.close

We now write the information from the database to the page.
Response.Write arraytime(0,0) & “<br>”
Response.Write arraytime(1,0) & “<br>”
Response.Write Year(arraytime(1,0))& “/” & Right(“0” & Month(arraytime(1,0)), 2) & “/” & Right(“0” & Day(arraytime(1,0)), 2) & “<br>”
Response.Write arraytime(2,0)& “<br>”
Response.Write arraytime(3,0)& “<br>”
Response.Write arraytime(4,0)& “<br>”

The EndTime is now set and the total time it took for the process is displayed.
EndTime = Timer

Response.write “<p>Processing took “&(EndTime-StartTime)&” seconds<p>&nbsp;”
%>
</body>
</html>

Now that you have information into the database and IIS running, you can display the data in various ways.
Charts:
iis109 display
Graphs:
iis108 display Gauges:
iis107 display
This ends our robust logger design. For the complete PLC program, VB source code and web page file please send me an email and ask for the ACC Robust Logger Program. I will be happy to email you the information.
If you have any questions or need further information, please contact me.
Regards,
Garry

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
Now You Can Have Robust Data Logging for Free – Part 7
Now You Can Have Robust Data Logging for Free – Part 8
Now You Can Have Robust Data Logging for Free – Part 9
Now You Can Have Robust Data Logging for Free – Part 10
Now You Can Have Robust Data Logging for Free – Part 11
Now You Can Have Robust Data Logging for Free – Part 12




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

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.

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

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

HTML and Scripting Languages

 We have the following accomplished:
  • PLC program
  • Visual Basic Program
  • Data collected in a Database
  • IIS web service established
The machine that has the IIS web service must have the Microsoft Access Database Engine 2010 installed. This can be obtained by the following link:
You can select the 32 bit or 64 bit version that matches your computer.

Microsoft Access Database Engine 2010 Redistributable
Note:  If you have office installed on your machine already then you probably will already have this file.

ActiveX Data Objects (ADO) is used to access databases from your web pages. ADOVBS.inc is a file that has all of the ADO constants defined.  Be sure to add this file in your root web application directory. How to add this code to a web page is shown in the sample code below .
You can download ADOVBS.inc from this site in text format. (Just rename to ADOVBS.inc from ADOVBS.txt)
ADO Introduction:
http://www.w3schools.com/asp/ado_intro.asp

Lets set up ASP on IIS to display any error messages to our browser.
Call up Control Panel and then goto Administrative Tools. Call up Internet Information Services (IIS) Manger.iis100

From IIS Manager, double click on ASP under IIS. Expand Debugging Properties and change the Send Errors To Browser to True.

iis102

iis103

Lets also ensure that your browser is set to display the error messages in internet explorer (IE). Call up Internet options from the main settings.

iis104

iis105

Click the setting for ‘Show friendly HTTP error messages’. This will ensure that the error messages show up in your browser.

The last part  of our project is to display the database information to the network. We do this by using a webpage. The HTML and VBScript can be writing in any editor. (Like Notepad)

There are also a great number of online editors that you can visual see what your page will look like while developing your code.
To learn more about VBScript following the link below:
Lets take a look at the AccRL.asp file:


<html>
<head>
<meta HTTP-EQUIV=”Refresh” CONTENT=”300″>
<title>ACC Automation – Robust Logger</title>
<LINK REL=”SHORTCUT ICON” HREF=”http://192.168.1.3/ACC_Do.ico”/></head>
<!– #include virtual=”/adovbs.inc” –>
<%
Dim StartTime, EndTime
StartTime = Timer

Dim OBJdbConnection
Dim rs1
Dim objCmd

Set OBJdbConnection = Server.CreateObject(“ADODB.Connection”)
OBJdbConnection.Open “Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=C:\AccRL\data\AccRL.accdb;Persist Security Info=False;”
set rs1 = Server.CreateObject(“ADODB.recordset”)
with rs1
 .CursorType = adOpenForwardOnly
 .LockType = adLockReadOnly
 .CursorLocation = adUseServer
 .ActiveConnection = OBJdbConnection
 .Source = “SELECT * FROM Minute_Log;”
end with

rs1.Open
arraytime = rs1.getrows()
rs1.close

Response.Write arraytime(0,0) & “<br>”
Response.Write arraytime(1,0) & “<br>”
Response.Write Year(arraytime(1,0))& “/” & Right(“0” & Month(arraytime(1,0)), 2) & “/” & Right(“0” & Day(arraytime(1,0)), 2) & “<br>”
Response.Write arraytime(2,0)& “<br>”
Response.Write arraytime(3,0)& “<br>”
Response.Write arraytime(4,0)& “<br>”

EndTime = Timer
Response.write “<p>Processing took “&(EndTime-StartTime)&” seconds<p>&nbsp;”
%>
</body>
</html>

Place this AccRL.asp file into the root directory of our web server. Call up the page though our browser (http:\\localhost\AccRL.asp) and the following output will be seen.
iis106
In part 12 we will break down the ASP code and modify. For the complete PLC program, VB source code and web page file please send me an email and ask for the ACC Robust Logger Program. I will be happy to email you the information.
If you have any questions or need further information, please contact me.
Regards,
Garry

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
Now You Can Have Robust Data Logging for Free – Part 7
Now You Can Have Robust Data Logging for Free – Part 8
Now You Can Have Robust Data Logging for Free – Part 9
Now You Can Have Robust Data Logging for Free – Part 10
Now You Can Have Robust Data Logging for Free – Part 11




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

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.

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

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

Computer Web Server (IIS)

 We have come a long way. The PLC program has been written. The visual basic program has been written. Information is now being collected from the Do-more PLC via Modbus TCP and stored in a database using visual basic.
The next step is to deliver the information on the network. We will do this by installing the Internet Information Services. (IIS) This is a group of internet servers that include a Web or Hypertext Transfer Protocol server (HTTP) and a File Transfer Protocol server (FTP). IIS will allow us to connect the physical hardware to the data. This could be desktop computers, laptops, tablets, cell phones, watches etc. The advantage of using HTTP is that we can share the information to all of these devices without having to be concerned over the operating system of each of them. As long as they can display a web page we are good to go.
Active Service Pages (ASP) will be installed at the same time. This is a program that will run scrips at the server before delivering the HTML code to the browser. It is similar to CGI and Perl but is simpler and faster.
ASP.Net Tutorial
We will install this on a Windows 8.1 machine.
Call up the Control Panel.
  • Swiping in from the right and searching for “control panel”.
  • Win + x will call a menu to select the control panel.
IIS_000
Select Programs and Features
IIS_001
Select Turn Windows features on or off
IIS_002
Select ASP after expanding Internet Information Services / World Wide Web Services / Application Development Features. This will select all of the other options.
IIS_003
Hit OK to install the services.
IIS_004
IIS_005
We now have IIS installed.
IIS_006
Under the following default directory you will find the location to put your web pages.
C:\inetpub\wwwroot\
IIS_007
If you call up the iisstart.htm file in this directory it will call up a page from Microsoft to explain the IIS web service.
IIS_009
Installing IIS on windows 7 and XP is very similar to the above procedure. Windows 98 you had to install a personal web service (PWS) and then ASP separately.
Further information on ASP can be obtained from the following website:
This site will walk you through ASP.
In part 11 we will  look at HTML and scripting languages like JavaScript or VBScript.
If you have any questions or need further information, please contact me.
Regards,
Garry

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




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

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.

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

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

Computer Program Visual Basic (VB6) Continue

 MainScr

The final code will be completed for the program. If you want a link to download the complete code then go to the contact page and put Robust Logger Program in the description.

The actual code that will be seen will be in Italic. This way you can pick out the code from the commentary.

Private Sub Form_Load()
MbusStatus = 0
ProductionPointerNow = 10
MinutePointerNow = 660
End Sub
 
When our form loads, the MbusStatus will be set to 0. This will control all of the communications to the Do-More PLC. The ProductionPointerNow and the MinutePointerNow will be used to determine where we are in getting data.
Here are our declarations for the program.
Dim MbusQuery
Public MbusResponse As String
Dim MbusByteArray(255) As Byte
Public MbusStatus As Integer
Public ProductionPointer As Integer
Public ProductionPointerNow As Integer
Public MinutePointer As Integer
Public MinutePointerNow As Integer
Start Logging Button:
We will stop or ensure the timer between reads has been disabled.
We will then check the status of the winsock. If it is not opened and ready to send then change the background colour to indicate to the operator what is going on.
Note:  Winsock RemotePort = 502
Private Sub Command1_Click()
Timer1.Enabled = False ‘ Stop the interval between reads to the PLC
Dim StartTime
If Winsock1.State <> 7 Then
If (Winsock1.State <> sckClosed) Then
Winsock1.Close
End If
Winsock1.RemoteHost = Text1.Text ‘ Set IP Address
Winsock1.Connect
StartTime = Timer ‘ Use the timer to determine if a connection cannot be made
Do While ((Timer < StartTime + 2) And (Winsock1.State <> 7))
DoEvents
Loop
If (Winsock1.State = 7) Then
Text1.BackColor = &HFF00& ‘ Change background colour to green
Else
Text1.BackColor = &HFF ‘ Change background colour to red
Exit Sub
End If
End If
Check the status of the Winsock. If we are good to go then determine the MbusStatus (0 to 9) and either send a read or write string out to the PLC.
If (Winsock1.State = 7) Then
Select Case MbusStatus
Case 0, 2
‘Read all the Daily Production Values
MbusQuery = Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(6) + Chr(0) + Chr(3) + Chr((Val(ProductionPointerNow) \ 256)) + Chr(((Val(ProductionPointerNow) Mod 256) – 1)) + Chr(0) + Chr(20)
Case 3
‘Reset Daily Production Pointer to 30 (Write)
MbusQuery = Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(9) + Chr(1) + Chr(16) + Chr(0) + Chr(0) + Chr(0) + Chr(1) + Chr(2) + Chr(0) + Chr(30)
Winsock1.SendData MbusQuery
Case 4, 6
‘Read the Minute Log Pointer
MbusQuery = Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(6) + Chr(0) + Chr(3) + Chr(0) + Chr(1) + Chr(0) + Chr(1)
Case 5
‘Read all the Minute Log Values
MbusQuery = Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(6) + Chr(0) + Chr(3) + Chr((Val(MinutePointerNow) \ 256)) + Chr(((Val(MinutePointerNow) Mod 256) – 1)) + Chr(0) + Chr(20)
Case 7
‘Reset Minute Log Pointer to 670 (Write)
MbusQuery = Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(9) + Chr(1) + Chr(16) + Chr(0) + Chr(1) + Chr(0) + Chr(1) + Chr(2) + Chr(2) + Chr(158)
Winsock1.SendData MbusQuery
Case 8
‘Read the current Daily Production Values
MbusQuery = Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(6) + Chr(0) + Chr(3) + Chr(0) + Chr(9) + Chr(0) + Chr(20)
Case 9
‘Read the current Minute Log Values
MbusQuery = Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(0) + Chr(6) + Chr(0) + Chr(3) + Chr(2) + Chr(147) + Chr(0) + Chr(10) End Select
Winsock1.SendData MbusQuery ‘Send out the Modbus Information
Timer2.Enabled = True ‘Set the timeout timer for communications
Else
MsgBox (“Device not connected via TCP/IP”)
Exit Sub
End If
End Sub
 Retrieving the information from Winsock
 We first get all of the bytes of data from winsock. Then we determine the MbusStatus and then handle the data appropriately.
Private Sub Winsock1_DataArrival(ByVal datalength As Long)
Timer2.Enabled = False ‘Stop communications timeout timer
‘Get all the inforamtion from the data arriving
Dim B As Byte
Dim j As Byte
returnInfo = “”
For i = 1 To datalength
Winsock1.GetData B
MbusByteArray(i) = B
returnInfo = returnInfo & B
Next
j = 0
On Error Resume Next
Select Case MbusStatus
Case 0
‘Read the Daily Production Pointer
ProductionPointer = Val(Str((MbusByteArray(10) * 256) + MbusByteArray(11)))
If ProductionPointer <> 30 Then
ProductionPointerNow = ProductionPointerNow + 20
MbusStatus = 1
Else
MbusStatus = 4
End If
Case 1
With Adodc1
.CommandType = adCmdTable
.RecordSource = “Production_Log”
.Refresh
.Recordset.AddNew
End With
‘Read all the Daily Production Values
Label18.Caption = Format$((Str((MbusByteArray(10) * 256) + MbusByteArray(11)) & “/” & Str((MbusByteArray(12) * 256) + MbusByteArray(13)) & “/” & Str((MbusByteArray(14) * 256) + MbusByteArray(15))), “yyyy/mm/dd”)
Label19.Caption = Val(Str((MbusByteArray(16) * 256) + MbusByteArray(17)) & Str((MbusByteArray(18) * 256) + MbusByteArray(19)))
Label20.Caption = Val(Str((MbusByteArray(20) * 256) + MbusByteArray(21)) & Str((MbusByteArray(22) * 256) + MbusByteArray(23)))
Label21.Caption = Val(Str((MbusByteArray(24) * 256) + MbusByteArray(25)) & Str((MbusByteArray(26) * 256) + MbusByteArray(27)))
Label22.Caption = Val(Str((MbusByteArray(28) * 256) + MbusByteArray(29)) & Str((MbusByteArray(30) * 256) + MbusByteArray(31)))
Label23.Caption = Val(Str((MbusByteArray(32) * 256) + MbusByteArray(33)) & Str((MbusByteArray(34) * 256) + MbusByteArray(35)))
Label24.Caption = Val(Str((MbusByteArray(36) * 256) + MbusByteArray(37))) / 10
Label25.Caption = Val(Str((MbusByteArray(38) * 256) + MbusByteArray(39))) / 10
Label26.Caption = Val(Str((MbusByteArray(40) * 256) + MbusByteArray(41))) / 10
Label27.Caption = Val(Str((MbusByteArray(42) * 256) + MbusByteArray(43))) / 10
Label28.Caption = Val(Str((MbusByteArray(44) * 256) + MbusByteArray(45))) / 10
With Adodc1
.Recordset.Update
.Recordset.MoveLast
.Refresh
End With ProductionPointerNow = ProductionPointerNow + 20
If ProductionPointer = ProductionPointerNow Then
MbusStatus = 2
End If
Case 2
‘Read the Daily Production Pointer
ProductionPointer = Val(Str((MbusByteArray(10) * 256) + MbusByteArray(11)))
If ProductionPointer = ProductionPointerNow Then
MbusStatus = 3
Else
ProductionPointerNow = ProductionPointerNow + 20
MbusStatus = 1
End If
Case 3
‘Reset Daily Production Pointer to 30 (Write)
If (MbusByteArray(8) = 16) And (MbusByteArray(12) = 1) Then
MbusStatus = 4
ProductionPointerNow = 10
Else
Text1.BackColor = &HFF
End If
With Adodc1
.CommandType = adCmdTable
.RecordSource = “Production_Log”
.Refresh
.Recordset.AddNew
End With
Case 4
‘Read the Minute Log Pointer
MinutePointer = Val(Str((MbusByteArray(10) * 256) + MbusByteArray(11)))
If MinutePointer <> 670 Then
MinutePointerNow = MinutePointerNow + 10
MbusStatus = 5
Else
MbusStatus = 8
End If
Case 5
With Adodc2
.CommandType = adCmdTable
.RecordSource = “Minute_Log”
.Refresh
.Recordset.AddNew
End With
‘Read all the Minute Values
Label29.Caption = Format$((Str((MbusByteArray(10) * 256) + MbusByteArray(11)) & “/” & Str((MbusByteArray(12) * 256) + MbusByteArray(13)) & “/” & Str((MbusByteArray(14) * 256) + MbusByteArray(15))), “yyyy/mm/dd”)
Label30.Caption = Format$((Str((MbusByteArray(16) * 256) + MbusByteArray(17)) & “:” & Str((MbusByteArray(18) * 256) + MbusByteArray(19)) & “:” & Str((MbusByteArray(20) * 256) + MbusByteArray(21))), “hh:nn:ss”)
Label31.Caption = Val(Str((MbusByteArray(22) * 256) + MbusByteArray(23)) & Str((MbusByteArray(24) * 256) + MbusByteArray(25)))
Label32.Caption = Val(Str((MbusByteArray(26) * 256) + MbusByteArray(27)))
With Adodc2
.Recordset.Update
.Recordset.MoveLast
.Refresh
End With MinutePointerNow = MinutePointerNow + 10
If MinutePointer <= MinutePointerNow Then
MbusStatus = 6
End If
Case 6
‘Read the Minute Log Pointer
MinutePointer = Val(Str((MbusByteArray(10) * 256) + MbusByteArray(11)))
If MinutePointer = MinutePointerNow Then
MbusStatus = 7
Else
MinutePointerNow = MinutePointerNow + 10
MbusStatus = 5
End If
Case 7
‘Reset Minute Log Pointer to 670 (Write)
If (MbusByteArray(8) = 16) And (MbusByteArray(12) = 1) Then
MbusStatus = 8
MinutePointerNow = 660
Else
Text1.BackColor = &HFF
End If
With Adodc2
.CommandType = adCmdTable
.RecordSource = “Minute_Log”
.Refresh
.Recordset.AddNew
.Refresh
End With
Case 8
‘Read the current Daily Production Values
Label18.Caption = Format$((Str((MbusByteArray(10) * 256) + MbusByteArray(11)) & “/” & Str((MbusByteArray(12) * 256) + MbusByteArray(13)) & “/” & Str((MbusByteArray(14) * 256) + MbusByteArray(15))), “yyyy/mm/dd”)
Label19.Caption = Val(Str((MbusByteArray(16) * 256) + MbusByteArray(17)) & Str((MbusByteArray(18) * 256) + MbusByteArray(19)))
Label20.Caption = Val(Str((MbusByteArray(20) * 256) + MbusByteArray(21)) & Str((MbusByteArray(22) * 256) + MbusByteArray(23)))
Label21.Caption = Val(Str((MbusByteArray(24) * 256) + MbusByteArray(25)) & Str((MbusByteArray(26) * 256) + MbusByteArray(27)))
Label22.Caption = Val(Str((MbusByteArray(28) * 256) + MbusByteArray(29)) & Str((MbusByteArray(30) * 256) + MbusByteArray(31)))
Label23.Caption = Val(Str((MbusByteArray(32) * 256) + MbusByteArray(33)) & Str((MbusByteArray(34) * 256) + MbusByteArray(35)))
Label24.Caption = Val(Str((MbusByteArray(36) * 256) + MbusByteArray(37))) / 10
Label25.Caption = Val(Str((MbusByteArray(38) * 256) + MbusByteArray(39))) / 10
Label26.Caption = Val(Str((MbusByteArray(40) * 256) + MbusByteArray(41))) / 10
Label27.Caption = Val(Str((MbusByteArray(42) * 256) + MbusByteArray(43))) / 10
Label28.Caption = Val(Str((MbusByteArray(44) * 256) + MbusByteArray(45))) / 10
With Adodc1
.Recordset.Update
.Recordset.MoveLast
End With MbusStatus = 9
Case 9
‘Read the current Minute Log Values
Label29.Caption = Format$((Str((MbusByteArray(10) * 256) + MbusByteArray(11)) & “/” & Str((MbusByteArray(12) * 256) + MbusByteArray(13)) & “/” & Str((MbusByteArray(14) * 256) + MbusByteArray(15))), “yyyy/mm/dd”)
Label30.Caption = Format$((Str((MbusByteArray(16) * 256) + MbusByteArray(17)) & “:” & Str((MbusByteArray(18) * 256) + MbusByteArray(19)) & “:” & Str((MbusByteArray(20) * 256) + MbusByteArray(21))), “hh:nn:ss”)
Label31.Caption = Val(Str((MbusByteArray(22) * 256) + MbusByteArray(23)) & Str((MbusByteArray(24) * 256) + MbusByteArray(25)))
Label32.Caption = Val(Str((MbusByteArray(26) * 256) + MbusByteArray(27)))
With Adodc2
.Recordset.Update
.Recordset.MoveLast
End With
MbusStatus = 0
End Select
Timer1.Enabled = True ‘Set the interval between the next communication
End Sub
The last thing that we do is save and compile the VB program. I will be happy to send the complete program to you . Please go to the contact page and put Robust Logger Program in the description.
In part 10 we will display the information on a web server. We will use IIS and ASP to actively connect and display the information in the database.
If you have any questions or need further information, please contact me.
Regards,
Garry

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




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

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.

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

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

 

Computer Program Visual Basic (VB6) Continue

The display part of the program is done and we have reviewed the modbus TCP protocol. It is now time to start the VB6 code. Lets discuss how the logic will work.

1. User selects ‘Start Logging’
2. The timer for interval between communications is stopped.
3. The IP address is used to open the winsock connection. If the connection is made then the background colour of the IP Address will turn green and we will continue to step 4. If the connection already exists then continue to step 4. If the connection cannot be made then the background colour is red, further execution is stopped. Program will continue at step 1.
4. The following sequence of commands are made: Determine what command to send.

  • Read the Daily Production Log and Minute Log Pointers (MHR1 and MHR2 )
  • If MHR2 (Minute Log Pointer ) > 670 then
    • Request the Minute Log starting at MHR670 and keep incrementing by 10 until the last location is requested.
    • Write the value of 670 into MHR2 (Reset the pointer)
  • If MHR1 (Daily Production Log Pointer > 30 then
    • Request the Daily Production Log starting at MHR30 and keep incrementing by 20 until the last location is requested.
    • Write the value of 30 into MHR1 (Reset the pointer)
  • Read the current Minute Log information starting at MHR660
  • Read the current Daily Production Log information starting at MHR10
Once the command is sent a timer is set to determine if communications has been lost.
5. If the timer for communications is lost, goto step 3. Repeat the last command.
6. Turn off the timer to determine if communications has been lost. Read the information from the winsock tool. If the data needs to be stored, then update the database. Set the timer for interval between communications.

The above is the general program flow for the program.

Here are our variables:

Dim MbusQuery
Public MbusResponse As String
Dim MbusByteArray(255) As Byte
Public MbusStatus As Integer
Public ProductionPointer As Integer
Public MinutePointer As Integer  

Private Sub Command1_Click()
Timer1.Enabled = False ‘ Stop the interval between reads to the PLC

Timer1 is used to control the amount of time between intervals of communication to the PLC.

Dim StartTime
If Winsock1.State <> 7 Then
    If (Winsock1.State <> sckClosed) Then
        Winsock1.Close
    End If
    Winsock1.RemoteHost = Text1.Text ‘ Set IP Address
    Winsock1.Connect
    
    StartTime = Timer ‘ Use the timer to determine if a connection cannot be made
    
    Do While ((Timer < StartTime + 2) And (Winsock1.State <> 7))
        DoEvents
    Loop
    If (Winsock1.State = 7) Then
       Text1.BackColor = &HFF00& ‘ Change background colour to green
    Else
       Text1.BackColor = &HFF ‘ Change background colour to red
       Exit Sub
    End If
End If

Here is the code to control Winsock1. The IP address entered in Text1 is used to set the RemoteHost. We then check for the state of the Winsock1. The following are the different states that Winsock1 can be:

Constant Value Description
sckClosed 0 Default. Closed
sckOpen 1 Open
sckListening 2 Listening
sckConnectionPending 3 Connection pending
sckResolvingHost 4 Resolving host
sckHostResolved 5 Host resolved
sckConnecting 6 Connecting
sckConnected 7 Connected
sckClosing 8 Peer is closing the connection
sckError 9 Error
Here is the information that we will need to read and write to the MHR registers in the Do-More PLC.

‘ Read the information

‘0000:    Transaction Identifier
‘0000:    Protocol Identifier
‘0006:    Message Length (6 bytes to follow)
’00:      The Unit Identifier
’03:      The Function Code (read MHR Read Holding Registers)
‘0000:    The Data Address of the first register
‘0002:    The number of registers to write
‘ Write the information
‘0000:    Transaction Identifier
‘0000:    Protocol Identifier
‘0009:    Message Length (6 bytes to follow)
’01:      The Unit Identifier
’16:      The Function Code (read Analog Output Holding Registers)
‘0000:    The Data Address of the first register
‘0001:    The number of registers to write
’02:      The number of data bytes to follow
‘0030     The number to put into the register
All of the information will be bytes of data. The maximum value in a byte is 256. If we need to send a value of 600 then the two bytes of data will be:
600/256 = 2.34
The most significant byte is 02
600 – (256*2) = 88
The least significant byte is 88
So the information that we need to send through Winsock1 would be Chr(2) and Chr(88) to represent the value of 600.

In part 9 we will continue with writing the VB6 program. We will start reading and writing the information to the PLC.
If you have any questions or need further information please contact me.
Thank you,
Garry



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

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.

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

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

 

Computer Program Visual Basic (VB6) Continue

We have started our VB program and have set up our Adodc connections to the database. Lets continue by setting the labels up with the Adodc connections. Then we will set up the communications to the Do-More PLC and put information into our Access 2007 (*.accdb) database. (AccRL.accdb)

Select all of the labels that will be for the Production_Log table and set the properties. Under DataSource select Adodc1. Do the same thing for all the labels under the Minute_Log table.

Now go through each of the labels and select the DataField that it represents. Do this for both the Production_Log table and the Minute_Log table.
Note: You can also set the format in which the field will display

We now have our basic display set up in visual basic. The last thing that we will do is add a text box and command buttons to control the logging of the information.

A text box is added to enter the IP Address of the PLC.
A Command1 command button is added to start the logging of the information.
A Command2 command button is added to stop the logging of the information.
We now have everything on the dispay that we will need for the program.
Lets now take a look at the modbus protocol.

http://www.simplymodbus.ca/TCP.htm

All Modbus Commands:

Function Code Action Table Name
01 (01 hex) Read Discrete Output Coils
05 (05 hex) Write single Discrete Output Coil
15 (0F hex) Write multiple Discrete Output Coils
02 (02 hex) Read Discrete Input Contacts
04 (04 hex) Read Analog Input Registers
03 (03 hex) Read Analog Output Holding Registers
06 (06 hex) Write single Analog Output Holding Register
16 (10 hex) Write multiple Analog Output Holding Registers
Due to Homeland Security the automation direct Do-More PLC will allow only the MHR area of memory to be written and read. Since this controller resides on a network and can be connected to the internet, this makes perfect sense. So the only function codes that we will be using will be 03 Read and 16 Write.

A review of the numbering systems can be found on a previous blog here.

Here is what we have to send to the PLC. (In this example we will read registers.)
00 – Transaction ID
00 – Protocol ID
06 – Length of message words
0 – Unit ID (Default)
3 – Function Code (Read) 10hex – Write
10 – Data bits (In this case the number of registers to read)
We will receive what we sent out plus the data requested.
Note: The rest of the network protocol will be handled by TCP/IP. All of the error checking is also handled by the network.

In part 8 we will continue with writing the VB6 program. We will start to put everything together in the program using code.
If you have any questions or need further information please contact me.
Thank you,
Garry



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

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.

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 what VB is and discussed what we need to do in order 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 back to the data that 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 that we will be retrieving from the PLC.
See 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 lets start the visual basic programming:
Start a new project save it as AccRL in the directory mentioned above.

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 of the data that we wish to display. Fonts sizes etc can all change based upon how you would like it to appear.
Note: Everything shown on the form are labels for the data. This program will just 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 setup during the running of the program. On the form will will add a variable to tell the IP address of the PLC. We will deal with it after the database information has been setup.
Each of the Adodc controls represent the two tables set up earlier. Adodc1 is for the Production_Log table and Adodc2 is for the Minute_Log.
Lets 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 then 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 will only be able to 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 contact me.
Thank you,
Garry



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

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.