Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r2bb447181c2519690441d81f83563d17e0882ef2 -r85bfe5051e4d2bf67be39d394f96c075b4e52836 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 2bb447181c2519690441d81f83563d17e0882ef2) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 85bfe5051e4d2bf67be39d394f96c075b4e52836) @@ -61,7 +61,7 @@ #define BP_REV_PER_LITER 124.0 // rotor revolutions per liter #define BP_ML_PER_MIN_TO_PUMP_RPM_FACTOR ( BP_REV_PER_LITER / ML_PER_LITER ) #define BP_GEAR_RATIO 32.0 // blood pump motor to blood pump gear ratio -#define BP_MOTOR_RPM_TO_PWM_DC_FACTOR 0.000369 //717 // ~27 BP motor RPM = 1% PWM duty cycle +#define BP_MOTOR_RPM_TO_PWM_DC_FACTOR 0.0003717 // ~27 BP motor RPM = 1% PWM duty cycle #define BP_PWM_ZERO_OFFSET 0.1 // 10% PWM duty cycle = zero speed #define BP_PWM_FROM_ML_PER_MIN(rate) ( (rate) * BP_ML_PER_MIN_TO_PUMP_RPM_FACTOR * BP_GEAR_RATIO * BP_MOTOR_RPM_TO_PWM_DC_FACTOR + BP_PWM_ZERO_OFFSET ) Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r2bb447181c2519690441d81f83563d17e0882ef2 -r85bfe5051e4d2bf67be39d394f96c075b4e52836 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 2bb447181c2519690441d81f83563d17e0882ef2) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 85bfe5051e4d2bf67be39d394f96c075b4e52836) @@ -66,13 +66,13 @@ #define DIP_PWM_ZERO_OFFSET 0.1 // 10% PWM duty cycle = zero speed #define DIP_PWM_FROM_ML_PER_MIN(rate) ( (rate) * DIP_ML_PER_MIN_TO_PUMP_RPM_FACTOR * DIP_GEAR_RATIO * DIP_MOTOR_RPM_TO_PWM_DC_FACTOR + DIP_PWM_ZERO_OFFSET ) -#define DIAL_INPUMP_ADC_FULL_SCALE_V 3.0 // BP analog signals are 0-3V (while int. ADC ref V is 3.3V) -#define DIAL_INPUMP_ADC_MID_PT_BITS ( (F32)( INT_ADC_FULL_SCALE_BITS >> 1 ) * ( DIAL_INPUMP_ADC_FULL_SCALE_V / INT_ADC_REF_V ) ) -#define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)DIAL_INPUMP_ADC_MID_PT_BITS ) +#define DIAL_IN_PUMP_ADC_FULL_SCALE_V 3.0 // BP analog signals are 0-3V (while int. ADC ref V is 3.3V) +#define DIAL_IN_PUMP_ADC_MID_PT_BITS ( (F32)( INT_ADC_FULL_SCALE_BITS >> 1 ) * ( DIAL_IN_PUMP_ADC_FULL_SCALE_V / INT_ADC_REF_V ) ) +#define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)DIAL_IN_PUMP_ADC_MID_PT_BITS ) -#define DIAL_IN_FLOW_SAMPLE_FREQ ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) -#define SIZE_OF_ROLLING_AVG (U32)( (F32)DIAL_IN_FLOW_SAMPLE_FREQ * 0.8 ) // measured dialIn flow is filtered w/ moving average -#define MAX_FLOW_FILTER_INTERVAL 5 // slowest sample interval for filter is every 5th sample +#define DIAL_IN_FLOW_SAMPLE_FREQ ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) +#define SIZE_OF_ROLLING_AVG (U32)( (F32)DIAL_IN_FLOW_SAMPLE_FREQ * 0.8 ) // measured dialIn flow is filtered w/ moving average +#define MAX_FLOW_FILTER_INTERVAL 5 // slowest sample interval for filter is every 5th sample typedef enum DialInPump_States { @@ -658,13 +658,12 @@ /************************************************************************* * @brief resetDialInFlowMovingAverage - * The resetDialInFlowMovingAverage function re-sizes and re-initializes the \n + * The resetDialInFlowMovingAverage function resets the properties of the \n * dialIn flow moving average sample buffer. * @details * Inputs : none * Outputs : flowReadingsTotal, flowReadingsIdx, flowReadingsCount all set to zero. - * @param initFlow : the new dialIn flow set pt. - * @param flowDir : the new set direction + * @param none * @return none *************************************************************************/ static void resetDialInFlowMovingAverage( void ) @@ -753,8 +752,8 @@ * The checkDialInPumpDirection function checks the set direction vs. \n * the direction implied by the sign of the measured MC speed. * @details - * Inputs : - * Outputs : + * Inputs : adcDialInPumpMCSpeedRPM, dialInPumpDirectionSet, dialInPumpState + * Outputs : none * @param none * @return none *************************************************************************/ @@ -778,8 +777,8 @@ * The checkDialInPumpMCCurrent function checks the measured MC current vs. \n * the set state of the dialIn pump (stopped or running). * @details - * Inputs : - * Outputs : + * Inputs : dialInPumpState, dipCurrErrorDurationCtr, adcDialInPumpMCCurrentmA + * Outputs : none * @param none * @return none *************************************************************************/ Index: firmware/App/Services/CommBuffers.c =================================================================== diff -u -ref0b3f0ec00fadc50f95e0db1a6477fb4b076ea1 -r85bfe5051e4d2bf67be39d394f96c075b4e52836 --- firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision ef0b3f0ec00fadc50f95e0db1a6477fb4b076ea1) +++ firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision 85bfe5051e4d2bf67be39d394f96c075b4e52836) @@ -36,6 +36,9 @@ static U32 activeDoubleBuffer[ NUM_OF_COMM_BUFFERS ]; // for each buffer, which double buffer is being fed right now? static U08 commBuffers[ NUM_OF_COMM_BUFFERS ][ DOUBLE_BUFFERS ][ COMM_BUFFER_LENGTH ]; // each is double buffered to avoid thread contention +static U32 broadcastByteInCount = 0; // TODO - debug - remove these two later +static U32 broadcastByteOutCount = 0; + // ********** private function prototypes ********** static U32 switchDoubleBuffer( COMM_BUFFER_T buffer ); @@ -105,6 +108,11 @@ { U08 *buffPtr; // buffer destination for added data + if ( buffer == COMM_BUFFER_OUT_CAN_HD_BROADCAST ) + { + broadcastByteInCount += len; + } + // set destination pointer to end of active buffer data buffPtr = &commBuffers[ buffer ][ activeBuffer ][ currentActiveBufCount ]; // copy source data to destination buffer @@ -178,6 +186,11 @@ // will return # of bytes consumed result += remNumOfBytes; } + + if ( buffer == COMM_BUFFER_OUT_CAN_HD_BROADCAST ) + { + broadcastByteOutCount += result; + } } else // invalid get size given { Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r2bb447181c2519690441d81f83563d17e0882ef2 -r85bfe5051e4d2bf67be39d394f96c075b4e52836 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 2bb447181c2519690441d81f83563d17e0882ef2) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 85bfe5051e4d2bf67be39d394f96c075b4e52836) @@ -76,8 +76,9 @@ static BOOL uiIsCommunicating = FALSE; // has UI sent a message since last check static BOOL uiDidCommunicate = FALSE; // has UI every sent a message -static U32 sentCANPacketsCount = 0; +static U32 sentCANPacketsCount = 0; // TODO - debug - remove these two flags later static U32 compCANPacketsCount = 0; +static CAN_MESSAGE_BOX_T pendingXmitMsgBox = 0; // ********** private function prototypes ********** @@ -250,6 +251,11 @@ *************************************************************************/ void handleCANMsgInterrupt( CAN_MESSAGE_BOX_T srcCANBox ) { + if ( ( TRUE == isCANBoxForXmit( srcCANBox ) ) && ( srcCANBox != pendingXmitMsgBox ) ) + { + srcCANBox = (CAN_MESSAGE_BOX_T)0; + } + // message interrupt is for a transmit message box? if ( TRUE == isCANBoxForXmit( srcCANBox ) ) { @@ -500,8 +506,10 @@ if ( dataSize == CAN_MESSAGE_PAYLOAD_SIZE ) { signalCANXmitsInitiated(); + pendingXmitMsgBox = mBox; if ( canTransmit( canREG1, mBox, data ) == 0 ) { + signalCANXmitsCompleted(); // TODO - shouldn't get here, but let's see if we do SET_ALARM_WITH_1_U32_DATA( ALARM_ID_SOFTWARE_FAULT, (U32)mBox ) } Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r2bb447181c2519690441d81f83563d17e0882ef2 -r85bfe5051e4d2bf67be39d394f96c075b4e52836 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 2bb447181c2519690441d81f83563d17e0882ef2) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 85bfe5051e4d2bf67be39d394f96c075b4e52836) @@ -63,10 +63,10 @@ execBloodFlowController(); // control dialysate inlet pump - execDialInFlowController(); +// execDialInFlowController(); // control dialysate outlet pump - execDialOutUFController(); +// execDialOutUFController(); // manage alarm state execAlarmMgmt(); Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -r2bb447181c2519690441d81f83563d17e0882ef2 -r85bfe5051e4d2bf67be39d394f96c075b4e52836 --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 2bb447181c2519690441d81f83563d17e0882ef2) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 85bfe5051e4d2bf67be39d394f96c075b4e52836) @@ -52,10 +52,10 @@ execBloodFlowMonitor(); // monitor dialysate inlet pump and flow - execDialInFlowMonitor(); +// execDialInFlowMonitor(); // monitor dialysate outlet pump and reservoir load cells - execDialOutUFMonitor(); +// execDialOutUFMonitor(); // 2nd pass for FPGA execFPGAOut();