Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I'm currently trying to connect my vb.net application with my Twincat PLC. This is what I have so far (i call it from a sub):

What I have tried:

VB
Dim ads As TcAdsClient = New TcAdsClient

ads.Connect(netID, Int32.Parse(port)) 'default port of Twincat 3 is 851 / Twincat 2 is 801

If ads.IsConnected = True Then
   WriteLine("Connection ok" & vbCrLf)
Else
   WriteLine("Connection error")
              
End If


Now whenever I try to connect to the PLC, it says "Port not open". Weird is, I'm able to control my PLC through the Twincat PLC software using the same port. Please advise me on this matter. Thank you.
Posted
Comments
Ralf Meier 29-Mar-19 4:20am    
Beckhoff give very good internet-support inside the Beckhoff Information System.
Also there are provided a lot of samples (for TC2 as well as for TC3).
When I see the sample there the ads.connect is only done with the Port-Number and not with a Net-ID.
Perhaps you try it like suggested from Beckhoff ...
Member 14176541 29-Mar-19 5:13am    
Yeah, i already followed that way too, without the net-ID. but no luck.
even by using their sample also still couldnt get it to work.
Ralf Meier 29-Mar-19 6:09am    
It's some time ago since I made this the last time ...
At first : I don't know if the Connect-method works synchronous - perhaps it works asynchron and the isConnect is established after some time.
Second : do you have Twincat 2.0 ??? When I read the documentation I found allways TC 2.10 as minimum requirement.
Member 14176541 1-Apr-19 0:59am    
Hi Ralf,
Thank you for your reply.
1. Tried going this way but still no luck.
2. I'm running Twincat 2.11 at the moment.

Do you think i need to open port at the PLC side in order for this to work?
Ralf Meier 1-Apr-19 3:22am    
I'm not sure ... but I don't believe.
Do you get an Exeption ?
What does your debugger is saying ?
Please provide also your complete relevant Code.
Why do you parse the Port-Number to INT32 - isn't it an INT ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900