added Variablehandler for Temp

This commit is contained in:
2021-12-15 13:57:58 +01:00
parent de0ddf839a
commit 4ab90de28a
11 changed files with 49 additions and 174 deletions

View File

@ -33,9 +33,6 @@
#include "../PDEF_ProjectDefinitions.h"
#include "ANPO_AnalogPortsOut.h"
//Application
//#include "../Application/ELOG_ErrorLogger.h"
// Toolbox
#include "../Toolbox/UTIL_Utility.h"
@ -123,11 +120,16 @@ BOOL ANPO_boInitializeModule( VOID )
{
BOOL boOK = TRUE;
HAL_DAC_Start(&hdac1, DAC_CHANNEL_1);
boOK &= HAL_DAC_Start(&hdac1, DAC_CHANNEL_1) == HAL_OK ? TRUE : FALSE;
return( boOK );
}
//=================================================================================================
// Section: LOCAL FUNCTIONS
// Descriptionn: Definition (implementation) of local functions.
//=================================================================================================
//-------------------------------------------------------------------------------------------------
// Function: ANPO_boSetVoltage
// Description: Sets the DAC Output to a specific Voltage
@ -144,12 +146,6 @@ BOOL ANPO_boSetVoltage( FLOAT Voltage ){
return( boOK );
}
//=================================================================================================
// Section: LOCAL FUNCTIONS
// Descriptionn: Definition (implementation) of local functions.
//=================================================================================================
//-------------------------------------------------------------------------------------------------
// Function: u32ConvertVoltagetoRaw
// Description: Convert Voltage to Raw value for the DAC

View File

@ -248,17 +248,17 @@ VOID PECO_vTask( PVOID arg )
//-------------------------------------------------------------------------------------------------
// Function: boSetPeltierVoltage
// Description: Sets the Peltier elements to a specific Voltage
// Parameters: S8 Voltage (14V - -8V)
// Parameters: S8 Voltage (12V - -3V)
// Returns: Boolean TRUE if successful
//-------------------------------------------------------------------------------------------------
BOOL boSetPeltierVoltage( S16 Voltage ){
BOOL boOK = TRUE;
if( Voltage > 14000 ) Voltage = 14000;
if( Voltage < -8000 ) Voltage = -8000;
boOK &= ANPO_boSetVoltage( ((((FLOAT)Voltage)/1000) + 20.088) / 34.103 );
if( Voltage > 14000 ) Voltage = 12000;
if( Voltage < -8000 ) Voltage = -3000;
ANPO_boSetVoltage( ((((FLOAT)Voltage)/1000) + 20.088) / 34.103 );
return( boOK );
}

View File

@ -30,7 +30,7 @@
// Description: List of required include files.
//=================================================================================================
//#include "../Application/VARH_VariableHandler.h"
#include "../Application/VARH_VariableHandler.h"
#include "../PDEF_ProjectDefinitions.h"
#include "TEMP_Temperature.h"
@ -62,26 +62,16 @@
#define REFRESH_MS 100
// Konstanten f<>r Temperaturberechung
#define RTD_A 3.9083e-3
#define RTD_B -5.775e-7
#define R_REF 4000
#define R_NOMINAL 1000
//=================================================================================================
// Section: MACROS
// Description: Definition of local macros (visible by this module only).
//=================================================================================================
//=================================================================================================
// Section: ENUMERATIONS
// Description: Definition of local enumerations (visible by this module only).
//=================================================================================================
//=================================================================================================
// Section: STRUCTURES
// Description: Definition of local Structures (visible by this module only).
@ -100,13 +90,6 @@ PRIVATE VOID vTempTask( PVOID arg );
// Description: Definition of local constants (visible by this module only).
//=================================================================================================
LOCAL CONST osMutexAttr_t m_stMutexAttr =
{
"TEMP_Mutex", // human readable mutex name
osMutexRecursive | osMutexPrioInherit, // attr_bits
NULL, // memory for control block
0U // size for control block
};
LOCAL CONST osThreadAttr_t stTaskAttribute =
{
@ -127,9 +110,6 @@ LOCAL CONST osThreadAttr_t stTaskAttribute =
//=================================================================================================
LOCAL osThreadId_t m_pstThreadID = NULL;
LOCAL osMutexId_t m_pstMutexID = NULL;
LOCAL FLOAT m_flTempData[ADCD_eNumberOfTemps];
//=================================================================================================
// Section: EXTERNAL FUNCTIONS
@ -162,52 +142,10 @@ BOOL TEMP_boInitializeModule( VOID )
BOOL boOK = TRUE;
boOK &= ((m_pstThreadID = osThreadNew( vTempTask, NULL, &stTaskAttribute )) == NULL ) ? FALSE : TRUE;
boOK &= ((m_pstMutexID = osMutexNew( &m_stMutexAttr )) == NULL) ? FALSE : TRUE;
return( boOK );
}
//-------------------------------------------------------------------------------------------------
// Function: TEMP_dGetValue
// Description: Gets the desired temperature
// Parameters: ATEMP_EnTemperature enInput
// Returns: DOUBLE DValue Value from ADC
//-------------------------------------------------------------------------------------------------
FLOAT TEMP_dGetValue( ADCD_EnTemps enTemp )
{
osMutexAcquire( m_pstMutexID, osWaitForever );
DOUBLE dValue = m_flTempData[enTemp];
osMutexRelease( m_pstMutexID );
return( dValue );
}
//-------------------------------------------------------------------------------------------------
// Function: TEMP_boRegisterEventNotification
// Description: Register for a notification when there are new values
// Parameters: TEMP_pfnEventCallback pfnCallback
// PVOID pvCallbackArgument
// Returns: TRUE, if successfull, otherwise FALSE
//-------------------------------------------------------------------------------------------------
//BOOL TEMP_boRegisterEventNotification( TEMP_pfnEventCallback pfnCallback, PVOID pvCallbackArgument )
//{
// BOOL boRet = FALSE;
// osMutexAcquire( m_pstMutexID, osWaitForever );
// for( U16 u16Cnt = 0; u16Cnt < NUMBER_OF_EVENT_CALLBACKS; u16Cnt++ )
// {
// if( m_apfnEventCallback[u16Cnt] == NULL )
// {
// m_apfnEventCallback[u16Cnt] = pfnCallback;
// m_apvCallbackArgument[u16Cnt] = pvCallbackArgument;
// boRet = TRUE;
// break;
// }
// }
// osMutexRelease( m_pstMutexID );
// return( boRet );
//}
//=================================================================================================
// Section: LOCAL FUNCTIONS
// Descriptionn: Definition (implementation) of local functions.
@ -227,7 +165,7 @@ PRIVATE VOID vTempTask( PVOID arg )
BOOL boOK = TRUE;
U8 error;
U16 u16ADC_data[ADCD_eNumberOfTemps];
U8 u8Channel;
FLOAT flTempData[ADCD_eNumberOfTemps];
osDelay(10);
@ -240,24 +178,15 @@ PRIVATE VOID vTempTask( PVOID arg )
//if( u32Flags & EVENT_REFRESH )
//{
boOK &= ADCD_dReadData(ADCD_eHot, &error, &u16ADC_data[ADCD_eHot]);
boOK &= ADCD_dReadData(ADCD_eCold, &error, &u16ADC_data[ADCD_eCold]);
if( boOK )
{
osMutexAcquire( m_pstMutexID, osWaitForever );
m_flTempData[ADCD_eHot] = flConvertADCData( u16ADC_data[ADCD_eHot] );
//VARH_vSetVariableData( VARH_eTempHeatSink + u8Channel, (VARH_UVariable)(FLOAT)m_dbTempData[u8Channel] );
osMutexRelease( m_pstMutexID );
} else {
boOK = TRUE;
}
boOK &= ADCD_dReadData(ADCD_eCold, &error, &u16ADC_data[ADCD_eCold]);
if( boOK )
{
osMutexAcquire( m_pstMutexID, osWaitForever );
m_flTempData[ADCD_eCold] = flConvertADCData( u16ADC_data[ADCD_eCold] );
//VARH_vSetVariableData( VARH_eTempHeatSink + u8Channel, (VARH_UVariable)(FLOAT)m_dbTempData[u8Channel] );
osMutexRelease( m_pstMutexID );
} else {
boOK = TRUE;
flTempData[ADCD_eHot] = flConvertADCData( u16ADC_data[ADCD_eHot] );
flTempData[ADCD_eCold] = flConvertADCData( u16ADC_data[ADCD_eCold] );
VARH_vSetVariableData( VARH_eTemp_H, (VARH_UVariable)flTempData[ADCD_eHot] );
VARH_vSetVariableData( VARH_eTemp_C, (VARH_UVariable)flTempData[ADCD_eCold] );
VARH_vSetVariableData( VARH_eTemp_Diff, (VARH_UVariable)(flTempData[ADCD_eHot] - flTempData[ADCD_eCold]) );
}
//}

View File

@ -79,9 +79,6 @@ extern "C" {
//=================================================================================================
BOOL TEMP_boInitializeModule( VOID );
//BOOL TEMP_boRegisterEventNotification( TEMP_pfnEventCallback pfnCallback, PVOID pvCallbackArgument );
FLOAT TEMP_dGetValue( ADCD_EnTemps enTemp );
#ifdef __cplusplus
}