gclshortt

IMPLEMENTING THE OMRON HOST LINK PROTOCOL (VB.NET)

17 posts in this topic

Here is a link to a thread on a recent post showing how to communicate serially to an Omron PLC using VB.Net. This uses the Omron Host Link serial protocols. (C-Mode Commands) It will read 10 DM registers and display them on the form.

 

http://accautomation.ca/implementing-the-omron-host-link-protocol-vb-net/

Here is the source program that can be downloaded.

Other links:
VB6 Program:
http://accautomation.ca/how-to-implement-the-omron-plc-host-link-protocol/

VBA Program:
http://accautomation.ca/how-to-implement-the-omron-host-link-protocol-part-2-vba/

Regards,

Garry
www.accautomation.ca

How to implement the omron host link protocol vb net 190.png

1 person likes this

Share this post


Link to post
Share on other sites

Very Impressive, Garry!  :dance:

See my PM to you...

Share this post


Link to post
Share on other sites

Hi Garry,

Been trying for 2 days already to connect to an OMRON CP1L60M using hostlink thru serial connection on the second port on CPU unit(the first is connected to an NT unit.  Not sure why there is always no reply from the CPU unit.  Tried 9800-7-E-2 and also 9800-8-N-1 but without success.

Tried your program which is sending "@00RD0000001057*" or "@00TS0047*" without any reply.  Really appreciate you pointing me in the correct direction.  By the way, does the ladder program need to change to allow hostlink connection? The ladder program is not written my me.  I am just trying to interface to it to read DM data.

Thank You & Best Regards

Linus

Share this post


Link to post
Share on other sites

Hi Linus,

Can you communicate to the unit using CX Programmer through the same port? This will ensure that the cable and communication parameters are correct.

Here is the cable pin out required for communication:
http://accautomation.ca/wp-content/uploads/2017/05/How-to-implement-the-omron-host-link-protocol-vb-net-050-min.png

Regards,
Garry

Edited by gclshortt

Share this post


Link to post
Share on other sites

Hi Garry, 

I am not able to see the link you sent. I am currently connecting

PC to PLC

2-3

3-2

9-5

4and5 short at PLC side. 

Pin 1 to body

My pc side only has 3pins. Will be connecting to Raspberry Pi so only 3pins on PC side

I tried using COM3 to connect when connecting the PLC online but also fail. 

O

Added:only able to connect using USB

Edited by Linus Tan
Add

Share this post


Link to post
Share on other sites

Hi Linus,

I have attached the cable pin out diagram. All of the handshaking has been jumped out on the PLC side. 4-5, 7-8. The computer side has 4-5 jumped out.

It is important to try and discover if the program or cable is the cause of the communication error. You have indicated that you can communicate to the PLC via the USB connection. I would try the cable again with the other pins jumped using CX-Programmer. Once you have established communication using RS232 with the PLC, you will know that your cable connections are correct.

Regards,

How to implement the omron host link protocol vb net 050-min.png

Share this post


Link to post
Share on other sites

Hi Garry, 

Noted on the wiring. Will try it again tomorrow. One more question. For Hostlink communication, is there anything that is needed on the ladder program side? I have tried with the Keyence PLC and there is nothing that needs to be done on the ladder program side.  Is it the same for Omron? 

Thank You & Best Regards,

Linus

Share this post


Link to post
Share on other sites

Hi Linus,

There is nothing that needs to be done on the ladder program side for the computer to communicate to the Omron PLC via RS232. 
The default setting for Omron RS232 is 9600, E, 7 2.
 

Since you mentioned Raspberry Pi, there is a program that will run on this device that will take care of all of the communication protocols to the Omron PLC. This is AdvancedHMI which is written in VB.Net and runs in visual studio.
https://sourceforge.net/projects/advancedhmi/
http://accautomation.ca/omron-cp1h-advancedhmi-communication/
Here is how to make this software run on a Raspberry Pi:
http://advancedhmi.com/forum/index.php?topic=666.0
Just another way to do the same thing that you are trying to accomplish. (Cable would be the same)

Regards,

Share this post


Link to post
Share on other sites

Hi Garry,

Seems like when I connect the USB cable(USB A-B) together with the Serial(USB-RS232) cable, the PLC will not ignore everything that I send on the Serial side.  But when I remove the USB cable, the PLC will echo back everything I send to it.  Is this behaviour normal or is there still some problem with my connection.

Been trying to connect to this PLC for several days without success.

BR,

Linus

Share this post


Link to post
Share on other sites

Hi Linus,

I would start with the computer running CX-programmer. You mentioned that you are able to communicate usb to the PLC. Have you been able to communicate using the Serial port on the computer to the serial port on the PLC?

Note: If your computer does not have a serial port then use a USB to Serial converter. I have used the following with good success.
http://www.ugreen.com.cn/product-681-en.html

CX-Programmer should be able to communicate to the serial port on your PLC. This will prove that the cable is correct. You can then try your program for communication to the PLC. If that is working correctly then connect the PLC port to the raspberry pie serial port and test your program.

 

Regards,

Share this post


Link to post
Share on other sites

Hi Garry,

I have tried with mainly PL2303 based USB to serial converters. 

Tried with this as I was using it with my headless PI but when I tried to connect to the PLC, there is no reply.  I then connected this to a desktop PC and I ended up getting data only going from the desktop to the notebook but not the other way around.

http://www.dx.com/p/waveshare-pl2303-usb-uart-board-type-a-for-raspberry-pi-blue-282359#.Wbk9RtOg-EI

Rather than troubleshooting the convertor, I bought this other convertor yesterday night and did the desktop test first and data went both ways.  Thinking that I will finally succeed, I went ahead to connect to the PLC but then encountered the echo back when connecting with only the serial cable.   When connecting both the usb and serial cable, there is no response from the serial side.

https://biskandar.wordpress.com/2014/11/24/accessing-intel-galileo-board-via-3-5mm-serial-cable/

Using both convertors, I am not able to not able to connect to the PLC using direct online using COM port

4.jpg

Now I am at a loss as to whether it is still a cable issue or something else.

Best Regards,

Linus

Screen Shot 2017-09-13 at 10.24.42 PM.png

Share this post


Link to post
Share on other sites

Hi Linus,

 "I bought this other convertor yesterday night and did the desktop test first and data went both ways.  Thinking that I will finally succeed, I went ahead to connect to the PLC but then encountered the echo back when connecting with only the serial cable."

It looks like you are close to a solution. Connecting to the RS232 port on the PLC involves only the three connection pins. The ground should be the same. 9 - 9. The SD and RD signals can only be one of two ways depending on the pin out of the serial cable from the Pi. 2-3, 3-2 or 2-2, 3-3.

Raspberry Pie - Converter - RS232  to RS232 - Omron CP1L

Regards,

Share this post


Link to post
Share on other sites

Hi Garry,

Managed to finally solve the wire problem.. I searched the manuals for CP1L and found that the pinout for the original wire used by OMRON(images attached) and indeed, this is the correct pin out that managed to solve my communication problem.  The main difference is the straight 2-2 3-3 but also to 9-5 pinout for the ground.  Managed to get this working for PLC-PC.

Will be working to get it working for PLC-RaspPi.  Keeping my fingers crossed. 

Thank you for all you help along the way!!

Best Regards,

Linus

 

Screen Shot 2017-09-20 at 12.37.16 AM.png

Screen Shot 2017-09-20 at 12.33.31 AM.png

Share this post


Link to post
Share on other sites

That is great Linus. 

Congratulations. The raspberry pie should be similar to the PC pinout.

Thanks for the update.

Garry

Share this post


Link to post
Share on other sites

Hi Garry,

I have a new question regarding the programming of another model of PLC.  This time it is an OMRON NX1P2 PLC.  Can I use the same method to communicate with this PLC? ie using host link with C-mode commands to read the addresses on the PLC?

Thank you!! 

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