PECO update

This commit is contained in:
pique_n 2022-10-19 14:12:32 +02:00
parent ded2dc6ef9
commit 39607106d2
3 changed files with 54 additions and 60 deletions

View File

@ -52,7 +52,7 @@
// Description: Definition of local constants (visible by this module only).
//=================================================================================================
#define REFRESH 1000 // Refresh rate in ms
#define REFRESH 100 // Refresh rate in ms
#define EVENT_TIMER_UPDATE ((U32)(1<<0))
@ -105,7 +105,7 @@ LOCAL CONST osThreadAttr_t stTaskAttribute =
0, // size of provided memory for control block
NULL, // memory for stack
1024, // size of stack
osPriorityNormal, // initial thread priority (default: osPriorityNormal)
osPriorityHigh, // initial thread priority (default: osPriorityNormal)
0, // TrustZone module identifier
0, // reserved (must be 0)
};
@ -176,21 +176,6 @@ BOOL PECO_boInitializeModule( VOID )
return( boOK );
}
//-------------------------------------------------------------------------------------------------
// Function: PECO_boSetTemperature
// Description: Sets the Peltier Controller to a Specific Temperature
// Parameters: None
// Returns: Boolean TRUE if successful
//-------------------------------------------------------------------------------------------------
BOOL PECO_boSetTemperature( S16 Temperature ){
BOOL boOK = TRUE;
boOK &= boSetPeltierVoltage( Temperature );
return( boOK );
}
//-------------------------------------------------------------------------------------------------
// Function: PECO_Enable
// Description: Enables the Peltier Controller Output
@ -231,7 +216,7 @@ VOID vTask( PVOID arg )
FLOAT last_error = 0;
FLOAT integral = 0;
FLOAT dT = REFRESH; // 1s
FLOAT dT = REFRESH / 1000.0f; // 1s
while ( TRUE )
{
@ -243,6 +228,9 @@ VOID vTask( PVOID arg )
HAL_IWDG_Refresh(&hiwdg);
if ( PECO_isEnabled() )
{
if ( VARH_u32GetVariableData( VARH_eMode ) == PECO_eConstTemp )
{
// TODO: check the measurements, everything ok?
@ -279,8 +267,10 @@ VOID vTask( PVOID arg )
// limitter
if ( output > max ){
output = max;
integral = 0;
} else if ( output < min ){
output = min;
integral = 0;
}
boSetPeltierVoltage( output ); // set the output
@ -288,8 +278,13 @@ VOID vTask( PVOID arg )
} else if ( VARH_u32GetVariableData( VARH_eMode ) == PECO_eConst_Voltage )
{
boSetPeltierVoltage( VARH_flGetVariableData( VARH_eControlVoltage ) ); // set the output
last_error = 0;
integral = 0;
}
} else {
last_error = 0;
integral = 0;
}
}

View File

@ -88,7 +88,6 @@ typedef enum {
//=================================================================================================
BOOL PECO_boInitializeModule( VOID );
BOOL PECO_boSetTemperature( S16 Temperature );
VOID PECO_Enable( BOOL Enable );
BOOL PECO_isEnabled( VOID );

View File

@ -1,5 +1,5 @@
##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.15.2] date: [Thu Jul 07 18:17:37 CEST 2022]
# File automatically-generated by tool: [projectgenerator] version: [3.15.2] date: [Tue Sep 06 08:17:33 CEST 2022]
##########################################################################################################################
# ------------------------------------------------