Piping raw IQ data from rtl-sdr to Max

notes

Here is a discussion about mkfifo (pipes) but  I can’t seem to get Max to interpret the FIFO as audio samples

http://www.reddit.com/r/RTLSDR/comments/rd15f/some_noob_questions_after_succesfully_getting/

I think I know how to figure out the streaming IQ thing now. Capture samples to a file, then look at the format. Then maybe pipe the file through something like auconvert to make it into a wave file. If that works, then maybe there is a way to to it as streaming.

Or figure out how to stream from tcp/ip version to audio.

Phase locked loop FM detection in Max

Here is an example of audio from the patch.

The source is a speech by Barack Obama which is FM modulated on an audio carrier at 23040 Hz.  Warning turn down the volume. You can hear as the PLL locks on to the signal. Then some of the params are tweaked in such a way that it is impossible to lock on to the signal, but the algorithm keeps on trying – producing an interesting result

A picture of the signal as its locking-on and when it loses the lock:

[original post]

A phase-locked loop algorithm running in Max (gen~)

The patch is unstable – but actually demodulates FM now.

download

in max-projects: https://github.com/tkzic/max-projects

folder: demodulation/max/phase-locked-loop

patch

gen-fm-detector2.maxpat

(also uses output from modem3.maxpat in folder: demodulation/max/)

instructions

  • run modem3.maxpat
  • set FM modulation level to less than 250
  • run gen-fm-detector2.maxpat
  • turn up audio output and try presets

notes

Two things: 1) I really don’t know what I’m doing with gen~ and 2) There are serious issues with the P and I coefficients in the algorithm. There is no ‘D’ coefficient yet – nor do I know whether its needed.

The thing that finally got it working was the loop filter component – which cleans up the output of the phase detector. The phase detector is essentially a phase ring modulator which contains not only the error signal, but also the sum of the incoming carrier and the reference oscillator. So the low pass filter gets rid of the high frequency component. By setting the resonance and cutoff extremely low, you can make the PLL start going a bit crazy in a beautiful way, lots of motion and spectral shifting.

Need to go through and analyze the output of the various stages, now to get the coefficients set properly – also, may need some kind of AGC on the input stage. Its very sensitive to over modulation and will distort badly.

Its interesting to play with the coefficients and hear the difference in how the demodulation works. By slowing down the P coefficient  it not only slows lock response, but during lock, the output is muffled  – so the P coefficient acts as a low pass filter – because it changes how responsive the circuit is in detecting changes in the input signal frequency (i.e., modulation).

There’s a weird thing going on – a fixed carrier is getting mixed with the error signal (output)   The patch is using notch filters to eliminate it, but it seems like it shouldn’t be there at all. Or should get filtered by the Loop filter.

Another thing to mention if I haven’t already is that I’m using a somewhat inefficient way to detect phase difference. Its the convert to complex and slope detection method used in the differentiator – but done using signals from reference oscillator instead of from delayed samples from original signal. Simply multiplying the two signals without complex conversion would probably do.

FCDproplus

Mac OS frequency control and Max external

notes

update 11/29/2013 – Checked the fcdpp in Mac OS 10.8 – still having issues with sync loss – also noticed that the fcdpp picks up interference from the Macbook trackpad in the shortwave bands – but after further research determined trackpad really does transmit RF.

My notes from September seemed a bit sparse. But I was able to determine that maxsdr5c.maxpat in maxsdr6 and the basicSDR4.maxpat were modified to use the new fcdpp external driver – also, maxsdr5c has the arrow keys mapped to awsd – due to an issue with metro/qmetro – but I will probably map them back again.

Am thinking about giving up on the fcdpp – but should test it out on windows first to make sure its not a hardware issue.

update 9/24/2013 – have written a Max external for the fcdp+ – its called funcubeplus.mxo

Its in the 6.1.3 sdk folder under basic examples. There’s a test patch in Max teaching examples called: funcube-pro-plus-test.maxpat

I have updated the code in tkzic/maxsdr6/maxsdr6 with the new drivers, etc., but have not posted to github – as am awaiting answer to sync issues.

Need to use the ad_portaudio core audio driver – or Max will crash.

Audio sync issues: the fcdp+ produces annoying buzzing artifacts during normal listening and especially right after you change frequency on the device. Have tried every possible Max audio setting to no avail. There have been other postings to the development group – so we’ll see what happens…

= previous post =

I’m listening to the fcdproplus radio in a Max SDR patch on the Macbook. Will need to fix a bug in the maxsdr5 patch with arrow keys – and write a new external for the pro plus – but here are the other details.

Using Alex Csete’s and David Pello’s fcdctrl code – see this post on R-pi

http://www.oz9aec.net/index.php/funcube-dongle/479-the-funcube-dongle-propro-on-the-raspberry-pi

Here’s the hacked fcdctrl code that works with the pro plus:

https://gitorious.org/fcdcontrol/fcdcontrol-proplus/source/d8055cfe4ba2e015a23f2ad8f4a80f4135441e74:

This project was set for linux, so I downloaded the most recent hidapi from here:

https://github.com/signal11/hidapi/downloads

and used the mac hid.c and hidapi.h code.

changed  Makefile to use these files and the Mac frameworks…

Code is in tkzic/fcdproplus/mac-fcdcontrol-proplus/

Also added this line to fcd.c – for the pro-plus

#define FCDPP 1

Also in Max, needed to use the ad_portaudio Core Audio driver – it crashed with the regular core audio driver.