Welcome to Radarspotting. Please login or sign up.

April 18, 2024, 04:47:03 PM

Login with username, password and session length

New Members

New Members

You should get an activation email when you join.  If not, please use the Contact option.

Displaying rtl_sdr's I/Q raw file in Matlab / Octave

Started by muriloconte, February 08, 2015, 12:46:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

muriloconte

Hi folks,

I'm trying to display in Matlab the mode-s waveform using rtl_sdr's I/Q raw data. I used the following command to generate the I/Q raw file:

# rtl_sdr -f 1090e6 -s 2000e3  modes.bin

According rtl_sdr documentation, the I/Q values are 8-bit unsigned int encoded (0-255), with 'I' and 'Q' data interleaved (e.g. I Q I Q I Q ...). With this information, I used the Matlab code below to display the data:


% Matlab / GNU Octave code
N = 2000; % Number of samples to read
fid = fopen('modes.bin','r');
iq_data = fread(fid,[N 2],'uint8');
i_mag = iq_data(:,1) - 127; % Fix range to be in (+-127)
q_mag = iq_data(:,2) - 127; % Same as above
x = sqrt(i_mag.^2 + q_mag.^2); % Computing amplitude
plot(x)


The result does not look like anything like mode-s messages (see attachments between what I expected and what i actually got). Does it need demodulation / filtering or whatsoever? What did I miss?

For sanity check, I tested the I/Q file generated above with dump1090, and it decoded ADS-B messages successfully, so I guess the I/Q file is fine.

Thanks in advance.


[Attachment deleted by Admin to save file space]

IanH

I'm impressed with what you have done  ;D.

You will have to wait for an answer from someone who understands and can help.

Seems complicated to me!

Might be worthwhile sending a PM to member "junglejet" since he wrote RTL_SDR and will know the details of the output.

muriloconte

Thank you IanH for this input. I'm new to this community and such information is highly valuable  ;)

As soon as I figure out how to solve this puzzle, I'll post it here.