From dbb313977c473b3829de61b80a0fe3e08b8309f8 Mon Sep 17 00:00:00 2001 From: Christian Lind Vie Madsen Date: Tue, 14 Oct 2025 10:48:25 +0200 Subject: [PATCH] first commit --- cm_heatsink_emulator.c | 31 +++++++++++++++++++++++++++++++ cm_heatsink_emulator.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 cm_heatsink_emulator.c create mode 100644 cm_heatsink_emulator.h diff --git a/cm_heatsink_emulator.c b/cm_heatsink_emulator.c new file mode 100644 index 0000000..24c3835 --- /dev/null +++ b/cm_heatsink_emulator.c @@ -0,0 +1,31 @@ +/* + * cm_heatsink_emulator.c + * + * Created on: 14 Oct 2025 + * Author: Christian L. V. Madsen (OZ1CM) + */ +#include "cm_heatsink_emulator.h" +#include "math.h" + +#define EULER_NUM 2.7182818284590452353602 + +static float deltaTempElement(cm_heatsink_thermalElement_t *element, float temperature, float power){ + + return temperature + (power * element->thermal_resistance); + +} + +float cm_heatsinkEmul_getRespon(cm_heatsinkEmul_t *inst, float dt){ + + float t = 0.0; + + for(int i = inst->thermalElements_len; i > 0; i--){ + + + } + + inst->heatsinkTemperature = inst->heatsinkTemperature + (1.0 / inst->thermal_capacity) * (pj5_ThermEmul_Heatsink_RespVal(inst) - inst->heatsinkTemperature) * dt; + + return v_prev; + +} diff --git a/cm_heatsink_emulator.h b/cm_heatsink_emulator.h new file mode 100644 index 0000000..a65051d --- /dev/null +++ b/cm_heatsink_emulator.h @@ -0,0 +1,33 @@ +/* + * cm_heatsink_emulator.h + * + * Created on: 14 Oct 2025 + * Author: Christian L. V. Madsen (OZ1CM) + */ + +#ifndef CM_HEATSINK_EMULATOR_H_ +#define CM_HEATSINK_EMULATOR_H_ + +typedef struct { + char label[32]; + float thermal_resistance; // In Kelvin/Watt or Celsius/Watt (you can mix!) + +}cm_heatsink_thermalElement_t; + +typedef struct { + + cm_heatsink_thermalElement_t *thermalElements; + int thermalElements_len; + + float power; + float ambientTemp; + float thermal_capacity; + + // Dynamic + float heatsinkTemperature; + +}cm_heatsinkEmul_t; + + + +#endif /* CM_HEATSINK_EMULATOR_H_ */