How to interact with Allen Bradley PLC Driver on Linux

niraj1234

Member
Join Date
Mar 2012
Location
pune
Posts
2
Hello everyone,
I am a beginner in PLC . I have to write a driver (C/C++) to read/write Allen Bradley PLC tags.

After doing some search on PLC ethernet library I have found two such library.

http://www.novellshareware.com/info/cip-ethernet-library-for-linux.html
http://sourceforge.net/projects/abplc5/files/latest/download

Can some one suggest whether this would work . And from where to start . Any good links or help in this direction would be really helpful .

TIA
 
Thanks - this was a great suggestion. I was able to compile it and run it for an ARM board without any porting at all. But when I enter in the register addresses it doesn't seem to be finding anything. In the first test that came with the code I have:

char *IP="192.168.0.100\0";
var = "N7:1\0";

It connects to the PLC ok but the console output is:
Reading N7:1
Error : ReadLgxData The particular item referenced could not be found (261:0)

I'm using a MicroLogix 1100.

Any thoughts?
 
Nevermind - dumb problem. Didn't read the instructions. Was using ReadLgxData when I should've been using ReadPLCData. Now it works great.

Thanks again for the tip - this library is so easy to use. No more headaches trying to port modbus libraries. You really just made my day :)
 
Can you please post the full code you are using???
I keep getting an error while reading on mine.
Error : ReadPLCData Illegal commmand or format (16:0)
 
I'm really just using the code examples that came with the library - I've only changed the register address and length. I didn't change anything in the library. I can't post all of the code since there's some proprietary stuff in there (and honestly it woudn't be any better than the example code). But my guess is the problem you're having is with the PLC config, not the code.

Are you using ethernet? Could it be a network connection issue? Do you have a firewall? And if you are using ethernet, do you have ethernet turned on in your PLC's settings?

Also, make sure it's set up for the right protocol - should be DF1 and not Modbus.
 
[FONT=&quot]I am using a Micrologix 1000 connected to the Ethernet trough a 1761-NET-ENI to a local private network with no firewall. I am able to connect, program an get online from Windows, (even AdvancedHMI works perfect), but from Linux, the error is constant, I am convinced that is something I am doing Wrong either in the code or in the usage.[/FONT]
[FONT=&quot]It says it connects and opens the session, but when reading it goes into the error.[/FONT]
[FONT=&quot]Starting, Pid = 1265[/FONT]
[FONT=&quot]Entering OpenSession[/FONT]
[FONT=&quot]OpenSession Ok[/FONT]
[FONT=&quot]Entering RegisterSession[/FONT]
[FONT=&quot]RegisterSession Ok[/FONT]
[FONT=&quot]Entering ConnectPLCOverCNET[/FONT]
[FONT=&quot]ConnectPLCOverCNET Ok,[/FONT]
[FONT=&quot]Reading N7:00[/FONT]
[FONT=&quot]Error : ReadPLCData Illegal command or format (16:0)[/FONT]
[FONT=&quot]Entering Forward_Close[/FONT]
[FONT=&quot]Forward_Close Success[/FONT]
[FONT=&quot]UnRegister : Success[/FONT]
[FONT=&quot]Entering CloseSession[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]This is what I have in code [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]printf("entering RegisterSession \n");[/FONT]
[FONT=&quot] res=RegisterSession(session);[/FONT]

[FONT=&quot] if (res!=Error)[/FONT]
[FONT=&quot] { int i,val_int,val_bool;[/FONT]
[FONT=&quot] float val_float;[/FONT]
[FONT=&quot] printf("RegisterSession Ok\n");[/FONT]
[FONT=&quot] printf("entering ConnectPLCOverCNET\n");[/FONT]
[FONT=&quot] Eip_Connection *connection=ConnectPLCOverCNET([/FONT]
[FONT=&quot] session, // session whe have open[/FONT]
[FONT=&quot] LGX, // plc type[/FONT]
[FONT=&quot] 0x12345678, // Target To Originator connection ID[/FONT]
[FONT=&quot] 0x6789, // Connection Serial Number[/FONT]
[FONT=&quot] 5000, // Request Packet Interval[/FONT]
[FONT=&quot] path, // Path to the ControlLogix[/FONT]
[FONT=&quot] sizeof(path) // path size[/FONT]
[FONT=&quot] );[/FONT]

[FONT=&quot] if (connection!=NULL)[/FONT]
[FONT=&quot] {[/FONT]
[FONT=&quot] printf("ConnectPLCOverCNET Ok, \n");[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] printf("Reading %s\n",var);[/FONT]

[FONT=&quot] PLC_Read *data=ReadPLCData(session,connection,NULL,NULL,0,LGX,tns++,var,count);[/FONT]
[FONT=&quot] [/FONT]
 
That's pretty much exactly the same code I have - all of the params are exactly the same. Although I'm using an 1100 with built in Ethernet. The only difference I see between mine and yours is that the address I'm using is "N7:0" not "N7:00".

I noticed that I can get that error if I hit the PLC with read data requests too quickly, but I've never gotten it on the first one.
 
Hello,

I can add that reading/writing a ML via PCCC over direct connected Ethernet is not the same as reading/writing via an NET-ENI connected to the serial port of the PLC. The packet format is not the same.

IIRC the document eipexp1_2.pdf gives more data.

Maybe tuxeip does not cover NET-ENI usage.
 

Similar Topics

I am taking over a CTC Interact project. All I have to start with is the LRP file. I do not know what version it was written in. It was done...
Replies
0
Views
1,824
Greetings! (First timer here) I've got a machine (b&r ipc 2001), and in its CompactFlash theres DOS and Interact (Version 5.2) My contractor...
Replies
0
Views
1,151
Hello Mr PLC Experts, I am working with a Parker CTC application on XP in VMWare. I am trying to modify and existing project and now it is not...
Replies
1
Views
1,857
Has anyone had any experience with this? I know how to setup users and user levels in the software and such but cannot seem to find where to...
Replies
0
Views
1,371
I am working on a conversion project, upgrading some old CTCs to Panelview 1000s, and have run into several buttons with addresses I don't know...
Replies
0
Views
1,329
Back
Top Bottom