Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Trying to pull data from an AB Plc using Kepware without having a TAG in the Kepware Database. Looking for a way to just pass-through the READ request. I know the below code snippet works just fine, however, the tag "YourPLCTag" needs to be in Kepware DB. I just want to access "YourPLCTag" without the tag being in Kepware.
var serverUrl = new Uri("opc.tcp://localhost:4840");
// Connect to the OPC server
using (var client = new OpcClient(serverUrl))
{
client.Connect();
// Read PLC value
var nodeId = "ns=2;s=YourPLCTag"; // Replace with your PLC tag
var value = client.ReadNode(nodeId);
// Do something with the value...
client.Disconnect();
}
Solved! Go to Solution.
I stated earlier this did not work because the TAG 'TAG_ADDRESS1' was already created/defined in the Tagname Dictionary of the KepWare server (which it is). I also stated I can easily poll tags that have already been created in the TagName dictionary. I tried several times to get the above sample to work to no avail when a tag is NOT created in the TagName dictionary and thought the above solution was not helpful.
What I failed to try is fully qualifying the TagName in the request -- which solved my problem. IE: when polling STRING data directly, the following was required. ns=2;s=ABCLX.Device1.THIS_IS_A_STRING_TAG.DATA/82@String. Please note the ....DATA/82@String at the end of the fully qualified TagName. This was the trick.
Thanks
Please take a look at the Kepware knowledge base article in the following link which covers Dynamic Addressing in Allen-Bradley ControlLogix devices:
Thanks,
*Chris
I stated earlier this did not work because the TAG 'TAG_ADDRESS1' was already created/defined in the Tagname Dictionary of the KepWare server (which it is). I also stated I can easily poll tags that have already been created in the TagName dictionary. I tried several times to get the above sample to work to no avail when a tag is NOT created in the TagName dictionary and thought the above solution was not helpful.
What I failed to try is fully qualifying the TagName in the request -- which solved my problem. IE: when polling STRING data directly, the following was required. ns=2;s=ABCLX.Device1.THIS_IS_A_STRING_TAG.DATA/82@String. Please note the ....DATA/82@String at the end of the fully qualified TagName. This was the trick.
Thanks