[FPGA Wave Velocity Formation] Design and Implementation of FPGA-based Wave Velocity Formation System

1. Software version

MATLAB2013b,quartusii12.1

2. Theoretical knowledge of this algorithm

The beamforming technology comes from the principle that the array is directional, and a receiving transducer array composed of N non-directional array elements is set up. Each array element is located at the space point (xn, yn, zn), and all the array elements are added to obtain the output, which forms the natural directivity of the matrix. At this time, if a far-field plane incident wave is incident on this array, its output amplitude will vary with the plane incident angle.

When the signal sources are in different directions, since the phase difference between the received signal and the reference signal of each array is different, the amplitude of the formed and output signals is different, that is, the response of the array is different.

 

It is shown that the output amplitude of a multi-element array varies with the incident angle of the signal. Generally speaking, for an arbitrary array, no matter which direction the sound waves are incident from, it is impossible to form an in-phase addition or obtain the maximum output. Only a linear array or a space plane array can form an in-phase addition in the normal direction of the array to obtain maximum output. However, after proper processing, the array of any formation can form in-phase addition in a predetermined direction to obtain the maximum output, which is the general principle of beamforming.

 

 

 3. Core code

`timescale 1ns / 1ps
module tops(
            i_clk,
				i_rst,
				o_index,
				o_cos,
				o_sin,
				o_I_cos,
				o_Q_sin,
				o_I_filter,
				o_Q_filter,
				o_I_fft,
				o_Q_fft,	
	         o_boxs		
           );

input              i_clk;
input              i_rst;
output [15:0]      o_index;		
output signed[9:0] o_cos;
output signed[9:0] o_sin;
output signed[31:0]o_I_cos;
output signed[31:0]o_Q_sin;
output signed[15:0]o_I_filter;
output signed[15:0]o_Q_filter;
output signed[13:0]o_I_fft;
output signed[13:0]o_Q_fft;			  
output signed[15:0]o_boxs;			  
			  
wire signed[9:0]o_signal1 ,o_signal2 ,o_signal3 ,o_signal4 ,o_signal5 ,o_signal6 ,o_signal7 ,o_signal8 ,o_signal9 ,o_signal10;
wire signed[9:0]o_signal11,o_signal12,o_signal13,o_signal14,o_signal15,o_signal16,o_signal17,o_signal18,o_signal19,o_signal20;
wire signed[9:0]o_signal21,o_signal22,o_signal23,o_signal24,o_signal25,o_signal26,o_signal27,o_signal28,o_signal29,o_signal30;
wire signed[9:0]o_signal31,o_signal32,o_signal33,o_signal34,o_signal35,o_signal36,o_signal37,o_signal38,o_signal39,o_signal40;
wire signed[9:0]o_signal41,o_signal42,o_signal43,o_signal44,o_signal45,o_signal46,o_signal47,o_signal48,o_signal49,o_signal50;
Signal Signal_u(
               .i_clk     (i_clk),
				   .i_rst     (i_rst),
				   .o_signal1(o_signal1),
				   .o_signal2(o_signal2),
				   .o_signal3(o_signal3),
				   .o_signal4(o_signal4),
					.o_signal5(o_signal5),
					.o_signal6(o_signal6),
					.o_signal7(o_signal7),
					.o_signal8(o_signal8),
					.o_signal9(o_signal9),
					.o_signal10(o_signal10),

				   .o_signal11(o_signal11),
				   .o_signal12(o_signal12),
				   .o_signal13(o_signal13),
				   .o_signal14(o_signal14),
					.o_signal15(o_signal15),
					.o_signal16(o_signal16),
					.o_signal17(o_signal17),
					.o_signal18(o_signal18),
					.o_signal19(o_signal19),
					.o_signal20(o_signal20),

				   .o_signal21(o_signal21),
				   .o_signal22(o_signal22),
				   .o_signal23(o_signal23),
				   .o_signal24(o_signal24),
					.o_signal25(o_signal25),
					.o_signal26(o_signal26),
					.o_signal27(o_signal27),
					.o_signal28(o_signal28),
					.o_signal29(o_signal29),
					.o_signal30(o_signal30),

				   .o_signal31(o_signal31),
				   .o_signal32(o_signal32),
				   .o_signal33(o_signal33),
				   .o_signal34(o_signal34),
					.o_signal35(o_signal35),
					.o_signal36(o_signal36),
					.o_signal37(o_signal37),
					.o_signal38(o_signal38),
					.o_signal39(o_signal39),
					.o_signal40(o_signal40),

				   .o_signal41(o_signal41),
				   .o_signal42(o_signal42),
				   .o_signal43(o_signal43),
				   .o_signal44(o_signal44),
					.o_signal45(o_signal45),
					.o_signal46(o_signal46),
					.o_signal47(o_signal47),
					.o_signal48(o_signal48),
					.o_signal49(o_signal49),
					.o_signal50(o_signal50),					
	            .o_index	  (o_index)		  
              );


hunpin hunpin_u(
               .i_clk(i_clk),
				   .i_rst(i_rst),
				   .i_index(o_index),
				   .i_signal1(o_signal1) ,
					.i_signal2(o_signal2) ,
					.i_signal3(o_signal3) ,
					.i_signal4(o_signal4) ,
					.i_signal5(o_signal5) ,
					.i_signal6(o_signal6) ,
					.i_signal7(o_signal7) ,
					.i_signal8(o_signal8) ,
					.i_signal9(o_signal9) ,
					.i_signal10(o_signal10),
				   .i_signal11(o_signal11),
					.i_signal12(o_signal12),
					.i_signal13(o_signal13),
					.i_signal14(o_signal14),
					.i_signal15(o_signal15),
					.i_signal16(o_signal16),
					.i_signal17(o_signal17),
					.i_signal18(o_signal18),
					.i_signal19(o_signal19),
					.i_signal20(o_signal20),
				   .i_signal21(o_signal21),
					.i_signal22(o_signal22),
					.i_signal23(o_signal23),
					.i_signal24(o_signal24),
					.i_signal25(o_signal25),
					.i_signal26(o_signal26),
					.i_signal27(o_signal27),
					.i_signal28(o_signal28),
					.i_signal29(o_signal29),
					.i_signal30(o_signal30),
				   .i_signal31(o_signal31),
					.i_signal32(o_signal32),
					.i_signal33(o_signal33),
					.i_signal34(o_signal34),
					.i_signal35(o_signal35),
					.i_signal36(o_signal36),
					.i_signal37(o_signal37),
					.i_signal38(o_signal38),
					.i_signal39(o_signal39),
					.i_signal40(o_signal40),
				   .i_signal41(o_signal41),
					.i_signal42(o_signal42),
					.i_signal43(o_signal43),
					.i_signal44(o_signal44),
					.i_signal45(o_signal45),
					.i_signal46(o_signal46),
					.i_signal47(o_signal47),
					.i_signal48(o_signal48),
					.i_signal49(o_signal49),
					.i_signal50(o_signal50),
 				   .o_I_cos(o_I_cos),
				   .o_Q_sin(o_Q_sin),
				   .o_cos(o_cos),
				   .o_sin(o_sin) 
              );
				  
				  
fir_filter fir_filter_real(
                       .i_clk (i_clk),
						     .i_rst (i_rst),
						     .i_din (o_I_cos[15:0]),
						     .o_dout(o_I_filter)
                       );				  
				  
fir_filter fir_filter_imag(
                       .i_clk (i_clk),
						     .i_rst (i_rst),
						     .i_din (o_Q_sin[15:0]),
						     .o_dout(o_Q_filter)
                       );	
	
//FFT
reg[11:0]cnt;
always @(posedge i_clk or posedge i_rst)
begin
     if(i_rst)
	  begin
	  cnt <= 12'd0;
	  end
else begin
          if(cnt == 12'd2000)
			 cnt <= 12'd2000;
	  else
	       cnt <= cnt + 12'd1;  
     end
end

reg start;
always @(posedge i_clk or posedge i_rst)
begin
     if(i_rst)
	  begin
	  start <= 1'd0;
	  end
else begin
          if(cnt == 12'd406)
			 start <= 1'd1;
	  else
	       start <= 1'd0;  
     end
end


fft256 fft256_u( 
              .CLK  (i_clk),
				  .RST  (i_rst),
				  .ED   (1'b1),
				  .START(start),
				  .SHIFT(4'b0000),
				  .DR   (o_I_filter[15:6]),
				  .DI   (o_Q_filter[15:6]),
				  .RDY  (),
				  .OVF1 (),
				  .OVF2 (),
				  .ADDR (),
				  .DOR  (o_I_fft),
				  .DOI  (o_Q_fft)
				  );




//ABS
wire signed[23:0]tmps;
assign tmps   = o_I_fft*o_I_fft+o_Q_fft*o_Q_fft;
assign o_boxs = tmps[17:2];

			
endmodule 
clc
clear
close all;

%分析一:天线的角分辨率(能探测角度的精度)
Err = [];
for i = 0:60
    N        =  32;
    d        =  0.5;
    lamada   =  2*d;
    theta    = -pi/2:pi/720:pi/2;
    fai      =  2*pi/lamada*d*sin(theta);

    k        = 0:N-1;
    S        = exp(1j*k'*fai);
    theta_yi0= i; 
    theta_yi = theta_yi0*pi/180;
    r        = round(N*d/lamada*sin(theta_yi))+1;
    Ar       = fft(S,32);
    
    [VV,II]  = max(abs(Ar(r,:)));
    JIAODU   = abs(theta(II)*180/pi);
    
    
    figure(1); 
    plot(theta*180/pi,abs(Ar(r,:)));
    
    Err = [Err,abs(JIAODU-theta_yi0)];
end
figure;
plot(0:60,Err,'b-o');





%分析二:提高信噪比
Err = [];
SNR_SET = [-20:10];
for SNR = SNR_SET
    N        =  32;
    d        =  0.5;
    lamada   =  2*d;
    theta    = -pi/2:pi/720:pi/2;
    fai      =  2*pi/lamada*d*sin(theta);

    k        = 0:N-1;
    S        = exp(1j*k'*fai);
    S        = awgn(S,SNR,'measured');
    
    
    theta_yi0= 45; 
    theta_yi = theta_yi0*pi/180;
    r        = round(N*d/lamada*sin(theta_yi))+1;
    Ar       = fft(S,32);
    
    [VV,II]  = max(abs(Ar(r,:)));
    JIAODU   = abs(theta(II)*180/pi);
    
    
    figure(1); 
    plot(theta*180/pi,abs(Ar(r,:)));
    
    Err = [Err,abs(JIAODU-theta_yi0)];
end
figure;
plot(SNR_SET,Err,'b-o');



%分析三:天线能够探测的角度范围
Err = [];
for i = 0:80
    N        =  32;
    d        =  0.5;
    lamada   =  2*d;
    theta    = -pi/2:pi/720:pi/2;
    fai      =  2*pi/lamada*d*sin(theta);

    k        = 0:N-1;
    S        = exp(1j*k'*fai);
    theta_yi0= i; 
    theta_yi = theta_yi0*pi/180;
    r        = round(N*d/lamada*sin(theta_yi))+1;
    Ar       = fft(S,32);
    
    [VV,II]  = max(abs(Ar(r,:)));
    JIAODU   = abs(theta(II)*180/pi);
    
    
    figure(1); 
    plot(theta*180/pi,abs(Ar(r,:)));
    
    Err = [Err,abs(JIAODU-theta_yi0)];
end
figure;
plot(0:80,Err,'b-o');










 4. Operation steps and simulation conclusion

 

 

 

 

Here, this waveform, the simulation effect is as follows:

In the fpga, the simulation results are as follows:

Because after FFT, he will automatically appear two peaks. The modified simulation results are as follows:

5. References

A21-10

Guess you like

Origin blog.csdn.net/ccsss22/article/details/124442150