RS-232 communication

  • Would it be possible to do RS-232 communication with the Duet? I have an accessory that uses RS-232 and I would like to control it with the Duet in synchrony with the printing.

  • administrators

    Do you actually mean RS232 with its 12V signal levels, or do you mean async comms?

  • @dc42 I mean RS-232 with the 12V signal levels. I was told by the manufacturer of the peripheral device that I would likely need extra circuitry to increase the signal voltage to the proper levels. So assuming I have this external voltage increase circuitry, then can I use the Duet plus this simple voltage increasing circuitry to do RS-232 signaling?

  • administrators

    If you don't have a PanelDue connected and you are prepared to modify the firmware to send whatever commands your other device needs at the correct times, then you could drive your RS232 device from the PanelDue serial port via a RS232 transceiver that works with 3.3V logic signals levels. Make sure that your transceiver doesn't put more than 3.3V into the receive data pin of the PanelDue port - use a voltage divider if necessary.

  • I will be using a PanelDue. I will be modifying the firmware to send the serial commands at the correct times as you said.

    Is there a way to implement software serial? Or some other way?

  • Could I use UTXD1 and URXD1 on the ESP_COMMS port? (I can solder headers on there). Or are those used by the wifi module?

  • administrators

    @jml said in RS-232 communication:

    Could I use UTXD1 and URXD1 on the ESP_COMMS port? (I can solder headers on there). Or are those used by the wifi module?

    They are used to program the WiFi module and also to report status back from the WiFi module for debugging purposes.

  • @dc42 Thanks. Could I convert a GPIO pin to do software serial?

  • administrators

    Software serial could be used if the baud rate was low enough. The best option would be to create an RTOS task to do it.

    If you don't need to use the SharedSPI function (used to interface to PT100 and thermocouple daughter boards, and to support an external SD card), you could modify the firmware to use that USART in async mode instead, and connect to it using the temperature daughter board connector.

  • @dc42 Thank you for the suggestions. Option1: software serial with RTOS task. Option2: hijack the temp daughter board connector.

    I don't use any daughter boards (I use the dyze extruder). I don' think Dyze requires the daughter boards, so option 2 may be an option.

    Thank you for the suggestions!

  • @dc42 When you say SharedSPI is used to support an external SD card, that does not refer to the microSD card that attaches to the Duet, right? I saw a SD card slot on the panel Due, is that what you are referring to?

  • administrators

    I am referring to the SD card on PanelDue. The build-in SD card does not use SPI, it uses a much faster 4-bit wide interface.

  • A different approach, maybe you'll like it, maybe not 🙂


    • @jml has a device that does true RS232, electrically +12 to -12V that convey serial bits.
    • That device will RECEIVE commands FROM the Duet (but not send them, correct?)
    • A PanelDue will be used, thus occupying its port on the Duet.

    I can see two ways to do this that seem (to me) much easier than the firmware mods to implement SharedSPI or similar.

    Question: @jml Are the "event triggers" that will send to your device, are those something that can be timed well enough by embedding M117 commands (write to console) into the G-Code?

    If yes:

    Build a small device, probably Arduino (or ATtiny) based, that plugs into the Duet USB port, and filters console messages for particular "key" start bytes, and passes the rest of the message to the device. M117 MAGIC123 xxxxxx results in xxxxxx going to the device.


    Passively "split" the 3.3V "Send" pin on the PanelDue port, again passing this to an Arduino or ATtiny that "filters and translates" for the receiving RS232 Device. It would have to "understand" the packet format that conveys a console message to the PanelDue. Otherwise, the same concepts as above.

    Slightly more complex code in the outboard translator, but leaves the USB free.


    If No: (M117s not sufficient):

    Same hardware concept as above, tap into either USB console or Duet 3.3V transmit pin that sends to Panel.
    Also modify Duet firmware to send messages to console at correct times. Again, fixed header to let "filtering" device pick up only correct messages.


    This would seem to minimize changes to the Duet, by putting a little of the work in an outboard device. Could potentially simplify taking on new releases of Duet firmware... Thoughts?

  • @danal Interesting ideas. I like the M117 command option best.

    Your ideas give me an idea. I could use the I2C output of the Duet to communicate with an external device (Arduino or ATtiny) which will output the serial commands.

    Another idea - perhaps there is a I2C to Rs-232 chip out there already - this would save me some time. I found this interesting thing:

    Apparently it can be used for converting I2C to RS232 ... not sure if I'll have to step up the voltage or not ... we'll see. But this chip might be easier than the other options.

  • @jml And what about M118 ... If I have nothing connected to USB, then I could connect my rs232 device to the usb (through a voltage converter) and use M118 P1 S"Message"

    I'd like to keep the USB port open though, but I'll remember this as a backup.

Log in to reply