greatscottgadgets / hackrf

low cost software radio platform
https://greatscottgadgets.com/hackrf/
GNU General Public License v2.0
6.24k stars 1.48k forks source link

How do I leverage the HackRF One in GNURadio? #1396

Closed DerrickLau closed 4 months ago

DerrickLau commented 5 months ago

What would you like to know?

I am trying to follow the video lesson 11c, but modify it so I can transmit in FM what I am saying into a microphone plugged into a USB sound card. I created a simple GNURadio flow graph with an Audio Source (device name matching my USB sound card), send to a WBFM Transmitter element, then to a Band Pass Filter element, and finally to an Osmocom sink with device argments being hackrf=serialno. I set the gain in the WBFM transmitter to 30db, the frequency to 145.8 MHz. I set the sample rate in the Audio Source to 48k, but in the Osmocom sink have it at 8M. Is this correct? Attached is a screenshot of my GNURadio flowgraph. Also, do I have to use the GNURadio that came with the PothosSDK download from the HackRF One site? Or will vanilla GNURadio work with HackRF One too? I ask because I cannot get the one bundled with PothosSDK to work as it consistently says it cannot find Python 3.9 for AMD64, and my laptop is x64.
20240107_2253_GNuRadio_FMTransmitFlowgraph Thanks for taking the time to read this and answer my question!

martinling commented 5 months ago

I see at least three problems here:

  1. You're mixing up several different sample rates. You should have two sample rates here. One for the audio samples and one for the IQ samples. Currently you have your audio sample rate set to 32k in the audio source and the WBFM block, which is fine. But your IQ sample rate is set to three different values in three different places.

    • In the WBFM block, it's set to 192k (the 'Quadrature Rate').
    • In the filter, it's set to 32k.
    • In the Osmocom block, it's set to 8M.

    Choose your IQ sample rate and use that rate in the whole IQ signal path.

  2. It's not clear what you're trying to do with the filter, and I think you've misunderstood what the nature of the signal is at that stage. The output of the WBFM Transmit block is an IQ sample stream with the FM signal centred at zero frequency. It looks like you're trying to filter the signal to the band around your intended RF frequency, but it's not at that frequency yet. The upconversion to the RF frequency only happens inside the HackRF.

  3. Your RF frequency has the wrong units. The frequency parameter to that block is in Hz, not MHz. You need to put in a value of 145800000 to get 145.8 MHz.