2016年5月8日日曜日

Wireless audio and remote rig control

This post describes using wifi for (1) remote control of a receiver and (2) wireless streaming of the receiver's audio to a remotely-located computer. This post is merely an outline rather than a step-by-step guide, intended to show one combination of computer technologies that can solve the problems of wireless receiver control and wireless audio streaming.

The problem is that I want to place an antenna and receiver on a balcony where RF reception is good. Then I want to wirelessly transmit that audio to my radio room, which is a far-away room with poor RF reception. The reason for wireless transmission is that I don't want to run any cables -- no antenna cables, no power cables, no audio cables -- from the indoor radio room to the outdoor balcony. I want a completely self-contained balcony radio station (with no cables snaked across rooms and onto the balcony) that can wirelessly transmit its audio to my radio room.

Furthermore, I of course need the ability to remotely tune the balcony-sited radio, from my operating position in the radio room.

This problem has already been solved by by hams connecting their rigs to the Internet with appropriate control software. But rather than investigating existing solutions I did it all based on the technologies I was familiar with and that I had on hand.

Here's how I solved it.

  1. The balcony fortunately has a 100V AC power outlet, so I don't need to run anything off of batteries.
  2. On the balcony, I have an commercial Yaesu transceiver whose audio output goes into the microphone input of a laptop PC, called the controller PC.
  3. The controller PC also has a USB-serial cable that connects to a CAT cable for PC-based tuning of the Yaesu transceiver.
  4. The controller PC runs under the Linux OS and the fldigi program is used to control the tuning frequency of the receiver (via hamlib) and to provide a waterfall display of the rig's audio.
  5. The PC uses the JACK audio system software for real-time routing of audio input and output sources.
  6. In addition to enabling the radio-to-fldigi audio connection, JACK allows me to additionally duplicate/redirect the radio's audio signal into a separate digital data stream for network streaming.
  7. The ffmpeg program is used to capture the duplicated audio signal from JACK and to encode and stream the audio via RTP over a local-area wifi network.
  8. Due to the great distance between the balcony and the radio room, the controller PC cannot make a direct wifi connection to the client PC in the radio room. Therefore, I had to set up a wifi router located at an intermediate position between the controller PC and the client PC. The wifi router is not a dedicated unit, but is instead a re-purposed old PC (running Linux) with two wifi cards. Theoretically I should have needed to setup a network bridge and/or some Network Address Translation in order to allow network traffic to cross from one wifi card to another, but it worked without any explicit bridge or NAT setup. I'm not complaining. :-)
  9. On the client PC in the radio room, I run the VLC media player to play the RTP audio stream from the controller PC. When using ffmpeg as the streaming source on the controller PC, the streaming connection is reliable, latency (the time lag between audio output being generated at the radio, and the final audio being heard on the client PC in the radio room) is somewhere between 1 and 2 seconds, and (importantly) the latency does not increase over time. (Some other streaming solutions I investigated, such as using VLC as the stream source and/or using HTTP as the transport, had higher latency that would increase over time.)
  10. In order to control the radio tuning from the radio room, I run a VNC client on the client PC in order to remotely access the desktop of the controller PC, which gives me a real-time display of the fldigi program running on the controller PC. Though remote desktop displays are never animated as smoothly as the original desktop display, in this case the remote desktop display on the controller PC is updated fast enough such that even the scrolling waterfall display is usable.
  11. Finally, the antenna on the balcony is a broadband active loop antenna (requiring no tuning). I found that it was quite noisy when powered from the same AC adapter used to power the radio, but it became much quieter when powered off of a separate battery. So currently I'm running it off of a separate rechargeable laptop battery.

The result is that I can tune the radio from my radio room by clicking/scrolling/typing in the fldigi program, and I can hear the audio with only 1-2s delay. Not perfect, but it's as close as I'm going to get. And there are no ugly wires routed through windows or doors to the outdoor balcony.

Since the whole solution above is a home-rolled audio-over-wifi solution, I next can play with various audio quality parameters like

  • Codec
  • Bitrate
  • Sound card (maybe investigate using an external USB soundcard).


Future plans include

  • Devising some hardware and software to allow the controller PC to control relays
  • Using those relays to drive motors for remote tuning of a small transmitting loop antenna
  • Investigating how to allow the controller PC to control a regenerative receiver (either via motors turning knobs, or by direct generation of control voltages for tuning and regeneration). This would then allow the indoor-located client PC to remotely and wirelessly control a balcony-sited, homebrew regenerative receiver (a problem I previously investigated and solved with a CAT-5 cable).