diff --git a/Source/DeviceThread.cpp b/Source/DeviceThread.cpp index 6ee2e2c..cf4ec03 100644 --- a/Source/DeviceThread.cpp +++ b/Source/DeviceThread.cpp @@ -2136,10 +2136,13 @@ short DeviceThread::getAdcRange(int channel) const void DeviceThread::runImpedanceTest() { if (!checkBoardMem()) return; - impedanceThread->stopThreadSafely(); + + setSampleRate(Rhd2000ONIBoard::SampleRate30000Hz, true, false); // set to 30 kHz temporarily impedanceThread->runThread(); + setSampleRate(settings.savedSampleRateIndex, false, true); // set to 30 kHz temporarily + } diff --git a/Source/ImpedanceMeter.cpp b/Source/ImpedanceMeter.cpp index 39b0596..2ddcb19 100644 --- a/Source/ImpedanceMeter.cpp +++ b/Source/ImpedanceMeter.cpp @@ -359,8 +359,10 @@ void ImpedanceMeter::runImpedanceMeasurement(Impedances& impedances) int numPeriods = (0.020 * actualImpedanceFreq); // Test each channel for at least 20 msec... if (numPeriods < 5) numPeriods = 5; // ...but always measure across no fewer than 5 complete periods double period = board->settings.boardSampleRate / actualImpedanceFreq; - int numBlocks = ceil((numPeriods + 2.0) * period / 60.0); // + 2 periods to give time to settle initially + int numBlocks = ceil((numPeriods + 2) * period / float(SAMPLES_PER_DATA_BLOCK(board->evalBoard->isUSB3()))); // + 2 periods to give time to settle initially + LOGD("ImpedanceMeter: Initial numBlocks = ", numBlocks); if (numBlocks < 2) numBlocks = 2; // need first block for command to switch channels to take effect. + LOGD("ImpedanceMeter: Padded numBlocks = ", numBlocks); CHECK_EXIT; board->settings.dsp.cutoffFreq = board->chipRegisters.setDspCutoffFreq(board->settings.dsp.cutoffFreq);