sense actual Vm value

This commit is contained in:
Matthew Kennedy 2020-12-11 00:25:50 -08:00
parent b0d837f038
commit d89cda413b
3 changed files with 5 additions and 5 deletions

View File

@ -17,7 +17,7 @@ ADCConversionGroup convGroup =
ADC_CFGR1_CONT | ADC_CFGR1_RES_12BIT, // CFGR1 ADC_CFGR1_CONT | ADC_CFGR1_RES_12BIT, // CFGR1
ADC_TR(0, 0), // TR ADC_TR(0, 0), // TR
ADC_SMPR_SMP_7P5, // SMPR ADC_SMPR_SMP_7P5, // SMPR
ADC_CHSELR_CHSEL0 | ADC_CHSELR_CHSEL1 | ADC_CHSELR_CHSEL2 ADC_CHSELR_CHSEL0 | ADC_CHSELR_CHSEL2 | ADC_CHSELR_CHSEL3
}; };
static float AverageSamples(adcsample_t* buffer, size_t idx) static float AverageSamples(adcsample_t* buffer, size_t idx)
@ -42,7 +42,7 @@ AnalogResult AnalogSample()
return return
{ {
.NernstVoltage = AverageSamples(adcBuffer, 0) * NERNST_INPUT_GAIN, .NernstVoltage = AverageSamples(adcBuffer, 0) * NERNST_INPUT_GAIN,
.VirtualGroundVoltage = AverageSamples(adcBuffer, 1), .PumpCurrentVoltage = AverageSamples(adcBuffer, 1),
.PumpCurrentVoltage = AverageSamples(adcBuffer, 2), .VirtualGroundVoltageInt = AverageSamples(adcBuffer, 2),
}; };
} }

View File

@ -3,8 +3,8 @@
struct AnalogResult struct AnalogResult
{ {
float NernstVoltage; float NernstVoltage;
float VirtualGroundVoltage;
float PumpCurrentVoltage; float PumpCurrentVoltage;
float VirtualGroundVoltageInt;
}; };
AnalogResult AnalogSample(); AnalogResult AnalogSample();

View File

@ -43,7 +43,7 @@ static void SamplingThread(void*)
nernstAc = f_abs(r2_opposite_phase - r_2); nernstAc = f_abs(r2_opposite_phase - r_2);
nernstDc = (r2_opposite_phase + r_2) / 2; nernstDc = (r2_opposite_phase + r_2) / 2;
pumpCurrentSenseVoltage = 0.8f * pumpCurrentSenseVoltage + 0.2f * (result.PumpCurrentVoltage - HALF_VCC); pumpCurrentSenseVoltage = 0.8f * pumpCurrentSenseVoltage + 0.2f * (result.PumpCurrentVoltage - result.VirtualGroundVoltageInt);
// Shift history over by one // Shift history over by one
r_3 = r_2; r_3 = r_2;