📄 radproc.c
字号:
#include <stdlib.h>
#include <math.h>
#include "rtdspc.h"
/*********************************************************************
RADPROC.C - Real-Time Radar Processing
This program subtracts successive complex echo signals to
remove stationary targets from a radar signal and then
does power spectral estimation on the resulting samples.
The mean frequency is then estimated by finding the peak of the
FFT spectrum.
Requires complex input (stored real,imag) with 12
consecutive samples representing 12 range locations from
each echo.
*********************************************************************/
/* FFT length must be a power of 2 */
#define FFT_LENGTH 16
#define M 4 /* must be log2(FFT_LENGTH) */
#define ECHO_SIZE 12
void main()
{
int i,j,k;
float tempflt,rin,iin,p1,p2;
static float mag[FFT_LENGTH];
static COMPLEX echos[ECHO_SIZE][FFT_LENGTH];
static COMPLEX last_echo[ECHO_SIZE];
/* read in the first echo */
for(i = 0 ; i < ECHO_SIZE ; i++) {
last_echo[i].real = getinput();
last_echo[i].imag = getinput();
}
for(;;) {
for (j=0; j< FFT_LENGTH; j++){
/* remove stationary targets by subtracting pairs (highpass filter) */
for (k=0; k< ECHO_SIZE; k++){
rin = getinput();
iin = getinput();
echos[k][j].real = rin - last_echo[k].real;
echos[k][j].imag = iin - last_echo[k].imag;
last_echo[k].real = rin;
last_echo[k].imag = iin;
}
}
/* do FFTs on each range sample */
for (k=0; k< ECHO_SIZE; k++) {
fft(echos[k],M);
for(j = 0 ; j < FFT_LENGTH ; j++) {
tempflt = echos[k][j].real * echos[k][j].real;
tempflt += echos[k][j].imag * echos[k][j].imag;
mag[j] = tempflt;
}
/* find the biggest magnitude spectral bin and output */
tempflt = mag[0];
i=0;
for(j = 1 ; j < FFT_LENGTH ; j++) {
if(mag[j] > tempflt) {
tempflt = mag[j];
i=j;
}
}
/* interpolate the peak loacation */
p1 = mag[i] - mag[i-1];
p2 = mag[i] - mag[i+1];
sendout((float)i + (p1-p2)/(2*(p1+p2+1e-30)));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -