From charlesreid1

Kenwood All-Mode Multi-Bander TS-570S radio:

KenwoodTS570S.jpg

TS-570 has a straight-through female 9-pin RS232 to female RS232 cable [1].

Manual

The following information is from the TS-570S manual.

Serial Port (Hardware)

Radio Serial Port Photo

There is an RS-232 serial port on the back of the radio, pictured below:

KenwoodTS570S Serial.jpg

Radio Serial Port Pinout

The radio's manual gives the pinout for this port, and some information on how to communicate with the radio using the serial connection:

KenwoodTS570S SerialSchematic1.png

Here is a table with information about which pins go where, and the function of each pin. There are basically five pins used:

  • Two pins are TX/RX pins for transferring data between the computer and the radio.
  • Two pins are on/off switches for the TX/RX functionality (i.e., these have to be supplied with voltage for the radio and the computer to be able to transmit signals back and forth).
  • One pin is a ground pin.

KenwoodTS570S SerialSchematic2.png

KenwoodTS570S SerialSchematic3.png

Computer Serial Port

I am connecting to the Kenwood radio's serial port using a MacBook Pro. I used a USB to RS-232 cable. Unfortunately, it was a USB to male RS232, and the radio also had a male RS232 connection in the back, so I used some tiny female-female wires to connect each of the individual pins:

Serial to RS232.jpg

On the MacBook, I will be using Python together with the pyserial library [2] to send serial commands out and over the wire.

Serial Communication (Software)

The pyserial library can be used to communicate with devices using a serial port/protocol. The pyserial library is available on Github: https://github.com/pyserial/pyserial

Serial Command Format

The Kenwood TS-570S manual details the pinout of the serial cable, and what hardware connections need to be made. But it also covers the specifics of how to send commands from a computer to the radio. The commands are classified as follows:

  • Computer control commands
    • Input command (input to the transceiver)
      • Set command (sets particular condition)
      • Read command (reads an answer)
    • Output command (from the transceiver)
      • Answer command (transmits a condition)

Command syntax is as follows:

FA     00007000000   ;
^^     ^^^^^^^^^^   ^^
                    Terminator
       Parameters
Alphabetical command

For example, the following is a Set command:

FA00007000000;

The prefix FA will set the frequency (F) of variable frequency oscillator A (VFO A) to 7 MHz.

Likewise, the following is a corresponding Get (or Answer) command, asking for the frequency of VFO A:

FA;

When this command is sent, the radio will return the following:

FA00007000000;

This indicates that the frequency of VFO A is set to 7 MHz.

Alphabetical Commands

The following is a table of alphabetical commands given in the appendix of the TS-570S user manual:

KenwoodTS570S AlphaCom.jpg

A good "Hello World" command is the ID command, which returns the model number of the radio. I'll be using this to demonstrate basic serial communication with the TS-570S.

Finding the Serial Device

No matter what library we happen to choose to communicate with the serial device, we will need to specify the device file associated with the serial device. This will be a file in the /dev/ folder that shows up when we plug in the USB-RS232 cable.

Finding the USB to Serial Device

Trying to find the device file associated with the USB-RS232 adapter.

I started by unplugging the USB-RS232 cable from the laptop's USB port, shutting down the radio, and running the command /bin/ls -1 /dev/ > /tmp/noradio.

Next, I plugged the USB-RS232 cable into the laptop's USB port, turned on the radio, and ran the command /bin/ls -1 /dev/ > /tmp/withradio.

I then looked for any devices that showed up when I plugged in the USB-RS232 cable into the USB port:

$ vim -d /tmp/noradio /tmp/withradio

No luck - there were no devices that showed up when I plugged in the serial cable.

Installing Drivers

My next step was to try installing a driver for the USB-RS232 cable from the manufacturer (in this case, CableMatters). Their drivers page [3] provided a link to a Mac driver. Specifically, the page with the driver listed it as "Smart I/O > USB to UART/Serial/Printer > PL2303 Mac OS X Driver Download".

I downloaded version 1.6.0, which was a zipped up pkg file. It was only 94 KB, but required a restart. oooookay, annoying driver software, let's reboot.

Finding the USB to Serial Device Redux

After installing the driver, trying again.

Unplug the USB-RS232 cable, power off the radio, and list all device files:

$ /bin/ls -1 /dev/ > /tmp/noradio

Power on the radio, plug in the USB cable, and list all device files again:

$ /bin/ls -1 /dev/ > /tmp/withradio

Now look for devices that showed up when the radio was turned on and plugged in:

$ vim -d /tmp/noradio /tmp/withradio

BINGO!!! We have our USB serial device showing up when we plug in the USB-RS232 device. Two device files show up when the USB-RS232 cable is plugged in:

/dev/cu.usbserial
/dev/tty.usbserial

Pyserial Library

An excellent tutorial on the essentials of the pyserial library is here: http://www.zilogic.com/blog/tutorial-pyserial.html

To install pyserial:

$ pip install pyserial

Now you can import pyserial by adding import serial to your Python code, and create a serial device corresponding to the device file.

$ python
Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
>>> ser = serial.Serial('/dev/tty.usbserial')
>>> ser
Serial<id=0x1018750d0, open=True>(port='/dev/tty.usbserial', baudrate=9600, bytesize=8, parity='N', stopbits=1, timeout=None, xonxoff=False, rtscts=False, dsrdtr=False)

Start by setting the timeout, so if you aren't sending the commands correctly you don't have to sit around and wait forever:

>>> ser.timeout=1

Not working... probably because RTS and CTS are not enabled. So enable them:

>>> ser.rtscts=True

Check with this: http://www.tldp.org/HOWTO/Serial-HOWTO-19.html

Twisted Library

The Twisted library also allows for asyncronous communication with a serial device. Twisted is an event-driven Python library. Examples are provided with the Twisted documentation.

Serial MouseMan example: https://twistedmatrix.com/documents/16.2.0/_downloads/mouse.py

Serial NMEA GPS example: https://twistedmatrix.com/documents/16.2.0/_downloads/gpsfix.py

All examples: https://twistedmatrix.com/documents/16.2.0/core/examples/index.html

Links

Manual for the TS-570S transceiver: http://www.manualslib.com/manual/86121/Kenwood-Ts-570d-Ts-570s.html


Flags