Read Tag from Rockwell PLC from Codesys?

I have done some playing with two codesys PLCs, and you have it right: with no connections listed on the Remote Adapter's Connections tab, it does not go to Running. Adding a valid connection gets it to running. Once in running, the generic service works.

The thing is, valid connections here are only special class 1 connections, you can't just choose any available service/class/instance/attribute. The only class 1 connections I know of for a Logix Processor are produced tags.
I couldn't find a document describing the correct format for these produced tags. I assume it would just be the symbolic path... But how much data does it need to send? If someone has a wireshark of a successful Produce Consume, you or I could dissect it and see what is needed.
 
I realize that most of the effort here is going toward using the message router or finding a way to get CoDeSys to natively run a 0x4C or 0x4D service.

But I did spend some time this weekend learning how CoDeSys handles embedded external files, including text files and Python scripts, and how to execute them with the SysProcess library from inside a CoDeSys logic routine.

When I run simple Python scripts that just print something to stdout, the result happily shows up in a string in CoDeSys.

But when I execute a PyLogix script, which includes printing the result to stdout, there's an Error Code 25 and no data in response. If I put a print() function at the start of the script, that line does appear in stdout.

Maybe it's the time that PyLogix takes to import and call and execute and generate a result, even though it's only a few milliseconds, that prevents SysProcess.SysProces***ecuteCommand2 from seeing the result.

If I figure out that method, I'll post (maybe as a separate thread).
 
Last edited:
AustralIan and theColonel26:
Hello. I am either doing something very silly or I may be very close. I created the tags FromCodesys_20words and ToCodesys_10words in Logix.
Then in Codesys I created a connection with the symbolic syntax as per below:
91 13 46 72 6f 6d 43 6f 64 65 73 79 73 5f 32 30 77 6f 72 64 73

I am getting from Logix a Forward Open failure response with extended status "Invalid Network Connection Parameter." It seems the path is being understood, but my understanding of the CIP communication parameters is fuzzy.

Tried a number of things but can't get it working. Any suggestions?

20201116CodesysLogixSymbolic1.jpg
 
Alfredo, can you ZIP and post that CoDeSys project file ? I'd like to take a look at it myself, and my platform is a Raspberry Pi B+ running CoDeSys 3.05.16.
 
AlfredoQuintero


If you select "Path defined by symbolic name" it does the conversion for you I think. So just put in the tag name.

Do you have access to a Allen Bradley PLC? What model are you using? just curious.



If you want to do it manually like you are you need to use "User -defined path"


The problem with that dialog is that it doesn't allow you to specify a service. Which is why we are using the generic_service function block.
 
If you see the lower half of screenshot in post # 34 you can see the 1769-16ER that I am using. The symbolic path does the conversion? I did not know this. Will try this out later. This may be the reason why it is not working. Will also try what you suggest about user-defined path.

The reason this dialog does not allow one to specify a service is because this dialog is for the definition of connections. Connections are established with the Forward Open command and then the communication takes place implicitly. It is not possible to define services other than Forward_Open and Forward_close. Any ways in order to do explicit messaging, you need to get the scanner running, even if there is no valid implicit connection. Codesys needs to have a handle for the remote adapter to which explicit messages are to be sent. I am not sure how this generic_service function block is used. Will need to study this further. Do you mean you can use CIP services other than those indicated in this link?
 
AutralIan: tried to do as you say but, do not get a connection.
theColonel26: You are right about the sybol syntax in Codesys. It is much easier doing it like this. Thanks for the hint.

Will keep trying but may need some help from either of you or Ken.

20201117_Logix_Codesys.jpg
 
@alfredo
I think you need go add 2 bytes at the beginning 4C 0B
The a pad byte 00 at the end to make up the 11 words
4C 0B 91 13 46 72 6f 6d 43 6f 64 65 73 79 73 5f 32 30 77 6f 72 64 73 00
 
@alfredo
I think you need go add 2 bytes at the beginning 4C 0B
The a pad byte 00 at the end to make up the 11 words
4C 0B 91 13 46 72 6f 6d 43 6f 64 65 73 79 73 5f 32 30 77 6f 72 64 73 00


chelton, hi. Thanks for your comments: This explanation of yours, do you mean using the "Read Tag Service" (service ID 0x4C) by means of MSG instructions?
 
Last edited:
I've seen some examples of executing external routines using the SysProcess.SysProces***ecuteCommand2 function, so there might be a way to use the PyLogix library, or some other library to execute a tag read or write, without adding another element of middleware.
 
I am not sure how this generic_service function block is used. Will need to study this further. Do you mean you can use CIP services other than those indicated in this link?
Yes, that is just an enum supplied with the library. you should be able to send any hexdec value you want with it. My understanding is that all this is doing is sending a value that represents the requested service. It is up to the remote device to interpret that value and send back the correct data.
 

Similar Topics

Dear colleagues, I am reaching out for assistance with an issue I am having. I have a code that can successfully insert data from FactoryTalk...
Replies
6
Views
999
Hello expert; I want to read the tag values from control logix plc over the WiFi connection. I did it by using Rs link OPC and successfully read...
Replies
1
Views
1,153
Good Evening Gentlemen, we have a FT View SE client running in windows 7 system, now I want to update that system with windows 10. I did the...
Replies
2
Views
2,693
Hi, I'm pretty new to FactoryTalk and PLC's in general. In View SE, is it possible to read a string contained in a UDT and use it in another tag...
Replies
1
Views
1,220
How to solve the error BAD:Configuration Error:Not Limited in Wonderware system management Console Diagnostics
Replies
0
Views
1,987
Back
Top Bottom