Lüftergeschwindigkeit in Ist-Anzeige integriert.

This commit is contained in:
Carsten Keller 2024-06-09 17:57:59 +02:00
parent 03552cbae4
commit 3cc25b2cae
Signed by: carsten
GPG Key ID: DF06343A3A9B8868
3 changed files with 19 additions and 2 deletions

View File

@ -48,6 +48,7 @@ static uint32_t dac_value;
static uint32_t strom; static uint32_t strom;
static uint32_t spannung; static uint32_t spannung;
static uint32_t temperatur; static uint32_t temperatur;
static uint32_t geschwindigkeit;
int main (void) int main (void)
{ {
@ -80,6 +81,7 @@ int main (void)
strom = adc.get_current(); strom = adc.get_current();
spannung = adc.get_voltage(); spannung = adc.get_voltage();
temperatur = adc.get_temperature(); temperatur = adc.get_temperature();
geschwindigkeit = fan.get_speed();
serial_cyclic(); serial_cyclic();
} }
@ -120,7 +122,8 @@ uint16_t ist_werte(CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t
if(((recall == 1U) && ((int32_t)(systick - last_call) > 999)) || recall == 0U) if(((recall == 1U) && ((int32_t)(systick - last_call) > 999)) || recall == 0U)
{ {
char buffer[64]; char buffer[64];
snprintf(buffer, sizeof(buffer), "\rI: %5" PRIu32 " U: %5" PRIu32 " T: %5" PRIu32, strom, spannung, temperatur); snprintf(buffer, sizeof(buffer), "\rI: %5" PRIu32 " U: %5" PRIu32 " T: %5" PRIu32 " V: %5" PRIu32,
strom, spannung, temperatur, geschwindigkeit);
pfvOutFunction(buffer); pfvOutFunction(buffer);
last_call = systick; last_call = systick;
} }

View File

@ -18,7 +18,7 @@ extern "C" void TIM14_IRQHandler(void)
{ {
LL_TIM_ClearFlag_UPDATE(TIM14); LL_TIM_ClearFlag_UPDATE(TIM14);
fan_speed = LL_TIM_GetCounter(TIM2) *60U / 2UL; fan_speed = LL_TIM_GetCounter(TIM2);
LL_TIM_SetCounter(TIM2, 0UL); LL_TIM_SetCounter(TIM2, 0UL);
} }
extern "C" void FanControl_SetDuty(uint32_t d) extern "C" void FanControl_SetDuty(uint32_t d)
@ -116,4 +116,17 @@ namespace ElektronischeLast
this->compare_value = duty; this->compare_value = duty;
LL_TIM_OC_SetCompareCH1(TIM3, this->compare_value); LL_TIM_OC_SetCompareCH1(TIM3, this->compare_value);
} }
/**
* @brief Lüftergeschwindigkeit in Umdrehungen pro Minute.
* @details Das Tachosignal gibt zwei Impule pro Umdrehung heraus.
* Die Messdauer der Pulsanzahl beträgt eine Miunute.
* v = pulse / 2 * 60 => erst mal 60, damit es ganuer wird
* wegen Datentyp ungenauigkeit beim Teilen.
* @return
*/
std::uint32_t FanControl::get_speed(void)
{
return fan_speed *60UL / 2UL;
}
} }

View File

@ -20,6 +20,7 @@ namespace ElektronischeLast
FanControl(void); FanControl(void);
~FanControl(void); ~FanControl(void);
void run(std::uint32_t temp); void run(std::uint32_t temp);
std::uint32_t get_speed(void);
private: private:
std::uint32_t compare_value; std::uint32_t compare_value;
}; };