Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

How to specify Attribute ID in OPC Server DevicenetExplicit

I'm trying to set up an Allen Bradley 842D Devicenet Absolute Encoder using the OPC server.  The manuals for the device mention that the data can be retrieved from the various Attribute ID's in each class.  From the OPC Server Help example below,  it starts to describe the location of the data desired,  but fails to show me where I specify the attribute ID.  For example, lets say in the example below,  I now want Attribute 2 or 3.  How does the below example tell me how?.

Since I'm trying to get all this data in via the IA OPC server,  I'm not planning on using the DNET Vi's.  BUT.....I did look at the "GetIdentityAttrs.vi" and notice that the VI's provided allow for Class ID, Instance ID, and Attribute ID.  All of which correctly gives me the information I want when I run this VI with the 842D encoder.

From OPC Server Online Help:

NIDeviceNetExplicit Example
Suppose you want to get attribute 1 from Class ID 1, Instance 3 of an object. Class ID 1 is the Identity Class, where all the identification information for the device is contained.
Enter the background information when you create the NIDeviceNetExplicit object, setting the Service Code to 14 and the Class ID to 1. From the manufacturer’s documentation, you know that GetAttribute only accepts an unsigned integer (USINT) as a parameter.

The baud rate for the object in question is an 8-bit unsigned integer (USINT). To read the baud rate, access the IID3.USINT0 data member.

From the Above,  this is what how i'm interpreting the configuration:  IID ( Instance ID).USINT (data offset)


To re-iterate my question:  How do I specify the Attribute ID when using the IA OPC Server DeviceNetExplicit Object? 

Regis
0 Kudos
Message 1 of 9
(5,287 Views)
UPDATE:

 I tried using the IID ( Instance ID).USINT (Attribute ID -1) but to no avail. It's not that i don't get any data, it's just that the data received does mean anything. As a number, or Hex, or any combination thereof.

I did modify the NI Labview DNET example (GetIdentityAttrs.vi) to get the data i'm looking for; position and velocity.

The parameters are such.

MAC ID = 32 (allen bradley Slave device)
Service Code = 14 (Get)
Class Code = 2F (47) - Encoder
Instance ID = 1
Attribute ID = 12 (position) = UDINT data type
Attribute ID = 22 (Velocity) = UINT data type

With the DNET setup of MAC ID (0)
Baud Rate = 500k
Poll = Automatic

So it's good to know that I'm reading the position and velocity in LV. That means the device is functioning properly. If i use the OPC Server with the above set up: IID1.UDINT11 (or UDINT12) & IID1.UDINT21 (or UDINT22), I get '0's as my data. There is NO read error, which is promising, but no data either.

As a test, I decided to look at the buffer as UDINT all the way from IID1.UDINT0 to IID1.UDINT35. I only get data for the first two. UDINT1 and UDINT2. Neither data seems to correspond to anything i'm looking for nor does it follow any pattern for attribute ID's (unless I'm completely going about this wrong)

Changing the value associated with the Instance ID (ie. IID2 or IID3) makes the OPC item throw an error.


The problem is that the OPC server that we have doesn't have Labview installed and since we have about 6 other devices read directly into the OPC server, I'd hate to have to change the set up.

You can view screenshots of my setup here:

http://forums.lavausergroup.org/index.php?showtopic=2317&st=0&gopid=7883&#entry7883


Thanks,

Regis
0 Kudos
Message 2 of 9
(5,271 Views)
Hi Regis,
 
The general steps to send & receive the explicit message using the NI OPC Server:
  1. Configure an OPC item to write the explicit message, you have to set the attribute ID for the GET request message here.
  2. Configure an OPC item to read the explicit message, you will get the explicit response from it.
Example: Read the Vendor ID (ClassID=1, InstanceID=1, AttributeID=1, DataType=UINT)
 
(1) Configure the NIDeviceNetExp object with the right MAC ID, ServiceCode=14(GET), ClassID=1
(2) Add an OPC item (Data Member) NIDeviceNetExp1.IID1.USINT0 to write the parameter.
(3) Add an OPC item (Data Member) NIDeviceNetExp1.IID1.UINT0 to read the Vendor ID.
(4) Then you get the alarm message in IA OPC server and get failure message in your OPC client , if you have one started allready, because it reads the item automatically.
The magic action is here: you write the value 1 to NIDeviceNetExp1.IID1.USINT0. (then the attribute ID 1 is set correctly).
You can get the vendor ID then reading NIDeviceNetExp1.IID1.UINT0.
 
2. Example: If you want to get the Serial Number (ClassID=1, InstanceID=1, AttributeID=6, DataType=UDINT)
Add an OPC item NIDeviceNetExp1.IID1.UDINT0
You write the value 6 to NIDeviceNetExp1.IID1.USINT0
You can get the Serial Number in NIDeviceNetExp1.IID1.UDINT0
 
So you can conclude that:
(1) if you write to NIDeviceNetExp1.IID1.USINT0, USINT is the data type used to encode the request message parameter.
(2) if you read from NIDeviceNetExp1.IID1.UDINT0, UDINT is the data type used to decode the response message.
 
Attached you can find an example using LV and  Datasocket to read the Vendor ID.
 
Hope that helps with your problem.
 
DirkW
Message 3 of 9
(5,235 Views)
Dirk,

thanks for the clarification...I'll give this a shot and report back here in a bit...

Regis
0 Kudos
Message 4 of 9
(5,231 Views)
I have a few more questions regarding the capabilities...

1)  if I wanted to read a bunch of Attributes,  would the have to perform a set of "Write Attribute, wait, Read Data Type"  for each data point?

2) Any other way to request a set of <insert number greater than 1>  attributes??

I'll also be looking at SETTING values to attributes as well....I'm assuming i'll WRITE to the Attribute ID first (using Service code 14),  then WRITE the Attribute's Value I want to set (using Service code 10).  Does this seem right?

Regis
0 Kudos
Message 5 of 9
(5,221 Views)

Regis,

Explicite Messaging knows other services then get attribute single (0EH), for example (10H) read attribute single, (02H) set attributes all and (01H) get attributes all.

The class definition states how the attributes are packed into the message.

But for the single attribute you are right, thats the way.

 

DirkW

0 Kudos
Message 6 of 9
(5,194 Views)
DirkW,

I'm still having problems grasping the concept of Setting a value to a specific Attribute ID.  The Device I have is an encoder wheel that will determine the distance traveled and speed of a web converting machine.  Every so often,  I'd like to "reset" the distance traveled after a run is complete.  Basically,  the logic is to SET the position value (attribute ID =10) to 0.  I can Read the position value (attribute ID =12) and velocity (attribute ID=22) but haven't quite gotten how to Write a value....

Here are some more specific questions:

1a)  Do I need to create another OPC DevicenetExplicit "Object" (in the OPC Server) specifically for Writing?  The reason I think this is necessary is that the first object I created (for reading),  I set the Service code value to 14 (GET).   Writing would require the service code value to be 16 (10h). 

1b) Related to this,  Does it then follow that the Instance ID of this new "Object" would be "2" instead of "1"?  We are accessing the same device and since Instance ID=1 is related to the reading,  would I need to set Instance ID=2 for Writing?  Again,  Not sure if my logic is correct here...I've tried both but all i get is "bad" data when i set up the OPC server this way.

2)  Base on your "Read" Data logic,  this is what i gather for "Writing":

2. Example: If you want to SET the Encoder Position Value to 360 (ClassID=1, InstanceID=1(?), AttributeID=10, DataType=UDINT)
Add an OPC item NIDeviceNetExp1.IID1.UDINT0
You write the value 10 to NIDeviceNetExp1.IID1.USINT0  <--- This is to target the right Attribute?
??? You Write the value 360 to NIDeviceNetExp1.IID1.UDINT0 ???<--- This is where i'm just guessing.  Not sure how to set value of "360" into Attribute ID 10.

Then If i went and read the position Attribute ID 12,  I'd like to see that the new position is 360.

Thanks,
Regis

0 Kudos
Message 7 of 9
(5,166 Views)
I'd like to revive this thread if possible...still looking for a solution...

Regis
0 Kudos
Message 8 of 9
(5,093 Views)

Hi Regis,

sorry for answering a little late but i took a timeout during cristmas.

To your problem: I know it is a little tricky to get it running with the OPC Server.

Here is how it should work:

1. How to write the following parameter:

Encoder Position (ClassID=1, InstanceID=1, AttributeID=10, DataType=UDINT)   !!Notice: The instance ID shouldn't be changed to 2. We want to set the same paramter to a new value.!!  

(1) Configure the NIDeviceNetExp object with the right MAC ID, ServiceCode=16(SET), ClassID=1 (The object name is NIDeviceNetExpWrite1 here)

(2) Add an OPC item (Data Member) NIDeviceNetExpWrite1.IID1.USINT0 to write AttributeID.

Add an OPC item (Data Member) NIDeviceNetExpWrite1.IID1.UDINT1 to write new Encoder Position.

(3) Write the value 10 to NIDeviceNetExpWrite1.IID1.USINT0

Write the value 360 to NIDeviceNetExpWrite1.IID1.UDINT1

(4) Now  and this is important you have to  create the complete request message action

Read NIDeviceNetExpWrite1.IID1.USINT0 to send the request message and write the new value to your device

Attached you can find a VI showing how to program it in LabVIEW.

Hope that helps

DirkW

0 Kudos
Message 9 of 9
(5,071 Views)