Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for impedance measurement bug #19

Merged
merged 4 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Source/DeviceThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

}


Expand Down
4 changes: 3 additions & 1 deletion Source/ImpedanceMeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down