From 6555442f154b18b1e4ba1330d34bd747ab7bd647 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Sun, 26 Jul 2026 21:32:56 +0200 Subject: [PATCH] commit stale changes --- .gitignore | 1 + mppt.py | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/mppt.py b/mppt.py index 20a74c9..d7902ad 100644 --- a/mppt.py +++ b/mppt.py @@ -3,17 +3,18 @@ import random from matplotlib import pyplot as plot import numpy as np + def calc_p(U0, Ri, Rl): I = U0 / (Ri + Rl) Ul = I * Rl P = Ul * I - return P + return P, I, Ul U0 = 10 -Ri = 3.14 -Rl_min = 0.1 +Ri = 5.0 +Rl_min = 0.0 Rl_max = 10. Rl_step_start = 1 Rl_step_stop = 0.01 @@ -27,11 +28,11 @@ Rl_step = Rl_step_start dir = "inc" dir_last = dir while Rl_step > Rl_step_stop: - p0 = calc_p(U0, Ri, Rl_s) + p0, _, _ = calc_p(U0, Ri, Rl_s) p1 = p0 if "inc" in dir: Rl_s = min(Rl_max, Rl_s + Rl_step) - p1 = calc_p(U0, Ri, Rl_s) + p1, _, _ = calc_p(U0, Ri, Rl_s) if p0 > p1: if 'inc' in dir_last: Rl_step /= 2 @@ -39,7 +40,7 @@ while Rl_step > Rl_step_stop: elif "dec" in dir: Rl_s = max(Rl_min, Rl_s - Rl_step) - p1 = calc_p(U0, Ri, Rl_s) + p1, _, _ = calc_p(U0, Ri, Rl_s) if p0 > p1: if 'dec' in dir_last: Rl_step /= 2 @@ -50,12 +51,12 @@ while Rl_step > Rl_step_stop: # -------------------------------------------------- -P = calc_p(U0, Ri, Rl) +P, I, U = calc_p(U0, Ri, Rl) plot.plot(Rl, P) plot.ylabel("Power [W]") plot.xlabel("RL [Ohms]") plot.title("Power vs RL") -plot.legend("RL [Ohms]") +plot.legend(("P_RL",)) plot.grid() plot.show()