Previous in Forum: Restoring Google Image Settings   Next in Forum: Hydraulic Simulation Software?
Close
Close
Close
9 comments
Rate Comments: Nested
Active Contributor

Join Date: Oct 2008
Posts: 17
Good Answers: 1

Interfacing PLCs and VB.NET

08/07/2009 3:34 AM

Hi,

Can anyone pls tell me the basic ideas for communicating the PLC's with VB.net.So, that I can read and write data's to the PLC's from VB.

Thanks

Karthick

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#1

Re: Communication between VB.net and PLC

08/07/2009 3:46 AM

What kind of PLC (make, model)? What type of interface?

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply
Anonymous Poster
#2
In reply to #1

Re: Communication between VB.net and PLC

08/07/2009 3:53 AM

Its Triconex PLC.I can get datas in Excel from TRiconex with the help of DDE server.Similarly I want to get in VB.net.

Thanks

Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#3
In reply to #2

Re: Communication between VB.net and PLC

08/07/2009 4:05 AM

If you can get details of the DDE source(s) in the server, you could use DDE to transfer directly into your VB (tho' I use VB6, not VB.net, so I'm not 100% sure that VB.net supports DDE).

Alternatively, use Excel as an intermediary, and interface your VB to the spreadsheet to get the data.

Another way would be to write your own driver. I did this for Allen Bradley DF1 protocol (to avoid paying a huge licence fee every time I produce an app with comms to an AB PLC) - but I warn you it's not easy, and would only be possible with the spec of the interface protocol.

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply
Active Contributor

Join Date: Oct 2008
Posts: 17
Good Answers: 1
#4
In reply to #3

Re: Communication between VB.net and PLC

08/07/2009 4:25 AM

Hi John,

Thanks....Im not well versed in VB to write a code for driver..I can go for option 1 (excel)rather..

Could you pls help me in communicating between VB6 and DDE server atleast..

Thanks

Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#5
In reply to #4

Re: Communication between VB.net and PLC

08/07/2009 4:47 AM

I can probably help with the VB - but to use their DDE driver you'll need details like the application name, link topic(s) and link item(s), and what kind of data you can expect to get. Do you have a contact at your equipment supplier who may be able to help you with these? Alternatively, they may be given in the documentation of the server.

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply
Active Contributor

Join Date: Oct 2008
Posts: 17
Good Answers: 1
#6
In reply to #5

Re: Communication between VB.net and PLC

08/07/2009 4:55 AM

Yes, I have those details like application name, topic name required for dde server...mainly boolean type datas, which i expect to read and write..

Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#7
In reply to #6

Re: Communication between VB.net and PLC

08/07/2009 6:57 AM

Ok ...

I'd suggest setting up a test, with a form called, say, frmInterface. Create two labels, called lblPLCCommand and lblPLCStatus.

This is an (edited!) chunk of code lifted from one of my programs:

' -------------------------------------------------------------------------

dim loadtime, dummy, dummy2

On Error Resume Next
Err.Clear

dummy = Shell("path_and_name_of_driver", vbNormalNoFocus) ' Start the driver
loadtime = Timer

Do
Err.Clear
AppActivate "application_title", True
DoEvents
Loop While ((Err.Number = 5) And (Timer - loadtime) < 10) ' give it 10 seconds to start up
On Error GoTo 0

dummy2 = Timer - loadtime

If Err.Number = 5 And ((Timer - StartTime) >= 10) Then
MsgBox "Error - timeout trying to start driver", vbOKOnly
End
End If

On Error GoTo 0

'Try to link to driver
With frmInterface.lblPLCStatus
.LinkMode = vbLinkNone
.LinkTopic = "application_name|status_topic_name"
.LinkItem = "status_item_name"
On Error Resume Next
.LinkMode = vbLinkAutomatic
On Error GoTo 0

If .LinkMode <> vbLinkAutomatic Then
MsgBox$ "No link to driver"

End
End If
End With


' If the code above worked, lblPLCStatus will be continuously updated with whatever the driver puts in "status_item_name"

' The next bit of code illustrates how to send data to the PLC (via the driver)

With frmInterface.lblPLCCommand
.LinkMode = vbLinkNone
.LinkTopic = "application_name|command_topic_name"

.LinkItem = "command_item_name"
.LinkMode = vbLinkManual
.Caption = "12345"

.LinkPoke
End With

'-------------------------------------------------------------------------

Hope this helps. The formatting in the CR4 editor doesn't make it easy to read - lots of the leading whitespace is lost so there's no indenting. Also, our internet connection died for a while when I was editing it, so I lost the plot a bit! If you're really stuck, pm me with your e-mail address and I'll try sending you stuff as a text file.

Probably won't be able to get back on line today - I've just had a call-out for a job. Let me know how you get on - I'll be around over the weekend.

Good luck,

John.

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply Score 1 for Good Answer
Active Contributor

Join Date: Oct 2008
Posts: 17
Good Answers: 1
#9
In reply to #7

Re: Communication between VB.net and PLC

08/07/2009 10:31 AM

Hi john,

i really havent checked your code..but want to thank you for the effort you put in for my interests...thanks a lot..will let u know once the code is checked..

Register to Reply
Anonymous Poster
#8

Re: Interfacing PLCs and VB.NET

08/07/2009 9:03 AM
Register to Reply
Register to Reply 9 comments

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Copy to Clipboard

Users who posted comments:

Anonymous Poster (2); JohnDG (4); karthickranii (3)

Previous in Forum: Restoring Google Image Settings   Next in Forum: Hydraulic Simulation Software?

Advertisement