Finding a suitable Direction Finder Alogrithm
Show older comments
Hi, am doing a radio direction finder project and i used parasatic monopole antenna array to switch the radiation beam in each direction. am using hackrf to capture the data and then i matlab i used this code:
function y = loadFile(filename)
% fid = fopen(filename,'rb'); y = fread(fid,'uint8=>double'); y = y-127.5; y = y(1:2:end) + i*y(2:2:end);
compass(y)
but i seem to be getting only one reading which gives me only one direction all the time. can you help me out please and is there a better way for me to process the captured file.
17 Comments
Walter Roberson
on 21 Jun 2018
If I remove the comment mark, then it works with the random data I created.
data = randi([0 255], [1 50],'uint8');
filename = 'test.bin';
fid = fopen(filename,'w');
fwrite(fid,data,'uint8');
fclose(fid);
fid = fopen(filename,'rb'); y = fread(fid,'uint8=>double'); y = y-127.5; y = y(1:2:end) + i*y(2:2:end);
compass(y)
Ahmed Siddig
on 21 Jun 2018
Ahmed Siddig
on 21 Jun 2018
Edited: Walter Roberson
on 21 Jun 2018
Walter Roberson
on 21 Jun 2018
The first statement would need to be
fid = fopen('ahm.bin','rb');
Walter Roberson
on 21 Jun 2018
Note that max() applied to a complex number ignores the imaginary part.
When I look in the file, I see that the odd-numbered components are 6 or 5, and that the event components are in the range of 248 to 251. There is no way I can see that you could get an angle near 0 from that. I can manipulate it to get angles of 135.117265041982 or of 307.694240466689 but not near 0.
Ahmed Siddig
on 21 Jun 2018
Walter Roberson
on 21 Jun 2018
fid = fopen('ahm.bin','rb');
y = fread(fid, 'int8=>double');
fclose(fid);
t = mean(y(1:2:end)) + 1i * mean(y(2:2:end));
ang = angle(t) * 180/pi;
"highest reading" does not have a clear meaning for complex numbers.
Ahmed Siddig
on 21 Jun 2018
Walter Roberson
on 21 Jun 2018
What do the values represent? For example if the adjusted values represent signal strength in decibels then you should probably not be doing plain vector addition on them. One plausible interpretation would be
mean(10.^(y(1:2:end) + 1i*y(2:2:end)))
angle(ans) * 180/pi
ans =
35.0483889088682
but also plausible would be
>> mean(10.^y(1:2:end) + 1i*10.^y(2:2:end))
ans =
190000 + 1.351e-06i
>> angle(ans) * 180/pi
ans =
4.07403148011443e-10
Ahmed Siddig
on 21 Jun 2018
Ahmed Siddig
on 21 Jun 2018
Walter Roberson
on 21 Jun 2018
When I check around, I find that it is signed values, not unsigned like you used. It needs to be demodulated though.
Quadrature signals are deliberately phase encoded, so you cannot use the information as a direction finder.
Ahmed Siddig
on 21 Jun 2018
Edited: Walter Roberson
on 21 Jun 2018
Walter Roberson
on 21 Jun 2018
You need
y = fread(fid,'int8=>double');
I do not think the 10^ version is appropriate now that I have read more about the data. I consistently found people saying it was 8 bit signed complex data. As such, -128 is the minimum and 127 is the maximum, so my original thought that you could perhaps read them as degrees turned out to be incorrect.
With a sufficiently long signal you should be able to plot the quadrature constellations in order to determine how many states are being encoded.
The phase is manipulated deliberately as part of the signal, so you cannot use the phase information to locate direction -- at least not on a sample by sample basis.
Ahmed Siddig
on 21 Jun 2018
Ahmed Siddig
on 21 Jun 2018
Ahmed Siddig
on 22 Jun 2018
Answers (0)
Categories
Find more on Signal Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!