\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[table]{xcolor}
\usepackage{multirow}% http://ctan.org/pkg/multirow
\usepackage{hhline}% http://ctan.org/pkg/hhline
\usepackage{listings}
%\usepackage{amssymb}
%\usepackage{amsmath}

\makeatletter
\newcommand{\verbatimfont}[1]{\renewcommand{\verbatim@font}{\ttfamily#1}}
\makeatother

\begin{document}

\title{Rig Interface MK2}
\author{M.T. Konstapel}
\date{2023-03-22}
\maketitle

\begin{abstract}
\begin{figure}[ht!]
  \centering
  \includegraphics[width=6cm]{finished-1.jpg}
  \label{fig:cover}
\end{figure}

As an amateur radio operator I like to make contacts all over the world. Besides voice (or phone), I frequently operate digital modes like JS8 or FT8. In my shack I use a bulky home made interface, which I named \textit{Rig Interface}. It works perfectly well, but as I plan to do POTA, or Parks On The Air, I need something more portable. I could buy a commercial device, but where's the fun in that? It is time for an updated design. It is time for \textit{Rig Interface MK2}.
\end{abstract}

\section{The theoretical design}

To use digital modes, the radio has to be connected to the computer. Most modern and not so modern radios have special connectors on the back to make this possible.

\subsection{Signals radio side}

\begin{figure}[ht!]
  \centering
  \includegraphics[width=6cm]{block-diagram_1.eps}
  \caption{signals from radio}
  \label{fig:signals-from-radio}
\end{figure}

The most important signals to connect to the computer are the audio signals from and to the transceiver. On most transceivers these signals are available on the back.

Using the VOX of the transceiver to switch between receive and transmit, it is possible to start the digital journey right now. But a dedicated PTT signal is preferable as the computer can than switch the transceiver into transmit itself. This gives the transmitter time to stabilize before the signal is sent.

A nice to have feature is a key signal. This way the computer can send Morse code messages. Sending Morse code could also be done by generating an audio tone, of course. But some computer programs can take advantage of a dedicated key signal, which is less complicated than generating an audio signal. Another advantage is that when using the key input, there is no frequency offset between the transceiver's VFO and the actual frequency of the cw signal.

Not strictly necessary, but necessary nevertheless is CAT control. This makes it possible to control the radio from the computer. Without it, operating digital modes is a real hassle. You will constantly be turning the frequency dial. And without audio feedback, you are more likely to be off frequency than when operating cw or ssb.

\subsection{Signals computer side}

\begin{figure}[ht!]
  \centering
  \includegraphics[width=\textwidth]{block-diagram_2.eps}
  \caption{signals to computer}
  \label{fig:signals-to-computer_rev1}
\end{figure}

All the signals from the radio have to be connected to the computer. The easiest way is to use the computer's sound card for the audio signals and a USB to serial adapter for CAT control. Apart from the PTT and KEY signals, this is simple and cheap. So that is what I will do, right?

\subsection{Ground loops}

Ground loops can cause headaches. Not physical of course: you don't need a tin head to prevent them. But ground loops can ruin your day by causing interference. Once I even burned a signal cable while troubleshooting a ground loop problem. I disconnected the ground of the power supply and all the current flowed through a signal cable, which got so hot, it burned.

To prevent this from happening in the field, which is even more annoying than when it happens in the shack, I want all the connections between the computer and the transceiver to be galvanically isolated.

\subsection{Bringing it all together}

\begin{figure}[ht!]
  \centering
  \includegraphics[width=\textwidth]{block-diagram_4.eps}
  \caption{block diagram}
  \label{fig:block_diagram}
\end{figure}

All the signals should thus be galvanically isolated. And then they have to be connected to the computer. And preferably in a neat way. Lets use a single USB cable to do this.

The blocks inside the dotted lines are part of the \textit{rig interface}. Two audio transformers and several opto couplers provide the galvanic isolation. A USB sound card takes care of the audio part. A USB to serial adapter translates the control signals from the computer into the needed signals for the transceiver. Because there are two USB devices and we want just the one cable to the computer we need a USB hub. The USB interface of the computer can provide the needed power for the \textit{rig interface}.

\section{The practical design}

\subsection{Audio}

\begin{figure}[ht!]
  \centering
  \includegraphics[width=\textwidth]{schematic_audio.eps}
  \caption{audio section}
  \label{fig:audio_section}
\end{figure}

To isolate the audio signals, two 600$\Omega$ audio transformers are used. The USB sound card can easily drive a $600\Omega$ transformer, but as not all transceiver have a low impedance audio output, they cannot all drive a 600$\Omega$ load. Thus an extra driver stage is added. The downside of this solution is that we need an extra power supply. But as most transceivers have a 13.8V output either available in the DATA connector or as a separate connector, this is not really a problem.

Two potentiometers are added to manually set the receive and transmit levels.

\subsection{Control}

\begin{figure}[htb!]
  \centering
  \includegraphics[width=\textwidth]{schematic_cat.eps}
  \caption{control section}
  \label{fig:control_section}
\end{figure}

To isolate the control signal, four high speed opto couplers are used. When using the 6N137 every speed imaginable is possible. When using the more modest 6N139 speeds up to 100kbps are possible. Which is probably still plenty fast.

These high speed opto couplers need a power supply. But as the audio transformer driver also needs one, we are good.

Transistor Q1 buffers the TxD signal from the transceiver. This is because not all transceivers are capable of driving an LED directly.

The combination of the 74HC04 inverters and the jumpers JP1..JP4 provide the possibility to invert all the signals. This can be handy when a transceiver expects an inverted signal or a computer program insists of inverting the PTT signal. It is also possible to disconnect one ore more signals all together. This can be useful when a computer program doesn't want to play nice with the RTS and DTR signals.

\subsection{Computer interface}

I could design everything from scratch: buy chips, design a PCB and hand solder the components to it. Sure, it has been done before, but the chips are ever so tiny! I choose to go another route: buy of the shelf devices and remove the PCBs from it and use these as ready made modules for my design. I still have to design a PCB, but with these larger modules it will be easier to etch it myself.

\subsubsection{USB hub}

\begin{figure}[ht!]
  \begin{subfigure}[b]{0.32\textwidth}
    \includegraphics[width=\textwidth]{usb_hub.jpg}
    \caption{Digitus USB hub}
    \label{fig:digitus}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.32\textwidth}
    \includegraphics[width=\textwidth]{pcb_usb_hub.jpg}
    \caption{internal PCB}
    \label{fig:hub_internal}
  \end{subfigure}
   %
  \begin{subfigure}[b]{0.32\textwidth}
    \includegraphics[width=\textwidth]{schematic_usb_hub.eps}
    \caption{schematic}
    \label{fig:hub_schematic}
  \end{subfigure}
  \caption{USB hub}
  \label{fig:usb_hub}
\end{figure}

The USB hub I use is a strange little beast. It's a spider from Digitus. Because of its design, the actual PCB is very small. And that's exactly what I need. And after removing the PCB you end up with some nice USB cables ready to use in other projects. 

\subsubsection{USB sound}

\begin{figure}[ht!]
  \begin{subfigure}[b]{0.32\textwidth}
    \includegraphics[width=\textwidth]{usb_sound.jpg}
    \caption{Manhattan sound card}
    \label{fig:sound_card}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.32\textwidth}
    \includegraphics[width=\textwidth]{pcb_usb_sound.jpg}
    \caption{internal PCB}
    \label{fig:sound_card_internal}
  \end{subfigure}
   %
  \begin{subfigure}[b]{0.32\textwidth}
    \includegraphics[width=\textwidth]{schematic_usb_sound.eps}
    \caption{schematic}
    \label{fig:sound_card_schematic}
  \end{subfigure}
  \caption{USB sound}
  \label{fig:usb_sound}
\end{figure}

Any sound card will do. I use one from Manhattan. It has a small PCB which can be easily extracted from its housing.

\subsubsection{USB serial adapter}

\begin{figure}[ht!]
  \begin{subfigure}[b]{0.32\textwidth}
    \includegraphics[width=\textwidth]{usb_serial.jpg}
    \caption{USB serial adapter}
    \label{fig:serial}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.32\textwidth}
    \includegraphics[width=\textwidth]{pcb_usb_serial.jpg}
    \caption{internal PCB}
    \label{fig:serial_internal}
  \end{subfigure}
   %
  \begin{subfigure}[b]{0.32\textwidth}
    \includegraphics[width=\textwidth]{schematic_usb_serial.eps}
    \caption{schematic}
    \label{fig:serial_schematic}
  \end{subfigure}
  \caption{USB serial}
  \label{fig:usb_serial}
\end{figure}

The USB serial adapter is a standard module based on the CH340 chip. Because I need both RTS and DTR signals and only RTS is available, I modified the PCB. I cut the trace that runs from the CTS pin to the chip and soldered a wire from this CTS pin to pin 13 (DTR) of the CH340. Now the DTR signal is available on the pin labeled CTS.

\begin{figure}[ht!]
  \begin{subfigure}[b]{0.49\textwidth}
    \includegraphics[width=\textwidth]{pcb_usb_serial_mod.jpg}
    \caption{top side}
    \label{fig:pcb_serial}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.51\textwidth}
    \includegraphics[width=\textwidth]{usb_serial-bottom.jpg}
    \caption{bottom side}
    \label{fig:pcb_usb_serial_mod}
  \end{subfigure}
  \caption{USB serial modification}
  \label{fig:usb_serial_mod_overview}
\end{figure}

Make sure you don't use an adapter based on the CH340E, as this particular chip does not have a DTR output.

\subsubsection{Selector DTR/RTS}

\begin{figure}[htb!]
  \centering
  \includegraphics[width=5cm]{schematic_selector.eps}
  \caption{control section}
  \label{fig:selector_section}
\end{figure}

In order to select whether the DTR pin acts as PTT or KEY and whether the RTS acts as KEY or PTT, I added two extra jumpers. This way, even the most suborn computer programs can be used.

\section{The build}

\subsection{Preparing the modules}

The PCBs from the three modules (hub, sound card and serial adapter) must be removed from the devices itself. Remove the connectors and wires from the printed circuit boards and clean the boards with isopropyl alcohol. You end up with some nice looking modules ready to be soldered to the board of the rig interface.

If not done already, do the modification on the serial adapter (see chapter \textit{The practical design}).

\subsection{Mounting the modules}

The modules are mounted to the computer interface PCB with pins coming from a standard 2.54mm pitch male header strip and solid wires. The wires to J4 and J5 (which are stranded wires) are soldered directly on the USB hub pads (see figure \ref{fig:pc-interface-board}). Which of the four ports are used is not important.

\subsection{Fixing mistakes on revision 1}

\subsubsection{Serial}

\begin{figure}[ht!]
  \begin{subfigure}[b]{0.49\textwidth}
    \includegraphics[width=\textwidth]{mod-overview.jpg}
    \caption{overview}
    \label{fig:mod-overview}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.51\textwidth}
    \includegraphics[width=\textwidth]{mod-detail.jpg}
    \caption{detail}
    \label{fig:mod-detail}
  \end{subfigure}
  \caption{fixing the cock-up}
  \label{fig:modification}
\end{figure}

I mixed up the TxD and RxD signals. A simple solution is to cut the TxD and RxD lines coming from the serial adapter on the computer interface board. This is shown in figure \ref{fig:modification}.

When using the rig interface board revision 2 of the \textit{rig interface MK2}, the modification of the computer interface board is not needed.

\subsubsection{Maximum CAT speed}

When using 6N139 opto couplers, the rise time of the output signals are to low to achieve a speed of 38400 bps. Pull up resistors R7 and R8 where added on revision 2. This resolved the problem.


\subsection{The PCB stack}

\begin{figure}[ht!]
  \begin{subfigure}[b]{0.49\textwidth}
    \includegraphics[width=\textwidth]{pcb_rig_interface.jpg}
    \caption{rig interface}
    \label{fig:rig-interface-board}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.51\textwidth}
    \includegraphics[width=\textwidth]{pcb_pc_interface.jpg}
    \caption{computer interface}
    \label{fig:pc-interface-board}
  \end{subfigure}
  \caption{the finished boards}
  \label{fig:the_boards}
\end{figure}

\begin{figure}[htb!]
  \centering
  \includegraphics[width=9cm]{finished-1.jpg}
  \caption{the finished rig interface MK2}
  \label{fig:fished-product-1}
\end{figure}

\begin{figure}[htb!]
  \centering
  \includegraphics[width=9cm]{finished-2.jpg}
  \caption{the finished rig interface MK2}
  \label{fig:fished-product-2}
\end{figure}


The \textit{rig interface MK2} is made up of two boards which stack together. A PCB interconnect routes the signals from one board to the other. The PCBs are double sided and can easily be made yourself by either the toner transfer method \footnote{https://www.meezenest.nl/mees/printplaat\_etsen.html} or with a light sensitive PCB base material. You can of course cheat and use a PCB prototype service.

Solder all the components to the boards and than mount the two board together using four spacers.

\subsection{Housing}

There are endless ways to enclose the \textit{rig interface MK2}. You can buy a universal enclosure or 3D print one. I simply sandwiched the boards between two pieces of acrylic glass.

\clearpage

\appendix

\section{Schematic rig interface}

\begin{figure}[h!]
  \centering
  \includegraphics[width=19cm, angle=90]{rig_interface_mk2_rev2_schematic.eps}
  \caption{full schematic of the rig interface revision 2}
    \label{fig:figure_b}
\end{figure}

\section{Schematic computer interface}

\begin{figure}[h!]
  \centering
  \includegraphics[width=19cm, angle=90]{pc_interface_mk2.eps}
  \caption{full schematic of the computer interface}
    \label{fig:figure_c}
\end{figure}

\section{Bill of materials}

\begin{figure}[htb!]
  \centering
  \includegraphics[width=\textwidth]{rig_interface_mk2_bom.eps}
  \caption{BOM rig interface mk2 revision 2}
  \label{fig:bom_rig_interface}
\end{figure}

\begin{figure}[htb!]
  \centering
  \includegraphics[width=\textwidth]{pc_interface_mk2_bom.eps}
  \caption{BOM computer interface mk2}
  \label{fig:bom_pc_interface}
\end{figure}

\clearpage

\section{Component placement}

\begin{figure}[htb!]
  \centering
  \includegraphics[width=\textwidth]{rig_interface_mk2-component_placement.eps}
  \caption{Component placement rig interface mk2}
  \label{fig:component_placement_rig_interface}
\end{figure}

\begin{figure}[htb!]
  \centering
  \includegraphics[width=\textwidth]{rig_interface_mk2_rev2-component_placement.eps}
  \caption{Component placement rig interface mk2 revision 2}
  \label{fig:component_placement_rig_interface_rev2}
\end{figure}

\begin{figure}[htb!]
  \centering
  \includegraphics[width=\textwidth]{pc_interface_mk2-component_placement.eps}
  \caption{Component placement computer interface mk2}
  \label{fig:component_placement_pc_interface}
\end{figure}

\clearpage

\section{Open source hardware and software}
All the design files are published under free licences and are available via my website: https://www.meezenest.nl/mees or can be found in my git repository: https://git.meezenest.nl/

\vskip 1cm

\copyright 2023 M.T. Konstapel

\vskip 1cm

This document is published under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

\begin{figure}[ht!]
  \begin{subfigure}[b]{0.1\textwidth}
    \includegraphics[width=\textwidth]{oshw-logo-outline.eps}
    \label{fig:7}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.2\textwidth}
    \includegraphics[width=\textwidth]{gpl-v3-logo.eps}
    \label{fig:8}
  \end{subfigure}
  \begin{subfigure}[b]{0.25\textwidth}
    \includegraphics[width=\textwidth]{by-sa.eps}
    \label{fig:9}
  \end{subfigure}
  \label{fig:fully-build}
\end{figure}

\end{document}
