Author Topic: Raspberry Pi as Serial to Ethernet adapter  (Read 23374 times)

Vitor

  • Newbie
  • *
  • Posts: 20
    • View Profile
Raspberry Pi as Serial to Ethernet adapter
« on: August 07, 2015, 06:23:59 AM »
Here is the result of one of mine experiments.
This uses the Raspberry to connect a PLC with a serial port trough a ethernet network to be accessed by AdvancedHMI.
Follow the link:

https://dl.dropboxusercontent.com/u/67765472/Instrutions-Software.zip
« Last Edit: August 07, 2015, 12:08:25 PM by Vitor »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #1 on: August 09, 2015, 06:27:32 PM »
For those who would like to experiment but don't have a Pi, you can use a Windows based PC/laptop with a PLC connected to its real COM port or to a USB to RS232 adapter (I tried 2 different USB2RS232 adapters: Prolific PL2303 and Belkin F5U109).

Server/Client software that I used is SerialToIP GUI found here: http://sourceforge.net/projects/serialtoip/?source=directory
A good side of this software is that even RSLinx, with the help of com0com and SerialToIP, can connect to a remote PLC by using its DF1 driver thus providing access to RSLogix to the same PLC.
I tried bunch of other different serial to net applications and none of them worked to provide transparent access to a PLC.

Here is what you will need all together:

Server side (with PLC):
1) PLC connected to a serial port on a PC/Laptop (real COM port or USB2RS232 adapter) and you will need to know which COM port number it is as well as Baudrate
2) SerialToIP GUI program set as a server (check the attached picture)
3) This PC/Laptop can be connected to a network through a WiFi or LAN port and you will need to know its IP address

Client side (with AHMI):
1) PC/Laptop connected to the same network through wired or wireless connection
2) com0com program to create a set of paired COM ports (one used in SerialToIP and the other in AHMI)
3) SerialToIP GUI program set as a client pointing to the server's IP address (check the attached picture)
4) AHMI project with DF1Com driver

I have com0com paired ports as COM1-COM7 and have used COM1 in SerialToIP while COM7 was used in DF1Com1 AHMI driver (check the attached picture).

"Socket port" setting of the SerialToIP program I left as default 8282 on both server and client computers.
All COM ports were set to 38400/N/8/2 for use with MicroLogix 1000 Analog PLC (specific to my setup).
SerialToIP only requires Baudrate and doesn't pay attention to other settings, but in your case these other settings need to be correct so AHMI can communicate with the PLC.

This is definitely a way to connect any serial based PLC to ethernet network.

Another freeware program that could possibly be used is Serial-TCP by CommFront: https://www.commfront.com/collections/device-server-serial-tcp-ip
« Last Edit: March 04, 2019, 08:34:13 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #2 on: August 12, 2015, 01:49:43 PM »
A good news for those who don't have a PLC either.

In previously mentioned setup with 2 PCs, RSEmulate 500 can be used instead of a PLC.

You can always use files from this topic: http://advancedhmi.com/forum/index.php?topic=516.0
« Last Edit: September 11, 2015, 12:46:24 AM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #3 on: September 11, 2015, 01:06:35 AM »
For those who might be interested in SerialToIPGUI VB Net version with some additional features, here is the link to a complete solution:

https://www.dropbox.com/s/76c4b3gwy0gp1h5/SerialToIPGUI%20VBNet.zip?dl=0

Attached here is a picture of 2 instances of this program on the same computer. Server and Client communicating together over loopback IP address(127.0.0.1) while connecting 2 serial based applications (or it could be an application and a device). 2 sets of com0com paired ports were used as well.

Far simpler way of having these 2 serial based applications talk to each other, could have been done by using just 1 set of com0com paired ports and nothing else, but I wanted to show the packets that they were exchanging as well as GUI interface which was modified from original.

All credits go to the original author of the SerialToIPGUI software (the link to which is provided in one of the previous posts).

EDIT: This VB Net version was updated in December 2016 and the attached picture doesn't reflect those updates.
« Last Edit: January 18, 2017, 11:17:03 PM by Godra »

ignacio200

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #4 on: December 31, 2015, 03:04:46 PM »
Hi everyone there!

This is Ignacio from Argentina!

I´m a C# developer with some experience in networks (Cisco CCNA), Win & Linux servers, Winforms, Webforms, SSQL Server and PosgreSQL, but I´m new to the HMI world!

Now, I´m starting some developing in order to communicate and control an Unitronics PLC.

I have started to try a lot of different things to connect in a secure way from Internet to the PLC.

I found SerialToIP very helpful, but I couldn´t make it work with the Unitronics PLC. I´m working hard on make it with com0com and hub4com.

I was planning to improve SerialToIP in order to add some authentication and SSL encryption in order to connect to the PLC from anywhere with full simplicity.

I´ve tried to contact the developer of SerialToIP but unit now I haven´t receive a response. Have you? I´ve seen Godra VB.Net version and it´s great!

And, could you please introduce me in a short way to this project about using a Raspberry Pi to connect to a PLC please? What is your scenario?

Thank you very much and have a happy new year!
Ignacio.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #5 on: January 02, 2016, 10:39:51 PM »
Ignacio,

You would have to follow scenario as it is in Vitor's experiment in order to see how Raspberry Pi works with PLC.

I cannot make any suggestion on how to modify SerialToIPGUI to have the new features and also work with Unitronics PLC.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #6 on: October 09, 2016, 12:49:09 PM »
Here is the result of one of mine experiments.
This uses the Raspberry to connect a PLC with a serial port trough a ethernet network to be accessed by AdvancedHMI.
Follow the link:

https://dl.dropboxusercontent.com/u/67765472/Instrutions-Software.zip

nice!
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #7 on: January 18, 2017, 05:45:51 PM »
I did some crazy thing today. using only one PC.

Here is the details:


1.    Run SerialtoIPGUI as server  using rs232-USB adapter COM8.
2.   Create a virtual pair COM13-14 using Com0Com.
3.   Run SerialtoIPGUI as client : set IP address and COM13
4.   Run AAHMI with driver SerialDF1forSLCMicroCom using COM14.
5.     It worked!!

My plan is to use SerialtoIP command line version on the Pi with mono ( atleast that what is said from the web site)
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #8 on: January 18, 2017, 06:42:11 PM »
You should be able to skip steps 2 and 3 and run AHMI with SerialDf1overTcpForSLCMicroCom and set its IP address as 127.0.0.1.
This way you can see how this driver works.

Since SerialToIPGUI program is not perfect, your current setup should be more responsive and have less communication lag.

As it appears, when the SerialToIPGUI server and client are connected to each other then the communication is continuous.
If either server or client is used alone then the program is cycling between disconnect/re-connect.
« Last Edit: January 18, 2017, 11:06:57 PM by Godra »

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #9 on: January 18, 2017, 07:33:16 PM »
Good idea!! Thanks Godra.

it looks like I will have a few choices on the Pi: SerialToIP , Ser2net, Route_Serial_TCP_UDP
« Last Edit: January 18, 2017, 07:47:22 PM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #10 on: February 19, 2018, 07:43:41 PM »
bachphi,

Have you tried using Mono serial DF1 driver from this topic: https://www.advancedhmi.com/forum/index.php?topic=1975.0

Archie might be introducing serial drivers compatible with Mono in the next patched version so a feedback from those who have tried the above mentioned drivers could help him pay attention to and avoid possible bugs/issues.

Also, for those who might be interested, here is a link to slightly different SerialToIPGUI VB Net version:

https://www.advancedhmi.com/forum/index.php?topic=2592.0

« Last Edit: December 27, 2019, 06:09:55 PM by Godra »

Bad Sector

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #11 on: March 04, 2019, 09:02:06 AM »
Does anyone have the original instructions?  I'm wanting to use the pi zero as ethernet to serial interface for some MicroLogix processors.   But the first post instructions are on a dropbox that the link is no longer valid for.  If anyone can assist, I'd appreciate it.

Thanks,
Bad Sector

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #12 on: March 04, 2019, 08:30:13 PM »
Hopefully Vitor might update the link but for now, I have attached the original pdf file with his instructions.

The other 2 files that were inside his zip file are:
     - com0com_W7_x64_signed.exe (for this file, check this topic: https://www.advancedhmi.com/forum/index.php?topic=1961.0)
     - Serial-TCP.msi (there is a link to this file in the 2nd post of this topic)
« Last Edit: March 04, 2019, 08:41:09 PM by Godra »

Bad Sector

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #13 on: March 06, 2019, 08:28:55 AM »
Thank you!  This will get me going.  Much appreciated.

Vitor

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Raspberry Pi as Serial to Ethernet adapter
« Reply #14 on: March 07, 2019, 01:15:04 PM »
Hello Jeremy

I dont have those instructions and i've closed my dropbox account.
But i think i can help you.
Open a terminal on Raspberry:
sudo apt update
sudo apt upgrade -y
sudo apt install ser2net -y

with your serial-usb adapter attached try find out wath port is with:
sudo dmesg | grep tty*  or  ls /dev/tty*

next let'sedit the configuration file of ser2net:
sudo nano /etc/ser2net.conf

the only line that should be uncommented is like this:
4000:raw:120/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT

Where:
4000 - is a tcp port on the raspberry not blocked for a firewall and also the same port to use on the PC.
raw - is the format of the data (other options could be for example telnet).
120 - is te timeout in seconds.
ttyUSB0 - is an example and must be that port you find above.
9600 - is the baud rate, must adjust to you PLC.
8DATABITS -  the length of each block of information.
NONE - is the parity, others optios = ODD or EVEN
1STOPBIT - how the information block ends

To make ser2net autorun every time the raspberry is turned on, do this:
sudo nano /etc/rc.local

Add the following above exit 0

/usr/local/sbin/ser2net -n -c /etc/ser2net.conf

Now on the PC you need:
com0com
Serial-TCP or RealTerm (https://sourceforge.net/projects/realterm/)

The configuration of Serial-TCP or RealTerm is very simple, just match the tcp port. Both, Raspberry ant th PC must be on the same network or bridged by a gateway.

The connection to AHM is made by com0com.

PLC <=> ser2net <=====> Serial-TCP <=> com0com <=> AHMI

When i published in the forum, in 2015, i have used to connect a Micrologix 1000 via a TP-Link Wi-fi AP to a PC over 400m (1,312ft). But before i have tryed also with a Micrologix 1200, with DF1 and Modbus protocols and worked well without flaws.

Any questions?