Commit bfc85e48 authored by Your Name's avatar Your Name

pwm channel for debug. changed PCB_gain for O2 sensor.

parent aadf8eb8
Pipeline #1045 failed
......@@ -72,6 +72,6 @@ const int pwm_chan_exhale = 1;
const int pwm_resolution = 16; // 8 bit resolution; up to 16 possible
const int pwm_frequency = 500; // frequency in Hz
const int pwm_chan_debug = 1;
const int pwm_chan_debug = 4;
const int pwm_resolution_debug = 8; // 8 bit resolution; up to 16 possible
const int pwm_frequency_debug = 500; // frequency in Hz
\ No newline at end of file
const int pwm_frequency_debug = 500; // frequency in Hz
......@@ -289,12 +289,12 @@ void BreathingLoop::updateCycleReadings()
if (_bl_state == BL_STATES::BUFF_PRE_INHALE){
if(_cycle_done == false){
uint32_t tnow = static_cast<uint32_t>(millis());
ledcWrite(pwm_chan_debug, uint8_t(_fiO2_est*255));
ledcWrite(pwm_chan_debug, uint8_t(_fiO2_est*122));
_cycle_index = (_cycle_index == CYCLE_AVG_READINGS-1 ) ? 0 : _cycle_index+1;
_cycle_readings.timestamp = tnow;
_cycle_readings.fiO2_percent = _fiO2_est * 100.f; //_readings_avgs.o2_percent;// FIXME
_cycle_readings.fiO2_percent =_readings_avgs.o2_percent;//
_running_inhale_minute_volume[_cycle_index] = _volume_inhale ;
_running_exhale_minute_volume[_cycle_index] = _volume_exhale ;
_total_cycle_duration[_cycle_index] = (
......@@ -690,6 +690,7 @@ void BreathingLoop::assignFillFSM()
case BL_STATES::EXHALE:
if (_bl_laststate != BL_STATES::EXHALE){
_fill_state = determineFillMode();
logMsg("Fill state: " + String(_fill_state));
}
break;
case BL_STATES::BUFF_FILL:
......
......@@ -240,7 +240,7 @@ float adcToO2PercentFloat(float adc, float offset)
{
// calibration should flush air only (21% o2) or o2 only (100%) for N secs
float PCB_Gain = 5. ; // real voltage is 4 times higher thant the measured in the PCB (there is a voltage divider)
float PCB_Gain = 5.54 ; // real voltage is 4 times higher thant the measured in the PCB (there is a voltage divider)
float Sensor_Gain = 100./10000. ; // the sensor gain is 100 % / 10000 mVolts
float ADC_to_Voltage_Gain = 3300./4096.0 ; // maximum Voltage of 3.3V for 4096 ADC counts - (It might need recalibration?)
float ADC_to_mVoltage_Gain = 0.788; // this is the measured gain
......
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