Commit 146c1cfb authored by Your Name's avatar Your Name

Changed the calculation of the voltage from adc according to measured Voltag/ADC factor

parent 73a67801
Pipeline #763 failed
......@@ -329,7 +329,7 @@ void BreathingLoop::updateCycleReadings()
_ap_readings_N = 0;
_volume_inhale = 0;
_volume_exhale = 0;
_volume = 0;
_volume = 0;
//reset
_cycle_done = true;
......@@ -353,8 +353,8 @@ void BreathingLoop::updateCalculations() {
_calculations.flow = getFlow(); // TODO: can be run every 1 ms instead of every arduino cycle
//_calculations.flow_calc = calculateFlow(_readings_avgs.timestamp, _readings_avgs.pressure_patient, _readings_avgs.pressure_buffer);
_calculations.flow_calc = calculateFlow(_readings_avgs.timestamp, _readings_avgs.pressure_patient, _readings_avgs.pressure_buffer);
_calculations_time = tnow;
_calculations.volume = getVolume();
_calculations_time = tnow;
}
_calculations.pressure_airway = getAirwayPressure();
// _calculations.flow_calc = calculateFlow(tnow, adcToMillibarFloat(_readings_raw.pressure_patient, _calib_avgs.pressure_patient), adcToMillibarFloat(_readings_raw.pressure_buffer, _calib_avgs.pressure_buffer));
......
......@@ -221,24 +221,17 @@ float adcToMillibarDPFloat(float adc, float offset)
// The calibration for the DP sensor is provided by the manufacturer
// https://docs.rs-online.com/7d77/0900766b81568899.pdf
float PCB_Gain = 2. ; // real voltage is two times higher thant the measured in the PCB (there is a voltage divider)
float ADC_to_mVoltage_Gain = 3300./4096.0 ; // maximum Voltage of 3.3V for 4096 ADC counts - (It might need recalibration?)
float zeroDPmvoltageInADC = (2500./PCB_Gain)*(1./ADC_to_mVoltage_Gain);
float _voltage = PCB_Gain * ADC_to_mVoltage_Gain * (adc);// - offset + zeroDPmvoltageInADC);
float PCB_Gain = 2.; // real voltage is two times higher thant the measured in the PCB (there is a voltage divider)
float ADC_to_mVoltage_Gain = 0.788; // this is the measured gain
float ADC_offset = 162.; // this is the measured offset
float Aout = PCB_Gain * (ADC_to_mVoltage_Gain * adc + 162) ;
float Vdd = 5000;
float PaTombar = 0.01;
//float AoutVdd = _voltage/5000.; // The board provides 5000 mV to the input of the DP sensor
float AoutVdd = _voltage/(2*PCB_Gain*ADC_to_mVoltage_Gain*offset); // The board provides 5000 mV to the input of the DP sensor
float sign = 2*((AoutVdd-0.5 > 0.)-0.5);
float sign = 2*((Aout/Vdd-0.5 > 0.)-0.5);
float dp_mbar = PaTombar * sign * pow(((AoutVdd/0.4)-1.25), 2)*525; // same calculation as in the Labview Code
float dp_mbar = PaTombar * sign * pow(((Aout/(Vdd*0.4))-1.25), 2)*525; // same calculation as in the Labview Code
//String s = " dp "+String(dp_mbar)+ " off "+String(offset)+" zero "+String(zeroDPmvoltageInADC) +" adc " + String(adc);
//logMsg(s);
return static_cast<float>(dp_mbar);
}
......
......@@ -143,12 +143,12 @@ void loop()
alarm_loop.fireAlarms();
ui_loop.reportFastReadings();
// ui_loop.reportReadbackValues();
// ui_loop.reportCycleReadings();
// ui_loop.reportAlarms();
// ui_loop.reportIVTReadings();
// ui_loop.reportDebugValues(); // data duplicated to fast and readback
// ui_loop.reportTargets();
ui_loop.reportReadbackValues();
ui_loop.reportCycleReadings();
ui_loop.reportAlarms();
ui_loop.reportIVTReadings();
ui_loop.reportDebugValues(); // data duplicated to fast and readback
ui_loop.reportTargets();
// per cycle receiver
comms.receiver();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment