Optimize signal gain scaling
This commit is contained in:
parent
d0c52e33d0
commit
8704c4ec7c
22
gpssim.c
22
gpssim.c
@ -1655,7 +1655,7 @@ void usage(void)
|
||||
" -l <location> Lat,Lon,Hgt (static mode) e.g. 35.681298,139.766247,10.0\n"
|
||||
" -t <date,time> Scenario start time YYYY/MM/DD,hh:mm:ss\n"
|
||||
" -T <date,time> Overwrite TOC and TOE to scenario start time\n"
|
||||
" -d <duration> Duration [sec] (dynamic mode max: %.0f static mode max: %d)\n"
|
||||
" -d <duration> Duration [sec] (dynamic mode max: %.0f, static mode max: %d)\n"
|
||||
" -o <output> I/Q sampling data file (default: gpssim.bin)\n"
|
||||
" -s <frequency> Sampling frequency [Hz] (default: 2600000)\n"
|
||||
" -b <iq_bits> I/Q data format [1/8/16] (default: 16)\n"
|
||||
@ -1740,6 +1740,7 @@ int main(int argc, char *argv[])
|
||||
data_format = SC16;
|
||||
g0.week = -1; // Invalid start time
|
||||
iduration = USER_MOTION_SIZE;
|
||||
duration = (double)iduration/10.0; // Default duration
|
||||
verb = FALSE;
|
||||
ionoutc.enable = TRUE;
|
||||
|
||||
@ -2139,6 +2140,7 @@ int main(int argc, char *argv[])
|
||||
computeRange(&rho, eph[ieph][sv], &ionoutc, grx, xyz[iumd]);
|
||||
else
|
||||
computeRange(&rho, eph[ieph][sv], &ionoutc, grx, xyz[0]);
|
||||
|
||||
chan[i].azel[0] = rho.azel[0];
|
||||
chan[i].azel[1] = rho.azel[1];
|
||||
|
||||
@ -2154,7 +2156,7 @@ int main(int argc, char *argv[])
|
||||
ant_gain = ant_pat[ibs];
|
||||
|
||||
// Signal gain
|
||||
gain[i] = (int)(path_loss*ant_gain*100.0); // scaled by 100
|
||||
gain[i] = (int)(path_loss*ant_gain*128.0); // scaled by 2^7
|
||||
}
|
||||
}
|
||||
|
||||
@ -2172,8 +2174,9 @@ int main(int argc, char *argv[])
|
||||
ip = chan[i].dataBit * chan[i].codeCA * cosTable512[iTable] * gain[i];
|
||||
qp = chan[i].dataBit * chan[i].codeCA * sinTable512[iTable] * gain[i];
|
||||
|
||||
i_acc += (ip + 50)/100;
|
||||
q_acc += (qp + 50)/100;
|
||||
// Accumulate for all visible satellites
|
||||
i_acc += ip;
|
||||
q_acc += qp;
|
||||
|
||||
// Update code phase
|
||||
chan[i].code_phase += chan[i].f_code * delt;
|
||||
@ -2212,11 +2215,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// Scaled by 2^7
|
||||
i_acc = (i_acc+64)>>7;
|
||||
q_acc = (q_acc+64)>>7;
|
||||
|
||||
// Store I/Q samples into buffer
|
||||
iq_buff[isamp*2] = (short)i_acc;
|
||||
iq_buff[isamp*2+1] = (short)q_acc;
|
||||
|
||||
} // End of omp parallel for
|
||||
}
|
||||
|
||||
if (data_format==SC01)
|
||||
{
|
||||
@ -2239,10 +2245,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else // data_format==SC16
|
||||
{
|
||||
/*
|
||||
for (isamp=0; isamp<2*iq_buff_size; isamp++)
|
||||
iq_buff[isamp] = iq_buff[isamp]>0?1000:-1000; // Emulated 1-bit I/Q
|
||||
*/
|
||||
fwrite(iq_buff, 2, 2*iq_buff_size, fp);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user