Linrad with rtlsdr with and the e4000 tuner.

Steve Markgraf steve at
Fri Jun 22 20:43:34 UTC 2012

Hi Leif,

On 22.06.2012 21:55, Leif Asbrink wrote:
> The most important modification is the gain setting.
> The tuner code requires knowledge of the gain table
> or searcing for legal gain values by use of the returned
> error code. I think that this is impractical and I changed it
> so the routine will now always set the nearest possible gain
> value and return it to the caller.

That's exactly what we have rtlsdr_get_tuner_gains() for.

> The routine e4k_set_enh_gain(...) does not affect the gain 
> of my hardware so I allow the gain setting function to use it
> with always the same value because I have no idea what this
> function is intended to do....

Enhanced gain works only when both LNA and mixer gains are set to
maximum, take a look at e4000_set_gain() in librtlsdr.c.
Also be sure to enable the manual gain mode with the library function

> The default IF gain is too high. I reduced it by 6dB for
> a 6 dB better dynamic range.

We still have to add functions to set the IF-gain from external
applications, this is something on the todo-list.

> With the tuner_e4k.c currently incorporated in Linrad
> there is an AGC action that degrades the dynamic range by
> about 10 dB. I do not know anything about the e4000 internals
> but in case this remaining AGC can be disabled and the gain
> set 10 dB lower in the particular gain step controlled by the
> AGC, the dynamic range would improve from 66 dB to 76 dB
> with respect to the usual MDS (noise in 500 Hz bandwidth.)

The remaining AGC that's active is not in the E4K, but it's the Digital
AGC (DAGC) of the RTL2832. Unfortunately we don't know how to disable
it, since the way it's supposed to be disabled does not work.

> To be able to use the callback in Linrad I have had to include
> various structures in the Linrad c code. I need to have this 
> code in Linrad:
>   i = libusb_handle_events_timeout(dev_rtlsdr->ctx, &tv1);
> Therefore I need the structure rtlsdr_dev which is not included
> in rtl-sdr.h. That structure requires other structures and it
> would be a good thing if those things as well as something

I don't really know why you're doing that... the way the asynchronous
callback is meant to be used is spawning a thread and calling
rtlsdr_read_async() from there. Just take a look at how gr-osmosdr or
rtl_tcp handles it. Another example of correct usage is sdrsharp [1].



More information about the osmocom-sdr mailing list