mirror of https://github.com/EspoTek/Labrador.git
Recentreing in.
This commit is contained in:
parent
7c3ae61fe8
commit
445a301029
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 4.1.0, 2017-06-20T08:23:37. -->
|
<!-- Written by QtCreator 4.1.0, 2017-06-22T14:16:09. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
<value type="int">2</value>
|
<value type="int">0</value>
|
||||||
</data>
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||||
|
|
Binary file not shown.
|
@ -191,7 +191,7 @@ double isoBuffer::sampleConvert(short sample, int TOP, bool AC){
|
||||||
double voltageLevel;
|
double voltageLevel;
|
||||||
|
|
||||||
voltageLevel = (sample * (vcc/2)) / (R4/(R3+R4)*scope_gain*TOP);
|
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
|
#ifdef INVERT_MM
|
||||||
if(virtualParent->driver->deviceMode == 7) voltageLevel *= -1;
|
if(virtualParent->driver->deviceMode == 7) voltageLevel *= -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
bool serialAutoScroll = true;
|
bool serialAutoScroll = true;
|
||||||
unsigned char channel = 255;
|
unsigned char channel = 255;
|
||||||
QTimer *updateTimer;
|
QTimer *updateTimer;
|
||||||
|
double voltage_ref = 1.65;
|
||||||
private:
|
private:
|
||||||
//Generic Vars
|
//Generic Vars
|
||||||
short *buffer, *readData = NULL;
|
short *buffer, *readData = NULL;
|
||||||
|
|
|
@ -109,17 +109,19 @@ void isoDriver::timerTick(void){
|
||||||
//free(isoTemp);
|
//free(isoTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void isoDriver::analogConvert(short *shortPtr, QVector<double> *doublePtr, int TOP, bool AC){
|
void isoDriver::analogConvert(short *shortPtr, QVector<double> *doublePtr, int TOP, bool AC, int channel){
|
||||||
|
|
||||||
double scope_gain = (double)(driver->scopeGain);
|
double scope_gain = (double)(driver->scopeGain);
|
||||||
double accumulated = 0;
|
double accumulated = 0;
|
||||||
currentVmax = -20;
|
currentVmax = -20;
|
||||||
currentVmin = 20;
|
currentVmin = 20;
|
||||||
|
|
||||||
|
double ref = (channel == 1 ? ch1_ref : ch2_ref);
|
||||||
|
|
||||||
double *data = doublePtr->data();
|
double *data = doublePtr->data();
|
||||||
for (int i=0;i<GRAPH_SAMPLES;i++){
|
for (int i=0;i<GRAPH_SAMPLES;i++){
|
||||||
data[i] = (shortPtr[i] * (vcc/2)) / (R4/(R3+R4)*scope_gain*TOP);
|
data[i] = (shortPtr[i] * (vcc/2)) / (R4/(R3+R4)*scope_gain*TOP);
|
||||||
if (driver->deviceMode != 7) data[i] += vcc*(R2/(R1+R2));
|
if (driver->deviceMode != 7) data[i] += ref;
|
||||||
#ifdef INVERT_MM
|
#ifdef INVERT_MM
|
||||||
if(driver->deviceMode == 7) data[i] *= -1;
|
if(driver->deviceMode == 7) data[i] *= -1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -688,7 +690,7 @@ void isoDriver::frameActionGeneric(char CH1_mode, char CH2_mode) //0 for off, 1
|
||||||
|
|
||||||
|
|
||||||
if (CH1_mode == 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;
|
xmin = (currentVmin < xmin) ? currentVmin : xmin;
|
||||||
xmax = (currentVmax > xmax) ? currentVmax : xmax;
|
xmax = (currentVmax > xmax) ? currentVmax : xmax;
|
||||||
broadcastStats(0);
|
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 (CH1_mode == 2) digitalConvert(readData375_CH1, &CH1);
|
||||||
|
|
||||||
if (CH2_mode == 1){
|
if (CH2_mode == 1){
|
||||||
analogConvert(readData375_CH2, &CH2, 128, AC_CH2);
|
analogConvert(readData375_CH2, &CH2, 128, AC_CH2, 2);
|
||||||
ymin = (currentVmin < ymin) ? currentVmin : ymin;
|
ymin = (currentVmin < ymin) ? currentVmin : ymin;
|
||||||
ymax = (currentVmax > ymax) ? currentVmax : ymax;
|
ymax = (currentVmax > ymax) ? currentVmax : ymax;
|
||||||
broadcastStats(1);
|
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 (CH2_mode == 2) digitalConvert(readData375_CH2, &CH2);
|
||||||
|
|
||||||
if(CH1_mode == -1) {
|
if(CH1_mode == -1) {
|
||||||
analogConvert(readData750, &CH1, 128, AC_CH1);
|
analogConvert(readData750, &CH1, 128, AC_CH1, 1);
|
||||||
xmin = (currentVmin < xmin) ? currentVmin : xmin;
|
xmin = (currentVmin < xmin) ? currentVmin : xmin;
|
||||||
xmax = (currentVmax > xmax) ? currentVmax : xmax;
|
xmax = (currentVmax > xmax) ? currentVmax : xmax;
|
||||||
broadcastStats(0);
|
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));
|
readData375_CH1 = internalBuffer375_CH1->readBuffer(window,GRAPH_SAMPLES, false, delay + ((triggerEnabled&&!paused_multimeter) ? triggerDelay + window/2 : 0));
|
||||||
|
|
||||||
QVector<double> x(GRAPH_SAMPLES), CH1(GRAPH_SAMPLES);
|
QVector<double> 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<GRAPH_SAMPLES; i++){
|
for (double i=0; i<GRAPH_SAMPLES; i++){
|
||||||
x[i] = -(window*i)/((double)(GRAPH_SAMPLES-1)) - delay;
|
x[i] = -(window*i)/((double)(GRAPH_SAMPLES-1)) - delay;
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
genericUsbDriver *driver;
|
genericUsbDriver *driver;
|
||||||
bool doNotTouchGraph = true;
|
bool doNotTouchGraph = true;
|
||||||
|
double ch1_ref = 1.65, ch2_ref = 1.65;
|
||||||
//State Vars
|
//State Vars
|
||||||
bool AC_CH1 = false, AC_CH2 = false;
|
bool AC_CH1 = false, AC_CH2 = false;
|
||||||
bool cursorStatsEnabled = true;
|
bool cursorStatsEnabled = true;
|
||||||
|
@ -63,7 +64,7 @@ private:
|
||||||
double triggerDelay;
|
double triggerDelay;
|
||||||
bool singleShotEnabled = false;
|
bool singleShotEnabled = false;
|
||||||
//Generic Functions
|
//Generic Functions
|
||||||
void analogConvert(short *shortPtr, QVector<double> *doublePtr, int TOP, bool AC);
|
void analogConvert(short *shortPtr, QVector<double> *doublePtr, int TOP, bool AC, int channel);
|
||||||
void digitalConvert(short *shortPtr, QVector<double> *doublePtr);
|
void digitalConvert(short *shortPtr, QVector<double> *doublePtr);
|
||||||
bool properlyPaused();
|
bool properlyPaused();
|
||||||
void autoGain(void);
|
void autoGain(void);
|
||||||
|
|
|
@ -1269,10 +1269,19 @@ void MainWindow::vertScaleEvent(bool enabled){
|
||||||
void MainWindow::on_actionCalibrate_triggered()
|
void MainWindow::on_actionCalibrate_triggered()
|
||||||
{
|
{
|
||||||
//Must be mode 4
|
//Must be mode 4
|
||||||
//Must be AC
|
//Must be DC coupled
|
||||||
|
//Voltage must be disconnected
|
||||||
|
|
||||||
qDebug() << "Calibration routine beginning!";
|
qDebug() << "Calibration routine beginning!";
|
||||||
unsigned char oldMode = ui->controller_iso->driver->deviceMode;
|
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);
|
ui->controller_iso->clearBuffers(1,0,0);
|
||||||
QTimer::singleShot(1200, this, SLOT(calibrateStage2()));
|
QTimer::singleShot(1200, this, SLOT(calibrateStage2()));
|
||||||
}
|
}
|
||||||
|
@ -1280,7 +1289,15 @@ void MainWindow::on_actionCalibrate_triggered()
|
||||||
void MainWindow::calibrateStage2(){
|
void MainWindow::calibrateStage2(){
|
||||||
double vref_CH1 = ui->controller_iso->meanVoltageLast(1, 1);
|
double vref_CH1 = ui->controller_iso->meanVoltageLast(1, 1);
|
||||||
double vref_CH2 = ui->controller_iso->meanVoltageLast(1, 2);
|
double vref_CH2 = ui->controller_iso->meanVoltageLast(1, 2);
|
||||||
qDebug() << "VRef (CH1) = " << centre_voltage_CH1;
|
qDebug() << "VRef (CH1) = " << vref_CH1;
|
||||||
qDebug() << "VRef (CH2) = " << centre_voltage_CH2;
|
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;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue