From 554836d1f3d42d46f19682cad4fc498c7c121276 Mon Sep 17 00:00:00 2001 From: Antoine Grenier Date: Wed, 12 Apr 2023 11:12:01 +0300 Subject: [PATCH] [Convert Channel class to C implementation #44] Continue acquisition convertion, not working. --- core/c_functions/channel_l1ca.c | 97 ++++++++++++++++++++++++++++----- core/c_functions/fft8g.h | 33 +++++++++++ 2 files changed, 115 insertions(+), 15 deletions(-) diff --git a/core/c_functions/channel_l1ca.c b/core/c_functions/channel_l1ca.c index 57322e3..1efdce6 100644 --- a/core/c_functions/channel_l1ca.c +++ b/core/c_functions/channel_l1ca.c @@ -2,6 +2,8 @@ #include #include +#include "fft8g.h" + /// CONSTANTS // GPS' definition of Pi #define PI 3.1415926535898 @@ -38,6 +40,7 @@ struct st_Channel_L1CA { // Satellite variables int satelliteID; // PRN number int* code; // PRN code sequence (size 1023 for GPS L1CA) + complex double* codeFFT; // Numerically Controled Oscilator (NCO) double NCO_code; @@ -53,7 +56,14 @@ struct st_Channel_L1CA { double codeCounter; // Acquisition parameters - + complex double* cohCorrelationMap; + double* correlationMap; + int acq_nbCohIntegration; + int acq_nbNoncohIntegration; + double acq_frequencyRange; + double acq_frequencySteps; + int cohIntegrationCounter; + int noncohIntegrationCounter; // Tracking parameters double* correlatorsSpacing; @@ -106,8 +116,45 @@ void ProcessHandler(st_Channel_L1CA channelVar){ // -------------------------------------------------------------------------------------------------------------------- -void RunAcquisition(){ +void RunAcquisition(st_Channel_L1CA channelVar){ + + int nbBins = channelVar.acq_frequencyRange*2 / channelVar.acq_frequencySteps + 1; + complex double _correlationMap[nbBins][channelVar.size]; + + // Perform PCPS + PCPS( + channelVar.rfData, channelVar.codeFFT, channelVar.size, channelVar.acq_frequencyRange, + channelVar.acq_frequencySteps, channelVar.samplingFrequency, _correlationMap + ); + + // Perform coherent / non-coherent integration + for(int i=0; i < nbBins; i++){ + for(int j=0; j < channelVar.size; j++){ + + // Coherent integration + channelVar.cohCorrelationMap[i][j] += _correlationMap[i][j]; + + if (channelVar.cohIntegrationCounter+1 == channelVar.acq_nbCohIntegration){ + // Non-coherent integration + channelVar.correlationMap[i][j] += abs(channelVar.cohCorrelationMap[i][j]); + + // Reset variables + channelVar.cohCorrelationMap[i][j] = 0.0; + channelVar.cohIntegrationCounter = 0; + } + else{ + channelVar.cohIntegrationCounter++; + } + } + } + + // Perform non-coherent integration + if(channelVar.cohIntegrationCounter >= channelVar.acq_nbCohIntegration){ + + } + + return; } // -------------------------------------------------------------------------------------------------------------------- @@ -158,30 +205,50 @@ void RunTracking(st_Channel_L1CA channelVar){ // -------------------------------------------------------------------------------------------------------------------- -void PCPS(complex double* rfData, double* code, size_t size, double freqRange, double freqstep, int cohIntegration, - int nonCohIntegration, double samplesPerCode, double samplingFreq){ +void PCPS(complex double* rfData, complex double* codeFFT, size_t size, double freqRange, double freqStep, + double samplingFreq, complex double* r_correlationMap){ - size_t size_phasePoints = cohIntegration * samplesPerCode]; - double* phasePoints[size_phasePoints]; + int nbBins = freqRange*2 / freqStep + 1; + double phasePoints[size]; + complex double signal[size]; + double freq = 0.0; // Compute the phase points - for(int i=0; i < cohIntegration * samplesPerCode; i++){ - phasePoints[i] = i * 2 * PI / samplingFreq + for(int i=0; i < size; i++){ + phasePoints[i] = i * 2 * PI / samplingFreq; } // Compute frequency bins - int i = 0; - double freq = 0.0 - while(freq < freqRange){ - freq = -freqRange + freqStep * i + for(int i = 0; i < nbBins; i++){ + freq = -freqRange + freqStep * i; - // Generate replica - for(int i=0; i