Lüfter-Stuerung eingebaut

Min-Max-Bestimmung entfernt
This commit is contained in:
Carsten Keller 2024-06-09 17:57:52 +02:00
parent d609bdfe24
commit 9fb30d640f
Signed by: carsten
GPG Key ID: DF06343A3A9B8868

View File

@ -15,6 +15,7 @@
#include "ADC.hpp"
#include "serial.hpp"
#include "PID.h"
#include "FanControl.hpp"
using namespace ElektronischeLast;
@ -31,16 +32,6 @@ static PIDController pid =
.T = 0.001f,
};
static uint32_t dac_value;
static struct
{
uint32_t current_min;
uint32_t current_max;
} current_spitze;
static struct
{
uint32_t voltage_min;
uint32_t voltage_max;
} voltage_spitze;
int main (void)
{
@ -50,6 +41,7 @@ int main (void)
LED led = LED(500U);
iDAC dac = iDAC();
iADC adc = iADC();
FanControl fan = FanControl();
std::uint32_t last_tick = systick;
printf("\r\nElektronische Last\r\n");
@ -64,14 +56,10 @@ int main (void)
if(last_tick != systick)
{
last_tick = systick;
uint32_t tmp = adc.get_current();
if(tmp > current_spitze.current_max) current_spitze.current_max = tmp;
if(tmp < current_spitze.current_min) current_spitze.current_min = tmp;
tmp = adc.get_voltage();
if(tmp > voltage_spitze.voltage_max) voltage_spitze.voltage_max = tmp;
if(tmp < voltage_spitze.voltage_min) voltage_spitze.voltage_min = tmp;
dac_value = (uint32_t)PIDController_Update(&pid, i_soll, adc.get_current());
dac.write(iDAC::CHANNEL_1, dac_value);
fan.run(adc.get_temperature());
}
}
}