1

I have a PC upstairs running my 3D printing slicer program (Simplify 3D). In the basement, I have several USB-enable 3D printers. My PC upstairs has a USB-to-RS-232 serial adapter. The serial side of that USB-to-Serial adapter connects to the Serial port of a Moxa Nport 6150 RS232-to-Ethernet protocol adapter. I get those Moxa devices for free when they break at work and then fix them for a couple of dollars.

The other side of the Moxa connects to my home computer network router. In the basement I can plug another Moxa into an ethernet cable on my home network and the serial RS232 output I need to connect to the Micro-USB jack of the 3D printer. How can I use an Arduino Nano (or Uno or Mega if required) to convert the RS232 data to the USB input of my 3D printer?

So I have PC->(RS-232)->[MOXA(RS-232)->Moxa(Ethernet)]->Router->[Moxa(Ethernet)->Moxa(RS-232)]->[Arduino(RS-232)->Arduino(USB)]->3D Printer(USB)... How can I get the Arduino to do that function? Items within [ and ] brackets are single devices performing a protocol conversion.

I know people use Raspberry Pi's and a program called OctoPrint to remotely control their 3D printers but I get the Moxas for free and Uno's or Nanos are dirt cheap. RPi's are more expensive and for several 3D printers it can start adding up. Any ideas? enter image description here

6
  • 1
    The Nano can't take RS-232: it takes logic-level serial. You will need some kind of level shifter, like the MAX232 chips. – Edgar Bonet Apr 28 at 18:08
  • Hmm.. something like that MAX232 chip is the part I replace in the MOXA's to fix them. If I took the serial output of the Moxa through a MAX232 chip, then the TTL serial to the RX and TX of the Arduino... that's where I get lost. – ABNormal Apr 28 at 18:12
  • Or can I just connect the RX and TX TTL data from the MAX232 and connect it directly to the Micro-USB jack? I found a MicroUSB pinout diagram but it shows the data as "D+" and "D-". Not sure how that correlates to TX and RX. Also, somewhere I am going to have to set the baud rate of whatever does the conversion to the 115200 speed of my 3D printer. Thats also why I think I need a Microcontroller? But I can set the serial baud rate on the Printer-side Moxa to 115200, then send that RS232 to the MAX232 but now I need a UART chip to convert the RX and Tx to D+ and D- ? Is that right? – ABNormal Apr 28 at 18:32
  • 1
    RX and TX directly to D+ and D- is a no go. Different protocol, different voltage levels and different functions of the pins. – chrisl Apr 28 at 20:10
  • 1
    If the printer is an RS-232 protocol with a built-in USB converter, then one solution would be to open up the 3D printer, hack the RS-232 signal off of the UART, and connect the moxa directly to the printer's internal RS-232 lines. The arduino RS-232/USB converter only works one way - the USB is the host side, not the device side. – J... Apr 29 at 11:07
6

Its not as easy as you think. An Arduino will not be enough for connecting the USB of the 3D printer. The USB protocol is strictly divided into slaves and masters. A USB(us) has exactly one master, which totally controls, what the slave can do. The slave itself cannot do much of its own.

Your 3D printer is a USB slave device. That enables a USB master (like a computer) to control it. The Arduino is also a USB slave device. If you connect both, you have a USB connection without a master. Nothing will happen. So you need to implement a USB master on the Arduino, which can handle the UART communication; all in software. That is generally possible, but I wouldn't recommend it. Also you definitely need extra hardware, because D+ and D- on USB are also electrically totally different from the TTL lines RX and TX (and also from the RS232 lines). They work differentially. So you need extra hardware to do that.

The easiest way with an Arduino would be to buy a USB host shield. With that you may be able to build, what you want.

But I would dispute, if this really makes sense. The cheapest USB host shield for Arduino, that I could find at amazon is around 10€, plus the price for an Arduino and the hassle of getting it all to work. A RaspberryPi Zero W only costs 10€. If you don't want to use wifi, you can add a USB to Ethernet adapter. And depending on the used software and its installation you might even be able to handle multiple printers with only one Pi (I use the Repertier Server, which has the ability to control multiple printers, I think). (Though depending on the number of printers and the resulting load you might wanna step up the game to a full Pi4)


There might be an additional way, depending on your printers. The printers microcontroller board might break the TX and RX pins out for you. Then you could connect the Arduino to them, no need for USB in that case. But that might not be an option. If the used microcontroller has a direct USB interface, there are no RX and TX pins to break out.

2

The Nano, like the Uno, has an onboard serial ↔ USB converter. If you can get a logic level serial from the Moxa, then you can use the Nano to convert that to USB:

  1. Load a do-nothing sketch in the Nano
  2. Connect the Moxa TX to the Nano's Tx through a 1 kΩ resistor, and the Moxa RX to the Nano's RX.

Yes, the second step looks backwards. The reason is that the labels RX and TX refer to the ATmega328P that runs your sketches on the Nano. Internally, the pin labeled RX is connected (through a resistor) to the TX pin of the serial ↔ USB converter, and this is thus the pin you want to connect the Moxa's RX. And similarly for the pin label TX (it's the RX of the onboard converter).

Step 1 is important because you do not want the 328P to open its serial port. The resistor is needed for the short time when the 328P is running the bootloader, and has its serial port open.

3
  • 1
    +1 Jumping RESET to GND is typically what I do, although putting the do-nothing sketch on there is a good idea also. With it held in reset, the bootloader doesn't get an opportunity to play with the serial lines either. – timemage Apr 28 at 18:36
  • That's great! So I already have some of these RS232 to TTL converter boards I bought from Amazon: smile.amazon.com/gp/product/B07PFB4MHR/… I can then take the TX from that converter board to the TX of the Nano (running something like the Blink sketch) and the RX from the converter board to the RX of the Nano and then connect the Mini-USB of the NANO to the Micro USB of my 3D printer. – ABNormal Apr 28 at 19:19
  • @ABNormal connect the Mini-USB of the NANO to the Micro USB of my 3D printer. No, that can never work. USB is a host-driven protocol. You can't just connect two devices together at the business end without a host. – J... Apr 29 at 11:11
1

There's not enough information to provide a general solution at this time. As chrisl rightly says, the 3D printers are expecting a connection from a host. That host connection depends on whether the USB-serial interface inside the printer is supported. These are typically FTDI or WCH (QinHeng) chips, and would need the appropriate system driver for each type. This would be hard to implement on a USB host shield for Arduino.

Most 3d printers are, in essence, an Arduino inside. The typical 8-bit controller on the vast majority of 3d printers uses a very similar ATMega microcontroller. Some newer machines use 32-bit ARM microcontrollers, which are typically 3.3 V logic compared to the Arduino's (typical) 5 V. To add a standard RS-232 port you'd need to find the RX, TX, GND and Vcc points on each printer controller board and connect the right pins of your RS-232 to TTL converter boards to those points. This would bypass the USB ports on the printers entirely.

You might experience issues with flow control and buffering with multiple ports sending from one PC and Serial-Network-Serial latency. Marlin-style Gcode printers (= most filament printers that aren't Makerbot or Flashforge, approximately) don't use flow control: the printer sends back ok when it's ready for the next command. If your serial ports send data too slowly, the printer will pause and print quality may suffer. 3d printers don't need a really fast serial connections (under 20 kbit/s per printer, if using Gcode) but they need the data when they're ready to print.

OctoPrint can be quite an expensive option. The minimum supported platform is a Raspberry Pi 3b+ (+ power supply, SD card, USB cable, case, ...) dedicated to each printer. While you can run a very cut-down OctoPrint on a Raspberry Pi Zero, the author does not recommend it, and you have to click through an Unsupported Configuration: Use at your own risk dialogue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.