Serial Over LAN (Wireless) for 3D Printers

Fecha de publicación: Jul 28, 2013 12:58:5 AM

If you want to make your RepRap 3D printer wireless capable there are many aproaches to choose. The obvious first is using Octoprint on a RaspberryPi (or Cubieboard, Beagleboard ,etc). Another is to install the host software on a computer and remoting with VNC. These will work but what if you are happy with the "fat" Repetier-Host and their super interactivity or want to use the power of your main computer to do the slicing in one shot?

The control board of your printer "talks" the serial protocol natively and has a converter to USB (eg FTDI chip) to permit hooking with a modern computer. If you can skip this converter probably you can use a direct serial to wireless module like Xbee or 3DR Radio. As I do not want to mess with my tiny Printrboard the final option is some kind of "Serial Over LAN" trick. This means we need to encapsulate the byte stream your computer sends/receive to the printer's microcontroller inside the IP protocol and transmit over the WiFi infrastructure.

Googling i've found some hints and personally verified that this approach works very well. I'm going to describe the procedure to making this work with a Windows 7 Computer and a RaspberryPi.

RaspberryPi Side

Yor RaspberryPi obviously must have a Wireles USB network interface connected to your home router. I'm not covering that setup here.

You need the socat utility. Install with:

sudo apt-get install socat

Hook your printer to a USB port of your RaspberryPi (running Raspbian probably) and turn it on. If you look at the /var/log/message log, you will see the new /dev/ttyACM0 serial port creation.

Then, execute the following command.

sudo socat TCP-LISTEN:5577,reuseaddr file:/dev/ttyACM0,raw,echo=0

Windows Side

As Repetier-Host program does not send the byte stream to IP sockets, we need to emulate a "COM" port and convert the data to IP. For this task nothing better that com0com project. You need to get the null modem driver and the com2tcp utility, available at the project download page. Read the install instructions, driver will require some changes in windows and reboot. The com2tcp utility must be manually copied to C:\windows\system32.

Then you need to create an "in" port and "out" port with the com0com's Setup program. I've choosen COM30 and COM31 respectively. Read the documentation.

Repetier-Host needs to talk to the "in" port, so configure it to COM30 and set the "Reset on connect" option to Disable.

Under a CMD.EXE terminal execute this command (replace the raspberry IP address with yours):

com2tcp --ignore-dsr \\.\COM31 192.168.100.50 5577

This command reads from the "out" port and sends to the data to the specified IP/Port

Final

Now you can press the Connect button on Repetier-Host and your printer should act as normal, but wirelessly!

Do not close the socat and com2tcp programs before finishing your work!

Probably socat can be started automatically by some udev rules and com2tcp can be encapsulated in a windows service. That will be a task for another post :)