Sign in to follow this  
Followers 0
Rick16bit

Communication between CP1L USB and .NET program

6 posts in this topic

Dear reader, I'd like to read and write a couple of (CIO) addresses in a CP1L PLC. Basic stuff. The same must be done sooner or later on a CJ1M PLC as well by the way. First I tried to make use of the 2nd COMport, set the mode to RS232C in the PLC, and wrote a VB.NET program that connects using the SerialPort class. It worked...sort of, but unstable. To begin with, I had a hard time finding the right RS232 pin layouts - the ones in the Omron documentation didn't work. Now I can receive commands from the PLC, but sending commands back often doesn't work for unclear reasons. Whether its the PLC, the cable, the VS2008 SerialPort class or my program, I have no clue. What I really want is to get rid of the self produced "hobby" cables and use a more robust protocol. For example, is it possible to communicatie via the USB cable with my CP1L, using FINS command (or something else). Pretty much the same way as CX-programmer would communicatie with the PLC? Same question for CJ1M PLC's, though I'm using a different cable here (connecting via the Toolbus protocol & CN226 cable). There are various code snippets when googling, but they are often old, plus the variaty of articles, different cables, techniques and is overwhelming to pick directions. I also noticed several ActiveX libraries from OMRON are available on my computer that might be useful, but again I have no idea how to use them. Another way might be buying CX-Compolet maybe. But its quite expensive (for the basic stuff we need), plus I want to make sure it fits with our desires. Anyone experience with solid & simple communications between the CP1L (or CJ1M) and a PC?

Share this post


Link to post
Share on other sites
This question had been asked many times and I forgot how many times I posted the same answer, but again I'm copying and pasting: I suggest you use Ethernet communication and there are 2 ways to do this. 1- Using FINS commands (low level): You should download this VB.Net source code and see how it communicates with UDP then do the same in your application. http://forums.mrplc....ds&showfile=992 Also, download the following pdf file for details on FINS command. http://forums.mrplc....ds&showfile=620 These are the only 2 links you need to build a VB .NET application to read/write bits in your PLC. 2- Using either DDE or OPC connection (high level): The other option is to have DDE or OPC connection to your PLC to read/write data. You can either use CX-Server DDE Manager (search for CDMDDE.exe) or OPC server such as Kepware ((http://www.kepware.com/kepserverex/) to setup the communication and tags. DDE connection software comes with the Omron suite, so there is no cost to you. But, if you prefer OPC connection, then you have to buy or use the trail version. If you search the web, you can find plenty of .NET example source code to implement a DDE or OPC connection.

Share this post


Link to post
Share on other sites
Well, I did search the web multiple times about this matter, but the amount of terms and options is overwhelming for a newbie. Profibus, Toolbus, SYSMAC, FINS Command, RS232C, DDE, OPC, CX-Server, CX-Lite, CX-Compolet... And not to mention the billion different cables and pin lay-outs. Piece of a cake for experts, but a dense jungle for a guy like me. Finding the *right* stuff isn't easy if you don't know where to look for in the first place. Anyhow. thanks for pointing directions. That FINS command example sounds like what I need. In our case we don't have Ethernet modules. I guess that's just a matter of buying an expansion unit, but since its just a tiny application here, I was hoping the options we have right now, will do the job. The CP1L has a USB & RS232 "snap-in" module. The CJ1M has a RS232 and (no idea what its called!) it's programming port. In the meanwhile I found another (old) Serialport - FINS command based example. And it works (after trying several different cable pin assignments!). Now I wonder 2 things: - Polling; As far as I know, you have to request values when using FINS command ("read address x") I just need to know the state of a few digital inputs, and toggle a couple of digital outputs (basically the PLC is just an IO unit). This isn't really time critical, but the faster It's not really time critical, but the sooner I know digital inputX is on, the better. Do I have to poll many times per second ( I'd like the delay to be lower than 50 millisecs, thus 20 polls / second), or are there smarter methods, using FINS command? - Are there good reasons to chose Ethernet (or one of the other available ports) over a serial connection, in terms of stability? As explained, we already had a RS232 cable (using no protocol & TXD / RXD instructions), but it didn't work very well. I suspect the cable wasn't 100%, but it could just as well be Windows7 running on the IPC, the notorious System.IO.Net SerialPort component, a bad setting, or my own code. Ciao

Share this post


Link to post
Share on other sites
Have you looked at AdvancedHMI? It has Omron drivers which makes it very each to read/write with .NET

Share this post


Link to post
Share on other sites
Didn't hear about AdvancedHMI (just starting a Youtube video now). Sounds good! Might be an overkill for the simplistic needs we have so far, and I managed to talk with a CP1L using FINScommand, the serialport, and a RS232 cable. Don't know if its truly stabile yet, hopefully we can find out this friday when we put it to the test. But anyway, that sounds good! Got to play with it and see if/how it can help. Thanks!

Share this post


Link to post
Share on other sites

Hi...Rick can you kindly walk through how you give command using AdvancedHMI...thank in advance

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0