Jump to content

Configuring IA OPC Server to get data from Allen Bradley 842D Encoder


regisphilbin

Recommended Posts

I'm trying to set up an Allen Bradley 842D Devicenet Absolute Encoder using the OPC server. To start, I verified that the device and network is functioning properly. The manuals for the device mention that the data can be retrieved from the various Attribute ID's in each class. For example , In Class 1, you can retrieve Vendor ID (Attribute 1), Device Type (Attribute 2), Serial Number (Attribute 4) etc....

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?.

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

Link to comment

Hi Regis,

Have you tried IID3.UINSTx? Where x is the Attribute - 1. Also, "UNIST" may have to be replaced with whatever datatype that particular Attribute happens to be.

I haven't tried the above -- it's just what I gathered from the documentation; maybe worth a try.

This is not my final answer :P

-Khalid

Link to comment

Khalid,

Thanks for the suggestions. 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.

Below I have screenshots of what i'm encountering. If anyone has any suggestions or see an error in my ways, Please let me know!

Thanks,

Regis

post-127-1133899206.jpg?width=400

post-127-1133899225.jpg?width=400

post-127-1133899237.jpg?width=400

post-127-1133899248.jpg?width=400

post-127-1133899261.jpg?width=400

Link to comment

I received a reply from NI and posted the message below.

It seems like I was expecting the Attribute to be clearly "visible" in the buffer of the encoder. Nowhere was it mentioned that In order to read an explicit attribute item, you have to first "WRITE" to the encoder, the attribute ID. This will populate the buffer with the data corresponding to that item. Then perform a "READ" from the encoder of the correct data type. this will return to you the correct value.

Here are some other questions I have:

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

-------------- NI Response: --------------------------------------

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.

Hope that helps with your problem.

DirkW

Link to comment
  • 2 weeks later...

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

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.