Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using FFT analysis/synthesis/filtering

Similar presentations


Presentation on theme: "Using FFT analysis/synthesis/filtering"— Presentation transcript:

1 Using FFT analysis/synthesis/filtering
9th of October

2 Today’s issues Basic signal theory Frequency-domain signal analysis
Using Discrete Fourier Transformation (DFT) Analysis and Synthesis Using overlap and add method Introducing DSPLIB Implementation of FFT and other DSP algorithms Building Frequency domain Digital filter Using DSPLIB

3 주기 신호의 표현 주기 신호 (Periodic signal) 퓨리어 급수 이론
일정한 시간 간격으로 똑같은 모양의 신호가 반복 (1/주기 = 기본주파수) 100Hz sinewave 사인(sine) 모양의 파형이 초당 100번 반복 200Hz 구형파 계단 모양의 파형이 1/200초 간격만큼 동일하게 반복 퓨리어 급수 이론 For any periodic function Composed of its harmonic sinusoidals Fundamental frequency = 1/T

4 푸리어 급수 T F0=1/T 2F0 3F0 4F0

5 주기 신호의 스펙트럼 기본주파수(=1/주기)의 정수배 되는 위치에서만 존재 선스펙트럼 (line spectrum)
또는 불연속스펙트럼(discrete spectrum) T(sec) F0 = 1/T F (Hz) F0 2F0 3F0 4F0 5F0

6 비주기 신호의 스펙트럼 비주기 신호 주기가 무한대( ) 기본주파수는 1/주기 에서 “0” 으로 수렴
주기가 무한대( ) 기본주파수는 1/주기 에서 “0” 으로 수렴 스펙트럼은 연속스펙트럼 (continuous spectrum) 형태를 갖음. T T(sec) F (Hz) “0”

7 Time domain signal의 구분 결정 신호 (Deterministic signal)
수학적으로 정의될 수 있는 신호 Sinewave : Amplitude/Phase/Frequency에 의해 완벽하게 정의될 수 있다. Impulse train : 펄스의 간격, 펄스의 크기에 의해 완벽하게 정의됨. 랜덤 신호 (Stochastic or Random signal) 수학적으로 정의 할 수 없지만 모델링 가능한 신호 백색 가우시안 잡음 : 분산/평균으로 정의됨.

8 Stochastic signal의 예 분산                                  평균

9 Time-to-Frequency mapping

10 Well-known T-to-F mapping
Fourier Series 주기 신호에 대한 시간-주파수 변환 Fourier Transform 주기/비주기 신호에 대한 시간-주파수 변환 Joseph Fourier (1768~1830, France)

11 Another T-to-F mapping
Laplace transformation FT보다 더 일반화된 형태 신호의 감소율도 고려 Pierre-Simon Laplace (1749~1827, France)

12 Fourier transform; Review
Fourier series -> 주기신호에 대해 Fourier transform -> 비주기신호에 대해

13 Discrete Fourier Transform (DFT)
퓨리어 변환은 무한대의 길이를 갖는 신호에 대해 정의된다. 실제적인 이산 신호는 신호의 길이가 제한되어 있다. -> 퓨리어 변환이 불가능? 따라서, 제한된 길이의 신호를 무한대의 길이를 갖는 신호로 변환해야 된다. 제한된 길이의 신호가 반복적으로 나타난다고 가정하여 퓨리어 변환 이산 퓨리어 변환은 퓨리어 시리즈와 같은 의미

14 DFT; Time & Frequency domain

15 Spectrum analysis; a practical issue
무한 길이에 대한 DFT Frame N-1 Frame N DFT DFT

16 Ping/Pong buffer에서 windowing
Ping buffer Pong buffer 첫번째 프레임 두번째 프레임 세번째 프레임 네번째 프레임 첫번째 프레임은 이전 buffer의 마지막 데이터들을 꺼내온다. 이전 buffer의 일부 데이터를 저장

17 Windowing effect (=Gibbs effect)
DFT

18 Window 함수와 주파수 응답

19 Short-time FT analysis and synthesis
Frame N-1 Frame N Input signal DFT processing IDFT DFT processing IDFT Output signal

20 Short-time signal 로 부터 continuous signal을 합성하는 방법
실질적으로 window 함수가 두 번 곱해졌으므로 window의 제곱값으로 overlap 된 값으로 나누어 준다.

21 Over-Lap and Add Source code
void OverLapAdd(Int16 *out, float *st_da, Int16 *pre_da, float *pre_win, float *win, float *swin) { int i; Int16 temp_val; for(i=0; i<FRAME_LEN; i++) { if ( i<FRAME_SHIFT ) { temp_val=(pre_da[i]+st_da[i*2]*win[i])/(pre_win[i]+swin[i]); out[i]=(temp_val>MAX_INT16)?MAX_INT16:temp_val; } else { pre_da[i-FR_RATE]=pre_da[i]+fftb[i*2]*win[i]; pre_win[i-FR_RATE]=pre_win[i]+swin[i]; 프레임이동 만큼 데이터 출력 = overlap & add 사용 나머지 부분은 과거 데이터 저장용 버퍼에 overlap & add 를 수행하여 저장함. Window함수에 대해서도 똑같이 overlap & add 수행

22 DSPLIB An optimized floating-point DSP Function Library
for C programmers using TI DSPs. Includes general-purpose signal-processing routines C-callable, assembly-optimized typically used in computationally intensive real-time applications where optimal execution speed is critical. Execution speeds considerably faster than equivalent code written in standard ANSI C language. Providing ready-to-use DSP functions

23 DSPLIB에서 제공되는 함수 Adaptive Filtering Correlation FFT
Filtering and convolution Math Matrix Misc DSPF_sp_lms DSPF_sp_autocor DSPF_sp_bitrev_cplx DSPF_sp_fir_cplx DSPF_sp_dotp_sqr DSPF_sp_mat_mul DSPF_sp_blk_move DSPF_dp_lms DSPF_dp_autocor DSPF_sp_cfftr4_dif DSPF_sp_fir_gen DSPF_sp_dotprod DSPF_sp_mat_trans DSPF_sp_blk_eswap16 DSPF_sp_cfftr2_dit DSPF_sp_fir_r2 DSPF_sp_dotp_cplx DSPF_sp_mat_mul_cplx DSPF_sp_blk_eswap32 DSPF_sp_fftSPxSP DSPF_sp_fircirc DSPF_sp_maxval DSPF_dp_mat_mul DSPF_sp_blk_eswap64 DSPF_sp_ifftSPxSP DSPF_sp_biquad DSPF_sp_maxidx DSPF_dp_mat_trans DSPF_sp_fltoq15 DSPF_sp_icfftr2_dif DSPF_sp_iir DSPF_sp_minval DSPF_dp_mat_mul_cplx DSPF_sp_q15tofl DSPF_dp_bitrev_cplx DSPF_sp_iirlat DSPF_sp_vecrecip DSPF_sp_minerror DSPF_dp_cfftr4_dif DSPF_sp_convol DSPF_sp_vecsum_sq DSPF_dp_blk_move DSPF_dp_cfftr2 DSPF_sp_w_vec DSPF_dp_icfftr2 DSPF_sp_vecmul DSPF_dp_fir_cplx DSPF_dp_dotp_sqr DSPF_dp_fir_gen DSPF_dp_dotprod DSPF_dp_fir_r2 DSPF_dp_dotp_cplx DSPF_dp_fircirc DSPF_dp_maxval DSPF_dp_biquad DSPF_dp_maxidx DSPF_dp_iir DSPF_dp_minval DSPF_dp_iirlat DSPF_dp_vecrecip DSPF_dp_convol DSPF_dp_vecsum_sq DSPF_dp_w_vec DSPF_dp_vecmul

24 How to get/update DSPLIB?

25 DSPLIB에 포함된 내용 C6700을 위한 각종 파일 각 함수에 대한 사용 설명
\CCStudio\c6700\dsplib\bin FFT 연산을 수행하기 위한 각종 파라메터 생성 프로그램 \CCStudio\c6700\dsplib\include 함수에 대한 헤더 파일 \CCStudio\c6700\dsplib\lib 라이브러리 파일 (소스 코드 포함) \CCStudio\c6700\dsplib\support FFT 연산을 위한 각종 보조 함수들 각 함수에 대한 사용 설명 \CCStudio\docs\pdf\SPRU657B.pdf

26 DSPLIB을 사용하기 위한 준비(1) 라이브러리 소스의 컴파일
Download시 이미 67X 계열의 DSP로 compile이 된 library 라면 컴파일 불필요 만일 그대로 사용시 building error 가 발생하는 경우 다른 계열 (특히 62X 계열) 의 DSP로 compile된 경우임. mk6x –mv6710 dsp67x.src –l dsp67x.lib mk6x : library build tool -mv6710 : 6710 DSP 용으로 컴파일 dsp67x.src : \CCStudio\c6700\dsplib\lib 에 포함된 library source code dsp67x.lib : 출력될 binary library file

27 DSPLIB을 사용하기 위한 준비(2) DSPLIB용 header file이 저장된 directory 지정

28 DSPLIB을 사용하기 위한 준비(3) DSPLIB용 library file이 저장된 directory 지정

29 FFT 관련 함수의 사용법(1) DSPF_sp_cfftr2_dit
Single-precision floating point radix-2 FFT for complex input Void DSPF_sp_cfftr2_dit(float *x, float *w, short n) x : pointer to complex data input w : pointer to complex twiddle factor in bit-reverse order n : length of FFT in complex samples Must be power of 2 such that 32<=n<=32K

30 FFT 를 위한 complex array 구조
Imag[x(0)] Imag[x(1)] Imag[x(N-1)] Real[x(0)] Real[x(1)] Real[x(N-1)]

31 FFT 관련 함수의 사용법(2) FFT 수행시 필요한 twiddle factor를 계산, look up table에 저장

32 FFT loop-back 예제

33 실습1 Build FFT loop-back program
Windowing->FFT->IFFT->OverLapAdd FFT_SIZE : 512 또는 256 Stereo data -> Mono data 로 변환 (optional) DIP switch에 의해 FFT/IFFT 결과 또는 original data를 선택 CCS의 insert graphic 기능 이용, FFT 결과의 plot

34 Overlap and Add 방법의 원리 Void OverLapAdd(short *out, float *fftb, short *pre_da) { int i; for(i=0; i<FR_LEN; i++) { if ( i<FR_RATE ) out[i]=pre_da[i]+fftb[i*2]; else pre_da[i-FR_RATE]=pre_da[i]+fftb[i*2]; }

35 Fast Fourier Transform
High computational complexities -> too many addition and multiplication Fast DFT algorithm (by Turkey & Cooley) Size must be power of 2 Results are bit-reverse ordered

36 Bit-reversal order의 확인

37 Frequency domain Digital Filter 구현
N=16 pt FFT 결과 Complex conjugate X(n)=X*(N/2-n) X(0)=DC Filtering 후 FT계수가 항상 대칭이 되도록 한다. Frequency response (LPF)

38 FFT 결과와 절대주파수값간의 관계 N=16 pt FFT 결과 N-번째 FFT 계수는 몇 Hz에 해당?
X(0)=0Hz (DC) ? X(FFT_SIZE/2)=Fs/2 N-번째 FFT 계수는 몇 Hz에 해당? -> 비례식을 이용

39 An Example of Frequency index function
// Compute Frequency index for a given (real) frequency (in Hz) // fid = f_real *(FFT_SIZE/Fs) // Where Fs = Sampling frequency // Note : 0 <= f_real <= Fs/2 int Get_Freq_id(int Freal, int Fs) { return Freal*((float)FFT_SIZE/Fs); } void LPF(float *fftb) int i, fidL, fidH; fidL=Get_Freq_id(500, 32000); // -> should be matched with AIC Fs setting.. fidH=Get_Freq_id(5000, 32000); for(i=0; i<FFT_SIZE_2; i++) { if ( !(fidL <= i && i <= fidH) ) fftb[i*2]=fftb[i*2+1]=0.; for(i=1; i<FFT_SIZE_2; i++) { fftb[(i+FFT_SIZE_2)*2]=fftb[(FFT_SIZE_2-i)*2]; fftb[(i+FFT_SIZE_2)*2+1]=-fftb[(FFT_SIZE_2-i)*2+1];

40 Frequency-domain digital filter; flow chart
Windowing FFT Bit-reversing 두 신호간 시간 영역에서 비교 두 신호간 주파수 영역에서 비교 Taking lower frequency components Bit-reversing IFFT 이전 time-domain digital filter의 결과 와 비교

41 실습2 Build frequency-domain digital filter Using FFT/IFFT
Yesterday (time-domain digital filter) 와 비교 Filtering 전/후 스펙트럼 비교 Using insert graphic function 다양한 형태의 필터 구현 LPF, HPF, BPF 등


Download ppt "Using FFT analysis/synthesis/filtering"

Similar presentations


Ads by Google