Finding a suitable Direction Finder Alogrithm
10 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2018-6-21
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
2018-6-21
Sorry about the comment mark i forgot it. So when i tried the code above with a different filename i got this error : Error using fwrite Invalid file identifier. Use fopen to generate a valid file identifier.
Error in Untitled (line 4) fwrite(fid,data,'uint8');
Ahmed Siddig
2018-6-21
编辑:Walter Roberson
2018-6-21
For example i have this file inside it is a .bin file which i captured using the hackrf one with a sampling rate of 2000000 & a number of samples of 10 & a gain of 32 and when i try this code:
fid = fopen(ahm.bin,'rb');
y = fread(fid,'uint8=>double');
y = y-127.5;
y = max(y(1:2:end) + i*y(2:2:end));compass(y)
I end up with the direction in the middle between 90 and 180 (i believe it's 135) knowing that i captured it in the 0 direction.
thanks.
Walter Roberson
2018-6-21
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
2018-6-21
Ok about the max() can't i use any other function to display the highest reading. And let's say we want 307.69 how did you get that? thanks.
Walter Roberson
2018-6-21
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
2018-6-21
Sorry but apparently am getting no where it still plots the same direction no matter what i tried. don't you know any way to display the direction of arrival. thanks again.
Walter Roberson
2018-6-21
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
2018-6-21
There are IQ data but the problem is that i have to plot the result in compass().
Walter Roberson
2018-6-21
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
2018-6-21
编辑:Walter Roberson
2018-6-21
OK sorry to ask but any idea how to deal with it in the same manner. For the record i added one of your codes above:
fid = fopen('ahm.bin','rb');
y = fread(fid,'uint8=>double');
fclose(fid)
y=mean(10.^(y(1:2:end) + 1i*y(2:2:end)))
compass(y);
actually it went well most of them started moving and some of them were right so that's a start how can i improve it thanks.
Walter Roberson
2018-6-21
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
2018-6-21
Oh that's an issue i'll keep looking and notify you of any updates. thanks a lot Mr.Roberson
Ahmed Siddig
2018-6-21
You know i tried the RTL-SDR with the original code and it was good most of them were right so i guess we'll just have for figure out a way to either convert the signed value to unsigned value or modify the code to deal with singed values.
Ahmed Siddig
2018-6-22
Hi, so as i said using the RTL-SDR, the arrow started moving with every reading but i can't get it to point to the right position so how can i manipulate the reading to get it fixed? and if possible how to improve it? I attached some readings that i recorded E,N,W,S indicates the direction where i took the reading from. Thanks.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Phased Array Design and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)