AB PLC to PC (serial) communication

S

Thread Starter

Sam

Hi, I am a 4th year electrical engineering student, currently involved in my senior project. As part of my project I need to connect an Allen Bradley PLC-5 with a PC to exchange data. On PLC side I am using ASCII Read block to read data from the PC. On the PC side I am using Visual Basic MSComm control to sent data to the PLC. The cable (null modem) is connected from the COM port of the PC to the Channel 0 (serial port) of the PLC-5/11. From the past experience and reading I understand that channel 0 of the PLC-5 uses RS-232 protocol to transfer data. If that is correct then it should be receiving the data being sent through the COM port of the PC. But for some reason PLC doesn't seems to be accepting any data through channel 0. Can anyone tell me what's wrong with this set up and what do I need to do to correct this problem? Right now I am doing the on-line programming changes to the PLC through the channel 0. Once I do the changes I change ch.0 mode to 'user' so that it can read data being sent by VB application. Once I change ch.0 mode to 'user' I'll loose the on-line connection with the PLC. So right I am using ch.0 for both on-line programming and data exchange. May be this is causing any problem? I had to do like this because I don't have a KTX or PCMK network card to get on-line with PLC. As a student I can't effort to buy those network cards for $700 (even a used one). Can anyone please tell is there any inexpensive way to get online with PLC other than through ch.0 so I can leave ch.0 for data exchange only? Anyone kind of help on this issue is greatly appreciated! Thank you in advance!
 
Sam,
You are correct about doing two things at once. I think you'll find that you can only use Ch0 for one thing at a time. If you can live with not being online and polling data at the same time you should be able to do something....swapping between applications alot and reconfig of the Ch0 port. I haven't personally used Ch0 for polling data but I know there are third party people out there that do it. When you're done with your project....package it and sell it like everyone else.
Now if you've got DataHighway available then you can do all kinds of cool stuff....but you said you don't have the $$ for purchase a card...KT, KTX, PCMK, S&S, Etc. You may want to check out some third party vendors regarding DataHighway cards. They tend to be cheaper. I remember Allen-Bradley donated a KT? card to my cause back when I was in college.
RSlater
RSmike
 
You can use DF1 protocol to send data to a PLC5 without user mode. Just send a Typed Write to a string element (i.e. ST21:0), and let your ladder logic program take some action based on the string
that it receives. If you have Linux and Perl, you can use my PLC.pm perl module available here or at ftp://
metalab.unc.edu/pub/Linux/libs/PLC-0.1.0.tar.gz
See the example programs, but it's pretty easy.

Dan
 
Dan,
Thanks for you reply. I am not sure what do u mean by type write? U mean use a MSG write instruction instead of ASCII write? but I thought MSG write/read is for to exchange data between PLC's and not between a PLC and a PC. Correct me on this if I am wrong. Oh...by the way I got ascii write working yesterday. I can able sent data from PLC to the PC. Now PC to the PLC is the problem. for ascii write ch0 doesn't have to be in user mode, it can be in point to point...but for ascii read ch0 must be in user mode. That's why I am having problem with ascii read. I don't quite understand about the perl example part of ur mail. If you don't mind explaining that to me in detail. Thank You.

-Ram
 
Well, I'm not sure this is what you're looking for, but a Typed Write command is sent from the computer to the PLC via port 0 or one of the other ports (DH+,Ethernet,etc) in order to write data directly into a PLC data element. No ladder logic (MSG,etc) is required, and the port doesn't need to be in user mode. If you are using Windows, my program probably wouldn't help (without modification and testing) because I have only used it with Linux. But if you have Linux and perl, your perl program would use my PLC.pm module to send data directly to a PLC data element (N7:0, ST11:2, etc) and your PLC ladder logic would take the data and do something with it. So for example, your program could use:
PLC::pLCcommand('PLCNAME',0x0F,0x67,'ST11:0',1,'This String goes to the PLC');
to send the above string to ST11:0.
the 0x0F and 0x67 above specify the Allen-Bradley PLC5 Typed Write Command, which is command F-67.
The serial port, baud rate, etc that you are using would be specified in the configuration file entry for 'PLCNAME'.
If you are using windows, you would need similar PLC communication software, such as the 'Full' version of RSLINX, to do it this way.
Unfortunately, I don't think RSLINX LITE can be used with Visual Basic or other user programs.
There might be a free PLC communications program for windows. You could do a search for DF1 and windows (DF1 is the name of the data protocol).
More information on the DF1 protocol can be found at:
http://www.ab.com/manuals/cn/17706516.pdf
 
Well, I'm not sure this is what you're looking for, but a Typed Write command is sent from the computer to the PLC via port 0 or one of the other ports (DH+,Ethernet,etc) in order to write data directly into a PLC data element. No ladder logic (MSG,etc) is required, and the port doesn't need to be in user mode. If you are using Windows, my program probably wouldn't help (without modification and testing) because I have only used it with Linux. But if you have Linux and perl, your perl program would use my PLC.pm module to send data directly to a PLC data element (N7:0, ST11:2, etc) and your PLC ladder logic would take the data and do something with it. So for example, your program could use:
PLC::pLCcommand('PLCNAME',0x0F,0x67,'ST11:0',1,'This String goes to the PLC');
to send the above string to ST11:0.
the 0x0F and 0x67 above specify the Allen-Bradley PLC5 Typed Write Command, which is command F-67.
The serial port, baud rate, etc that you are using would be specified in the configuration file entry for 'PLCNAME'.
If you are using windows, you would need similar PLC communication software, such as the 'Full' version of RSLINX, to do it this way.
Unfortunately, I don't think RSLINX LITE can be used with Visual Basic or other user programs.
There might be a free PLC communications program for windows. You could do a search for DF1 and windows (DF1 is the name of the data protocol).
More information on the DF1 protocol can be found at:
http://www.ab.com/manuals/cn/17706516.pdf
 
An easier solution may be to download a trial version of an opc server such as KepServer or
RSLinx. I suggest the KepServer "http://www.kepserver.com":http://www.kepserver.com . The download also includes VB examples on how to communicate with a PLC. Since you have vb and can download the examples you should be able to set up communications with the PLC 5. This would also represent a more real world example of how to communicate with a PLC. Most people don't write their own serial comm based driver applications to read and write data to a plc. Also check out
"http://www.opcfoundation.com":http://www.opcfoundation.com for some useful info. Good Luck.
 
Top