Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -rf861c4c5ab64f429e0b8b9cc456e2ed14e472f2b -rb5756e5b5041288a2e95585990cce5a93756d693 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision f861c4c5ab64f429e0b8b9cc456e2ed14e472f2b) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision b5756e5b5041288a2e95585990cce5a93756d693) @@ -44,7 +44,8 @@ #define BLOOD_FLOW_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the blood flow data is published on the CAN bus -#define MAX_BLOOD_PUMP_PWM_STEP_CHANGE 0.01 ///< max duty cycle change when ramping +#define MAX_BLOOD_PUMP_PWM_STEP_UP_CHANGE 0.008 ///< max duty cycle change when ramping up ~ 100 mL/min/s. +#define MAX_BLOOD_PUMP_PWM_STEP_DN_CHANGE 0.016 ///< max duty cycle change when ramping down ~ 200 mL/min/s. #define MAX_BLOOD_PUMP_PWM_DUTY_CYCLE 0.88 ///< controller will error if PWM duty cycle > 90%, so set max to 88% #define MIN_BLOOD_PUMP_PWM_DUTY_CYCLE 0.12 ///< controller will error if PWM duty cycle < 10%, so set min to 12% @@ -437,7 +438,7 @@ if ( getTargetBloodFlowRate() != 0 ) { // set initial PWM duty cycle - bloodPumpPWMDutyCyclePctSet = BP_PWM_ZERO_OFFSET + MAX_BLOOD_PUMP_PWM_STEP_CHANGE; + bloodPumpPWMDutyCyclePctSet = BP_PWM_ZERO_OFFSET + MAX_BLOOD_PUMP_PWM_STEP_UP_CHANGE; setBloodPumpControlSignalPWM( bloodPumpPWMDutyCyclePctSet ); // allow blood pump to run in requested direction setBloodPumpDirection( bloodPumpDirection ); @@ -466,7 +467,7 @@ if ( 0 == getTargetBloodFlowRate() ) { // start ramp down to stop - bloodPumpPWMDutyCyclePctSet -= MAX_BLOOD_PUMP_PWM_STEP_CHANGE; + bloodPumpPWMDutyCyclePctSet -= MAX_BLOOD_PUMP_PWM_STEP_DN_CHANGE; setBloodPumpControlSignalPWM( bloodPumpPWMDutyCyclePctSet ); result = BLOOD_PUMP_RAMPING_DOWN_STATE; } @@ -487,7 +488,7 @@ // continue ramp up else { - bloodPumpPWMDutyCyclePctSet += MAX_BLOOD_PUMP_PWM_STEP_CHANGE; + bloodPumpPWMDutyCyclePctSet += MAX_BLOOD_PUMP_PWM_STEP_UP_CHANGE; setBloodPumpControlSignalPWM( bloodPumpPWMDutyCyclePctSet ); } @@ -508,7 +509,7 @@ BLOOD_PUMP_STATE_T result = BLOOD_PUMP_RAMPING_DOWN_STATE; // have we essentially reached zero speed - if ( bloodPumpPWMDutyCyclePctSet < (MAX_BLOOD_PUMP_PWM_STEP_CHANGE + BP_PWM_ZERO_OFFSET) ) + if ( bloodPumpPWMDutyCyclePctSet < (MAX_BLOOD_PUMP_PWM_STEP_UP_CHANGE + BP_PWM_ZERO_OFFSET) ) { stopBloodPump(); result = BLOOD_PUMP_OFF_STATE; @@ -530,7 +531,7 @@ // continue ramp down else { - bloodPumpPWMDutyCyclePctSet -= MAX_BLOOD_PUMP_PWM_STEP_CHANGE; + bloodPumpPWMDutyCyclePctSet -= MAX_BLOOD_PUMP_PWM_STEP_DN_CHANGE; setBloodPumpControlSignalPWM( bloodPumpPWMDutyCyclePctSet ); } @@ -803,7 +804,7 @@ static void publishBloodFlowData( void ) { // publish blood flow data on interval -#ifndef READ_FPGA_ASYNC_DATA +#ifndef FLOW_DEBUG if ( ++bloodFlowDataPublicationTimerCounter >= getPublishBloodFlowDataInterval() ) #endif { @@ -814,7 +815,7 @@ F32 measMCSpd = getMeasuredBloodPumpMCSpeed(); F32 measMCCurr = getMeasuredBloodPumpMCCurrent(); F32 pumpPWMPctDutyCycle = bloodPumpPWMDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; -#ifdef READ_FPGA_ASYNC_DATA +#ifdef FLOW_DEBUG // TODO - temporary debug code - remove later char debugFlowStr[ 256 ]; @@ -827,8 +828,9 @@ sprintf( debugFlowStr, "Blood: %5d, %5d, %5d Dial-I: %5d, %5d, %5d Dial-O: %5d\n", (S32)measFlowSig, (S32)measFlow, (S32)bldOccl, (S32)dialFlowSig, (S32)dialFlow, (S32)dpiOccl, (S32)dpoOccl ); sendDebugData( (U08*)debugFlowStr, strlen(debugFlowStr) ); -#endif +#else broadcastBloodFlowData( flowStPt, measFlow, measRotSpd, measSpd, measMCSpd, measMCCurr, pumpPWMPctDutyCycle ); +#endif bloodFlowDataPublicationTimerCounter = 0; } } Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -rf861c4c5ab64f429e0b8b9cc456e2ed14e472f2b -rb5756e5b5041288a2e95585990cce5a93756d693 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision f861c4c5ab64f429e0b8b9cc456e2ed14e472f2b) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision b5756e5b5041288a2e95585990cce5a93756d693) @@ -41,7 +41,8 @@ #define DIAL_IN_FLOW_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the dialIn flow data is published on the CAN bus -#define MAX_DIAL_IN_PUMP_PWM_STEP_CHANGE 0.01 ///< duty cycle TODO - fixed or parameterized or set in motor controller? +#define MAX_DIAL_IN_PUMP_PWM_STEP_UP_CHANGE 0.0133 ///< max duty cycle change when ramping up ~ 200 mL/min/s. +#define MAX_DIAL_IN_PUMP_PWM_STEP_DN_CHANGE 0.02 ///< max duty cycle change when ramping down ~ 300 mL/min/s. #define MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.88 ///< controller will error if PWM duty cycle > 90%, so set max to 88% #define MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.12 ///< controller will error if PWM duty cycle < 10%, so set min to 12% @@ -435,7 +436,7 @@ if ( getTargetDialInFlowRate() != 0 ) { // set initial PWM duty cycle - dialInPumpPWMDutyCyclePctSet = DIP_PWM_ZERO_OFFSET + MAX_DIAL_IN_PUMP_PWM_STEP_CHANGE; + dialInPumpPWMDutyCyclePctSet = DIP_PWM_ZERO_OFFSET + MAX_DIAL_IN_PUMP_PWM_STEP_UP_CHANGE; setDialInPumpControlSignalPWM( dialInPumpPWMDutyCyclePctSet ); // allow dialIn pump to run in requested direction setDialInPumpDirection( dialInPumpDirection ); @@ -464,7 +465,7 @@ if ( 0 == getTargetDialInFlowRate() ) { // start ramp down to stop - dialInPumpPWMDutyCyclePctSet -= MAX_DIAL_IN_PUMP_PWM_STEP_CHANGE; + dialInPumpPWMDutyCyclePctSet -= MAX_DIAL_IN_PUMP_PWM_STEP_DN_CHANGE; setDialInPumpControlSignalPWM( dialInPumpPWMDutyCyclePctSet ); result = DIAL_IN_PUMP_RAMPING_DOWN_STATE; } @@ -485,7 +486,7 @@ // continue ramp up else { - dialInPumpPWMDutyCyclePctSet += MAX_DIAL_IN_PUMP_PWM_STEP_CHANGE; + dialInPumpPWMDutyCyclePctSet += MAX_DIAL_IN_PUMP_PWM_STEP_UP_CHANGE; setDialInPumpControlSignalPWM( dialInPumpPWMDutyCyclePctSet ); } @@ -506,7 +507,7 @@ DIAL_IN_PUMP_STATE_T result = DIAL_IN_PUMP_RAMPING_DOWN_STATE; // have we essentially reached zero speed - if ( dialInPumpPWMDutyCyclePctSet < (MAX_DIAL_IN_PUMP_PWM_STEP_CHANGE + DIP_PWM_ZERO_OFFSET) ) + if ( dialInPumpPWMDutyCyclePctSet < (MAX_DIAL_IN_PUMP_PWM_STEP_UP_CHANGE + DIP_PWM_ZERO_OFFSET) ) { stopDialInPump(); result = DIAL_IN_PUMP_OFF_STATE; @@ -528,7 +529,7 @@ // continue ramp down else { - dialInPumpPWMDutyCyclePctSet -= MAX_DIAL_IN_PUMP_PWM_STEP_CHANGE; + dialInPumpPWMDutyCyclePctSet -= MAX_DIAL_IN_PUMP_PWM_STEP_DN_CHANGE; setDialInPumpControlSignalPWM( dialInPumpPWMDutyCyclePctSet ); } Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -rf124efbd92b66cb23ac24dccbdbef48e52cab7c5 -rb5756e5b5041288a2e95585990cce5a93756d693 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision f124efbd92b66cb23ac24dccbdbef48e52cab7c5) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision b5756e5b5041288a2e95585990cce5a93756d693) @@ -45,7 +45,8 @@ #define MIN_DIAL_OUT_FLOW_RATE 100 ///< Minimum dialysate outlet pump flow rate in mL/min. #define DPO_FLOW_ADJ_DUE_TO_HIGHER_INLET_PRES 0.875 ///< Adjustment factor to account for higher pump inlet pressure (than DPi pump inlet). -#define MAX_DIAL_OUT_PUMP_PWM_STEP_CHANGE 0.01 ///< Maximum duty cycle change when ramping. +#define MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE 0.0133 ///< Maximum duty cycle change when ramping up ~ 200 mL/min/s. +#define MAX_DIAL_OUT_PUMP_PWM_STEP_DN_CHANGE 0.02 ///< Maximum duty cycle change when ramping down ~ 300 mL/min/s. #define MAX_DIAL_OUT_PUMP_PWM_DUTY_CYCLE 0.88 ///< Controller will error if PWM duty cycle > 90%, so set max to 88%. #define MIN_DIAL_OUT_PUMP_PWM_DUTY_CYCLE 0.12 ///< Controller will error if PWM duty cycle < 10%, so set min to 12%. @@ -488,7 +489,7 @@ if ( lastGivenRate > 0 ) { // set initial PWM duty cycle - dialOutPumpPWMDutyCyclePctSet = DOP_PWM_ZERO_OFFSET + MAX_DIAL_OUT_PUMP_PWM_STEP_CHANGE; + dialOutPumpPWMDutyCyclePctSet = DOP_PWM_ZERO_OFFSET + MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE; setDialOutPumpControlSignalPWM( dialOutPumpPWMDutyCyclePctSet ); // allow dialOut pump to run in requested direction setDialOutPumpDirection( dialOutPumpDirection ); @@ -521,7 +522,7 @@ if ( dialOutPumpPWMDutyCyclePct < NEARLY_ZERO ) { // start ramp down to stop - dialOutPumpPWMDutyCyclePctSet -= MAX_DIAL_OUT_PUMP_PWM_STEP_CHANGE; + dialOutPumpPWMDutyCyclePctSet -= MAX_DIAL_OUT_PUMP_PWM_STEP_DN_CHANGE; setDialOutPumpControlSignalPWM( dialOutPumpPWMDutyCyclePctSet ); result = DIAL_OUT_PUMP_RAMPING_DOWN_STATE; } @@ -541,7 +542,7 @@ // continue ramp up else { - dialOutPumpPWMDutyCyclePctSet += MAX_DIAL_OUT_PUMP_PWM_STEP_CHANGE; + dialOutPumpPWMDutyCyclePctSet += MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE; setDialOutPumpControlSignalPWM( dialOutPumpPWMDutyCyclePctSet ); } @@ -562,7 +563,7 @@ DIAL_OUT_PUMP_STATE_T result = DIAL_OUT_PUMP_RAMPING_DOWN_STATE; // have we essentially reached zero speed - if ( dialOutPumpPWMDutyCyclePctSet < (MAX_DIAL_OUT_PUMP_PWM_STEP_CHANGE + DOP_PWM_ZERO_OFFSET) ) + if ( dialOutPumpPWMDutyCyclePctSet < (MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE + DOP_PWM_ZERO_OFFSET) ) { stopDialOutPump(); result = DIAL_OUT_PUMP_OFF_STATE; @@ -583,7 +584,7 @@ // continue ramp down else { - dialOutPumpPWMDutyCyclePctSet -= MAX_DIAL_OUT_PUMP_PWM_STEP_CHANGE; + dialOutPumpPWMDutyCyclePctSet -= MAX_DIAL_OUT_PUMP_PWM_STEP_DN_CHANGE; setDialOutPumpControlSignalPWM( dialOutPumpPWMDutyCyclePctSet ); } @@ -617,9 +618,9 @@ newPWM = runPIController( PI_CONTROLLER_ID_ULTRAFILTRATION, refVol, totVol ); // limit PWM change to max deltaPWM = newPWM - dialOutPumpPWMDutyCyclePctSet; - if ( FABS( deltaPWM ) > MAX_DIAL_OUT_PUMP_PWM_STEP_CHANGE ) + if ( FABS( deltaPWM ) > MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE ) { - newPWM = ( deltaPWM < 0.0 ? dialOutPumpPWMDutyCyclePctSet - MAX_DIAL_OUT_PUMP_PWM_STEP_CHANGE : dialOutPumpPWMDutyCyclePctSet + MAX_DIAL_OUT_PUMP_PWM_STEP_CHANGE ); + newPWM = ( deltaPWM < 0.0 ? dialOutPumpPWMDutyCyclePctSet - MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE : dialOutPumpPWMDutyCyclePctSet + MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE ); } // set new PWM dialOutPumpPWMDutyCyclePctSet = newPWM; Index: firmware/App/HDCommon.h =================================================================== diff -u -rffb9960f7b97e71ba78844c60158d344c909db94 -rb5756e5b5041288a2e95585990cce5a93756d693 --- firmware/App/HDCommon.h (.../HDCommon.h) (revision ffb9960f7b97e71ba78844c60158d344c909db94) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision b5756e5b5041288a2e95585990cce5a93756d693) @@ -28,9 +28,9 @@ // ********** build switches ********** -#define UF_TEST_ENABLED 1 -//#define UF_TEST_WITH_DG 1 #ifndef _RELEASE_ +#define UF_TEST_ENABLED 1 +#define UF_TEST_WITH_DG 1 #ifndef _VECTORCAST_ // #define RM46_EVAL_BOARD_TARGET 1 // #define BREADBOARD_TARGET 1 @@ -45,7 +45,8 @@ #define DISABLE_PRESSURE_CHECKS 1 // #define SHOW_LOAD_CELL_IN_ROTOR_RPM 1 // #define READ_FPGA_ASYNC_DATA 1 - #define EMC_TEST_BUILD 1 +// #define FLOW_DEBUG 1 +// #define EMC_TEST_BUILD 1 #define ALARMS_DEBUG 1 #include Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -rffb9960f7b97e71ba78844c60158d344c909db94 -rb5756e5b5041288a2e95585990cce5a93756d693 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision ffb9960f7b97e71ba78844c60158d344c909db94) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision b5756e5b5041288a2e95585990cce5a93756d693) @@ -46,7 +46,7 @@ { ALARM_PRIORITY_T alarmPriority; ///< priority of alarm U32 alarmEscalatesAfter; ///< time (s) after start when alarm will escalate if not cleared (zero indicates no escalation) - ALARM_ID_T alarmEscalatesTo; ///< ID of alarm that this alarm will escalate to (ALARM_ID_NO_ALARM indicates no esclation) + ALARM_ID_T alarmEscalatesTo; ///< ID of alarm that this alarm will escalate to (ALARM_ID_NO_ALARM indicates no escalation) BOOL alarmIsFault; ///< alarm is a system fault? BOOL alarmStops; ///< alarm activation should cause a controlled stop BOOL alarmNoClear; ///< alarm cannot be cleared (unrecoverable)? Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rffb9960f7b97e71ba78844c60158d344c909db94 -rb5756e5b5041288a2e95585990cce5a93756d693 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision ffb9960f7b97e71ba78844c60158d344c909db94) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision b5756e5b5041288a2e95585990cce5a93756d693) @@ -119,9 +119,9 @@ U08 dialInPumpHallSensorStatus; ///< Reg 291. Dialysate inlet pump hall sensor status. U32 adc1Channel0; ///< Reg 292. ADC1 channel 0 data. U32 adc1Channel1; ///< Reg 296. ADC1 channel 1 data. - U32 adc1Channel2; ///< Reg 300. ADC1 channel 2 data. - U32 adc1Channel3; ///< Reg 304. ADC1 channel 3 data. - U32 adc1channel4; ///< Reg 308. ADC1 channel 4 data. + U32 bloodFlowSoundSpeedData; ///< Reg 300. Blood flow sensor - sound speed data. + U32 bloodFlowAccFlowData; ///< Reg 304. Blood flow sensor - accumualted flow data. + F32 bloodFlowSignalStrength; ///< Reg 308. Blood flow sensor - signal strength. U08 adc1SequenceCount; ///< Reg 312. ADC1 round robin channel sequence count. U08 adc1ErrorCount; ///< Reg 313. ADC1 error count. U16 accelX; ///< Reg 314. Accelerometer X axis data. @@ -138,6 +138,23 @@ U08 dialOutPumpSensorStatus; ///< Reg 335. Dialysate outlet pump hall sensor status. U16 dialInPumpHallSensorCount; ///< Reg 336. Dialysate inlet pump hall sensor count. U16 dialOutPumpHallSensorCount; ///< Reg 338. Dialysate outlet pump hall sensor count. + U32 dialysateFlowSoundSpeedData; ///< Reg 340. Dialysate flow sensor - sound speed data. + U32 dialysateFlowAccFlowData; ///< Reg 344. Dialysate flow sensor - accumualted flow data. + F32 dialysateFlowSignalStrength; ///< Reg 348. Dialysate flow sensor - signal strength. + U16 fan1PulseTime; ///< Reg 352. Fan 1 pulse time in 2.5 uSec resolution. 0xFFFF if fan RPM < 500 RPM. + U16 fan2PUlseTime; ///< Reg 354. Fan 2 pulse time in 2.5 uSec resolution. 0xFFFF if fan RPM < 500 RPM. + U16 fpgaGPIO; ///< Reg 356. FPGA GPIO register. + S16 VBaPosition; ///< Reg 358. Encoder position from VBA pinch valve. 0 until PID interface is enabled. + S16 VBvPosition; ///< Reg 360. Encoder position from VBV pinch valve. 0 until PID interface is enabled. + S16 VDioPosition; ///< Reg 362. Encoder position from VDio pinch valve. 0 until PID interface is enabled. + S16 VDzrPosition; ///< Reg 364. Encoder position from VDZR pinch valve. 0 until PID interface is enabled. + S16 VDfPosition; ///< Reg 366. Encoder position from VDf pinch valve. 0 until PID interface is enabled. + U16 valveStatus; ///< Reg 368. Valve status register. + U16 VBaPWMTarget; ///< Reg 370. PWM target duty cycle for VBA pinch valve. + U16 VBvPWMTarget; ///< Reg 372. PWM target duty cycle for VBV pinch valve. + U16 VDioPWMTarget; ///< Reg 374. PWM target duty cycle for VDio pinch valve. + U16 VDzrPWMTarget; ///< Reg 376. PWM target duty cycle for VDZR pinch valve. + U16 VDfPWMTarget; ///< Reg 378. PWM target duty cycle for VDF pinch valve. } FPGA_SENSORS_T; /// Record structure for FPGA continuous priority writes. @@ -1005,7 +1022,6 @@ fpgaHeader.fpgaControl = ctrl; } -#ifdef READ_FPGA_ASYNC_DATA /*********************************************************************//** * @brief * The getFPGABloodFlowSignalStrength function gets the latest blood flow \n @@ -1017,7 +1033,7 @@ *************************************************************************/ F32 getFPGABloodFlowSignalStrength( void ) { - return fpgaSensorReadingsAsync.bloodFlowSignalStrength; + return fpgaSensorReadings.bloodFlowSignalStrength; } /*********************************************************************//** @@ -1031,9 +1047,8 @@ *************************************************************************/ F32 getFPGADialysateFlowSignalStrength( void ) { - return fpgaSensorReadingsAsync.dialysateInFlowSignalStrength; + return fpgaSensorReadings.dialysateFlowSignalStrength; } -#endif /*********************************************************************//** * @brief Index: firmware/App/Services/FPGA.h =================================================================== diff -u -rffb9960f7b97e71ba78844c60158d344c909db94 -rb5756e5b5041288a2e95585990cce5a93756d693 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision ffb9960f7b97e71ba78844c60158d344c909db94) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision b5756e5b5041288a2e95585990cce5a93756d693) @@ -45,10 +45,8 @@ U16 getFPGAStatus( void ); void setFPGAControl( U16 ctrl ); -#ifdef READ_FPGA_ASYNC_DATA F32 getFPGABloodFlowSignalStrength( void ); F32 getFPGADialysateFlowSignalStrength( void ); -#endif F32 getFPGABloodFlow( void ); F32 getFPGADialysateFlow( void );