Compare commits
6 commits
aea84609b2
...
b52f772845
Author | SHA1 | Date | |
---|---|---|---|
b52f772845 | |||
8974b812f2 | |||
3054904768 | |||
821cd9189d | |||
9997b63c7e | |||
518d6f55db |
|
@ -2,11 +2,13 @@
|
|||
|
||||
Using RP2040 / Raspberry Pi Pico as a software-defined radio receiver.
|
||||
|
||||
See the [blog post](https://blog.porucha.net/2024/pico-sdr/) for more information. Older code the article is mostly referring to can be found in the branch `old`.
|
||||
See the [blog post](https://blog.porucha.net/2024/pico-sdr/) for more information. Older code the article is mostly referring to can be found in the branch `old` and a more up-to-date approach in the branch `master`.
|
||||
|
||||
This branch contains code to use RP2040 and some passives as a superheterodyne receiver. It is still very much work in progress.
|
||||
|
||||
## Circuit
|
||||
|
||||
![](circuit.svg)
|
||||
Please refer to [the simulation](https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCBMB0CsCmBaMAGEAOW0AsLboHYA2SWSIsWMIkAtFaFFCWNBZMAKEoE5wV06ENiE8ekYULZpUTOfM4BzfoMnhU2NfU4AlED2ybERTeh41jmmfpHyZ0IrHAOn9OJ0goC4AMyQhiOa+RGiBNE4AkgBi3ESihiBh-LiJQehgBlAgPtA+INp6BkZ+NprUwiBOPnZy2bn5DQywnABOtGSJGRIEHUkydpwA7smhXSOpNCicAMaVIRMgjhZBMkjeyA7YYjzoXiGwPuJGYC6cADaLsMs0PRJ9+Yzy288vz4k5B8REPGAi2HSQHzoNb5GbtO5BW6NcBIIQnEzbIgmMCQOiwWDEZyOJTghpQ8raYZQpLoEQLKbDUkBIJFcmtbJxBbYEzkypTTwQVEQmiQSBGFY2ELySS1BhPV4SsTgcRyTgRcbIcSlTpK6w5HxDOahIJXNBkqYANygBG5DOpk3AGHQnmF9Ea7jaGm1NDAYB81warBxbv8DR9cItU1m-oWIbtYFhiTFzDi4lYkDA1oIQJQVnO4EBppD92jcklkqjj2YifQPhN5BIBgIgm8FOViokVJVEjrTYbuPbUwARhgiOs+TJsK79LXOAAPXtORCkPgGPjTq4VPkgHQABU8uHHtBNiU8eWtRhtFXKAHFVxEAPIAHQAzs0J8R56gaNaIMgUHkyjQz5fb+hNU6iQsoBJR1mIEhkrqWhbgQBAQIcGCAsIEHgN+57XjePCalBSTMvykycD2GRvpQEDMnkiBAqCE7ugE1A0ORnREJ+UCaAAggAdgALvAHEcQAhmCrruqGmasrmTAQPCQJXL8sDiD4PhuhiWLNAA9tklQon6PiwNgPhWHAZZIjsyImO6PCuEWEBoBIeQakAA).
|
||||
|
||||
## Software
|
||||
|
||||
|
@ -32,4 +34,4 @@ See the [blog post](https://blog.porucha.net/2024/pico-sdr/) for more informatio
|
|||
|
||||
4. Open `grc/PicoSDR-WBFM.grc` in GNU Radio Companion, adjust carrier frequency to match your favorite FM radio station and press `F6`.
|
||||
|
||||
5. Alternatively [gqrx](https://www.gqrx.dk/) works fine with `rtl_tcp` input mode. Maximum sample rate seem to be 400 ksps, above that the samples are dropped. Make sure to adjust LNA gain to +30 dB. It's not accurate, but it does control bias strength which in turn does affect analog gain.
|
||||
5. Alternatively [gqrx](https://www.gqrx.dk/) works fine with `rtl_tcp` input mode. Maximum sample rate seem to be 400 ksps, above that the samples are dropped. Make sure to set LNA gain to 0, gain control is digital and does not provide any benefits unless you lower your sampling rate significantly.
|
||||
|
|
18
src/main.c
18
src/main.c
|
@ -25,8 +25,8 @@
|
|||
#define CLK_SYS_HZ (300 * MHZ)
|
||||
|
||||
#define LO_PIN 9
|
||||
#define RX_PIN 10
|
||||
#define FB_PIN 11
|
||||
#define RX_PIN 8
|
||||
#define FB_PIN 5
|
||||
#define PSU_PIN 23
|
||||
|
||||
#define PIO pio1
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
#define IQ_SAMPLES 32
|
||||
#define IQ_BLOCK_LEN (2 * IQ_SAMPLES)
|
||||
#define IQ_QUEUE_LEN 4
|
||||
#define IQ_QUEUE_LEN 8
|
||||
|
||||
#define LO_BITS_DEPTH 15
|
||||
#define LO_WORDS (1 << (LO_BITS_DEPTH - 2))
|
||||
|
@ -129,11 +129,11 @@ static void init_fb()
|
|||
|
||||
gpio_set_input_hysteresis_enabled(RX_PIN, false);
|
||||
gpio_set_drive_strength(FB_PIN, GPIO_DRIVE_STRENGTH_2MA);
|
||||
gpio_set_slew_rate(FB_PIN, GPIO_SLEW_RATE_FAST);
|
||||
gpio_set_slew_rate(FB_PIN, GPIO_SLEW_RATE_SLOW);
|
||||
|
||||
const uint16_t insn[] = {
|
||||
pio_encode_mov_not(pio_pins, pio_pins) | pio_encode_sideset(1, 1) |
|
||||
pio_encode_delay(1),
|
||||
pio_encode_delay(0),
|
||||
//pio_encode_nop() | pio_encode_sideset(1, 0) | pio_encode_delay(0),
|
||||
};
|
||||
|
||||
|
@ -384,9 +384,9 @@ static void rf_rx_stop(void)
|
|||
|
||||
inline static int next_sample(const uint32_t *buf, int *h)
|
||||
{
|
||||
int x1 = 2 * (buf[0] - buf[1]);
|
||||
int x1 = buf[0] - buf[1];
|
||||
int x2 = 0;
|
||||
int x3 = -2 * (buf[4] - buf[5]);
|
||||
int x3 = buf[5] - buf[4];
|
||||
int x4 = 0;
|
||||
|
||||
int sample = 18 * h[9] + 14 * h[8] - 32 * h[7] - 33 * h[6] + 106 * h[5] + 362 * h[4] +
|
||||
|
@ -404,7 +404,7 @@ inline static int next_sample(const uint32_t *buf, int *h)
|
|||
h[1] = x3;
|
||||
h[0] = x4;
|
||||
|
||||
return sample >> 10;
|
||||
return sample / 2260;
|
||||
}
|
||||
|
||||
static void rf_rx(void)
|
||||
|
@ -563,6 +563,8 @@ static void do_rx()
|
|||
if (queue_try_remove(&iq_queue, &block)) {
|
||||
fwrite(block, IQ_BLOCK_LEN, 1, stdout);
|
||||
fflush(stdout);
|
||||
} else {
|
||||
sleep_us(25);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue