Findpeaks outputs random values for distant targets!!
2 次查看(过去 30 天)
显示 更早的评论
I am working on Frequency Modulated Continuous Wave (FMCW) radar which linearly modulate frequency according to the amplitude of a sawtooth. My model is capable of detecting target ranging from 0.5m to 300m. The signal processor block is coded to provide 4 maximum peaks through 'findpeaks' and thereby 2 targets placed at different distances. Technically it should give me two peaks at respective frequencies and thus calculating distances. function but when I set one target at 1m and the other at 299m it gives accurate distance for 1m target but not for 299m object. Scenario 2 : 1st target 250m and second target 299m, it gives accurate results for both targets. I think my code is correct but I cannot isolate the problem. Help is appreciated , attached is my model and the code.
3 个评论
dpb
2017-4-4
Undoubtedly it's the data for the specific cases and its peaks that don't satisfy the criterion you've defined. Look at which peaks your usage of findpeaks is actually identifying and study of them and the choice of input parameters should let you figure out why they're being selected. Then, find an algorithm that eliminates the unwanted but still finds the one(s) you need.
Hassam Mahmood
2017-4-4
Sir if you can be more specific? I got your point but this is quite general of you. I need modifications in my signal processor code
dpb
2017-4-4
Not sure much of anybody else other than you with access to the data and the model can do that, specifically; at least without quite a lot of effort trying to solve what is, after all, your problem. (Not to be rude, but... :) ). I don't have Simulink so I can't do anything with the model file at all other than look at it; not sure if even those who do have everything the would need to run it?? And, why would you think a virtual newcomer at first blush would have a chance to solve a problem the pro who's been working on it for quite some time can't?
I think if you were to provide some actual spectra that do and don't "work" and the way for others to reproduce those, then somebody might have a chance to see the patterns but just from the model I think "not a chance!".
Sorry...best I know; maybe somebody else will come along and be the cat's meow...
采纳的回答
Honglei Chen
2017-4-5
编辑:Honglei Chen
2017-4-5
Haven't got chance to run your model. But what is the wrong value it reports when the target at 299m is not detected? Is it very close to 1 m? If so, this may due to the return of the 1m target much stronger than that of the 299m target, so you are essentially getting the sidelobe of the first target.
HTH
30 个评论
Hassam Mahmood
2017-4-5
编辑:Hassam Mahmood
2017-4-5
Sir attached is the output result of beat signal. As you can see the two peaks for two different targets one at 1m and other at 299m respectively. The wrong value is -3.476m for 299m target.
If this is the case of much stronger return then why does it give accurate detection values for targets at 1m and 5m or even if the second target is placed from 2m to 27m it gives perfect results. After 27m it gives negative value. I am not getting this trend.
Here is my code :
function [T1,T2] = calculation(beat_signal)
coder.extrinsic('clc');
clc;
%#codegen
length=numel(beat_signal);
p = nextpow2(length);
N = 2^p;
sweep_slope= 500e6/1e-3;
c=3e8;
fs=2e6;
f = fs*(-0.5+(0:N-1)/N);
P = abs(fftshift(fft(beat_signal,N))).^2;
[~,idx] = findpeaks(P,'NPeaks',2,'SortStr','descend');
www= size(idx)
TARGET=zeros(2,1);
index=zeros(2,1);
if ~isempty(idx)
for u=1:2;
index(u,1)=f(idx(u,1));
TARGET(u,1)=double(beat2range(index(u,1),sweep_slope,c));
end
T1=TARGET(1,1);
T2=TARGET(2,1);
else
T1=0;
T2=0;
end
dpb
2017-4-5
编辑:dpb
2017-4-5
We can't do anything with the code nor make comparisons to what does/does not work with out the actual physical data that was passed to the function for cases that did and did not work. Attach .mat files that illustrate both. We don't have beat2range which is where the magic occurs it appears, so that's probably the key.
I'd suspect if you were to use the debugger and step through the code and study what happens each step there would be an aha! moment.
ADDENDUM
Oh, btw...your question title seems to lay the blame on findpeaks, I suspect undeservedly. idx returns the index of the two peaks in the spectrum that you expect does it not? If so (and I just can't imagine it doesn't) then the culprit is clearly in how you get from those locations to the inferred distance and that's buried inside beat2range as noted above. Therein lies the problem...
Honglei Chen
2017-4-7
From the screen shot it seems the peaks are there. Do you have the data set? You mention that you attached model but I didn't find it.
Hassam Mahmood
2017-4-9
Here is the model, kindly set the value of target1 to 1m and target2 to 299m
dpb
2017-4-10
Again, what we need to be able to do anything is the .mat file containing the waveform and the beat2range function. Clearly, you have two peaks; there's no doubt whatever that findpeaks will locate them correctly and the conversion of their location in the spectrum to a location is buried in the above function.
Failing that, set a breakpoint in the debugger and step through on your own; also as noted before I've pretty high confidence that will reveal the source of the logic error in the calculation to you.
Honglei Chen
2017-4-10
It is the issue of sidelobes. The closeby return is so strong that its sidelobes masks the return from the far away target. Ideally you may want to do a CFAR detector in such situation so you can detect the target based on nearby noise. In this case, I did a inverse range weighting for the return and it seems working reasonabally well.
P = abs(fftshift(fft(beat_signal,N))).^2;
fvalid = f(N/2+1:N);
Pvalid = P(N/2+1:N);
Pvalid = Pvalid.*(beat2range(fvalid(:),sweep_slope,c).^2);
[~,idx] = findpeaks(Pvalid,'NPeaks',2,'SortStr','descend');
if ~isempty(idx)
index1 = idx(1,1);
index2=idx(2,1);
fb_range1 = fvalid(index1);
fb_range2=fvalid(index2);
range1 = double(beat2range(fb_range1,sweep_slope,c));
range2= double(beat2range(fb_range2,sweep_slope,c));
else
range1 = 0;
range2 = 0;
end
As pointed out by dpb, your subject may be a bit misleading as findpeaks is doing what it supposed to do. So you may want to rewrite that subject line to correctly reflect the real issue.
HTH
Hassam Mahmood
2017-4-10
编辑:Hassam Mahmood
2017-4-10
Sir thank you for your prompt reply. I am not getting your code, can you please elaborate what is "inverse range weighting" through your code? especially this part
Pvalid = Pvalid.*(beat2range(fvalid(:),sweep_slope,c).^2);
Honglei Chen
2017-4-11
The signal level falls proportional to r^2 where r is the distance from the source. So this is a predictable loss. Two way loss is actually r^4, but it seems r^2 works better in this case.
Hassam Mahmood
2017-4-12
Okay I get it. You saw my model, is it possible to replace Tx URA block and Rx URA block with phase shift beamformer block by enabling weights option?
Honglei Chen
2017-4-12
beamformer should come after the RX URA block, but yes you can use the weights option to do simple beamforming at RX URA.
Hassam Mahmood
2017-4-18
Sir thank you for your help this issue has been resolved and now just a quick question. I added A/D converter block right before signal processor block and converted the input to real. I see 8 peaks for 02 targets which is not what I expected. I get it that by changing it to real input I see mirror images on negative frequencies but why 2 more peaks on the other side? Attached is the image
A/D converter parameters are 14bit from 0 to 5V
Honglei Chen
2017-4-18
I don't see the image but I also don't quite understand what you described. All algorithms in your shared model assumes complex base band so to match that assumption, you may want to use two A/D converter to get both I and Q channels. If you only have one channel, then there is no phase information and you may need to make adjustment to certain algorithms.
Hassam Mahmood
2017-4-18
编辑:Hassam Mahmood
2017-4-18
Sir, I changed complex base band to real values as the input for ADC block because otherwise it was giving this error " Complex signal mismatch. Input port 1 of 'newmodelproject_WithoutADC/SIGNAL PROCESSING/FIR Decimation' expects a signal of numeric type real. However, it is driven by a signal of numeric type complex" Even if I add two ADC blocks it still gives this error and I ended up converting it to real values and it gives me numerous peaks Attached are the images as stated by their names
Honglei Chen
2017-4-18
You can split complex signal to real and imaginary and then AD both channels and assemble back to complex.
Hassam Mahmood
2017-4-18
Sir this is exactly what I did. I split the signal, inserting the real part in ADC port and then combined other imaginary part with ADC's output. Attached is the image of modified model. Issue remain persists, anymore suggestions would be appreciated. And if you kindly elaborate the reason behind getting these much peaks?
Honglei Chen
2017-4-18
Why isn't your imaginary part through an ADC? also your ADC has a vmax at 5v, so have you checked your input signal? if you have a lot of saturation, the frequency spectrum changes.
Hassam Mahmood
2017-4-18
编辑:Hassam Mahmood
2017-4-19
because when I applied complex signal to ADC it gave me an error which I stated above. So I converted it to real and split it up. Now I applied imaginary part to ADC as well and then combined both ADCs outputs but issue is still there. I fail to understand why after ADC I get 4 peaks instead of two
Honglei Chen
2017-4-19
I'm not an ADC expert, but I think your should do an ADC on your imaginary part too, just as in the real part. I don't see a reason that you need to do ADC only in the I channel, not in Q channel. In addition, I would check the signal after the ADC, how different are they compared to the signal before the ADC? Like I said, I suspect there are saturation which distorts the signal. if that is the case, you need to scale the signal before passing through the ADC.
Hassam Mahmood
2017-4-19
I applied ADC to imaginary part as well, still there is no change. I selected 14 bits based on dynamic range of 85 dB (noise floor -70dbm and maximum input power of 15dbm) As you can see in the images the output is quite a random one. My knowledge is limited in this regard , how much should be the Vmax and Vmin? I set Vmax as 1.77V (for max 15dbm) and Vmin as 99e-3( for minimum -120dbm detectable signal). I don't know if I did it right or not but it had no effect on ADC. I have attached images 'beforeADC' and 'AfterADC' for your ease. Thanks
Honglei Chen
2017-4-20
the figure shows the Vmin as 0 and Vmax as 5, which is different than what you mentioned. Also, it might be easier to look at the signal itself instead of the spectrum to see if there is saturation.
dpb
2017-4-20
编辑:dpb
2017-4-20
"...easier to look at the signal itself instead of the spectrum to see if there is saturation."
+1
Unless the input signal is known and clean, is almost impossible to tell after sampled/transformed in many (most?) cases. (Altho I have seen instances where clipping was so bad as to lead to an almost square wave which is recognizable by the odd harmonics in decreasing magnitude being prevalent...but that's just grossly clipped with a device that doesn't saturate which isn't found all that common in the wild.)
Hassam Mahmood
2017-4-20
编辑:Hassam Mahmood
2017-4-20
It is showing the same output even for the values I specified.
How can I rectify this problem?
Hassam Mahmood
2017-4-20
Okay so dpb what do you suggest? I don't think ADc is being saturated because as I mentioned earlier I chose values according to my signal min and max
dpb
2017-4-21
编辑:dpb
2017-4-21
"I don't think ADc is being saturated..."
Don't "think", make certain.
Have you actually checked for absolute certain the time history never hits the limits, not just assumed so, as you say "thinking" you've got the scaling/range ok?
Nothing exotic; just be absolutely positive by direct examination.
Hassam Mahmood
2017-4-21
编辑:Hassam Mahmood
2017-4-21
it doesn't Sir. Sir dpb throughout this chain your comments are very general. You may want to hit the bullseye if you are aware of the problem? or add something which is somehow leading to resolve my problem
dpb
2017-4-21
编辑:dpb
2017-4-21
Dunno...have no background in specific field; can't run Simulink model and you've posted nothing but pictures of spectra so can't do more than look at them if were to try to do something specific regarding the peaks...so what you expect?
Just been following thread; Honglei Chen seems to be pretty knowledgeable and his comment on clipping seemed to have been brushed off; just felt significant-enough point to make certain you had really, really checked, not "just thought". If it isn't clipped, that's good, but I don't have any further insights, no. I'll bow out if you wish...
dpb
2017-4-21
Altho I will say the issue of complex signal and an ADC is puzzling...but perhaps my lack of knowledge in the field is showing.
My background is all physical instrumentation wherein sampling is always of a real signal from some sort of instrument or the other which is, of course, never a complex signal. How/where does a complex signal come from that is somehow going to be sampled; this doesn't seem physically realizable to me, but perhaps as said that's just 'cuz I have no background in the field...again, general question, not specific but makes me wonder if something is going on there, particularly since your earlier comment of getting four peaks vis a vis two after the split vs before. I suspect there's a conceptual problem here but I do not have the actual answer, no, sorry, just a suspicion that "Houston, we have a problem!".
Honglei Chen
2017-4-23
Could you show me the time domain signal before and after the ADC? The frequency spectrum isn't very helpful.
Hassam Mahmood
2017-5-1
编辑:Hassam Mahmood
2017-5-2
Attached is the new model for different parameters. I set fc 25Ghz , Tx 0.1W and 900 element array antenna for sector scanning of 60 degrees with maximum range of 500m. My questions are
a) Model works fine for targets placed above 22 meters, but below this value lets say if I place one target at 10m and other at 499m it gives false values for distant one. Why is it so?
b) This code is for steering vector
y=complex(zeros(900,1));
az=60;
fc=25e9;
v=3e8;
lambda=v/fc;
persistent ss stv;
if isempty(ss)
ss=phased.URA('Size',[30 30],'ElementSpacing' , lambda/2);
end
if isempty(stv)
stv=phased.SteeringVector('SensorArray',ss, 'PropagationSpeed', v);
end
for w=1:10:az
y=conj(step(stv, fc, w));
end
if true
% code
end
When I change the value of 'w' in 'for loop' that is if I reduce it to 1 it changes the value of both the targets. And furthermore, by changing the value of Azimuth to 180 degrees it gives me accurate results!!!! what is the relation between 'w' and azimuth and target distance? Just could not derive any theory out of it
c) I am using FIR Decimator block, as you can see I applied bandpass filter from 50khz to 1Mhz as my maximum beat frequency is of 1Mhz. I used it to suppress the strong signal from nearby targets. But what I see is that after dechirp block I get 2 peaks but after decimation it does not show any peak for the second target placed at 499m and first target placed below 22m.
I am trying to derive any sort of relation between FIR decimator block, Antenna arrays, steering vector and target detection.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Continuous Waveforms 的更多信息
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 (한국어)