diff --git a/Desktop_Interface/Labrador.pro.user b/Desktop_Interface/Labrador.pro.user index 0c94ad3c..7dd480fc 100644 --- a/Desktop_Interface/Labrador.pro.user +++ b/Desktop_Interface/Labrador.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -8,7 +8,7 @@ ProjectExplorer.Project.ActiveTarget - 2 + 0 ProjectExplorer.Project.EditorSettings diff --git a/Desktop_Interface/bin/Labrador.exe b/Desktop_Interface/bin/Labrador.exe index f90819d6..9763c35d 100644 Binary files a/Desktop_Interface/bin/Labrador.exe and b/Desktop_Interface/bin/Labrador.exe differ diff --git a/Desktop_Interface/isobuffer.cpp b/Desktop_Interface/isobuffer.cpp index c38361b5..aaa7678b 100644 --- a/Desktop_Interface/isobuffer.cpp +++ b/Desktop_Interface/isobuffer.cpp @@ -191,7 +191,7 @@ double isoBuffer::sampleConvert(short sample, int TOP, bool AC){ double voltageLevel; voltageLevel = (sample * (vcc/2)) / (R4/(R3+R4)*scope_gain*TOP); - if (virtualParent->driver->deviceMode != 7) voltageLevel += vcc*(R2/(R1+R2)); + if (virtualParent->driver->deviceMode != 7) voltageLevel += voltage_ref; #ifdef INVERT_MM if(virtualParent->driver->deviceMode == 7) voltageLevel *= -1; #endif diff --git a/Desktop_Interface/isobuffer.h b/Desktop_Interface/isobuffer.h index a2a3208c..dc884c7a 100644 --- a/Desktop_Interface/isobuffer.h +++ b/Desktop_Interface/isobuffer.h @@ -44,6 +44,7 @@ public: bool serialAutoScroll = true; unsigned char channel = 255; QTimer *updateTimer; + double voltage_ref = 1.65; private: //Generic Vars short *buffer, *readData = NULL; diff --git a/Desktop_Interface/isodriver.cpp b/Desktop_Interface/isodriver.cpp index b847c0bb..3128765d 100644 --- a/Desktop_Interface/isodriver.cpp +++ b/Desktop_Interface/isodriver.cpp @@ -109,17 +109,19 @@ void isoDriver::timerTick(void){ //free(isoTemp); } -void isoDriver::analogConvert(short *shortPtr, QVector *doublePtr, int TOP, bool AC){ +void isoDriver::analogConvert(short *shortPtr, QVector *doublePtr, int TOP, bool AC, int channel){ double scope_gain = (double)(driver->scopeGain); double accumulated = 0; currentVmax = -20; currentVmin = 20; + double ref = (channel == 1 ? ch1_ref : ch2_ref); + double *data = doublePtr->data(); for (int i=0;ideviceMode != 7) data[i] += vcc*(R2/(R1+R2)); + if (driver->deviceMode != 7) data[i] += ref; #ifdef INVERT_MM if(driver->deviceMode == 7) data[i] *= -1; #endif @@ -688,7 +690,7 @@ void isoDriver::frameActionGeneric(char CH1_mode, char CH2_mode) //0 for off, 1 if (CH1_mode == 1){ - analogConvert(readData375_CH1, &CH1, 128, AC_CH1); + analogConvert(readData375_CH1, &CH1, 128, AC_CH1, 1); xmin = (currentVmin < xmin) ? currentVmin : xmin; xmax = (currentVmax > xmax) ? currentVmax : xmax; broadcastStats(0); @@ -696,7 +698,7 @@ void isoDriver::frameActionGeneric(char CH1_mode, char CH2_mode) //0 for off, 1 if (CH1_mode == 2) digitalConvert(readData375_CH1, &CH1); if (CH2_mode == 1){ - analogConvert(readData375_CH2, &CH2, 128, AC_CH2); + analogConvert(readData375_CH2, &CH2, 128, AC_CH2, 2); ymin = (currentVmin < ymin) ? currentVmin : ymin; ymax = (currentVmax > ymax) ? currentVmax : ymax; broadcastStats(1); @@ -704,7 +706,7 @@ void isoDriver::frameActionGeneric(char CH1_mode, char CH2_mode) //0 for off, 1 if (CH2_mode == 2) digitalConvert(readData375_CH2, &CH2); if(CH1_mode == -1) { - analogConvert(readData750, &CH1, 128, AC_CH1); + analogConvert(readData750, &CH1, 128, AC_CH1, 1); xmin = (currentVmin < xmin) ? currentVmin : xmin; xmax = (currentVmax > xmax) ? currentVmax : xmax; broadcastStats(0); @@ -820,7 +822,7 @@ void isoDriver::multimeterAction(){ readData375_CH1 = internalBuffer375_CH1->readBuffer(window,GRAPH_SAMPLES, false, delay + ((triggerEnabled&&!paused_multimeter) ? triggerDelay + window/2 : 0)); QVector x(GRAPH_SAMPLES), CH1(GRAPH_SAMPLES); - analogConvert(readData375_CH1, &CH1, 2048, 0); //No AC coupling! + analogConvert(readData375_CH1, &CH1, 2048, 0, 1); //No AC coupling! for (double i=0; i *doublePtr, int TOP, bool AC); + void analogConvert(short *shortPtr, QVector *doublePtr, int TOP, bool AC, int channel); void digitalConvert(short *shortPtr, QVector *doublePtr); bool properlyPaused(); void autoGain(void); diff --git a/Desktop_Interface/mainwindow.cpp b/Desktop_Interface/mainwindow.cpp index 8dde9084..9ccb6c1f 100644 --- a/Desktop_Interface/mainwindow.cpp +++ b/Desktop_Interface/mainwindow.cpp @@ -1269,10 +1269,19 @@ void MainWindow::vertScaleEvent(bool enabled){ void MainWindow::on_actionCalibrate_triggered() { //Must be mode 4 - //Must be AC + //Must be DC coupled + //Voltage must be disconnected qDebug() << "Calibration routine beginning!"; unsigned char oldMode = ui->controller_iso->driver->deviceMode; + + ui->controller_iso->ch1_ref = 1.65; + ui->controller_iso->ch2_ref = 1.65; + + ui->controller_iso->internalBuffer375_CH1->voltage_ref = 1.65; + ui->controller_iso->internalBuffer750->voltage_ref = 1.65; + ui->controller_iso->internalBuffer375_CH2->voltage_ref = 1.65; + ui->controller_iso->clearBuffers(1,0,0); QTimer::singleShot(1200, this, SLOT(calibrateStage2())); } @@ -1280,7 +1289,15 @@ void MainWindow::on_actionCalibrate_triggered() void MainWindow::calibrateStage2(){ double vref_CH1 = ui->controller_iso->meanVoltageLast(1, 1); double vref_CH2 = ui->controller_iso->meanVoltageLast(1, 2); - qDebug() << "VRef (CH1) = " << centre_voltage_CH1; - qDebug() << "VRef (CH2) = " << centre_voltage_CH2; + qDebug() << "VRef (CH1) = " << vref_CH1; + qDebug() << "VRef (CH2) = " << vref_CH2; + + ui->controller_iso->ch1_ref = 3.3 - vref_CH1; + ui->controller_iso->ch2_ref = 3.3 - vref_CH2; + + ui->controller_iso->internalBuffer375_CH1->voltage_ref = 3.3 - vref_CH1; + ui->controller_iso->internalBuffer750->voltage_ref = 3.3 - vref_CH1; + ui->controller_iso->internalBuffer375_CH2->voltage_ref = 3.3 - vref_CH2; + } diff --git a/Desktop_Interface/release/isobuffer.obj b/Desktop_Interface/release/isobuffer.obj index 33fd1a03..7bd229fb 100644 Binary files a/Desktop_Interface/release/isobuffer.obj and b/Desktop_Interface/release/isobuffer.obj differ diff --git a/Desktop_Interface/release/isodriver.obj b/Desktop_Interface/release/isodriver.obj index f4a92a9e..3157a396 100644 Binary files a/Desktop_Interface/release/isodriver.obj and b/Desktop_Interface/release/isodriver.obj differ diff --git a/Desktop_Interface/release/main.obj b/Desktop_Interface/release/main.obj index 7d641335..efca7bbd 100644 Binary files a/Desktop_Interface/release/main.obj and b/Desktop_Interface/release/main.obj differ diff --git a/Desktop_Interface/release/mainwindow.obj b/Desktop_Interface/release/mainwindow.obj index ae8d20c3..699e3dcd 100644 Binary files a/Desktop_Interface/release/mainwindow.obj and b/Desktop_Interface/release/mainwindow.obj differ diff --git a/Desktop_Interface/release/moc_isobuffer.obj b/Desktop_Interface/release/moc_isobuffer.obj index e761c43c..eab43216 100644 Binary files a/Desktop_Interface/release/moc_isobuffer.obj and b/Desktop_Interface/release/moc_isobuffer.obj differ diff --git a/Desktop_Interface/release/moc_isodriver.obj b/Desktop_Interface/release/moc_isodriver.obj index 83634db4..aff3ddee 100644 Binary files a/Desktop_Interface/release/moc_isodriver.obj and b/Desktop_Interface/release/moc_isodriver.obj differ diff --git a/Desktop_Interface/release/moc_mainwindow.obj b/Desktop_Interface/release/moc_mainwindow.obj index 5f7a881e..52454ace 100644 Binary files a/Desktop_Interface/release/moc_mainwindow.obj and b/Desktop_Interface/release/moc_mainwindow.obj differ