Creating a HMI with Visual Basic/OPC (PLC5)

ptine

Member
Join Date
Nov 2006
Location
bc
Posts
79
Hello gentlemen. What I am trying to learn is how to create my own HMI using Visual Basic/OPC/Excel. I had the good fortune of spending a little time with some techs from a neighbouring plant and was introduced to this built it yourself approach. Saw a few programs working. Very impressive. However, they were running on a controllogix platform and we are running PLC5s. Shouldn't make much of a difference as its all being driven by RSLinx I think. Spent a bit of time on Rockwells site trying to figure it out. Didn't learn much. What I need is a simple explanation with a few details on how to set up the OPC server/client. I can stumble through the VB part but I'm having difficulties getting my data out of the PLC and into the VB program. Any and all suggestions/ideas would be greatly appreciated. Thanks in advance.
 
If you are going to use VB as an OPC client, program the ASYNC !! procedures/events and not the sync procedures/evets to read data or write data. Sync takes to much time to make a fast responding user interface.
 
Thanks guys. I was really busy at work today and didn't have a chance to respond. I thank you for your responses. I plan to invest some time into this during the weekend. However, if anyone else has any experience I sure would appreciate a brief overview. Thanks.
 
Install opc server. EG kepware.
mnake reference to opcdaauto.dll (microsoft) or delivered with the opc server. Google on opcdaauto.dll for a manual about it.

Create routines in vb for:
0. Dim opcserver with events, OPCGroups, OPCGroup, OPCItems
1. Connect to opc server with: .Connect
2. Create groups on OPC server with: .OPCGroups
3. Make groups active with: .DefaultGroupIsActive
4. Create group with: .OPCGroup
5. Set properties: .UpdateRate; IsSubscribed; .IsActive
6. Add items to group with: .AddItem
7. DataChange event. Server fires event in case of a data change.
8. Delete group
9. Delete groups
10. Disconnect opcserver

When adding items to a group, the vb program receives a serverhandle for the item. In the data change event the serverhandles and the data are transferred. Store your serverhandles to make it work.
Remove groups and server connections before closing the program, otherwise your groups remains active.
It is also possible to hit the opc server to send all the data to your project with the datachange event.

Good luck. (y)

Regards
 
Just got home from work a few minutes ago. Still haven't even had a beer. Brutual problem at work today. Had to chase down a ground fault. Took all day. Thanks guys for the responses. I'll be looking into it tonight but I won't really have a lot of time until the weekend. Darn job. I'll keep you guys posted. Looks like a lot of fun. Anuthing else you can think of that will help would be great. I imagine that others want to know how to do this also.
 
Jiri I was just looking into your DF1 driver but I don't believe that it supports AB PLC5s though.
 
below is some simple sample code.

i use rslinx single node ($400) for single PLC applications and rslinx oem ($900) for multiple PLC applications. for me these have worked very well.

as you already may know, in rslinx you set up your driver and then set up a topic which points to the PLC via the driver. the topic name is the OPC access path.

good luck!




Option Explicit
Option Base 1

Private WithEvents mvarServer As RsiOPCAuto_OPCServer

Private WithEvents mvarProcessGroup As RsiOPCAuto_OPCGroup

Private mvarProcessHomingStateNumber As RsiOPCAuto_OPCItem
Private mvarProcessSolderTableStateNumber As RsiOPCAuto_OPCItem
Private mvarProcessGlassTableStateNumber As RsiOPCAuto_OPCItem
Private mvarProcessSolderTableLiftStateNumber As RsiOPCAuto_OPCItem



Private Sub Form_Load()

On Error GoTo ErrorHandler
'On Error Resume Next

Me.Caption = Me.Caption & " v" & App.Major & "." & App.Minor & " Build " & App.Revision

Set mvarServer = New RsiOPCAuto_OPCServer
mvarServer.Connect "RSLinx OPC Server"

Set mvarProcessGroup = mvarServer.OPCGroups.Add("LayupGroup1")

mvarProcessGroup.OPCItems.DefaultAccessPath = "process1"

mvarProcessGroup.UpdateRate = 1000

mvarProcessGroup.IsSubscribed = True

Set mvarProcessHomingStateNumber = mvarProcessGroup.OPCItems.AddItem("N7:5", 1)
Set mvarProcessSolderTableStateNumber = mvarProcessGroup.OPCItems.AddItem("N7:1", 2)
Set mvarProcessGlassTableStateNumber = mvarProcessGroup.OPCItems.AddItem("N7:2", 3)
Set mvarProcessSolderTableLiftStateNumber = mvarProcessGroup.OPCItems.AddItem("N7:3", 4)

mvarProcessGroup.IsActive = True

Exit Sub

ErrorHandler:
MsgBox "An error has occurred. Try again or contact a controls engineer.", , "Warning"

End Sub


Private Sub Form_Unload(Cancel As Integer)

On Error Resume Next

Set mvarProcessHomingStateNumber = Nothing
Set mvarProcessSolderTableStateNumber = Nothing
Set mvarProcessGlassTableStateNumber = Nothing
Set mvarProcessSolderTableLiftStateNumber = Nothing

Set mvarProcessGroup = Nothing

mvarServer.Disconnect
Set mvarServer = Nothing

End Sub



Private Sub mvarProcessGroup_DataChange(ByVal TransactionID As Long, ByVal NumItems As Long, ClientHandles() As Long, ItemValues() As Variant, Qualities() As Long, TimeStamps() As Date)

Dim i As Long

On Error GoTo ErrorHandler

For i = 1 To NumItems
Select Case ClientHandles(i)
Case 1
lblHoming(0).Caption = ItemValues(i)
Case 2
lblSolderTable(0).Caption = ItemValues(i)
Case 3
lblGlassTable(0).Caption = ItemValues(i)
Case 4
lblSolderTableLift(0).Caption = ItemValues(i)
End Select
Next i

Exit Sub

ErrorHandler:
fraProcess(0).BackColor = vbRed
MessageBox Me.hWnd, Err.Description, "Error: " & Err.Number, vbExclamation

End Sub
 
Sorry

Jiri I was just looking into your DF1 driver but I don't believe that it supports AB PLC5s though.

I apologize. Duh. It's been a while since I looked at it. It's true I never got around to do it for PLC5.
Since I have been doing the travel business I got disinterested in controls, particularly in view of the fact that the field is going to hell, just wait when H1B visas go up to 180 000 per year.
Our idiot in charge is working on that.
 

Similar Topics

I'm wanting to create some sort of lookup search window for equipment tags on the HMI. I have a factorytalk view studio hmi file that has been...
Replies
10
Views
3,036
Here is a recent post on creating a login form using AdvancedHMI. This will use the VB.Net to connect to an access database and compare the user...
Replies
3
Views
2,018
Good afternoon, I need to create a recipes display on the hmi ns8, to change the parameters of a servo and some strings . The PLC that im using is...
Replies
0
Views
2,752
Hi, I am very new to this technology, but I am trying to get close to it. I am searching about creating PC application for interacting S7 PLC. I...
Replies
3
Views
1,661
I am still playing with National Instruments Lookout HMI and have been trying to create a HOA using a "Radio Button" but cannot seem to figure out...
Replies
2
Views
5,858
Back
Top Bottom