Skip to content

SW_DevCH340TTY

Rolf Obrecht edited this page Feb 7, 2023 · 12 revisions

Device Module "CH340TTY"

Module Information

System

System Comments
RPi OK
PC Linux OK
PC Windows OK
Mac OK

Dependencies

Python
Module
Install Anaconda
pyserial pip install pyserial conda install pyserial

Command Line Arguments

USB-Serial-Adapter (CH340-chip) with base teletype (without dialing device):

-Y TTY
--tty TTY

USB-Serial-Adapter (CH340-chip) with TW39 teletype (pulse dial):

--ttyTW39 TTY

USB-Serial-Adapter (CH340-chip) with TWM teletype (keypad dial):

-M TTY
--ttyTWM TTY

USB-Serial-Adapter (CH340-chip) with V.10 teletype (FS200, FS220):

-V TTY
--ttyV10 TTY

Example Windows:

telex.py -W COM3

Example Linux:

telex.py -W /dev/ttyUSB0

Config File Parameter

Param Default type/range Description
portname "/dev/ttyUSB0" string serial port used (COMx: in Windows)
baudrate 50 50, 75, 100 Baud rate
bytesize 5 5 … 8 # of Databits
stopbits 1.5 1, 1.5, 2 # of stopbits
coding 0 0,1,2,3 0:ITA2=CCITT2, 1:US, 2:MKT2, 3:ZUSE (see txCode.md)
loopback true false / true if true, sent characters are removed from receive buffer
loc_echo false false / true if true, echo back all characters received from teleprinter
inverse_dtr false false / true If true, use inverted signal
inverse_rts false false / true If true, use inverted signal

Description

Using an adapter board (or adapter cable - for V.10) based on the chip CH340 the device is detected as normal (virtual) serial interface. In Windows the device is shown as 'COMx:'. In Linux it is shown as '/dev/ttyUSBx'.

With the Python library "PySerial" all necessary settings can be done to handle 50 baud, 5 data-bits and 1.5 stop-bits. Also, the handshake pins RTS and DTR can be set by this library.

RTS/CTS Hack for TW39

To decode the TW39 protocol correctly, it is necessary to detect a permanent low and high level on the RXD pin. Neither the CH340 chip nor the drivers drivers can handle that. The hack is to use a separate input pin (CTS) to detect the state of the line.

Therefore the pin RXD has to be connected to pin CTS of the CH340 chip.

Most PCBs with the CH340 chip do not route the CTS pin to a connector. Use a thin wire to connect the pins 3 and 9 directly on the chip.

Note: There are several USB/Serial adapters that use different chips. Be aware that ONLY adapters with CH340 chip are compatible with this project. Only the CH340 chip supports a baud rate of 50 Bd!

Implementation

TODO

Clone this wiki locally