Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r036a75d76ab01912646a480b935d97187a231a19 -r395522dffef1348e176564925656012f529c1910 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 036a75d76ab01912646a480b935d97187a231a19) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 395522dffef1348e176564925656012f529c1910) @@ -1,29 +1,31 @@ /************************************************************************** * -* Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. +* Copyright (c) 2024-2026 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file TaskGeneral.c * -* @author (last) Sean -* @date (last) 30-Jul-2024 +* @author (last) Dara Navaei +* @date (last) 31-Oct-2025 * -* @author (original) Sean -* @date (original) 30-Jul-2024 +* @author (original) Sean Nash +* @date (original) 01-Aug-2024 * ***************************************************************************/ #include "AirPump.h" #include "AirTrap.h" #include "BloodFlow.h" +#include "Ejector.h" #include "Messaging.h" #include "OperationModes.h" #include "Pressures.h" #include "Switches.h" #include "SystemCommTD.h" #include "TaskGeneral.h" +#include "Temperatures.h" #include "Valves.h" #include "Voltages.h" #include "WatchdogMgmt.h" @@ -91,7 +93,7 @@ execSwitches(); // Monitor temperatures -// execTemperatures(); + execTemperature(); // Monitor processor RAM status // execRAMMonitor(); @@ -108,6 +110,9 @@ // Control pinch valves execValvesController(); + // Control ejector + execEjectorController(); + // Control blood pump execBloodFlowController(); @@ -131,27 +136,63 @@ #ifdef TEST_PINCH_VALVES #if 0 - static BOOL vlvCmd = FALSE; + static U32 vlvCmd = 0; S16 pos = getH19EncoderPosition(); readValves(); // Get level sensor data readAirTrapLevelSensors(); - if ( TRUE == vlvCmd ) + if ( 1 == vlvCmd ) { - setValveCmdChangePosition( H1_VALV, 500, MOTOR_DIR_FORWARD ); // s/b ~30 deg - //setValveCmdChangePosition( H19_VALV, 2000, MOTOR_DIR_FORWARD ); - vlvCmd = FALSE; + setValveCmdChangePosition( H1_VALV, 896, MOTOR_DIR_FORWARD ); + setValveCmdChangePosition( H19_VALV, 1600, MOTOR_DIR_FORWARD ); + vlvCmd = 0; } + if ( 2 == vlvCmd ) + { + setValveCmdChangePosition( H1_VALV, 0, MOTOR_DIR_FORWARD ); + setValveCmdChangePosition( H19_VALV, 0, MOTOR_DIR_FORWARD ); + vlvCmd = 0; + } #endif #if 1 { static BOOL homeValveCmd = FALSE; static BOOL setValvePos = FALSE; + static BOOL homeBPCmd = FALSE; + static BOOL bpHomed = FALSE; + static BOOL bpRunCmd = FALSE; + static BOOL bpStopCmd = FALSE; + static U32 bpSetPt = 300; static VALVE_POSITION_T setPos = VALVE_POSITION_A_INSERT_EJECT; // VALVE_POSITION_B_OPEN VALVE_POSITION_C_CLOSE VALVE_POSITION_A_INSERT_EJECT execValvesController(); + execBloodFlowMonitor(); + execBloodFlowController(); + bpHomed = isPeristalticPumpHome(); + if ( TRUE == bpHomed ) + { + bpHomed = FALSE; + } + if ( TRUE == homeBPCmd ) + { + homeBloodPump(); + homeBPCmd = FALSE; + } + + if ( TRUE == bpRunCmd ) + { + setBloodPumpTargetFlowRate( bpSetPt, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + bpRunCmd = FALSE; + } + else if ( TRUE == bpStopCmd ) + { + setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + bpStopCmd = FALSE; + //signalBloodPumpHardStop(); + } + if ( TRUE == homeValveCmd ) { homeValve( H1_VALV, FALSE, FALSE ); @@ -174,7 +215,7 @@ ++tmpCtr; if ( tmpCtr == ( 5 * 20 ) ) { - setAirPumpMotorPower( 255 ); + setAirPumpMotorPower( 250 ); set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); } else if ( tmpCtr == ( 10 * 20 ) ) @@ -184,7 +225,7 @@ } else if ( tmpCtr == ( 15 * 20 ) ) { - setAirPumpMotorPower( 255 ); + setAirPumpMotorPower( 250 ); set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); } else if ( tmpCtr >= ( 20 * 20 ) ) @@ -204,19 +245,28 @@ if ( FALSE == bpStart ) { - setBloodPumpTargetRPM( 1000, MOTOR_DIR_FORWARD ); +// setBloodPumpTargetRPM( 1200, MOTOR_DIR_FORWARD ); + homeEjector(); + retractEjector(); bpStart = TRUE; } if ( TRUE == bpStop ) { signalBloodPumpHardStop(); +// setAirPumpState( AIR_PUMP_STATE_ON, AIR_PUMP_MOTOR_OFF ); +// set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); +// set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); + extendEjector(); bpStop = FALSE; } // Get level sensor data readAirTrapLevelSensors(); - // Control blood pump + execSwitches(); + // Control blood pump + execBloodFlowMonitor(); execBloodFlowController(); + execEjectorController(); execAirPumpController(); switch ( sta ) @@ -231,11 +281,11 @@ sta = 1; // lower the level set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); - setAirPumpState( AIR_PUMP_STATE_ON, 25 ); + setAirPumpState( AIR_PUMP_STATE_ON, 250 ); } break; case 1: - // look for air at high level and stop + // look for air at low level and stop if ( AIR_TRAP_LEVEL_AIR == getRawLevelSensorState( H16_LEVL ) ) { // stop lowering level @@ -248,7 +298,7 @@ case 2: #if 1 // stay low for 5 sec -// if ( ++ctr > ( 5 * 20 ) ) + if ( ++ctr > ( 5 * 20 ) ) { // raise the level set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); @@ -264,27 +314,28 @@ // stop raising level set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); setAirPumpState( AIR_PUMP_STATE_OFF, AIR_PUMP_MOTOR_OFF ); + ctr = 0; sta = 4; } break; case 4: -#if 1 +#if 0 // look for air at high level if ( AIR_TRAP_LEVEL_AIR == getRawLevelSensorState( H16_LEVL ) ) { // start raising level set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); - setAirPumpState( AIR_PUMP_STATE_ON, 25 ); + setAirPumpState( AIR_PUMP_STATE_ON, 100 ); sta = 3; } #endif -#if 0 +#if 1 // stay high for 5 sec if ( ++ctr > ( 5 * 20 ) ) { // lower the level set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); - setAirPumpState( AIR_PUMP_STATE_ON, 25 ); + setAirPumpState( AIR_PUMP_STATE_ON, 100 ); sta = 1; } #endif