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"
|
" -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> Scenario start time YYYY/MM/DD,hh:mm:ss\n"
|
||||||
" -T <date,time> Overwrite TOC and TOE to scenario start time\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"
|
" -o <output> I/Q sampling data file (default: gpssim.bin)\n"
|
||||||
" -s <frequency> Sampling frequency [Hz] (default: 2600000)\n"
|
" -s <frequency> Sampling frequency [Hz] (default: 2600000)\n"
|
||||||
" -b <iq_bits> I/Q data format [1/8/16] (default: 16)\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;
|
data_format = SC16;
|
||||||
g0.week = -1; // Invalid start time
|
g0.week = -1; // Invalid start time
|
||||||
iduration = USER_MOTION_SIZE;
|
iduration = USER_MOTION_SIZE;
|
||||||
|
duration = (double)iduration/10.0; // Default duration
|
||||||
verb = FALSE;
|
verb = FALSE;
|
||||||
ionoutc.enable = TRUE;
|
ionoutc.enable = TRUE;
|
||||||
|
|
||||||
@ -2139,6 +2140,7 @@ int main(int argc, char *argv[])
|
|||||||
computeRange(&rho, eph[ieph][sv], &ionoutc, grx, xyz[iumd]);
|
computeRange(&rho, eph[ieph][sv], &ionoutc, grx, xyz[iumd]);
|
||||||
else
|
else
|
||||||
computeRange(&rho, eph[ieph][sv], &ionoutc, grx, xyz[0]);
|
computeRange(&rho, eph[ieph][sv], &ionoutc, grx, xyz[0]);
|
||||||
|
|
||||||
chan[i].azel[0] = rho.azel[0];
|
chan[i].azel[0] = rho.azel[0];
|
||||||
chan[i].azel[1] = rho.azel[1];
|
chan[i].azel[1] = rho.azel[1];
|
||||||
|
|
||||||
@ -2154,7 +2156,7 @@ int main(int argc, char *argv[])
|
|||||||
ant_gain = ant_pat[ibs];
|
ant_gain = ant_pat[ibs];
|
||||||
|
|
||||||
// Signal gain
|
// 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];
|
ip = chan[i].dataBit * chan[i].codeCA * cosTable512[iTable] * gain[i];
|
||||||
qp = chan[i].dataBit * chan[i].codeCA * sinTable512[iTable] * gain[i];
|
qp = chan[i].dataBit * chan[i].codeCA * sinTable512[iTable] * gain[i];
|
||||||
|
|
||||||
i_acc += (ip + 50)/100;
|
// Accumulate for all visible satellites
|
||||||
q_acc += (qp + 50)/100;
|
i_acc += ip;
|
||||||
|
q_acc += qp;
|
||||||
|
|
||||||
// Update code phase
|
// Update code phase
|
||||||
chan[i].code_phase += chan[i].f_code * delt;
|
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
|
// Store I/Q samples into buffer
|
||||||
iq_buff[isamp*2] = (short)i_acc;
|
iq_buff[isamp*2] = (short)i_acc;
|
||||||
iq_buff[isamp*2+1] = (short)q_acc;
|
iq_buff[isamp*2+1] = (short)q_acc;
|
||||||
|
}
|
||||||
} // End of omp parallel for
|
|
||||||
|
|
||||||
if (data_format==SC01)
|
if (data_format==SC01)
|
||||||
{
|
{
|
||||||
@ -2239,10 +2245,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else // data_format==SC16
|
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);
|
fwrite(iq_buff, 2, 2*iq_buff_size, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user