📄 rxchannelest.c
字号:
/*****************************************************************************
Module : Channel Estimation
******************************************************************************
Function :
Procedures : none
Author : $Author: Adrian $
Revision : $Revision: 9 $
Modified : $Modtime: 05-05-29 23:35 $
File : $Workfile: rxchannelest.c $
******************************************************************************
KTH, Royal Institute of Technology, S3, Stockholm
*****************************************************************************/
/*--- Include files --------------------------------------------------------*/
/* import */
/* export */
#include "rxchannelest.h"
/*=== End of include files =================================================*/
/*--- Global variables definition ------------------------------------------*/
typRX_CHANNELESTSTATE ChannelState;
/* channel matrices */
float pH_hat_r[2][2];
float pH_hat_i[2][2];
float pH_pre_r[4][2];
float pH_pre_i[4][2];
/*=== End of global variables definition ===================================*/
/*--- Global constants definition ------------------------------------------*/
/*=== End of global constants definition ===================================*/
/*--- Local defines --------------------------------------------------------*/
/*=== End of local defines =================================================*/
/*--- Local types declaration ----------------------------------------------*/
/*=== End of local types declaration =======================================*/
/*--- Local variables definition -------------------------------------------*/
/*=== End of local variables definition ====================================*/
/*--- Local constants definition -------------------------------------------*/
extern const Int16 TRAININGSEQ[2][TRAINLEN];
// Hardcoded S'*inv(S*S');
/*
const float INV_TRAIN_MATX_R[2][TRAINLEN]={
{-0.0417,-0.0417, 0.0417,-0.0417,-0.0417,-0.0417,-0.0417,-0.0417, 0.0417, 0.0417,-0.0417, 0.0417},
{-0.0417,-0.0417,-0.0417,-0.0417, 0.0417, 0.0417,-0.0417, 0.0417,-0.0417, 0.0417, 0.0417, 0.0417},
};
const float INV_TRAIN_MATX_I[2][TRAINLEN]={
{ 0.0417, 0.0417,-0.0417, 0.0417, 0.0417, 0.0417, 0.0417, 0.0417,-0.0417,-0.0417, 0.0417,-0.0417},
{ 0.0417, 0.0417, 0.0417, 0.0417,-0.0417,-0.0417, 0.0417,-0.0417, 0.0417,-0.0417,-0.0417,-0.0417},
};
*/
const float S_est_r[TRAINLEN][2] = {
{-1.388888888889e-02f, -1.388888888889e-02f},
{-1.388888888889e-02f, -1.388888888889e-02f},
{1.388888888889e-02f, -1.388888888889e-02f},
{-1.388888888889e-02f, -1.388888888889e-02f},
{-1.388888888889e-02f, 1.388888888889e-02f},
{-1.388888888889e-02f, 1.388888888889e-02f},
{-1.388888888889e-02f, -1.388888888889e-02f},
{-1.388888888889e-02f, 1.388888888889e-02f},
{1.388888888889e-02f, -1.388888888889e-02f},
{1.388888888889e-02f, 1.388888888889e-02f},
{-1.388888888889e-02f, 1.388888888889e-02f},
{1.388888888889e-02f, 1.388888888889e-02f}
};
const float S_est_i[TRAINLEN][2] = {
{1.388888888889e-02f, 1.388888888889e-02f},
{1.388888888889e-02f, 1.388888888889e-02f},
{-1.388888888889e-02f, 1.388888888889e-02f},
{1.388888888889e-02f, 1.388888888889e-02f},
{1.388888888889e-02f, -1.388888888889e-02f},
{1.388888888889e-02f, -1.388888888889e-02f},
{1.388888888889e-02f, 1.388888888889e-02f},
{1.388888888889e-02f, -1.388888888889e-02f},
{-1.388888888889e-02f, 1.388888888889e-02f},
{-1.388888888889e-02f, -1.388888888889e-02f},
{1.388888888889e-02f, -1.388888888889e-02f},
{-1.388888888889e-02f, -1.388888888889e-02f}
};
/*=== End of local constants definition ====================================*/
/*--- Local functions definition -------------------------------------------*/
/*=== End of local functions definition ====================================*/
/*--- Global functions definition ------------------------------------------*/
/****************************************************************************
Function : Channel Estimation
****************************************************************************
Description : Estimate Cofficeant for Channel
Inputs : Recieved frame from Ant1 And Ant2
Outputs : Estimate chammel
By : 2005-05-02 Created First Rev. by Loghman Andimeh
2005-05-10 Modified(Loghman)
****************************************************************************/
void channelestimation(typRX_CHANNELESTSTATE *pChannelState)
{
int i;
float factor;
int offs, buflen, idx;
float RECIV_TRAIN_SEQ_I_1;
float RECIV_TRAIN_SEQ_Q_1;
float RECIV_TRAIN_SEQ_I_2;
float RECIV_TRAIN_SEQ_Q_2;
Int16 Ai, Bi;
offs = pChannelState->ioffset;
buflen = pChannelState->ibuflen;
factor = pChannelState->alpha;
pH_hat_r[0][0]=0;
pH_hat_r[0][1]=0;
pH_hat_r[1][0]=0;
pH_hat_r[1][1]=0;
pH_hat_i[0][0]=0;
pH_hat_i[0][1]=0;
pH_hat_i[1][0]=0;
pH_hat_i[1][1]=0;
// Recieved Training seq.
for(i=0; i<TRAINLEN; i++){
idx = (offs+i) % buflen;
RECIV_TRAIN_SEQ_I_1 = pChannelState->pfCplxSymbBuff1->pIBuffer[idx];
RECIV_TRAIN_SEQ_Q_1 = pChannelState->pfCplxSymbBuff1->pQBuffer[idx];
RECIV_TRAIN_SEQ_I_2 = pChannelState->pfCplxSymbBuff2->pIBuffer[idx];
RECIV_TRAIN_SEQ_Q_2 = pChannelState->pfCplxSymbBuff2->pQBuffer[idx];
// REAL PART
/*
pH_hat_r[0][0] += RECIV_TRAIN_SEQ_I_1 * INV_TRAIN_MATX_R[0][i]-
RECIV_TRAIN_SEQ_Q_1 * INV_TRAIN_MATX_I[0][i];
pH_hat_r[0][1] += RECIV_TRAIN_SEQ_I_1 * INV_TRAIN_MATX_R[1][i]-
RECIV_TRAIN_SEQ_Q_1 * INV_TRAIN_MATX_I[1][i];
pH_hat_r[1][0] += RECIV_TRAIN_SEQ_I_2 * INV_TRAIN_MATX_R[0][i]-
RECIV_TRAIN_SEQ_Q_2 * INV_TRAIN_MATX_I[0][i];
pH_hat_r[1][1] += RECIV_TRAIN_SEQ_I_2 * INV_TRAIN_MATX_R[1][i]-
RECIV_TRAIN_SEQ_Q_2 * INV_TRAIN_MATX_I[1][i];
*/
pH_hat_r[0][0] += RECIV_TRAIN_SEQ_I_1 * S_est_r[i][0]-
RECIV_TRAIN_SEQ_Q_1 * S_est_i[i][0];
pH_hat_r[0][1] += RECIV_TRAIN_SEQ_I_1 * S_est_r[i][1]-
RECIV_TRAIN_SEQ_Q_1 * S_est_i[i][1];
pH_hat_r[1][0] += RECIV_TRAIN_SEQ_I_2 * S_est_r[i][0]-
RECIV_TRAIN_SEQ_Q_2 * S_est_i[i][0];
pH_hat_r[1][1] += RECIV_TRAIN_SEQ_I_2 * S_est_r[i][1]-
RECIV_TRAIN_SEQ_Q_2 * S_est_i[i][1];
// IMAG PART
/* pH_hat_i[0][0] += RECIV_TRAIN_SEQ_Q_1 * INV_TRAIN_MATX_R[0][i]+
RECIV_TRAIN_SEQ_I_1 * INV_TRAIN_MATX_I[0][i];
pH_hat_i[0][1] += RECIV_TRAIN_SEQ_Q_1 * INV_TRAIN_MATX_R[1][i]+
RECIV_TRAIN_SEQ_I_1 * INV_TRAIN_MATX_I[1][i];
pH_hat_i[1][0] += RECIV_TRAIN_SEQ_Q_2 * INV_TRAIN_MATX_R[0][i]+
RECIV_TRAIN_SEQ_I_2 * INV_TRAIN_MATX_I[0][i];
pH_hat_i[1][1] += RECIV_TRAIN_SEQ_Q_2 * INV_TRAIN_MATX_R[1][i]+
RECIV_TRAIN_SEQ_I_2 * INV_TRAIN_MATX_I[1][i];
*/
pH_hat_i[0][0] += RECIV_TRAIN_SEQ_Q_1 * S_est_r[i][0]+
RECIV_TRAIN_SEQ_I_1 * S_est_i[i][0];
pH_hat_i[0][1] += RECIV_TRAIN_SEQ_Q_1 * S_est_r[i][1]+
RECIV_TRAIN_SEQ_I_1 * S_est_i[i][1];
pH_hat_i[1][0] += RECIV_TRAIN_SEQ_Q_2 * S_est_r[i][0]+
RECIV_TRAIN_SEQ_I_2 * S_est_i[i][0];
pH_hat_i[1][1] += RECIV_TRAIN_SEQ_Q_2 * S_est_r[i][1]+
RECIV_TRAIN_SEQ_I_2 * S_est_i[i][1];
}
// Position of switch Ch1Switch
Ai=(pChannelState->Ch1Switch==eSWITCH1 ? 0:1); // Rx1 or Rx2
Bi=(pChannelState->Ch2Switch==eSWITCH3 ? 2:3); // Rx3 or Rx4
// Estimate channel for next frame
pH_pre_r[Ai][0] = (1-factor)*pH_hat_r[0][0] + factor*pH_pre_r[Ai][0];
pH_pre_r[Bi][0] = (1-factor)*pH_hat_r[1][0] + factor*pH_pre_r[Bi][0];
pH_pre_r[Ai][1] = (1-factor)*pH_hat_r[0][1] + factor*pH_pre_r[Ai][1];
pH_pre_r[Bi][1] = (1-factor)*pH_hat_r[1][1] + factor*pH_pre_r[Bi][1];
pH_pre_i[Ai][0] = (1-factor)*pH_hat_i[0][0] + factor*pH_pre_i[Ai][0];
pH_pre_i[Bi][0] = (1-factor)*pH_hat_i[1][0] + factor*pH_pre_i[Bi][0];
pH_pre_i[Ai][1] = (1-factor)*pH_hat_i[0][1] + factor*pH_pre_i[Ai][1];
pH_pre_i[Bi][1] = (1-factor)*pH_hat_i[1][1] + factor*pH_pre_i[Bi][1];
}
/*=== End of global functions definition ===================================*/
/*--- AUTOMATICALLY GENERATED VERSION HISTORY --------------------------------
$Log: /MIMO/Receiver/rxchannelest.c $
*
* 9 05-05-29 23:36 Adrian
* changed the hardcoded inverse training sequence according to the one in
* MATLAB
*
* 8 05-05-27 20:44 Adrian
* modified the buffer access so that it is possible to use a circular
* buffer.
* Removed the bug in pH_pre_r and pH_pre_i (two missing matrix updates)
*
* 7 05-05-20 17:24 Loghman
* Remove TrainingSeqNo and includ alpha to the ChannelState struct
*
* 6 05-05-19 15:09 Loghman
* Change Trainings esq. lenght from 16 to 12
*
* 5 05-05-19 15:05 Loghman
* save memory by changing RECIV_TRAIN_SEQ_I_1[ ] toRECIV_TRAIN_SEQ_I_1.
*
* After verification with MATLAB and DSP, this function works well
* now.
*
* 4 05-05-19 11:19 Loghman
* Initiaize pH_hat_r and pH_hat_i
*
* 3 05-05-12 13:40 Loghman
* Change function from four channel estimation to two channel estimation
*
* 2 05-05-11 18:05 Loghman
*
* 1 05-05-11 17:00 Adrian
* created and added to VSS
===== END OF AUTOMATICALLY GENERATED VERSION HISTORY =======================*/
/**** End of file ***********************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -