cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

PLC Tag Read Pass through without Tag in Kepware Database - C#, VB, or Python

HK_9569113
7-Bedrock

PLC Tag Read Pass through without Tag in Kepware Database - C#, VB, or Python

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();
}

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2

@HK_9569113 

 

Please take a look at the Kepware knowledge base article in the following link which covers Dynamic Addressing in Allen-Bradley ControlLogix devices:

 

Article - CS401609 - Dynamic Addressing in Allen-Bradley ControlLogix Ethernet driver of PTC Kepware Products

 

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

Announcements


Top Tags