What a view. . .

What a view. . .

Saturday, December 20, 2014

pyFmRadio - Radio Broadcast Data System (RBDS) & Radio Data System (RDS)

I decided to add one last bit of functionality to my first Software Defined Radio (SDR) project - pyFmRadio.  There happens to be a low bit-rate digital signal hidden away in the FM spectrum known as Radio Broadcast Data System (RBDS) also known as Radio Data System (RDS) outside the United States.  I added a receiver for this signal to pyFmRadio.

The RBDS signal operates at 1187.5bps and if you account for the embedded block error correction code you wind up at a data rate of 730bps (1187.5 * 16/26).  What is neat about this signal is that it carries some metadata about the radio station and the current broadcast (song, artist, DJ, etc).  A handful of car radios display this data.  Apparently it is/was more prevalent in Europe than the US.

I chose to add this functionality because I wanted to learn a little bit about the mechanics of decoding a (albeit primitive) digital signal.  Some highlights of the signal include pulse-shaped BPSK modulation, Manchester coding, and cyclic block error correction coding,

Spectrum Details

Below is a cartoon image of a broadcast FM radio station's demodulated spectrum.  Off to the right, centered at 57KHz, is the RBDS (RDS) signal.  Note, 57KHz happens to be the third harmonic of the pilot tone.  This comes in handy when demodulating the signal.  The bandwidth of the RBDS signal is approximately 4.8KHz.

Cartoon Illustration of FM Spectrum Single Sideband

Below are two images from a real demodulated FM station highlighting the RBDS signal.

FM Station After Demodulation
Zoom in on RBDS Signal From Above Plot

Modulation Details

The carrier frequency of the RBDS signal is locked to the third harmonic of the 19KHz pilot tone at 57KHz.  You can see this in the above plots.  The RBDS signal is centered at 57KHz.  The signal is also phase locked.  According to the RBDS standard, the signal could also be phase locked w/an offset of 90 degrees.

The RBDS spectrum shown above is the product of a pulse-shaped BPSK signal.  The pulse shaping applied to the signal is that of a root raised cosine filter (RRC).  The root raised cosine filter is commonly used in communication systems on both the receive and transmit side.  The filter helps to bandlimit the signal and when combined with a RRC filter in the receiver, creates a raised cosine filter that reduces the inter-symbol interference (ISI) of the communications channel.  Below is a picture of the pulse-shaped BPSK RBDS signal in the time domain.

Magnitude of RBDS Signal in Time Domain

Receiver Details

The first step of an RBDS receiver is to perform the carrier and subcarrier demodulation.  First the carrier is FM demodulated.  Then the pilot tone is tripled and used to down-mix the subcarrier.  Next the resulting signal is low-pass filtered and decimated using an efficient polyphase implementation.  What is left is a baseband modulated signal.  This entire process is detailed in the image below.

Carrier and Subcarrier Demodulation

The next step in the receiver is baseband demodulation.  This step involves matched filtering, symbol synchronization, carrier synchronization, and differential Manchester decoding.  Data bits are the output. The image below illustrates this process.

Baseband Demodulation

First up in baseband demodulation is matched filtering.  The basebanded signal is match filtered using a root raised cosine filter.  Since the transmitted signal was also filtered using a root raised cosine filter, the overall result is that of a raised cosine which helps mitigate inter-symbol interference.  Below are images of the root raised cosine matched filter impulse response, the filter frequency response, and the RBDS signal after matched filtering.
Root Raised Cosine Impulse Response
Root Raised Cosine Frequency Response
Match Filtered RBDS Signal

Next the receiver performs timing recovery also known as symbol synchronization.  The receiver must know where to sample the match filtered signal to recover the symbol bits.  Nominally, an RBDS signal has a symbol rate of 2375 symbols/sec.   At the 25KHz rate of the basebanded signal, this corresponds to ~10.5 samples per symbol.  In the image directly above there are peaks and valleys.  The peaks represent symbol times.

A magnitude based symbol synchronization technique known as an "Early-Late" algorithm was chosen to perform the synchronization.  Such a method does not require carrier synchronization prior to symbol synchronization. The image below below illustrates a symbol synchronized state where only peaks are selected.  The red circles represent the samples selected for each symbol.  There are approximately 10.5 samples between each of the circles.  The output of this process is 2375 symbols/sec.
Match Filtered RBDS Signal With Symbol Synchronization

Symbol synchronization is followed by carrier synchronization.  While the signal was previously basebanded (nearly basebanded) by triple the pilot tone, there may still exist a small frequency offset and phase offset that prohibits demodulating the BPSK signal.  If the receiver attempted to convert the sampled symbols to data bits prior to carrier synchronization the process would fail.  This is easily observed by looking at a constellation diagram of the signal prior to carrier synchronization.
Unlocked Constellation Diagram

Removing these offsets is accomplished by a variation of a Costas loop.  The loop implementation is shown in the baseband demodulation diagram above.  Once the Costas loop has synchronized to the carrier, the BPSK signal can be properly decoded.  Constellation diagrams after synchronization are given below.  The first diagram shows the behavior of the receiver at the beginning stages of synchronization.  Notice the "swirls" while the loop acquires synchronization.  Once the loop is locked (carrier synchronized), the constellation diagram looks like the second.
Carrier Locking Constellation Diagram
Carrier Locked Constellation Diagram

The last step before data bits can be recovered is to perform differential Manchester decoding.  Differential Manchester encoding has the benefit that during decoding, the process is resilient to signal/phase inversion.  The process uses transitions and not absolute polarity to decode.

Receiver Bitstream Details

Now that the bits are extracted, the receiver must perform block synchronization in order to identify the data encoded by the bits.  The RBDS bitstream is made up of "groups" of 104 bits.  Each group is made up of four blocks.  Each block is made up of 26 bits and of those 26 bits, 16 are information bits and 10 are checkword bits.  Below is a snippet from the RBDS standard document illustrating this structure.

RBDS Standard Block Definition 

The 10 bits that make up the checkword are used for error correction.  However, the checkword is also "stamped" with an offset word prior to transmission.  Each block has a defined offset word applied to it.  The purpose of adding a defined offset word to each checkword is to allow the receiver to synchronize or identify the blocks.

Block Synchronization

Specific information and data is encoded in each block.  Hence it is important to synchronize and identify blocks in the bitstream.  Synchronization and block identification is accomplished by performing a block search routine.  Once synchronized, the receiver can commence decoding.

The block search routine incrementally checks the bits in the bitstream and looks for a particular syndrome.  A syndrome is a special signature that a parity check algorithm produces.  The parity check algorithm is part of the error correction process that is dual-purposed for block synchronization.  If the offset word were not applied to the checkword, the parity check algorithm would produce a predictable '0' at its output if the block contained no errors.  Adding an offset to each checkword purposefully adds an error to the block.  Now when the parity check algorithm is run on the block (now with an intentional error), it produces a non-zero output.  The value of the output (called a syndrome) depends on the error introduced.  Each block has a unique error and hence a unique syndrome.  Once a valid syndrome is found in the search routine, block synchronization is achieved and block decoding can commence.

The parity check algorithm is performed by application of a parity check matrix.  This matrix is specific to the error correction code.  It is a 26x10 matrix.  The 1x26 data vector is multiplied by the parity check matrix (bit addition is accomplished by xoring).  The output of this multiplication is the syndrome.

Error Correction

The error correction routine uses a burst-error-correcting shortened cyclic code.  This is a (26,16) block code that is able to correct burst errors (continuous errors) up to five bits in length.  Prior to running the error correction (and detection) algorithm, the syndrome corresponding to the offset word is removed from the calculated syndrome so that only unintentional errors are present in the syndrome.

One way to implement this error correction algorithm can be done via a look-up-table (LUT).  Syndromes and their corresponding error vectors for all of the possible correctable error vectors can be calculated ahead of time.  This information is stored into a LUT.  At run-time, the receiver calculates the syndrome corresponding to the current 26 bits in a block.  If the syndrome is zero, there is no error (or the error is not detectable).  If the syndrome is non-zero, the LUT is searched for that particular syndrome and if found the error vector also in the LUT is used to correct the block error.  If the syndrome is not present in the LUT, the error was detectable but not correctable.

Another method of performing error correction (and detection) from a cyclic code is to use the Meggitt algorithm.  This is the particular algorithm that is given in the RBDS Standard.  The Meggitt algorithm is an incremental shift-register based error correction/detection algorithm.  The Meggitt algorithm is the method implemented in the pyRmRadio RBDS receiver.



Code



Good References:

http://www.nrscstandards.org/DocumentArchive/NRSC-4-A%20Standard%202005.pdf

http://www.nrscstandards.org/documentarchive/NRSC-4-A%20Annexes%202005.pdf

The care and feeding of digital, pulse-shaping filters [Local Mirror]

Digital Pulse-Shaping Filter Basics [Local Mirror]
http://www.analog.com/static/imported-files/application_notes/AN-922.pdf

Digital Filtering Part 2: Pulse Shaping [Local Mirror]
http://cmclab.rice.edu/433/slides/4-FilteringPart2.pdf

Matched Filtering and Timing Recoveryin Digital Receivers [Local Mirror]
mobiledevdesign.com/images/archive/0901Litwin32.pdf

Synchronisation in Digital Receivers [Local Mirror]
http://www.cs.tut.fi/kurssit/TLT-5806/Synch.pdf

Symbol Timing Recovery for QPSK Digital Modulations [Local Mirror]
http://www.gaussianwaves.com/2013/11/symbol-timing-recovery-for-qpsk-digital-modulations/

An Introduction to Error Correcting Codes [Local Mirror]
http://circuit.ucsd.edu/~tjavidi/ECE154C/154C/Lecture_Notes_files/ErrorCorrectionI.pdf

Decoding of Cyclic Codes and Intro to BCH Codes [Local Mirror]
http://www.site.uottawa.ca/~damours/courses/ELG_5372/Lecture15.pdf

Cyclic Codes [Local Mirror]
wits.ice.nsysu.edu.tw/course/pdfdownload/95.../CC-04-CyclicCode.pdf



1 comment:

  1. Hello Mr Swiston,

    Thank you for this very impressive work !

    On my side, after FM demodulation, the RDS signal band seems to be modulated by the audio FM signal and I wonder if you have see also this phenomenon during your tests ?

    Jean - Pierre

    ReplyDelete