⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 data_track.c

📁 This model is just testing an idea of MIMO, which IEEE802.11n will have. But I havo not seen the s
💻 C
字号:
/*****************************************************************************//*   FIle Name : data_track.c                                                     *//*   Description : WLAN OFDM Subcarrier modulation DATA(&SIGNAL) tracking    *//*   author : miffie                                                         *//*   Date   : aug/11/05                                                      *//*   Copyright (c) 2005 miffie   All rights reserved.                          *//*****************************************************************************/struct complexset data_track (struct complexset datain,                         struct complexset *sram ,char *pilot_shifter,                        double *previous_drift , double *drift_amount, char *drift_change) {int 	ii ;char 	shifter ;double 	realp, image ;char    pilot_polarity ;struct 	complexset cset ;struct  complex  *top ;struct	complex tmp1, tmp2 ;double  angle , radius7, radius21, radius, slope ;double  drift , difference;char    pilot_length ;double  MAX_PILOTLENGTH  = 1.125 ;double  MIN_PILOTLENGTH  = 0.75 ;double  DRIFT_THRESHOLD  = 0.3 ;  //Main     if ((top = (struct complex *)malloc(64*sizeof(struct complex)) ) == NULL) {        PRINTF( " malloc failed in data_track.c\n") ;    } //fail    else { //allocated     //OFDM randomizer     *pilot_shifter = pilot_randomizer( *pilot_shifter ) ;     pilot_polarity = *pilot_shifter & 0x1 ;     if ( pilot_polarity ==1) pilot_polarity = -1 ;     else pilot_polarity =1 ;     PRINTF("data_track size=%d pilot_polarity=%d\n", datain.size, pilot_polarity ) ;     for(ii=-26;ii<=26;ii++) { //each subcarrier         top[ ii+32 ] = multiply_complex(datain.data[ii+32],                                         sram->data[ii+26] ) ;      } //each subcarrier       ////////////////////     //PILOT TRAINING     ////////////////////     pilot_length =1 ; //assume pilot_length is within the range     //-21     tmp1.realp = 1 * pilot_polarity ;     tmp1.image = 0 ;     tmp1 = multiply_complex(tmp1, top[-21+32]) ;     PRINTF ("pos -21 :" ) ;     //detect violation     if ((tmp1.realp>MAX_PILOTLENGTH)|(tmp1.realp<MIN_PILOTLENGTH)) pilot_length=0 ;     radius21 = tmp1.realp ;     angle = -polarizer ( tmp1 )/21.0 ;     drift =  polarizer ( tmp1 ) ;             //-7     tmp1.realp = 1 * pilot_polarity ;     tmp1.image = 0 ;     tmp1 = multiply_complex(tmp1, top[-7+32]) ;     PRINTF ("pos -7 :" ) ;     //detect violation     if ((tmp1.realp>MAX_PILOTLENGTH)|(tmp1.realp<MIN_PILOTLENGTH)) pilot_length=0 ;     radius7 = tmp1.realp ;     angle -= polarizer ( tmp1 )/7.0 ;     drift +=  polarizer ( tmp1 ) ;      //+7     PRINTF ("pos +7 :" ) ;     tmp1.realp = 1 * pilot_polarity ;     tmp1.image = 0 ;     tmp1 = multiply_complex(tmp1, top[7+32]) ;     //detect violation     if ((tmp1.realp>MAX_PILOTLENGTH)|(tmp1.realp<MIN_PILOTLENGTH)) pilot_length=0 ;     radius7 += tmp1.realp ;     angle += polarizer ( tmp1 )/7.0 ;     drift +=  polarizer ( tmp1 ) ;          //+21     PRINTF ("pos +21 :" ) ;     tmp1.realp = -1 * pilot_polarity ;     tmp1.image = 0 ;     tmp1 = multiply_complex(tmp1, top[21+32]) ;     //detect violation     if ((tmp1.realp>MAX_PILOTLENGTH)|(tmp1.realp<MIN_PILOTLENGTH)) pilot_length=0 ;     radius21 += tmp1.realp ;     angle += polarizer ( tmp1 )/21.0 ;     drift +=  polarizer ( tmp1 ) ;     //Take means of 4 pilot sub carriers     angle = angle/4 ;     PRINTF("angle =%6.3f\n" , angle ) ;     PRINTF("drift =%8.5f\n" , drift ) ;         //calculate radius & slope     radius21 = 2/radius21 ;     radius7 = 2/radius7 ;     //assume radius will be linear against freq     slope = (radius21-radius7)/14 ;     radius = radius7-slope*7 ;  //radius(0)     if (*previous_drift <10) { //DATA symbol       difference = (drift - *previous_drift )/(160*4) ;       //drift_change shall prevent from  back2back change on drift_amount        if ((fabs(drift)>DRIFT_THRESHOLD)&(*drift_change==0)) {//correction         *drift_amount -= difference ;         PRINTF(" drift=%8.5f  drift_amount=%8.5f\n", drift, *drift_amount ) ;          *drift_change=1 ;       } //correction       else *drift_change = 0 ;     }  //DATA symbol     *previous_drift = drift ;          //sram     if ((fabs(angle) > 0.002 ) & pilot_length) { //SRAM       PRINTF("...changing SRAM\n" ) ;       for(ii=-26;ii<=26;ii++) { //each subcarrier         tmp1.realp = cos(angle*ii) * (radius+slope*abs(ii)) ;         tmp1.image = -sin(angle*ii) * (radius+slope*abs(ii)) ;         PRINTF("sram(%d) %6.3f+j*%6.3f =>" , ii,                 sram->data[ii+26].realp, sram->data[ii+26].image ) ;         sram->data[ii+26] = multiply_complex(sram->data[ii+26], tmp1 ) ;         PRINTF(" %6.3f+j*%6.3f \n" , sram->data[ii+26].realp, sram->data[ii+26].image ) ;       } //each subcarrier     } //SRAM     cset.size = 64 ;     cset.data = top ;    }//allocated    free ( datain.data ) ;    return ( cset ) ;} //data_track

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -