Monday, June 18, 2018

Sideband in GNURadio for an FL2K VGA dongle transmitting WSPR with the Weaver method

Ross, VK1UN, and I have been tinkering with the low cost FL2K VGA dongle which can be used as a high speed digital to analog converter capable of generating RF.

As the WSPR spots shown here indicate, Ross has been successful. This is a VGA dongle simply matched into a dipole transmitting a WAV file of WSPR tones from Melbourne to Tasmania.

Along the way we've both been learning about GNURadio (or really the graphical interface called GNU Radio Companion or GRC). It's a fascinating tool.

We've been trying to figure out how to generate modulated RF in a form that can be output by the dongle. Our approach has ended up as one of reading the modulation audio in from a WAV file and writing a sample file that is then sent to the dongle using the fl2k_file tool.

Doing things like filtering can be very slow in GRC when you're trying to generate the full RF waveform. Sometimes it has taken me an hour to generate a few seconds of RF.

Last weekend I discussed this with Peter, VK2EMU, while we were on a bush walk and he suggested the Weaver method of SSB generation. Ross has built this in GRC and it works in real time!


Download the GRC file from here. Note you'll need to update the input wav file source.

The generated upper sideband looks pretty good.


The Weaver method of single sideband generation starts by mixing the audio spectrum with a carrier in the middle of that bandwidth. This is quite different to traditional methods that mix up to RF and then filter out a sideband which is much more computationally intensive.

Thursday, June 14, 2018

Australian Government reviewing broadcasting into the Asia Pacific

If you have an interest in having Australia resume broadcasting into the Asia Pacific region again, like we did up until budget cuts resulted in an end to Radio Australia's shortwave services in January 2017, I urge you to respond to the review being conducted by the Department of Communications and the Arts along with the Department of Foreign Affairs and Trade.

It closes on the 3rd of August 2018 at 17:00 AEST.

The terms of reference are very broad, seeking to assess the reach of Australia's media in the region, and covering many distribution platforms - they mention television, radio and online.

The striking thing that's changed in recent years is the increased output from China which has in some cases taken over frequencies that used to be used daily by Radio Australia (which of course they have every right to do).

Technical things have changed too:
  • Digital Radio Mondiale has been rolled out in India (although receivers are still not very good)
  • Smartphones and mobile data are much more available in the region
  • Use of home satellite receivers has declined globally as more content moves online
  • Use of shortwave AM radios has diminished but it's interesting to note that there are many new models of radio available.
There are many benefits arising from broadcasting into our region from Australia, perhaps the best defence against Fake News is just the provision of consistent, quality, regular news. Tecsun Radios Australia has a great article on the value of shortwave in the region. 

You can find out more by joining the Facebook group "Supporters of Australian Broadcasting in Asia and the Pacific".

The Strategist has a nice piece by Graeme Dobell backgrounding some of the politics.

I had an opportunity to talk about this on ABC RN Drive with Patricia Karvelas. Former Pacific correspondent Jemima Garrett was interviewed the next night on RN Drive.

There has been some additional coverage:


My tiny camper van came with a Pioneer car radio that has shortwave. I notice that in the afternoons Radio New Zealand belts in to Sydney and could be mistaken for a local AM station.


Let me know if you see more stories I've missed.

Saturday, June 09, 2018

Fascinating talk by Hans Summers

Thanks to Bill's Soldersmoke blog for this tip. At the "Dayton" (not actually there any more) hamvention this year, Hans Summers gave a terrific talk about his distain for the archaic NE602 based transceivers and how it's time to upgrade the design using modern methods.

I recommend, grabbing the slides and then playing the Ham Radio Workbench podcast episode. You might like to seek in 1hr 20 minutes to where the talk begins. Hans has also published a paper with more detail.

Hans describes in detail how to generate quadrature signals from an Si5351 clock generator. Great stuff.

Saturday, June 02, 2018

FreeDV digital voice story on WIA broadcast via FreeDV

The recursion appeals to me, here is a story about the new FreeDV 700D mode complete with comparison with SSB. I heard the story via the relay over FreeDV 1600 from Adelaide.


Interestingly I find digital voice decoded is more intelligible in a small external speaker than in headphones.

After the broadcast relay, Mark, VK5QI conducted a callback on 700D with stations VK3PR, VK3RV, VK5DGR and VK5APR. We often got perfect signals despite some interesting selective fading such as this on VK3RV.


The broadcast on FreeDV is at 10am Sunday Adelaide time on 7.177MHz.

700D uses much less bandwidth than sideband, here's a waterfall comparison David VK5DGR sent me this morning.


One thing to note (it confused me) is that FreeDV uses the same sideband as normal voice on each band. This is unlike other digital modes which generally use upper sideband everywhere.

Installing FreeDV 1.3 on Ubuntu or Debian

Not everyone likes to build from source. You can download and install FreeDV 1.3 (which you need for the new 700D mode) as follows:


Download these files:

http://launchpadlibrarian.net/372108070/libcodec2-0.8_0.8-2_amd64.deb
http://launchpadlibrarian.net/372171996/freedv_1.3-1_amd64.deb

In a terminal go to the Downloads folder and:

sudo dpkg --install libcodec2-0.8_0.8-2_amd64.deb
sudo dpkg --install freedv_1.3-1_amd64.deb


Wednesday, May 30, 2018

Generating RF with an osmo-fl2k VGA dongle

I've continued to play with the cheap ($10) USB VGA dongles which can be used as a fast digital to analog converter. Working with Ross, VK1UN, we've been climbing the learning curve of  GNURadio Companion to generate the samples we need to transmit modulated RF.

The fl2k_file command line tool needs a file with 8 bit signed samples. These are clocked out at 100M samples per second by default.

To get started I've written some pretty inefficient c to write out suitable files.

First here's a function that writes a suitable simple sine wave carrier. (I use 80 samples per cycle to get RF on 1.25MHz).

#include
#include
#include

const char *outFileName = "samples.dat";

void makeCarrier(int samplesPerCycle) {
    FILE *outfile = fopen(outFileName, "wb");
    int8_t byte;
    for(int sample = 0; sample < samplesPerCycle; sample++) {
double current_radian = M_PI * sample * 2 / samplesPerCycle;
        double carrier_sin_value = sin(current_radian);
        byte = (int8_t)(carrier_sin_value * 127.0);
        printf("%f, val = %f, byte = %d\n", current_radian, carrier_sin_value, (int)byte);
        fwrite(&byte, sizeof(byte), 1, outfile);
    }
    fclose(outfile);
}

Double sideband can be generated by simply multiplying samples of a modulating sine wave by the samples of the carrier.

// Produces an double sideband signal suitable for fl2k_file
void makeDsb(int samplesPerCycle) {
    // ratio of the carrier to the modulating sine wave
    int ratio = 3000;

    FILE *outfile = fopen(outFileName, "wb");
    // make sure we get enough samples for a full wave of the modulation
int totalSamples = samplesPerCycle * ratio;
    for(int sample = 0; sample < totalSamples; sample++) {
double carrier_radian = fmod((M_PI * sample * 2 / samplesPerCycle),(M_PI * 2));
        double mod_radian = fmod((M_PI * sample * 2 / samplesPerCycle) / ratio,(M_PI * 2));
        
//printf("%03d carrier r = %f, mod r = %f\n", sample, carrier_radian, mod_radian);

        double carrier_sin_value = sin(carrier_radian);
        double mod_sin_value = sin(mod_radian);
        
        double am_sample = carrier_sin_value * mod_sin_value;
        //printf("%f\t%f\t%f\n", carrier_sin_value, mod_sin_value, am_sample);

        int8_t byte = (int8_t)(am_sample * 127.0);
        //printf("byte = %d\n", byte);
        fwrite(&byte, sizeof(byte), 1, outfile);
    }
    fclose(outfile);
}

AM requires the modulating audio (ranging from -1 to +1) to have 1 added to it and the result divided by 2 before again multiplying by samples in the carrier sine wave.

// Produces an AM'd signal suitable for fl2k_file
void makeAm(int samplesPerCycle) {
    // ratio of the carrier to the modulating sine wave
    int ratio = 3000;

    FILE *outfile = fopen(outFileName, "wb");
    // make sure we get enough samples for a full wave of the modulation
int totalSamples = samplesPerCycle * ratio;
    for(int sample = 0; sample < totalSamples; sample++) {
double carrier_radian = fmod((M_PI * sample * 2 / samplesPerCycle),(M_PI * 2));
        double mod_radian = fmod((M_PI * sample * 2 / samplesPerCycle) / ratio,(M_PI * 2));
        
//printf("%03d carrier r = %f, mod r = %f\n", sample, carrier_radian, mod_radian);

        double carrier_sin_value = sin(carrier_radian);
        double mod_sin_value = (sin(mod_radian) + 1.0) / 2.0;
        
        double am_sample = carrier_sin_value * mod_sin_value;
        //printf("%f\t%f\t%f\n", carrier_sin_value, mod_sin_value, am_sample);

        int8_t byte = (int8_t)(am_sample * 127.0);
        //printf("byte = %d\n", byte);
        fwrite(&byte, sizeof(byte), 1, outfile);
    }
    fclose(outfile);
}

To look at the output file, to see if it's reasonable, I wrote a utility to read the bytes, spit out a text file with the numbers in it, feed that into gnuplot and look at the graph. Great but I've just had a better idea, the audio editing software Audacity can import files and setting it to signed 8 bit PCM works well and the waveform is easy to see.


Here's how AM looks:


The file is transmitted with fl2k_file simply as:

fl2k_file samples.dat

The output AM can view viewed on a CRO.


And shown on an SDR, here it is in SDR#. You can see the carrier and two nice sidebands.


On an AM radio, I hear a strong carrier with nice sounding tone.

I realise this is all very basic stuff but it's been great to learn a bit about it. The real power tool in all this is GRC (GNU Radio Companion).

Here's how I generate an amplitude modulated carrier suitable for sending to the fl2k dongle. (Click to enlarge it so you can read it).


The GNU Radio flow document is here.

Note that GRC always defaults to complex and in this case we want floats. This will run indefinitely and fill up your disk so just run for a few seconds and then open the file in Audacity to have a look at the waveform.

To avoid local AM stations I've been sending it with "fl2k_file -s 80e6 am_out.dat" which puts it on about 900kHz on the broadcast band.

Here's a GRC flow graph that shows how I read a WAV file with audio (ELO don't bring me down), resample it up and produce AM'd carrier to transmit. (Again click to read it).


Here's how it sounds on an AM radio.


Anyone know how to do this but with single side band?

Update: Ross transmits decodable WSPR

Transmitting a captured audio output from WSJT-X on AM, Ross has been able to decode the transmission.


And again but with double sideband modulation:


Next challenge is single sideband modulation.

Monday, May 28, 2018

Sydney - Adelaide via FreeDV 700D. Better than SSB

It's 4:30pm Sydney time and I've just had a digital voice contact using David, VK5DGR's new 700D FreeDV mode. Sydney to Adelaide is about 1,100km so a good distance for 7MHz. My local noise level here is not great at about S6 and yet we were able to have a pretty good contact on 40m.


Version 1.3, which includes the new 700D mode, is available as a pre-built binary for macOS, Linux and Windows. I grabbed the latest development source and it builds according to the README on Ubuntu 18.04 just fine.

My set up is a USB headset mic and a Signalink USB radio interface. All works well although David suggests that decoded digital voice might be more readable via a speaker than via headphones.

We chatted back and forth in digital mode pretty well and then switched to SSB to compare. I was certainly putting out more power on SSB and I suspect David was too but to me the digital copy was as good as or slightly better than SSB. This is a fantastic milestone to reach!

Signal notification service

As there isn't a huge amount of FreeDV activity at the moment, there is a fantastic feature that can monitor and send an email if there is five seconds of sync. You run a python script included in the source and give it your email credentials. This script listens on UDP port 3000 and if you enable this in FreeDV's options screen it will email you when someone's on the channel. (It only sends one email a minute so you don't get swamped).

This is a great idea and should be a standard for other digital mode clients.

How I sound

We had a three way contact today on 7.177 between Peter, VK3RV in Sunbury Victoria, David, VK5DGR in Adelaide and myself, VK2TPM in Sydney. David recorded one of my transmissions and sent me the off air recording which can be decoded in the FreeDV app. We could barely hear each other in SSB. Here's how it looks and sounds:


Note that there are command line tools distributed with the FreeDV source code including freedv_tx and freedv_rx which will encode and decode all the way from voice wav through to modem audio.

Here's how you decode a captured file:

freedv_rx 700D vk2tpm.wav - | sox -t raw -r 8000 -e signed-integer -b 16 - decoded.wav

Note that the output file is a 16 bit mono file with 8kHz sample rate.

Check out the FreeDV site for much more information and give me a call on 7.177Mhz.

Monday, May 21, 2018

Home made ubitx box

Inspired by the excellent ubitx.net web site, I have bent a larger box so that the front panel ergonomics are improved. I added a nice tuning knob with finger depression and added a microphone pre-amp, compressor and noise gate board. The tuning knob is on its own on the right (not cramped with the volume control and mic socket) and with the new software it's a pleasure to spin up and down the dial.


I'm just using the mic amp board as it comes with a dynamic mic and levels look good but there's the option to add trimmers for both the compression and noise gate level. I have an output gain control knob in there.


My rudimentary metal work skills are slowly improving and I'm quite proud of the nibbled hole for the LCD display in this one. My nibbler has been sticking, which was frustrating, but a little WD-40 did the trick. I learned from a recent Adam Savage video that WD stands for "water displacement".