add setRefVoltage

This commit is contained in:
2022-12-07 10:49:37 +01:00
parent 39704f6cc3
commit 0fe90f2ed0
4 changed files with 35 additions and 8 deletions

View File

@ -95,6 +95,8 @@ LOCAL osThreadId_t m_pstThreadID = NULL;
LOCAL osEventFlagsId_t m_pstEventID = NULL;
LOCAL osMutexId_t m_pstMutexID = NULL;
LOCAL FLOAT flRefVoltage = INT_ADC_REF;
//=================================================================================================
// Section: LOCAL CONSTANTS
// Description: Definition of local constants (visible by this module only).
@ -198,6 +200,17 @@ BOOL ANPI_boInitializeModule( VOID )
return( boOK );
}
//-------------------------------------------------------------------------------------------------
// Function: ANPI_vSetRefVoltage
// Description: Sets the Reference Voltage for calculating the Voltage
// Parameters: FLOAT flVoltage -> The Ref Voltage measured with an DMM for example
// Returns: None
//-------------------------------------------------------------------------------------------------
VOID ANPI_vSetRefVoltage( FLOAT flVoltage )
{
flRefVoltage = flVoltage;
}
//-------------------------------------------------------------------------------------------------
// Function: ANPI_vTask
// Description: ANPI_vTask
@ -234,7 +247,7 @@ VOID vTask( PVOID arg )
// multiply conversion factor and add the offset
for( U16 u16Cnt = 0; u16Cnt < ANPI_eInNumberOfInputs; u16Cnt++ )
{
flUadc = (FLOAT)au32ADCRawData[u16Cnt] / OVERSAMPLING_DIVISOR / ADC_RES * INT_ADC_REF;
flUadc = (FLOAT)au32ADCRawData[u16Cnt] / OVERSAMPLING_DIVISOR / ADC_RES * flRefVoltage;
aflValues[u16Cnt] = flUadc * m_aflConversionFactor[u16Cnt] - m_aflOffset[u16Cnt];
}