Compare commits

1 Commits

Author SHA1 Message Date
82caa88684 last commit before gitea mirror 2025-09-13 08:41:33 +02:00
4 changed files with 28 additions and 5 deletions

3
.gitmodules vendored
View File

@@ -2,3 +2,6 @@
path = cm_pid_regulator
url = https://OZ1CM@bitbucket.org/oz1cm/cm_pid_regulator.git
branch = master
[submodule "cm_mppt_regulator"]
path = cm_mppt_regulator
url = https://OZ1CM@bitbucket.org/oz1cm/cm_mppt_regulator.git

View File

@@ -23,10 +23,10 @@
// Load
#define R_LOAD 10 // Ohm
#define R_LOAD 10.0 // Ohm
// Simulation parameters
#define SIMULATION_TIME 0.6 // Seconds
#define SIMULATION_TIME 2.6 // Seconds
// Plot specific

1
cm_mppt_regulator Submodule

Submodule cm_mppt_regulator added at f78220273e

25
main.c
View File

@@ -7,12 +7,15 @@
#include <stdio.h>
#include "buck_specs.h"
#include "buck_emulator.h"
#include "cm_pid_regulator/cm_pid_regulator.h"
#include "file_print.h"
#include <Windows.h>
#include "cm_pid_regulator/cm_pid_regulator.h"
#include "cm_mppt_regulator/cm_mppt_regulator.h"
BuckEmulator_t buck_converter;
cm_pid_regulator_float_t Voltreg;
cm_mppt_regulator_t mppt_reg;
float kp = 0.00550;
float ki = 1.0;
@@ -32,6 +35,21 @@ float pid_regulator(float Vout){
}
float mppt_regulator(float Vout){
static uint32_t run_ctr = 0;
static float duty = 0.0;
if((run_ctr++ % 10) != 0)return duty;
duty = (float)cm_mppt_regulator_Compute(&mppt_reg, Vout*1000.0, (Vout*1000.0)/R_LOAD, 200.0) / 65535.0;
printf("duty: %f \r\n",duty);
return duty;
}
int printResult(float duty, float Vout, float time){
showProcentInCmd(time, SIMULATION_TIME);
@@ -45,10 +63,11 @@ int main(void){
buck_emulator_init(&buck_converter,
VIN,L_INDUCTOR,C_CAPACITOR,R_LOAD,SAMPLE_TIME, SIMULATION_TIME);
buck_emulator_RegRegulationEvt(&buck_converter,(regulate_evt_t)pid_regulator);
buck_emulator_RegRegulationEvt(&buck_converter,(regulate_evt_t)mppt_regulator);
buck_emulator_RegGetResultEvt(&buck_converter,(getResult_evt_t)printResult);
cm_PIDRegulatorf_Init(&Voltreg, kp, ki, kd, 0.0, 1.0);
//cm_PIDRegulatorf_Init(&Voltreg, kp, ki, kd, 0.0, 1.0);
cm_mppt_regulator_init(&mppt_reg, (VOUT_TARGET*1000.0), 500.0);
cm_file_open(BUCK_OUTPUT_FILE,VOUT_TARGET);