Write variables of TwinCAT 2 PLC via ADS remotely

541 views Asked by At

The reason why I am asking a question is because I am having issues writing variable values of a TwinCAT 2 system remotely (but reading variables works fine).

The setup what I am trying to make working is the following: There is an avreage PC where the I would like run my .NET 6 based application TwinCAT.Ads 6.0.129 included, and the 3.1 4024.29 build of TwinCAT 3 runtime is installed. The remote system an industrial assambly station based on (PC-165552) TwinCAT 2 runtime version 2.11 build 2126. The way why I trying to get acces to the variables of the TwinCAT 2 system is CreateVariableHandle, then use the ReadAny, and WriteAny methods. I tried other ways as well but this looks the easiest for me.

I have tested my code to running a test TwinCAT runtime PLC on my localhost, and get acces to the variables of test runtime. The whole data exchange worked fine I could read and write variables, but somehow if I change to remote and I try to acces to the remote PLC variables I can only read thier values, but not write them.

I tried several ways to indentify the problem. I installed the TwinCAT engineering and tried to analyse the ADS communication via the integrated ADS Monitor tool. I sent a Write Request with the ADS Command test tool to the certain variable but even taught the transfer was succesfull the variable did not changed. I also monitored the process with ADS monitor so I had a possibility to check the conctent of the Request and Response messages and they looked absolutely fine with no error. I studied all the available documentation, but I couldent find anything what could cause the mentioned issue.

Since the C# code works fine on local host, and I cant even write those variables remotely on the given target station even with the built in Beckhoff tools. My conclusion is some sort of settings must be wrong on the TwinCAT 2 target station (maybe firewall or something).

Could you please give me some hints where and what settigns I suppose to look around.

1

There are 1 answers

0
ZolkoKft On

The issue was the certain variable was overwriten cyclically on the remote (PLC) side. Unfortunatelly I did't have acces to the source code of the PLC, therefore I did't have a possibility to verifly it myself. I was expecting something like that because the I didn't received any error during the write request. So it was succesfull but right after the variable was overwriten. I just swithed the PLC to stop to stop the porgram execution, and after I tried to write the variable.