Pump voltage check and disabling mechanism if high

This commit is contained in:
VineetaGupta 2025-04-01 17:02:38 +02:00
parent e081882ad7
commit 71b468cc6e
4 changed files with 16 additions and 18 deletions

View File

@ -60,7 +60,6 @@ void AnalogMeasurementReadData(uint32 channel_u32, uint32 *adcValue_pu32)
{
return; /* Prevent dereferencing NULL pointer */
}
__disable_irq();
switch (channel_u32)
{
case PS1_ADC_CHANNEL: *adcValue_pu32 = adcBuffer_u32[0]; break;
@ -76,7 +75,6 @@ void AnalogMeasurementReadData(uint32 channel_u32, uint32 *adcValue_pu32)
case FM4_ADC_CHANNEL: *adcValue_pu32 = adcBuffer_u32[8]; break;
default: *adcValue_pu32 = 0uL; break;
}
__enable_irq();
}
/******************************************************************************

View File

@ -27,7 +27,7 @@
/******************************************************************************
* Private function Declarations
******************************************************************************/
static uint32 GrundfosPmpReadVoltage(uint8 channel_u8);
static float32 GrundfosPmpReadVoltage(uint8 channel_u8);
/******************************************************************************
* Extern Function Definitions
@ -45,9 +45,9 @@ void GrundfosPmpEnable(uint8 state_u8)
}
uint32 GrundfosPmpFeedbackSpeed(uint8 channel_u8)
float32 GrundfosPmpFeedback(uint8 channel_u8)
{
uint32 feedbackSpeed_u32 = (GrundfosPmpReadVoltage(channel_u8)) * 360uL;
float32 feedbackSpeed_u32 = (GrundfosPmpReadVoltage(channel_u8)) * 0.32f;
return feedbackSpeed_u32;
}
@ -90,12 +90,13 @@ bool GrundfosPmpSetSpeed(float32 setSpeed_f32)
* @return ADC output voltage based on sensor reading.
*
*/
static uint32 GrundfosPmpReadVoltage(uint8 channel_u8)
static float32 GrundfosPmpReadVoltage(uint8 channel_u8)
{
/* Convert ADC value to voltage (assuming 12-bit resolution and 3.3V reference) */
float32 voltage_f32 = 0.0f;
uint32 adcVal_u32 = 0uL;
AnalogMeasurementReadData(channel_u8, &adcVal_u32);
float32 voltage_f32 = (float32)adcVal_u32 * (ANALOG_MEAS_ADC_REF_VOLTAGE / ANALOG_MEAS_ADC_RESOLUTION);
voltage_f32 = (float32)adcVal_u32 * (ANALOG_MEAS_ADC_REF_VOLTAGE / ANALOG_MEAS_ADC_RESOLUTION);
return voltage_f32;
}

View File

@ -34,7 +34,7 @@ typedef struct
/******************************************************************************
* Extern Function Declarations
******************************************************************************/
uint32 GrundfosPmpFeedbackSpeed(uint8 channel_u8);
float32 GrundfosPmpFeedback(uint8 channel_u8);
void GrundfosPmpEnable(uint8_t state_u8);
bool GrundfosPmpSetSpeed(float setSpeed_f);
#endif /* GRUNDFOS_H_ */

View File

@ -173,7 +173,7 @@ void ProcessBoardRun(void)
******************************************************************************/
static void ProcessBoardGrundfosPumpHandler(void)
{
static uint32 pmpSpeed_u32 = 0uL;
static float32 pmpSpeed_f32 = 0.0f;
static uint8 speed_u8 = 0u;
static uint64 startTime_u64 = 0uLL;
uint64 currentTimeMs_u64;
@ -201,16 +201,15 @@ static void ProcessBoardGrundfosPumpHandler(void)
GrundfosPmpSetSpeed(speed_u8);
startTime_u64 = currentTimeMs_u64;
}
/* Grundfos Pump feedback speed OUT */
pmpSpeed_u32 = GrundfosPmpFeedbackSpeed(PMP_ADC_CHANNEL);
pmpSpeed_f32 = GrundfosPmpFeedback(PMP_ADC_CHANNEL);
/* To be verified */
if (pmpSpeed_u32 > PU_PUMP_MAX_SPEED)
if (pmpSpeed_f32 > 3.3f)
{
GrundfosPmpEnable(PU_PMP_DISABLE);
}
}
}