playduck / plotter-utils

Roland DXY-1150 Plotter Utilities
3 stars 0 forks source link

How to connect to serial interface of Roland DXY-1150? #1

Closed OrangeTux closed 1 year ago

OrangeTux commented 1 year ago

I recently bought a Roland DXY-1150 and I'd like to control it myself. Unfortunately, I can't get it working using this RS 232 cable I bought.

Here's a snippet that should toggle the pen using the RD-GL I instructions PD and PU

image

image

import time
import serial

with serial.Serial(
    port="/dev/ttyUSB0",
    baudrate=9600,
    bytesize=serial.SEVENBITS,
    parity=serial.PARITY_EVEN,
    stopbits=serial.STOPBITS_ONE,
    rtscts=True,
    timeout=3
) as ser:
    # Pen Down
    ser.write(b"PD;")
    time.sleep(1)

    # Pen Up
    ser.write(b"PU;")

Dip switch 2-8, 2-9 and 2-10 control the serial settings. 2-10 and 2-9 are off and 2-8 is on.

image

I'm wondering whether I bought the right cable. The data sheet states the device communicates over RS-232C. The Internet teaches me that RS-232C is the same as RS-232. However, the readme of this project indicate otherwise:

The Plotter uses the RS-232-C implementation. This requires much greater voltage levels than modern transmitters are capable of producing.

Do I have the wrong cable? Do you've any suggestions?

playduck commented 1 year ago

Something to try first would be using standard 8N1: 8 Data bits, No Parity, 1 Stop Bit (you can do this by simply omitting the bytesize, parity and stopbits options). Also worth a shot is trying it with rtscts=False, just in case that's causing any problems.

The modern standard for RS-232 is described by TIA-232-F. The actual protocol is identical to the original RS-232-C version from 1969. However, the voltage levels did change. Matter of fact, the SO question you linked mentions this in the second reply below ;). On paper they should be compatible, but who knows what the cables really implement.

I can't tell you what version of the standard your cable implements or what driver IC it uses. The cable could likely be the problem. Only way to verify for sure is by looking at the cable's output with an oscilloscope. The cable I initially used looked very similar to yours and it didn't work.

I solved this by frankensteining an adapter: Image

It's not perfect, but it gets the job (mostly) done. It consists of:

This monstrosity actually works. I can use it to send HPGL to the plotter. Only downside: The RTS and CTS signals are not transmitted. This means, if you send too much data at once, the plotters buffer can overflow, potentially ruining the plot. A simple hack to overcome this is to simply send data slower by just waiting a bit for each command. That's not perfect but it works. (This can be done with the python inter_byte_timeout option)

The real solution would be to build a device capable of both translating Tx and Rx as well as CTS and RTS. I think the repo already includes a KiCad board for this purpose (Designed by @SenpaiSimon). We never gotten around to building and testing it though.

OrangeTux commented 1 year ago

Many thanks for the response! Unfortunately, changing serial settings didn't work. So I've to build a Frankenstein connector.

Thanks again!

OrangeTux commented 1 year ago

I works! Many thanks for your help. I bought the hardware and also had to set rtscts to False. For anyone else stumbling at this issue in the future, here is my code. SP2 instructs the plotter to select pen in slot 2. Followed by SP1 which selects the first pen.

import time

import serial

with serial.Serial(
    port="/dev/ttyUSB0",
    baudrate=9600,
    bytesize=serial.SEVENBITS,
    parity=serial.PARITY_EVEN,
    stopbits=serial.STOPBITS_ONE,
    rtscts=False,
    timeout=1,
) as ser:
    ser.write(b"SP2;")
    time.sleep(1)
    ser.write(b"SP1;")