version13
version 11/12 auch noch
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
#include "stm32l4xx_hal.h"
|
||||
|
||||
#include "cmsis_os2.h"
|
||||
#include <math.h>
|
||||
|
||||
//=================================================================================================
|
||||
// Section: DEFINITIONS
|
||||
@@ -65,7 +66,7 @@
|
||||
#define OVERSAMPLING_DIVISOR 16.0f // calculated with parameters from hardware oversampling
|
||||
// 6 bits(64x) - 2 bit shift = 4bit -> 16x
|
||||
|
||||
#define ALMOST_ZERO 0.05
|
||||
#define ALMOST_ZERO 0.1
|
||||
|
||||
//=================================================================================================
|
||||
// Section: MACROS
|
||||
@@ -109,18 +110,26 @@ LOCAL FLOAT aflValues[ANPI_eInNumberOfInputs]; // values
|
||||
LOCAL CONST FLOAT m_aflConversionFactor[ANPI_eInNumberOfInputs] =
|
||||
{
|
||||
10, // 01 ANPI_eSupplyVoltage24V
|
||||
5, // 02 ANPI_eSupplyCurrent24V
|
||||
10, // 03 ANPI_eOutputVoltage
|
||||
5, // 04 ANPI_eOutputCurrent
|
||||
5, // 02 ANPI_eSupplyCurrent24V
|
||||
10, // 03 ANPI_eOutputVoltage
|
||||
5, // 04 ANPI_eOutputCurrent
|
||||
};
|
||||
|
||||
// Order must fit enumeration "ANPI_EnAnalogInput"
|
||||
LOCAL CONST FLOAT m_aflOffset[ANPI_eInNumberOfInputs] =
|
||||
{
|
||||
0.0f, // 01 ANPI_eSupplyVoltage24V
|
||||
8.25f, // 02 ANPI_eSupplyCurrent24V
|
||||
14.85f, // 03 ANPI_eOutputVoltage
|
||||
8.25f, // 04 ANPI_eOutputCurrent
|
||||
0.0f, // 01 ANPI_eSupplyVoltage24V
|
||||
8.25f, // 02 ANPI_eSupplyCurrent24V
|
||||
14.85f, // 03 ANPI_eOutputVoltage
|
||||
8.25f, // 04 ANPI_eOutputCurrent
|
||||
};
|
||||
|
||||
LOCAL CONST BOOL m_aboNegativeValuesAllowed[ANPI_eInNumberOfInputs] =
|
||||
{
|
||||
FALSE, // 01 ANPI_eSupplyVoltage24V
|
||||
FALSE, // 02 ANPI_eSupplyCurrent24V
|
||||
TRUE, // 03 ANPI_eOutputVoltage
|
||||
TRUE, // 04 ANPI_eOutputCurrent
|
||||
};
|
||||
|
||||
// inputs are connected to the following ADCs
|
||||
@@ -250,13 +259,20 @@ VOID vTask( PVOID arg )
|
||||
aflValues[u16Cnt] = 0.0f;
|
||||
}
|
||||
|
||||
for( U16 u16Cnt = 0; u16Cnt < ANPI_eInNumberOfInputs; u16Cnt++ )
|
||||
{
|
||||
if( ! m_aboNegativeValuesAllowed[u16Cnt] ){
|
||||
if( aflValues[u16Cnt] < 0.0f) aflValues[u16Cnt] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VARH_vSetVariableDataFromSystemFloat( VARH_ePeltier_U, aflValues[ANPI_eOutputVoltage] );
|
||||
VARH_vSetVariableDataFromSystemFloat( VARH_ePeltier_I, aflValues[ANPI_eOutputCurrent] );
|
||||
if ( aflValues[ANPI_eOutputCurrent] == 0.0f ){
|
||||
VARH_vSetVariableDataFromSystemFloat( VARH_ePeltier_R, 0.0f );
|
||||
} else {
|
||||
VARH_vSetVariableDataFromSystemFloat( VARH_ePeltier_R, aflValues[ANPI_eOutputVoltage] / aflValues[ANPI_eOutputCurrent] );
|
||||
VARH_vSetVariableDataFromSystemFloat( VARH_ePeltier_R, fabs( aflValues[ANPI_eOutputVoltage] / aflValues[ANPI_eOutputCurrent]) );
|
||||
}
|
||||
VARH_vSetVariableDataFromSystemFloat( VARH_ePeltier_P, aflValues[ANPI_eOutputVoltage] * aflValues[ANPI_eOutputCurrent] );
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ VOID vTask(PVOID arg)
|
||||
{
|
||||
boUpdateVoltage();
|
||||
|
||||
BOOL boPowerGood = DIPO_boGetInput(DIPO_ePG);
|
||||
// BOOL boPowerGood = DIPO_boGetInput(DIPO_ePG);
|
||||
/** @todo check power good pin */
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user