Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r647ed0beef9e4aeefb3a0bc0267254dd36cfe685 -rfda570ba4c27bd2f3458d3549474b18f2c367aa0 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 647ed0beef9e4aeefb3a0bc0267254dd36cfe685) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision fda570ba4c27bd2f3458d3549474b18f2c367aa0) @@ -18,6 +18,7 @@ // TODO for testing only remove #include "mibspi.h" +#include "FPGA.h" // TODO for testing only remove #include "AlarmMgmt.h" @@ -598,9 +599,9 @@ #ifdef DEBUG_ENABLED { char debugTempStr[ 256 ]; - sprintf( debugTempStr, "MPDuty: %6.2f, SPDuty: %6.2f, THDuty: %6.2f, TPi: %6.2f, TPo: %6.2f, TD1: %6.2f, " - "TD2: %6.2f, TRo: %6.2f, TDi: %6.2f, TPh: %6.2f, TTh: %6.2f, PTarg: %6.2f, TTarg: %6.2f\r\n", - mainPrimaryHeaterDutyCycle, smallPrimaryHeaterDutyCycle, trimmerHeaterDutyCycle, + sprintf( debugTempStr, "MPDC: %2d, SPDC: %2d, THDC: %2d, TPi: %6.2f, TPo: %6.2f, TD1: %6.2f, " + "TD2: %6.2f, TRo: %6.2f, TDi: %6.2f, TPh: %6.2f, TTh: %6.2f, PTarg: %6.2f, TTarg: %6.2f, ROFlow: %6.2f\r\n", + (U32)(mainPrimaryHeaterDutyCycle*100), (U32)(smallPrimaryHeaterDutyCycle*100), (U32)(trimmerHeaterDutyCycle*100), getTemperatureValue ( TEMPSENSORS_INLET_PRIMARY_HEATER_TEMP_SENSOR ), getTemperatureValue ( TEMPSENSORS_OUTLET_PRIMARY_HEATER_TEMP_SENSOR ), getTemperatureValue ( TEMPSENSORS_CONDUCTIVITY_SENSOR_1_TEMP_SENSOR ), @@ -609,7 +610,8 @@ getTemperatureValue ( TEMPSENSORS_INLET_DIALYSATE_TEMP_SENSOR ), getTemperatureValue ( TEMPSENSORS_PRIMARY_HEATER_INTERNAL_TEMP_SENSOR ), getTemperatureValue ( TEMPSENSORS_TRIMMER_HEATER_INTERNAL_TEMP_SESNOR ), - primaryHeaterTargetTemperature, trimmerHeaterTargetTemperature); + primaryHeaterTargetTemperature, trimmerHeaterTargetTemperature, + (F32)(getFPGAROPumpFlowRate()*0.00018)); sendDebugData ( (U08*)debugTempStr, strlen(debugTempStr) ); } #endif Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -re8cd5cfca4acc41b33c012e4d8aa6e76f0c3c661 -rfda570ba4c27bd2f3458d3549474b18f2c367aa0 --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision e8cd5cfca4acc41b33c012e4d8aa6e76f0c3c661) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision fda570ba4c27bd2f3458d3549474b18f2c367aa0) @@ -39,7 +39,7 @@ #define TRIMMER_HEATER_EXT_TEMP_SENSORS_REF_RESISTANCE 5110U ///< Trimmer heater external temperature sensors reference resistance #define TRIMMER_HEATER_EXT_TEMP_SENSORS_0_DEGREE_RESISTANCE 100U ///< Trimmer heater external temperature sensors zero degree resistance -#define HEATERS_INTERNAL_ADC_TO_TEMP_CONVERSION_COEFF 0.0625 ///< Heaters internal temperature sensors ADC to temperature conversion coefficient +#define HEATERS_INTERNAL_ADC_TO_TEMP_CONVERSION_COEFF 0.25 ///< Heaters internal temperature sensors ADC to temperature conversion coefficient #define TEMP_SENSORS_ADC_BITS 24U ///< External temperature sensors ADC bits #define TEMP_SENSORS_ADC_MAX_COUNT (pow(2,TEMP_SENSORS_ADC_BITS)) ///< Temperature sensors max ADC count @@ -363,7 +363,7 @@ * set the avgCalc to true * if the avgCalc in true, calculate all the steps and immediately convert to temperature */ - if ( sensorIndex != TEMPSENSORS_PRIMARY_HEATER_INTERNAL_TEMP_SENSOR || sensorIndex != TEMPSENSORS_TRIMMER_HEATER_INTERNAL_TEMP_SESNOR ) + if ( sensorIndex != TEMPSENSORS_PRIMARY_HEATER_INTERNAL_TEMP_SENSOR && sensorIndex != TEMPSENSORS_TRIMMER_HEATER_INTERNAL_TEMP_SESNOR ) { error = 0; adc = adc & MASK_OFF_U32_MSB; @@ -390,17 +390,24 @@ else { // Fault state is the 17th bit - U32 fault = adc & MASK_OFF_LSW; - fault = fault & 0x0001; + //U32 fault = adc & MASK_OFF_LSW; + //fault = fault & 0x0001; + //U32 thermoCouple = ( adc & MASK_OFF_LSW >> SHIFT_16_BITS_FOR_WORD_SHIFT ); + U32 faultBit = adc & 0x0001; + U32 temperatureTemp = ( ( adc & 0x0000FFFC ) >> 2 ); - if ( fault == HEATERS_INTERNAL_TEMP_SENSOR_FAULT ) + F32 temperatureTemp2 = temperatureTemp * HEATERS_INTERNAL_ADC_TO_TEMP_CONVERSION_COEFF; + + U32 a = 0; + + if ( faultBit == HEATERS_INTERNAL_TEMP_SENSOR_FAULT ) { // Fault alarm? or have a threshold? // If the fault is 1, should we check the individuals? } // TODO fix these - heatersTemperature = adc & 0xFF05; - heatersTemperature = (heatersTemperature & 0x7FFF) >> 2; //TODO use #define for 2 + //heatersTemperature = adc & 0xFF05; + //heatersTemperature = (heatersTemperature & 0x7FFF) >> 2; //TODO use #define for 2 } U32 previousReadCount = readAndErrorCounts [ sensorIndex ] [ READ_AND_ERROR_PREV_FPGA_COUNT_INDEX ]; @@ -586,8 +593,8 @@ processADCRead( TEMPSENSORS_CONDUCTIVITY_SENSOR_2_TEMP_SENSOR, getFPGACD2Temp(), 0, 0 ); processADCRead( TEMPSENSORS_OUTLET_REDUNDANCY_TEMP_SENSOR, getFPGATHDoTemp(), 0, 0 ); processADCRead( TEMPSENSORS_INLET_DIALYSATE_TEMP_SENSOR, getFPGATDiTemp(), 0, 0 ); - //processADCRead( TEMPSENSORS_PRIMARY_HEATER_INTERNAL_TEMP_SENSOR, getFPGAPrimaryHeaterTemp() ); - //processADCRead( TEMPSENSORS_TRIMMER_HEATER_INTERNAL_TEMP_SESNOR, getFPGATrimmerHeaterTemp() ); + processADCRead( TEMPSENSORS_PRIMARY_HEATER_INTERNAL_TEMP_SENSOR, getFPGAPrimaryHeaterTemp(), 0, 0 ); + processADCRead( TEMPSENSORS_TRIMMER_HEATER_INTERNAL_TEMP_SESNOR, getFPGATrimmerHeaterTemp(), 0, 0 ); return state; } Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r647ed0beef9e4aeefb3a0bc0267254dd36cfe685 -rfda570ba4c27bd2f3458d3549474b18f2c367aa0 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 647ed0beef9e4aeefb3a0bc0267254dd36cfe685) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision fda570ba4c27bd2f3458d3549474b18f2c367aa0) @@ -50,7 +50,7 @@ execSystemCommTx(); // Primary heaters state machine - execPrimaryHeaters(); + //execPrimaryHeaters(); // Trimmer heater state machine execTrimmerHeater();