some things are working but regulation is fucked!

This commit is contained in:
2025-05-13 17:51:47 +02:00
parent 643861529f
commit 5b329b710a
12 changed files with 429 additions and 64 deletions

35
buck_emulator.h Normal file
View File

@@ -0,0 +1,35 @@
/*
* buck_emulator.h
*
* Created on: 13. maj 2025
* Author: Christian L. V. Madsen (OZ1CM)
*/
#ifndef BUCK_EMULATOR_H_
#define BUCK_EMULATOR_H_
#include <stdio.h>
#include <stdint.h>
typedef float (*regulate_evt_t)(float Vout);
typedef int (*getResult_evt_t)(float duty, float Vout, float time);
typedef struct {
regulate_evt_t regulate_evt;
getResult_evt_t getResult_evt;
float simTime;
float Vin; // Input voltage
float Vout; // Output voltage
float IL; // Inductor current
float L; // Inductance
float C; // Capacitance
float Rload; // Load resistance
float dt; // Time step (e.g., 25e-6)
} BuckEmulator_t;
int buck_emulator_Run(BuckEmulator_t *inst);
int buck_emulator_RegGetResultEvt(BuckEmulator_t *inst, getResult_evt_t getRes_evt);
int buck_emulator_RegRegulationEvt(BuckEmulator_t *inst, regulate_evt_t reg_evt);
int buck_emulator_init(BuckEmulator_t *inst, float Vin, float L, float C, float Rload, float dt, float sim_time);
#endif /* BUCK_EMULATOR_H_ */