Hope everyone is well and staying healthy.
I posted this same question by mistake on a different section of the CODESYS forum, so my apologies for the duplicate information.
I'm kind of new to CODESYS and also to this forum.
I am trying to make a CODESYS device talk to a CompactLogix PLC over Ethernet IP by setting the CODESYS as a scanner and the AB controller as the adapter. The first test I did was exporting out the EDS file from RSLinx and importing this into CODESYS via the Device Repository under Tools. Then adding this adapter under the tree of the Ethernet IP Scanner device seemed to have worked well. The downside to this is that on the Studio5000 side you have to setup your tag as a Producer tag and so far I have only being able to read from the CompactLogix not write to it as Studio5000 doesn't allow me to setup a Consumer tag.
I was wondering if there is anyway you can setup a Generic_Ethernet_IP_device and communicate to a Logix5000 controller successfully and read and write from it? This way it will only look into the tags in the controller level at the AB controller through explicit CIP messaging and wouldn't have to depend on the EDS file setup, controller type etc?
I have been trying to somehow use some of the functions available in the Ethernet IP library to manipulate the Class ID and Instance ID etc but have no been very successful in doing so. Probably because I also lack full understanding on how to access the class and instance of the tags I am looking for in the AB device.
Thank you so much in advance for any advice or pointers!
Maybe this helps you?
But I guess you have found that allready....
I have poked around further.
Easiest to set up, but requires you to "touch" the AB Programming software.
You have seen already in SP15 CODESYS as consumer, AB Logix5000 as Producer.
In SP16 (coming soon), you should have the ability to configure CODESYS as Producer, AB Logix5000 as Consumer. Actually to realize this, you will add an Ethernet/IP Scanner AND a Ethernet/IP Adapter, and configure symbolic tags for the adapter. Still as you say, you have to "touch" the AB Programming software to do this.
Simply follow Chapter 2 of the document 1756-pm020 Rockwell provides for how to read and write tags using Generic Service Class Instance Attribute
Seems steps are:
1. Add the Ethernet IP Services Lib, and use the GenericService() to send messages to the Logix5000 PLC.
2. Read a table of every tag in the controller with its associated instance/attribute number
2. in your code, itterate through that table until you find the tag you want
3. use the instance/attribute of your found tag to send a message to the Logix 5000 PLC.
4. Somehow track when the original list of tags you read becomes invalid (eg. Logix online change, Logix project download.) Honestly I didn't read that sub chapter, but it is important.
This is not yet possible and not planned.
But in theory, if GenericService() were able to use symbolic addressing (or even custom path!) then you could just use the method described in that same rockwell document, under "Write Tag Service > Example Using Symbolic Segment Addressing"
Thanks so much for the tips! I greatly appreciate it.
Still trying to see if I can figure out how to use the GenericService() and if I could use it to read and write data successfully. So far I have tried to get the attribute of the data in he Logix5000 controller (L33ER) but the instance of the tag I am trying to get seems to change dynamically. Maybe I am not understanding well how to access this data through Ethernet IP but it seems strange to me that a tag was available under the Class 10x6B Instance 11 (example) one moment ago and if I request the same instance a moment later it is a completely different piece of data.
Still much that I need to learn it seem.
Thank you so much again for your time in sharing the above with me. If I come to a clear solution(or conclusion) in the near future I will repost again.
So sorry for the super delay response, I have been trying everything I could on this Ethernet IP Scanner test to communicate with a Compact Logix. Here are my findings. (these are the most promising results I got among the many tests I did)
on CODESYS using getAttributeAll() function from the library helps get some data back from the Comapct Logix. Doing this I was able to "find" some of the sample "controller tags" I had created in Studio 5000. I basically looked for them under the 10x6B class (got this from the Logix 5000 Controllers Data Access.pdf manual P42). Basically what I did was scan every instance from 0 to 17 (until I find the tag I was looking for). There is a good amount of data that comes back, it took me a while to find out some of the data was ASCII characters in decimal. The sample code I used for this operation is:
eClass:= 16#6B, (* cip class which contains the desired attribute *)
dwInstance:= Instance,(* value of 0 is class level, range from 1..x is instance level *)
pData:= ADR(data), (* data buffer *)
udiDataSize:= SIZEOF(data), (* size of the data buffer *)
udiReceivedDataSize=> udiReceivedData );
Doing the operation described above it will return a set of data to pData where data was declared as ARRAY[0..500] OF BYTE , when I toggle the BOOL variable getAttribute.
Then I said lets use this information to read from the tag I created, using the Ethernet IP/CIP service 10x4C (again according to the Logix 5000 Controllers Data Access.pdf manual P18 & P20). But whenever I do this I only get one decimal value and that is 196 as a response from the controller. The sample code used for this is shown below: (this value of 196 does not change regardless of the value that the tag holds in the compact logix)
eService:= 16#4C, //read tag service
udiReceivedDataSize=> iGenRecievedDataSize );
The arrays I am using to pReadData and pWriteData are declare as:
awreadData: ARRAY[0..5] OF BYTE;
awwriteData: ARRAY[0..5] OF BYTE;
Not sure at this point what I am doing wrong, if anyone out there may have had any luck in trying to communicate with a compact logix this way. If you could share anything I would greatly appreciate it!
Thanks so much for taking the time to read my post.
Stay safe and healthy out there!
Log in to post a comment.