Transmitting an efficient AM Stereo radio signal – Part 2

Before we conquer the AM broadcasting world with our newly efficient AM stereo signal, perhaps it might be good to start at the beginning and build a transmitter in GNURadio that will transmit a nice conventional AM mono broadcast signal.

Hopefully, you have GNU Radio installed and you’ve started the gnuradio-companion application. This presents you with an almost blank canvas across the screen with a whole list of ‘blocks’ on the right-hand side with which to drag onto the canvas and create your flowgraph.

I’m actually going to transmit the AM signals live over the air and receive them using my main amateur radio transceiver. However, it doesn’t matter if you don’t have a HackRF ONE or similar radio transmitter; you can save the output to a raw data file ‘as if’ you were transmitting the AM signal, and later play that file back into our AM receiver flowgraph ‘as if’ you were receiving it.

Since I’ll be transmitting a real signal, I have to ensure that:

  1. My amateur radio transmitting licence is current. If you love radio then it’s worth studying for the radio amateur exam and obtaining a licence. Radio amateurs are the only licensees that are allowed to build and transmit radio signals using ‘home-brew’ equipment, within strict rules.
  2. The audio I’m going to transmit contains legally appropriate content for my licence. I’ve recorded an audio file of me voicing my callsign, the word “testing”, and the words “left channel” or “right channel” only on the left or right stereo channel.
  3. I transmit only safely inside a designated amateur radio band. I’ll be using 51.000 MHz and about 1mW of radio signal power. 51 Mhz is half-way between the band limits of 50 and 52 MHz (the 6m band) which will ensure I am way inside the limits of the band even if I ‘splatter’ signal a bit. 1mW is going to give me about 100 metres range at best – perfect for not annoying my fellow amateurs.

Here is what the audio file looks like in the free audio editing software application called Audacity. Importantly, I’ve saved the file in a 16-bit WAV format with a Project Rate (Hz) of 48000 samples per second:

Audacity view of test audio

After a short pre-amble where I announce my callsign you can ‘see’ me saying ‘left channel’ then ‘right channel’ on one or other of the two stereo channels. This is followed by a 1 KHz tone, first on the left then on the right channel. This repeats for a total of 5 times. GnuRadio will then loop playback of the file from the beginning. The result is a continually transmitted test.

Now to the flowgraph for the AM Mono transmitter. Let me walk you through it:

Mono AM Transmitter

  1. I start a new GNURadio flowgraph
  2. I click on the Options block and give it the name Mono AM Transmitter with ID: monoAMtx
  3. The existing variable samp_rate value is changed to 48000
  4. I click the magnifying glass symbol at the top of the window (search) and type ‘Variable’ to quickly find the variable block, and drag that block into the flowgraph. I change the ID to ‘transmit_rate’ and give it the value 2000000 (2 million). This value is one of the ‘best working’ values for HackRF ONE transmitter as we’ll see later.
  5. I search ‘WAV’ and drag the Wav File Source to the flowgraph. I change ‘N Channels‘ to 2 (for stereo) and add the path to the stereo test audio file.
  6. Since I’m transmitting in mono I search the Add block. Having dragged it into the flowgraph, I click on the left (upper) output pin on the Wav file source then click immediately on the upper pin on the Add block, which causes an arrow to appear connecting the two pins. I do the same with the lower pins. However, I notice the resulting flow arrows are red;  this is because the default ‘number type’ for such blocks is ‘Complex’. Clicking on the Add block allows me to change various settings – so I change the IO Type from Complex to Float. The pins change from blue to orange and the arrows are no longer red. This results in the two channels being added together to create a single mono audio channel.
  7. AM broadcast radio has a maximum audio bandwidth of 5KHz, so I locate the Low Pass Filter block and set the cutoff freq to 5000 and transition width to 100. This means that the filter will cut out any audio frequency above 5KHz from my audio file, over a range of 100 Hz (so from approx 4.95 KHz to 5.05 KHz). You might think I should choose 0 Hz or 1 Hz for the transition; however, such small values use much more CPU as the mathematics have to be more precise. Having a larger transition width uses up less computer power. Finally, I change the FIR Type to Float->Float (Decimating).
  8. I then search out the Signal Source block. This signal source will provide a carrier signal so that conventional AM radios can demodulate the audio. More on this later but for now I change the Frequency from its default of 1000 (1 KHz) to 0. That seems a strange thing to do. Surely the carrier signal must have the value of the transmission frequency? Actually no. If we did that, the amount of computer power necessary to create such a signal on 51 MHz would be enormous and make for an unreliable radio signal. Usefully the HackRF ONE is able to sort this out in its hardware when we come to set its block up. For now, we are working in the world of ‘radio baseband’ which tends to centre around 0 KHz. This block is generating a signal (it isn’t DC) you’ll just have to bear with me! I also change the Output Type (from Complex) to Float.
  9. Next, I find the Float to Complex block. I attach the Low Pass filter to its upper pin and the Signal Source to its lower pin. Complex numbers are numbers with two values: a real value and a so-called imaginary value. By connecting the audio to the real (upper pin) and the signal source to the imaginary (lower) pin, the result is an amplitude modulated baseband radio signal.
  10. Now to set up the transmitter: I find the Osmocrom Sink block and set its sample rate (SRS) to ‘transmit_rate‘ (without quotes) which is the variable I created in step 4. I set the CH0: Frequency (Hz) to 51000000 – that’s exactly 51.0 MHz. The HackRF ONE will take our baseband signal and transmit on this frequency. I also set RF Gain to 0 to turn off the HackRF’s transmitter amplifier so the signal doesn’t go too far (if you set this value to 10 it turns the amplifier on and you can cover a large area depending on the size and efficiency of your transmitting antenna. Only values 0 and 10 (off and on) are noticed by the HackRF).
  11. I locate the Rational Resampler block. I set Interpolation to ‘transmit_rate’ and Decimation to ‘samp_rate’ (both without quotes). This block will then upconvert the sample rate from 48000 to 2000000 in our case. I join this block to the Osmocrom Sink and Float to Complex blocks. Why didn’t I use the 2000000 sample rate all the way through? The rule here is that you should work with the least amount of samples per second that is workable. The mathematics processed by each block is conducted on smaller amounts of data and thus uses less computer power. Whilst the HackRF ONE can work with the lower number of samples per second, it doesn’t seem to do it very well in my experience, with glitches occurring. 2000000 just seems to work smoothly.
  12. In order to visualise the transmission, I find the QT GUI Frequency Sink and QT GUI Waterfall Sink and connect them to the output pin on the Float to Complex block.
  13. Finally, I tune my AM radio to exactly 51.0 MHz, click the green triangle at the top of the GNURadio window to execute the flowgraph… and I’m on the air.

Next: Notes on the AM signal and then – let’s go stereo.