# Gnuradio DCS Module

**URL:** <https://www.ruby-forum.com/t/gnuradio-dcs-module/232409>\
**Category:** GNU Radio\
**Created:** [October 7, 2014, 10:11pm UTC](https://www.ruby-forum.com/t/gnuradio-dcs-module/232409 "2014-10-07T22:11:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [October 7, 2014, 10:11pm UTC](https://www.ruby-forum.com/t/gnuradio-dcs-module/232409/1 "2014-10-07T22:11:32Z")

</div>

Hi list,

I am pretty new to Gnuradio / SDR, experimenting with a HackRF. As a  
startup experiment, I wanted to communicate with simple handheld radio  
devices (toy radios). These radios used DCS, and in order for my  
computer to bypass their squelch, I need to

1. Determine DCS-code
2. Add DCS to my transmissions

Since I didn’t find any suitable tools for that (?), I have now  
implemented a gnuradio module to decode DCS. The source code is at  
bitbucket [1].

I started out by implementing the DCS decoder via a message block in  
python. This seemed a bit hacky, so I decided to implement it in C++  
instead following the “Out-of-tree modules” tutorial [2]. In the end, I  
implemented it as a Stream Tag block. My thought was that it would add  
tags to an audio stream, and a UI component somewhere would pick up the  
tags and display to the user (needless to say, a DCS-squelch could be  
built using the tagged stream).

I now have a few question, both regarding the digital signal processing  
in general, and regarding gnuradio.

1. Currently, my block takes digital input. Here [3] you can see a  
picture of how I go from 960 hz sampled audio stream via DC-blocker,  
thresholding , interpolation and decimation into a digital signal (to  
the ‘old’ message sink). In the next stage, I’d like to take an audio  
source (with a few selectable common audion samplerates) instead, which  
means that my block must do all those things within the block itself.  
How is this normally done? Do I create a hierarchical block containing  
these blocks “under the hood”, plus my new digital-in-DCS-decode block?

2. Does it make sense to have DCS as a tagged stream? Should I chose  
some other type to communicate DCS ?

3. Are there better ways to extract the digital signal from the audio  
source than my schematic above? Am I doing something stupid?

4. Are there any suitable UI-components I can use to display DCS  
information - e.g. something which show information from streamed tags ,  
or mechanisms to modify variables based on tag info?

Grateful for suggestions and ideas.  
Martin Holst Swende

[1] [https://bitbucket.org/holiman/gnuradio-dcs](https://bitbucket.org/holiman/gnuradio-dcs)  
[2] [http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules](http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules)  
[3] [http://martin.swende.se/graph\_part.png](http://martin.swende.se/graph_part.png)

---

<div class="post-metadata">

**Author:** ![Martin\_Holst\_Swende](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@Martin\_Holst\_Swende](https://www.ruby-forum.com/u/Martin_Holst_Swende)\
**Post date:** [October 8, 2014, 1:17am UTC](https://www.ruby-forum.com/t/gnuradio-dcs-module/232409/2 "2014-10-08T01:17:16Z")

</div>

Martin,

Some ideas inline … hope some of this is useful.

On 10/07/2014 03:30 PM, Martin Holst Swende wrote:

> implemented a gnuradio module to decode DCS. The source code is at  
> I now have a few question, both regarding the digital signal processing  
> in general, and regarding gnuradio.
> 
> 1. Currently, my block takes digital input. Here [3] you can see a  
> picture of how I go from 960 hz sampled audio stream via DC-blocker,  
> thresholding , interpolation and decimation into a digital signal (to  
> the ‘old’ message sink). In the next stage, I’d like to take an audio  
> source (with a few selectable common audion samplerates) instead, which  
> means that my block must do all those things within the block itself.  
> How is this normally done? Do I create a hierarchical block containing  
> these blocks “under the hood”, plus my new digital-in-DCS-decode block?

There’s no right way. You can make a hier block in GRC, Python, C++, or  
leave it in the top level flow graph. GRC hier block is the easiest if  
it works for you.

> 1. Does it make sense to have DCS as a tagged stream? Should I chose  
> some other type to communicate DCS ?

The choice of messages or tagged streams has to do with how you want to  
process the data downstream. If a downstream block needs the info  
associated with a sample (like a squelch) then tags are good. If it’s  
thought of more as data (like for logging) then messages are good. There  
is also a tag-to-message block, so you can have it both ways.

> 1. Are there better ways to extract the digital signal from the audio  
> source than my schematic above? Am I doing something stupid?

A low pass filter should be used to cut out voice. A rational resampler  
can replace the interpolate and 1-in-N blocks. You could combine the LPF  
and DC blocker into the taps for the resampler if you want to get fancy.  
The threshold can go after the resampler.

I’m not familiar with DCS, but typically a synchronizer block of some  
sort is used before the bits are processed. Otherwise, your bit  
alignment is due to luck (or short sequences).

> 1. Are there any suitable UI-components I can use to display DCS  
> information - e.g. something which show information from streamed tags ,  
> or mechanisms to modify variables based on tag info?

The QT time sink will display tags.

---

<div class="post-metadata">

**Author:** ![Martin\_Holst\_Swende](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@Martin\_Holst\_Swende](https://www.ruby-forum.com/u/Martin_Holst_Swende)\
**Post date:** [October 8, 2014, 11:56am UTC](https://www.ruby-forum.com/t/gnuradio-dcs-module/232409/3 "2014-10-08T11:56:49Z")

</div>

On 10/07/2014 07:16 PM, Jeff L. wrote:

> > computer to bypass their squelch, I need to  
> > implemented it as a Stream Tag block. My thought was that it would add  
> > the ‘old’ message sink). In the next stage, I’d like to take an audio  
> > 2. Does it make sense to have DCS as a tagged stream? Should I chose  
> > some other type to communicate DCS ?
> 
> The choice of messages or tagged streams has to do with how you want to  
> process the data downstream. If a downstream block needs the info  
> associated with a sample (like a squelch) then tags are good. If it’s  
> thought of more as data (like for logging) then messages are good. There  
> is also a tag-to-message block, so you can have it both ways.

Oh, tag-to-message is part of gr-baz, not gnuradio proper.

---

<div class="post-metadata">

**Author:** ![Martin\_Holst\_Swende](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@Martin\_Holst\_Swende](https://www.ruby-forum.com/u/Martin_Holst_Swende)\
**Post date:** [October 11, 2014, 2:15pm UTC](https://www.ruby-forum.com/t/gnuradio-dcs-module/232409/4 "2014-10-11T14:15:04Z")

</div>

On 2014-10-08 01:16, Jeff L. wrote:

> > computer to bypass their squelch, I need to  
> > implemented it as a Stream Tag block. My thought was that it would add  
> > the ‘old’ message sink). In the next stage, I’d like to take an audio  
> > 2. Does it make sense to have DCS as a tagged stream? Should I chose  
> > some other type to communicate DCS ?
> 
> The choice of messages or tagged streams has to do with how you want to  
> process the data downstream. If a downstream block needs the info  
> associated with a sample (like a squelch) then tags are good. If it’s  
> thought of more as data (like for logging) then messages are good. There  
> is also a tag-to-message block, so you can have it both ways.

I’ve now switched back into a sink, which output to stdout. It bugs me a  
bit that I haven’t found any suitable UI-widget to just display some  
info - it seems like a very simple component to have - or maybe a few:

- ‘console-like’ component with configurable buffer size
- label-like component where a key and value can be set dynamically

But maybe the existing labels can be used but I haven’t figured out how?

> > 1. Are there better ways to extract the digital signal from the audio  
> > source than my schematic above? Am I doing something stupid?
> 
> A low pass filter should be used to cut out voice.

I failed to mention that my source was already lp-filtered.

> A rational resampler  
> can replace the interpolate and 1-in-N blocks. You could combine the LPF  
> and DC blocker into the taps for the resampler if you want to get fancy.  
> The threshold can go after the resampler.

Thanks, I’m experimenting with that now. I’ve found how to implement LPF  
using fir-filters, but don’t quite know how to do DC-blocking. It seems  
to me it would require a bandpass-filter. Any docs floating around on  
that?

> I’m not familiar with DCS, but typically a synchronizer block of some  
> sort is used before the bits are processed. Otherwise, your bit  
> alignment is due to luck (or short sequences).

I think what made my solution work was that I thresholded with several  
higher frequencies still there, which made it kind of stable - as long  
as low-frequency audio disturbance was not there. In order to make it  
more robust, I need to filter more harshly, which will make the ones and  
zeroes less pronounced, and I will need a synchronizer.

I’ve looked at the docs for the MM\_clock\_recovery, and I understand the  
parameter settings - but I don’t understand what it actually does - how  
does it convey the synchronization/clock info to the next component in  
the flow-graph?

Thanks!  
/Martin

ps. When I write a flowgraph, I get more and more complicated  
expressiosn for parameters. e.g samplerate becomes  
sample\_rate/lp\_decimation1\*interp\_1/decim\_2… and so on. It would be  
nice to be able to refer to another component earlier in the flowgraph.  
For example, as sample\_rate be able to write:  
this.source[‘sample\_rate’]  
or  
source(“rr\_resampler”)[‘sample\_rate’] /  
source(“rr\_resampler”)[‘decimation’] \*  
source("rr\_resampler)[‘interpolation’]

The second example would search the source-chain for a component called  
“rr\_resampler” and determine the outgoing sample\_rate based on that  
component’s parameters.
