Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -rb77fd49e9083761003ec1f58392b1954d0956b20 -r6e22cc1ec54e6e283827b4b30fb02646343c809f --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision b77fd49e9083761003ec1f58392b1954d0956b20) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 6e22cc1ec54e6e283827b4b30fb02646343c809f) @@ -126,7 +126,7 @@ // Public functions /*********************************************************************//** - * @brief initHeaters + * @brief * The initHeaters function initializes the variables. * @details * Inputs : none @@ -146,20 +146,20 @@ trimmerHeaterTimerCounter = 5; dataPublicationTimerCounter = 0; - // initialize the PI controller for the primary heaters + // Initialize the PI controller for the primary heaters initializePIController( PI_CONTROLLER_ID_PRIMARY_HEATER, HEATERS_MIN_DUTY_CYCLE, PRIMARY_HEATERS_P_COEFFICIENT, PRIMARY_HEATERS_I_COEFFICIENT, HEATERS_MIN_DUTY_CYCLE, MAIN_PRIMARY_HEATER_MAX_DUTY_CYCLE + SMALL_PRIMAY_HEATER_MAX_DUTY_CYCLE ); - // initialize the PI controller for the trimmer heater + // Initialize the PI controller for the trimmer heater initializePIController( PI_CONTROLLER_ID_TRIMMER_HEATER, HEATERS_MIN_DUTY_CYCLE, TRIMMER_HEATER_P_COEFFICIENT, TRIMMER_HEATER_I_COEFFICIENT, HEATERS_MIN_DUTY_CYCLE, TRIMMER_HEATER_MAX_DUTY_CYCLE ); } /*********************************************************************//** - * @brief setPrimaryHeaterTargetTemperature + * @brief * The setPrimaryHeaterTargetTemperature function sets the primary heater * target temperature * @details @@ -174,7 +174,7 @@ } /*********************************************************************//** - * @brief setTrimmerHeaterTargetTemperature + * @brief * The setTrimmerHeaterTargetTemperature function sets the trimmer heater * target temperature * @details @@ -189,7 +189,7 @@ } /*********************************************************************//** - * @brief startPrimaryHeater + * @brief * The startPrimaryHeater function starts the primary heaters * @details * Inputs : none @@ -212,7 +212,7 @@ } /*********************************************************************//** - * @brief startTrimmerHeater + * @brief * The startTrimmerHeater function starts the trimmer heater * @details * Inputs : none @@ -235,7 +235,7 @@ } /*********************************************************************//** - * @brief stopPrimaryHeater + * @brief * The stopPrimaryHeater function stops the primary heaters * @details * Inputs : none @@ -250,7 +250,7 @@ } /*********************************************************************//** - * @brief stopTrimmerHeater + * @brief * The stopTrimmerHeater function stops the trimmer heater * @details * Inputs : none @@ -263,7 +263,7 @@ } /*********************************************************************//** - * @brief execHeatersMonitor + * @brief * The execHeatersMonitor function * @details * Inputs : none @@ -277,7 +277,7 @@ } /*********************************************************************//** - * @brief execHeatersSelfTest + * @brief * The execHeatersSelfTest function executes the heaters self test * @details * Inputs : none @@ -313,7 +313,7 @@ } /*********************************************************************//** - * @brief execPrimaryHeaters + * @brief * The execPrimaryHeaters function executes the primary heaters * @details * Inputs : none @@ -341,7 +341,7 @@ } /*********************************************************************//** - * @brief execTrimmerHeater + * @brief * The execTrimmerHeater function executes the trimmer heater * @details * Inputs : none @@ -371,7 +371,7 @@ // Private functions /*********************************************************************//** - * @brief handlePrimaryHeaterStateOff + * @brief * The handlePrimaryHeaterStateOff function handles the primary heaters at * off state * @details @@ -390,7 +390,7 @@ setPrimaryHeaterTargetTemperature ( 37 ); //if ( getTemperatureValue ( TEMPSENSORS_INLET_PRIMARY_HEATER_TEMP_SENSOR ) > 0 ) { - startPrimaryHeater(); + //startPrimaryHeater(); state = PRIMARY_HEATERS_EXEC_STATE_CONTROL_TO_TARGET; temporaryStartROPump(); temporaryStartFan(); @@ -403,7 +403,7 @@ } /*********************************************************************//** - * @brief handlePrimaryHeaterStateControlToTarget + * @brief * The handlePrimaryHeaterStateControlToTarget function handles the primary * heaters at control state when the heaters are active * @details @@ -415,7 +415,7 @@ { PRIMARY_HEATERS_EXEC_STATES_T state = PRIMARY_HEATERS_EXEC_STATE_CONTROL_TO_TARGET; - if ( ++primaryHeaterTimerCounter >= CONTROLLER_CHECK_INTERVAL_COUNT ) + /*if ( ++primaryHeaterTimerCounter >= CONTROLLER_CHECK_INTERVAL_COUNT ) { F32 outletTemp = getTemperatureValue ( TEMPSENSORS_OUTLET_PRIMARY_HEATER_TEMP_SENSOR ); mainPrimaryHeaterDutyCycle = runPIController ( PI_CONTROLLER_ID_PRIMARY_HEATER, primaryHeaterTargetTemperature, outletTemp ); @@ -434,7 +434,7 @@ setSmallPrimaryHeaterPWM ( smallPrimaryHeaterDutyCycle ); } primaryHeaterTimerCounter = 0; - } + }*/ publishTemperatureData(); // TODO remove this code @@ -451,7 +451,7 @@ } /*********************************************************************//** - * @brief handleTrimmerHeaterStateOff + * @brief * The handleTrimmerHeaterStateOff function handles the trimmer heater at * off state * @details @@ -470,7 +470,7 @@ setTrimmerHeaterTargetTemperature ( 38 ); //if ( getTemperatureValue ( TEMPSENSORS_OUTLET_REDUNDANCY_TEMP_SENSOR ) > 0 ) { - startTrimmerHeater(); + //startTrimmerHeater(); state = TRIMMER_HEATER_EXEC_STATE_CONTROL_TO_TARGET; //temporaryStartROPump(); //temporaryStartFan(); @@ -483,7 +483,7 @@ } /*********************************************************************//** - * @brief handleTrimmerHeaterControlToTarget + * @brief * The handleTrimmerHeaterControlToTarget function handles the trimmer * heater at control state when the heater is active * @details @@ -495,13 +495,13 @@ { TRIMMER_HEATER_EXEC_STATES_T state = TRIMMER_HEATER_EXEC_STATE_CONTROL_TO_TARGET; - if ( ++trimmerHeaterTimerCounter >= CONTROLLER_CHECK_INTERVAL_COUNT ) + /*if ( ++trimmerHeaterTimerCounter >= CONTROLLER_CHECK_INTERVAL_COUNT ) { F32 outletTemp = getTemperatureValue ( TEMPSENSORS_OUTLET_REDUNDANCY_TEMP_SENSOR ); trimmerHeaterDutyCycle = runPIController ( PI_CONTROLLER_ID_TRIMMER_HEATER, trimmerHeaterTargetTemperature, outletTemp ); setTrimmerHeaterPWM ( trimmerHeaterDutyCycle ); trimmerHeaterTimerCounter = 0; - } + }*/ publishTemperatureData(); // TODO remove this code @@ -518,7 +518,7 @@ } /*********************************************************************//** - * @brief setMainPrimaryHeaterPWM + * @brief * The setMainPrimaryHeaterPWM function sets the PWM of the main primary * heater * @details @@ -533,7 +533,7 @@ } /*********************************************************************//** - * @brief setSmallPrimaryHeaterPWM + * @brief * The setSmallPrimaryHeaterPWM function sets the PWM of the small primary * heater * @details @@ -548,7 +548,7 @@ } /*********************************************************************//** - * @brief setTrimmerHeaterPWM + * @brief * The setTrimmerHeaterPWM function sets the PWM of the trimmer heater * @details * Inputs : none @@ -562,7 +562,7 @@ } /*********************************************************************//** - * @brief resetHeaterState + * @brief * The resetHeaterState function resets the PI controller of the selected * heater * @details @@ -575,16 +575,18 @@ { if ( heater == PRIMARY_HEATER ) { + mainPrimaryHeaterDutyCycle = MAIN_PRIMARY_HEATER_MAX_DUTY_CYCLE; resetPIController ( PI_CONTROLLER_ID_PRIMARY_HEATER, MAIN_PRIMARY_HEATER_MAX_DUTY_CYCLE ); } else if ( heater == TRIMMER_HEATER ) { + trimmerHeaterDutyCycle = SMALL_PRIMAY_HEATER_MAX_DUTY_CYCLE; resetPIController ( PI_CONTROLLER_ID_TRIMMER_HEATER, SMALL_PRIMAY_HEATER_MAX_DUTY_CYCLE ); } } /************************************************************************* - * @brief publishTemperatureData + * @brief * The publishTemperatureData function publishes the temperature sensors * data into the USB debug port at the defined time interval * @details @@ -612,7 +614,7 @@ getTemperatureValue ( TEMPSENSORS_PRIMARY_HEATER_INTERNAL_TEMP_SENSOR ), getTemperatureValue ( TEMPSENSORS_TRIMMER_HEATER_INTERNAL_TEMP_SESNOR ), primaryHeaterTargetTemperature, trimmerHeaterTargetTemperature, - (F32)(10909.0909/getFPGAROPumpFlowRate()) ); + (F32)(10909.0909/getFPGAROPumpFlowRate()) ); //TODO Remove flow reader later sendDebugData ( (U08*)debugTempStr, strlen(debugTempStr) ); } #endif Index: firmware/App/Controllers/Heaters.h =================================================================== diff -u -r83352606f453107c3ac4636c8da0e8a65b17c723 -r6e22cc1ec54e6e283827b4b30fb02646343c809f --- firmware/App/Controllers/Heaters.h (.../Heaters.h) (revision 83352606f453107c3ac4636c8da0e8a65b17c723) +++ firmware/App/Controllers/Heaters.h (.../Heaters.h) (revision 6e22cc1ec54e6e283827b4b30fb02646343c809f) @@ -19,6 +19,15 @@ #include "Common.h" +/** + * @defgroup Heaters + * @brief Heaters driver modules. + * Controls the Primary and Trimmer Heaters + * + * @addtogroup Heaters + * @{ + */ + void initHeaters ( void ); void setPrimaryHeaterTargetTemperature ( F32 targetTemp ); Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -rb77fd49e9083761003ec1f58392b1954d0956b20 -r6e22cc1ec54e6e283827b4b30fb02646343c809f --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision b77fd49e9083761003ec1f58392b1954d0956b20) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 6e22cc1ec54e6e283827b4b30fb02646343c809f) @@ -25,7 +25,7 @@ * @{ */ -// Private variables +// Private defines #define PRIMARY_HEATER_EXT_TEMP_SENSORS_GAIN 16U ///< Primary heater external temperature sensors gain #define PRIMARY_HEATER_EXT_TEMP_SENSORS_REF_RESISTANCE 19600U ///< Primary heater external temperature sensors reference resistance @@ -73,11 +73,11 @@ #define EXTERNAL_TEMP_SENSORS_ERROR_VALUE 0x80 ///< External temperature sensors error value #define HEATERS_INTERNAL_TEMP_SENSOR_FAULT 0x01 ///< Heaters internal temperature sensor fault -#define SHIFT_BITS_BY_2 2U ///< Shift bits by 2 TODO add to AE -#define MIN_WATER_INPUT_TEMPERATURE 10U ///< Minimum water input temperature TODO add to AE -#define MAX_WATER_INPUT_TEMPERATURE 40U ///< Maximum water input temperature TODO add to AE -#define ADC_FPGA_READ_DELAY 30U ///< Delay in ms before reading the ADC values from FPGA TODO add to AE -#define INPUT_WATER_TEMPERATURE_CHECK_TIME_INTERVAL 100U ///< Time interval that is used to check the input water TODO add to AE +#define SHIFT_BITS_BY_2 2U ///< Shift bits by 2 +#define MIN_WATER_INPUT_TEMPERATURE 10U ///< Minimum water input temperature +#define MAX_WATER_INPUT_TEMPERATURE 40U ///< Maximum water input temperature +#define ADC_FPGA_READ_DELAY 30U ///< Delay in ms before reading the ADC values from FPGA +#define INPUT_WATER_TEMPERATURE_CHECK_TIME_INTERVAL 100U ///< Time interval that is used to check the input water /// Temperature sensor self test states typedef enum tempSensors_Self_Test_States @@ -97,21 +97,21 @@ NUM_OF_TEMPSENSORS_EXEC_STATES, ///< Total number of exec states } TEMPSENSORS_EXEC_STATES_T; -/// FPGA error and read counts +// Private variables static SELF_TEST_STATUS_T tempSensorsSelfTestResult; ///< Self test result of the TemperatureSensors module static TEMPSENSORS_SELF_TEST_STATES_T tempSensorsSelfTestState; ///< TemperatureSensor self test state static TEMPSENSORS_EXEC_STATES_T tempSensorsExecState; ///< TemperatureSensor exec state static U32 sampleCount; ///< Initial ADC read index until the array if filled up for the first time static S32 rawADCReads [ NUM_OF_TEMPERATURE_SENSORS ] [ MAX_NUM_OF_RAW_ADC_SAMPLES ]; ///< Raw ADC reads array -static S32 runningSumAndIndex [ NUM_OF_TEMPERATURE_SENSORS ] ///< Running sum and next ADC index array - [ NUM_OF_RUNNING_SUM_AND_INDEX_ARRAY_COLUMNS ]; +static S32 runningSumAndIndex [ NUM_OF_TEMPERATURE_SENSORS ] + [ NUM_OF_RUNNING_SUM_AND_INDEX_ARRAY_COLUMNS ]; ///< Running sum and next ADC index array static U32 tempSensorsConstants [ NUM_OF_TEMPERATURE_SENSORS ] - [ NUM_OF_TEMP_SENSORS_CONSTANTS_ARRAY_COLUMNS ];///< Temperature sensors constants + [ NUM_OF_TEMP_SENSORS_CONSTANTS_ARRAY_COLUMNS ];///< Temperature sensors constants array static U32 readAndErrorCounts [ NUM_OF_TEMPERATURE_SENSORS ] - [ NUM_OF_READ_AND_ERROR_ARRAY_COLUMNS ]; -static F32 temperatureValues [ NUM_OF_TEMPERATURE_SENSORS ]; + [ NUM_OF_READ_AND_ERROR_ARRAY_COLUMNS ]; ///< Read and error counts from FPGA array +static F32 temperatureValues [ NUM_OF_TEMPERATURE_SENSORS ]; ///< Temperature values array static U32 elapsedTime; ///< Elapsed time // Private functions prototypes @@ -178,6 +178,7 @@ tempSensorsConstants [ TEMPSENSORS_TRIMMER_HEATER_INTERNAL_TEMP_SESNOR ] [ ADC_READ_REF_RESISTANCE_INDEX ] = 0; tempSensorsConstants [ TEMPSENSORS_TRIMMER_HEATER_INTERNAL_TEMP_SESNOR ] [ ADC_READ_0_DEG_RESISTANCE_INDEX ] = 0; } + /************************************************************************* * @brief * The execTemperatureSensorsSelfTest function runs the TemperatureSensors @@ -217,8 +218,9 @@ return tempSensorsSelfTestResult; } + /************************************************************************* - * @brief execTemperatureSensors + * @brief * The execTemperatureSensors function runs the TemperatureSensors main * tasks * @details @@ -247,8 +249,9 @@ break; } } + /************************************************************************* - * @brief getTemperatureValue + * @brief * The getTemperatureValue function gets the enum of the requested * temperature sensor, converts the ADC of it to temperature in degree C * and returns the temperature @@ -314,7 +317,7 @@ // Private functions /************************************************************************* - * @brief getADC2TempConversion + * @brief * The getADC2TempConversion function calculates the temperature from * ADC read from FPGA * @details @@ -333,8 +336,9 @@ return temperature; } + /************************************************************************* - * @brief processADCRead + * @brief * The processADCRead function receives the ADC value and the sensor * index and calculates the running sum and the moving average of the ADCs * The temperatureSensorsADCRead and tempSensorsAvgADCValues are updated @@ -457,6 +461,7 @@ temperatureValues [ sensorIndex ] = temperature; } } + /************************************************************************* * @brief handleSelfTestStart * The handleSelfTestStart function waits for the ADC read array to be @@ -471,8 +476,9 @@ { return TEMPSENSORS_SELF_TEST_ADC_CHECK; } + /************************************************************************* - * @brief handleSelfTestADCCheck + * @brief * The handleSelfTestADCCheck function checks whether the ADC reads. If the * reads are above the maximum 24bit ADC count, it will throw an alarm and * switches to the next state @@ -500,8 +506,9 @@ return state; } + /************************************************************************* - * @brief handleSelfTestConsistencyCheck + * @brief * The handleSelfTestConsistencyCheck function checks the values of the * sensors to make sure they are within the allowed range from each other * @details @@ -537,8 +544,9 @@ return state; } + /************************************************************************* - * @brief handleExecStart + * @brief * The handleExecStart function switches the state to read * @details * Inputs : none @@ -562,8 +570,9 @@ return state; } + /************************************************************************* - * @brief handleExecGetADCValues + * @brief * The handleExecGetADCValues function reads the ADC values from FPGA * @details * Inputs : none Index: firmware/App/Controllers/TemperatureSensors.h =================================================================== diff -u -rb77fd49e9083761003ec1f58392b1954d0956b20 -r6e22cc1ec54e6e283827b4b30fb02646343c809f --- firmware/App/Controllers/TemperatureSensors.h (.../TemperatureSensors.h) (revision b77fd49e9083761003ec1f58392b1954d0956b20) +++ firmware/App/Controllers/TemperatureSensors.h (.../TemperatureSensors.h) (revision 6e22cc1ec54e6e283827b4b30fb02646343c809f) @@ -19,6 +19,16 @@ #include "Common.h" +/** + * @defgroup TemperatureSensors + * @brief Temperature Sensors driver module. + * Reads and processes the temperature sensors. + * + * @addtogroup TemperatureSensors + * @{ + */ + +/// Sensors name typedef enum SENSORS_NAME { TEMPSENSORS_INLET_PRIMARY_HEATER_TEMP_SENSOR = 0, ///< Inlet primary heaters temperature sensor Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -re7f256098e5c23cc621af73b17160a247d40559c -r6e22cc1ec54e6e283827b4b30fb02646343c809f --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision e7f256098e5c23cc621af73b17160a247d40559c) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 6e22cc1ec54e6e283827b4b30fb02646343c809f) @@ -74,6 +74,7 @@ *************************************************************************/ void transitionToInitAndPOSTMode( void ) { + // TODO Will be filled up by Sean Nash } /************************************************************************* Index: firmware/App/Services/FPGA.c =================================================================== diff -u -re8cd5cfca4acc41b33c012e4d8aa6e76f0c3c661 -r6e22cc1ec54e6e283827b4b30fb02646343c809f --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision e8cd5cfca4acc41b33c012e4d8aa6e76f0c3c661) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 6e22cc1ec54e6e283827b4b30fb02646343c809f) @@ -1129,7 +1129,7 @@ *************************************************************************/ U32 getFPGACD1Temp( void ) { - return 0;//fpgaSensorReadings.fpgaCD1Temp; + return fpgaSensorReadings.fpgaCD1; } /*********************************************************************//** @@ -1144,7 +1144,7 @@ *************************************************************************/ U32 getFPGACD2Temp( void ) { - return 0;//fpgaSensorReadings.fpgaCD2Temp; + return fpgaSensorReadings.fpgaCD2; } /*********************************************************************//** @@ -1233,7 +1233,7 @@ *************************************************************************/ U32 getFPGATDiTemp( void ) { - return fpgaSensorReadings.fpgaTDiTemp; + return fpgaSensorReadings.fpgaTDi; } /*********************************************************************//**