Author Topic: Beckhoff Twincat 2 connection  (Read 5610 times)

joseph_e2

  • Newbie
  • *
  • Posts: 21
    • View Profile
Beckhoff Twincat 2 connection
« on: June 10, 2020, 03:17:06 PM »
I've spent a lot of time working with Siemens and Allen-Bradley PLCs, but I recently changed jobs to a facility with a number of Beckhoff Twincat systems. Some are v2, others are 3. The one I'm working on now is Twincat 2. I want to be able to read tags out of the machine onto a PC for logging. It's been a long time, but I've done this before with Advanced HMI and an AB processor. I remember recently testing communications again and it "just worked" on the first try with little trouble, but I can't get the Beckhoff system to talk to me. Here's what we're running:

Machine information:
Windows XP Embedded
Beckhoff TwinCAT version 2.11.1553
PLC Control Version 2.11.0 Build 1016
This is an industrial PC mounted inside the machine cabinet and connected to a touch screen monitor on a swing arm. The PC is also running the OEM's custom HMI software.
IP Address: 192.168.0.20

Advanced HMI information:
Windows 7 x64 virtual machine (no extra firewall, virus scanner, or weird network security software on it) with a dedicated USB Ethernet adapter to bypass any IT issues on the host. The USB Ethernet adapter is attached to the VM as a device so it's invisible to the host.
Advanced HMI v3.99x in Visual Studio 2015
IP address: 192.168.0.50

The usb ethernet adapter attached to the VM is patched directly to the Beckhoff PC's NIC. The Beckhoff PC replies to ping from the VM.

I added a TwinCATCom driver and a panel meter to the main form.
I went into the PC and found a global variable to read. I have screenshots showing what I've done so far. What am I doing wrong?



Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Beckhoff Twincat 2 connection
« Reply #1 on: June 10, 2020, 04:31:03 PM »
Is TwinCAT installed on the PC you are running AdvancedHMI on? If so, it will not let it work. The TwnCAT AMS router intercepts packets destined for AdvancedHMI and will not let them through.

joseph_e2

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Beckhoff Twincat 2 connection
« Reply #2 on: June 11, 2020, 07:37:18 AM »
TwinCAT is not installed on the AdvancedHMI PC. It's a clean Windows 7 install with Visual Studio.

Weird...I don't remember hitting the "Post" button, and the original post still shows up in edit mode on the laptop I was using for this yesterday.

Let me summarize the settings I've looked at on the TwinCAT PC:
In the TwinCAT System Properties dialog box, System tab.
TwinCAT Server list box:
TcCam
Tclo
TcNc
TcPlc
TcRTime
Auto Boot is Enabled with Auto Logon checked. User Name is Administrator, Password is blank.

Same dialog box, AMS Router tab, AMS Net Id: 192.168.20.1.1 (I changed this from the previous setting of 127.255.255.1.1.1

I logged out of Windows and back in to verify that the login name is Administrator and its password is also blank.

Inside the PLC control, I found a list of global variables and chose a few at random to try to reach, ending up with "RunCnt" which looks like something we want to read anyway.

joseph_e2

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Beckhoff Twincat 2 connection
« Reply #3 on: June 11, 2020, 02:01:38 PM »
I just realized that I never described the problem. The solution builds and tests without any warnings, but the panel meter almost immediately shows error 999, no value returned by driver.

I tried it again as a test with the network definitely not connected at all and there are no messages at all, the digital panel meter just sits there displaying "0" with no errors. The output window shows a bunch of lines like this:
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll

When I get the "no value returned by driver" error, the output window shows a bunch of lines like this:
Exception thrown: 'MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException' in MfgControl.AdvancedHMI.Drivers.dll



Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Beckhoff Twincat 2 connection
« Reply #4 on: June 11, 2020, 02:19:59 PM »
The best way to see what is happening is to run a Wireshark capture. You will see the request using a certain port number. The response must come back on that same port. if not, then TwinCAT is rerouting the packets.

joseph_e2

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Beckhoff Twincat 2 connection
« Reply #5 on: June 17, 2020, 12:34:47 PM »
Sorry for the delayed response. I'm tied up this week and out of the office next week, so I'll try Wireshark when I get back. I'll let you know what I find out. Or if I need help, since I'm not a Wireshark expert...

joseph_e2

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Beckhoff Twincat 2 connection
« Reply #6 on: July 07, 2020, 09:31:18 AM »
It's been a crazy time, but I finally got back out to the machine after downloading and installing Wireshark. I'm...not sure what I'm looking at. There are UDP packets going back and forth. I've attached a screenshot showing what's going on.
It looks like the replies are returning to the same port.
Where should I look for further details?
« Last Edit: July 07, 2020, 09:49:27 AM by joseph_e2 »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Beckhoff Twincat 2 connection
« Reply #7 on: July 07, 2020, 08:08:09 PM »
Can you save the file and post it ?

joseph_e2

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Beckhoff Twincat 2 connection
« Reply #8 on: July 08, 2020, 09:01:59 AM »
Here it is.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Beckhoff Twincat 2 connection
« Reply #9 on: July 08, 2020, 09:12:03 AM »
Does the Administrator account on the TwinCAT PC have a password?

For remote connections, Windows requires a password.

joseph_e2

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Beckhoff Twincat 2 connection
« Reply #10 on: July 08, 2020, 10:17:17 AM »
You mean the Windows Administrator account? I can check. As long as it will still auto logon with the password, that shouldn't be a problem.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Beckhoff Twincat 2 connection
« Reply #11 on: July 08, 2020, 10:34:14 AM »
Yes, the Windows Administrator account. You can still use Auto Login, but it just needs a password

joseph_e2

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Beckhoff Twincat 2 connection
« Reply #12 on: July 09, 2020, 01:50:51 PM »
I added a password ("1") to the Administrator user account in Windows on the TwinCAT PC and tested the autologin to make sure I didn't break it. I also added that password to the "System" tab of the "TwinCAT System Properties" dialog box and to the properties of the COM object in the AHMI project. Here is an updated Wireshark capture.

Thanks!

joseph_e2

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Beckhoff Twincat 2 connection
« Reply #13 on: July 09, 2020, 01:53:19 PM »
Here are some screenshots.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Beckhoff Twincat 2 connection
« Reply #14 on: July 09, 2020, 02:36:39 PM »
I can see that AdvancedHMI is trying to add a route to the TwinCAT routing table. It must be failing because it keeps trying. I will have to try to find the details of the response to see if I can figure out which bytes are the error codes.

If you check the Router table on the TwinCAT machine, does it show an AdvancedHMI???? route?