From 42960f8c43fcac40b7b56442e9eb529eff47b6c8 Mon Sep 17 00:00:00 2001 From: "Jan N. Bader" Date: Tue, 13 Apr 2021 11:05:05 +0200 Subject: [PATCH] new approch on decades modelling --- lib/max_functions.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/max_functions.c b/lib/max_functions.c index 6eecb6a..47fb3d4 100644 --- a/lib/max_functions.c +++ b/lib/max_functions.c @@ -7,14 +7,22 @@ void set_output_voltage(double setpoint_voltage, ESeries E_resistors) { double R_high_resistance = 0.0; double R_low_resistance = 0.0; - int R_high_decade = 4; - int R_low_decade = 0; + //start at 10k for low resistor and at 1R for high resistor + int R_high_decade = 0; + int R_low_decade = 4; + // voltage computed from resistor configuration used to compare new result to previous optimum double output_voltage = 0.0; + // set the max array index for given e series ESeriesMaxValue max_value = get_E_MAX(E_resistors); - for (int e_value = 0; R_low_resistance <= 1E+6 * E_values[E_resistors][0]; e_value++) { + /* + * start at minimum given Rlow from datasheet and select optimal Rhigh for given Rlow and Vout. + * do this for all possible Rlows and choose the optimal combination + * (minimize |setpoint_voltage - output_voltage|) + */ + for () { } }