Experiments in computing and setting drift automatically

This commit is contained in:
Jordan Sherer 2020-05-06 20:08:30 -04:00
parent 4b36884abb
commit e87704f119
3 changed files with 38 additions and 28 deletions

View File

@ -2,7 +2,7 @@
parameter (NCOSTAS=1) !Which JS8 Costas Arrays to use (1=original, 2=three symmetrical costas)
parameter (NSPS=1920, NTXDUR=15, NDOWNSPS=32, NDD=100, JZ=32) ! 50 Hz 6.250 baud 16 wpm -25.0dB (1.0Eb/N0) 12.64s
parameter (NSPS=1920, NTXDUR=15, NDOWNSPS=32, NDD=100, JZ=36) ! 50 Hz 6.250 baud 16 wpm -25.0dB (1.0Eb/N0) 12.64s
parameter (AZ=12000.0/(1.0*NSPS)*0.64d0) !Dedupe overlap in Hz
parameter (ASTART=0.5) !Start delay in seconds

View File

@ -225,7 +225,7 @@ subroutine js8dec(dd0,icos,newdat,synconly,nQSOProgress,nfqso,nftx,ndepth,lapon,
endif
if(synconly) then
write(*,*) '<DecodeDebug> candidate X ', 'f', f1, 'sync', nsync, 'xdt', xdt
write(*,*) '<DecodeDebug> candidate X ', 'f1', f1, 'sync', nsync, 'xdt', xdt
flush(6)
endif
@ -424,9 +424,8 @@ subroutine js8dec(dd0,icos,newdat,synconly,nQSOProgress,nfqso,nftx,ndepth,lapon,
if(nbadcrc.eq.0) then
if(synconly) then
write(*,*) '<DecodeDebug> decode X ', 'f1', f1, 'sync', sync, 'xdt', xdt2
write(*,*) '<DecodeDebug> decode X ', 'f1', f1, 'sync', (sync*10), 'xdt', xdt2
flush(6)
return
endif
decoded0=decoded

View File

@ -4872,6 +4872,10 @@ void MainWindow::processDecodedLine(QByteArray t){
bool bAvgMsg=false;
int navg=0;
static bool hasNewDrift = false;
static int newDrift = 0;
if(t.indexOf("<DecodeDebug>") >= 0) {
if(t.indexOf("f1") >= 0){
auto segs = QString(t.trimmed()).split(QRegExp("[\\s\\t]+"), QString::SkipEmptyParts);
@ -4885,37 +4889,36 @@ void MainWindow::processDecodedLine(QByteArray t){
auto xdt1 = QString(segs.at(8));
auto xdt = int(xdt1.toFloat());
if(abs(xdt) <= 1.28){
//if(s > 7 && s < 10){
// m_wideGraph->drawLine(QColor(Qt::white), f, f + computeBandwidthForSubmode(m_nSubMode));
//} else if (s < 15){
// m_wideGraph->drawLine(QColor(Qt::darkMagenta), f, f + computeBandwidthForSubmode(m_nSubMode));
//} else {
/*
int secs = DriftingDateTime::currentDateTimeUtc().secsTo(nextTransmitCycle());
int txtime = computeFramesNeededForDecode(m_nSubMode)/RX_SAMPLE_RATE;
qDebug() << "seconds til transmit" << secs << "time offset" << xdt << "potential drift" << (secs-xdt)*1000;
setDrift((secs+xdt-txtime)*1000);
*/
if(abs(xdt) <= 2){
if(s < 10){
m_wideGraph->drawLine(QColor(Qt::darkCyan), f, f + computeBandwidthForSubmode(m_nSubMode));
} else if (s <= 21){
m_wideGraph->drawLine(QColor(Qt::white), f, f + computeBandwidthForSubmode(m_nSubMode));
}
}
if(t.contains("decode X")){
auto now = QDateTime::currentDateTimeUtc();
int n = 0;
int nPos = m_TRperiod - (now.time().second() % m_TRperiod);
int nNeg = (now.time().second() % m_TRperiod) - m_TRperiod;
float n = 0;
float nPos = m_TRperiod - (now.time().second() % m_TRperiod);
float nNeg = (now.time().second() % m_TRperiod) - m_TRperiod;
float offset = m_TRperiod - computeFramesNeededForDecode(m_nSubMode)/RX_SAMPLE_RATE + xdt;
if(abs(nNeg) < nPos){
n = nNeg;
if(qAbs(nNeg) < nPos){
n = nNeg + offset;
} else {
n = nPos;
n = nPos - offset;
}
int xdtmin = qMin(n*1000, (float)DriftingDateTime::drift());
int xdtmax = qMax(n*1000, (float)DriftingDateTime::drift());
int xdtmin = qMin(n*1000, (int)DriftingDateTime::drift());
int xdtmax = qMax(n*1000, (int)DriftingDateTime::drift());
setDrift(xdtmin + (xdtmax-xdtmin)/2);
m_wideGraph->drawLine(QColor(Qt::red), f, f + computeBandwidthForSubmode(m_nSubMode));
//}
m_wideGraph->drawLine(QColor(Qt::red), f, f + computeBandwidthForSubmode(m_nSubMode));
int oldNewDrift = newDrift;
newDrift = (xdtmin + (xdtmax-xdtmin)/2);
newDrift = qMin(oldNewDrift, newDrift) + (qMax(oldNewDrift, newDrift)-qMin(oldNewDrift, newDrift))/2;
hasNewDrift = true;
}
}
}
@ -4931,6 +4934,14 @@ void MainWindow::processDecodedLine(QByteArray t){
}
if(t.indexOf("<DecodeFinished>") >= 0) {
if(hasNewDrift){
int oldDrift = DriftingDateTime::drift();
newDrift = qMin(oldDrift, newDrift) + (qMax(oldDrift, newDrift)-qMin(oldDrift, newDrift))/2;
setDrift(newDrift);
hasNewDrift = false;
}
m_bDecoded = t.mid(16).trimmed().toInt() > 0;
int mswait=3*1000*m_TRperiod/4;
if(!m_diskData) killFileTimer.start(mswait); //Kill in 3/4 period