From 75a59d510e59bacdc53c68a7539af03e9ff775c7 Mon Sep 17 00:00:00 2001 From: Luke Dempsey Date: Sun, 12 Jul 2020 21:42:07 +0100 Subject: [PATCH] DPS5020 UI support (currents above 9.99A) (#201) * 15.00A user interface fix for DPS5015 * Added support for DPS5020 * Add UI support for above 9.99A on DPS5020 Co-authored-by: polihedron --- README.md | 4 ++-- opendps/dps-model.h | 39 +++++++++++++++++++++++++++++++++++---- opendps/func_cc.c | 4 ++-- opendps/func_cl.c | 4 ++-- opendps/func_cv.c | 4 ++-- opendps/hw.c | 2 +- opendps/pwrctl.c | 4 ++-- 7 files changed, 46 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 2205d271..91ce1b53 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ #### Give your DPS5005 the upgrade it deserves -OpenDPS is a FOSS firmware replacement for the DPS5005 (and DPS3003, DPS3005, DPS5015, DP50V5A and possibly others) that has the same functionality, has a less cluttered user interface and is remote controllable via wifi (ESP8266) or via a serial port. +OpenDPS is a FOSS firmware replacement for the DPS5005 (and DPS3003, DPS3005, DPS5015, DP50V5A, DPS5020 and possibly others) that has the same functionality, has a less cluttered user interface and is remote controllable via wifi (ESP8266) or via a serial port.

A DPS5005 with wifi @@ -176,7 +176,7 @@ The project consists of four parts: ### What about other DPS:es? -OpenDPS has been verified to work with other models in the DPSx0xx series, such as the DPS3003, DPS3005 and DPS5015. The maxium settable output current can be defined when building opendps, see the makefile. Plese note that the hardware design might change at any time without any notice (I am not affiliated with its designer). This will render OpenDPS unusable until fixed. +OpenDPS has been verified to work with other models in the DPSx0xx series, such as the DPS3003, DPS3005, DPS5015 and DPS5020. The maxium settable output current can be defined when building opendps, see the makefile. Plese note that the hardware design might change at any time without any notice (I am not affiliated with its designer). This will render OpenDPS unusable until fixed. --- Licensed under the MIT license. Have fun! diff --git a/opendps/dps-model.h b/opendps/dps-model.h index e4e33ffc..b3475367 100644 --- a/opendps/dps-model.h +++ b/opendps/dps-model.h @@ -42,10 +42,30 @@ * */ /** Contribution by @cleverfox */ -#if defined(DPS5015) +#if defined(DPS5020) #ifndef CONFIG_DPS_MAX_CURRENT - #define CONFIG_DPS_MAX_CURRENT (15000) // Please note that the UI currently does not handle settings larger that 9.99A + #define CONFIG_DPS_MAX_CURRENT (20000) // Please note that the UI currently does not handle settings larger that 9.99A #endif + #define CURRENT_DIGITS 2 + #define CURRENT_DECIMALS 2 + #define ADC_CHA_IOUT_GOLDEN_VALUE (59) + #define A_ADC_K (float)6.75449f + #define A_ADC_C (float)-358.73f + #define A_DAC_K (float)0.16587f + #define A_DAC_C (float)243.793f + #define V_ADC_K (float)13.2930f + #define V_ADC_C (float)-179.91f + #define V_DAC_K (float)0.07528f + #define V_DAC_C (float)6.68949f + + #define VIN_ADC_K (float)16.956f + #define VIN_ADC_C (float)6.6895f +#elif defined(DPS5015) + #ifndef CONFIG_DPS_MAX_CURRENT + #define CONFIG_DPS_MAX_CURRENT (15000) + #endif + #define CURRENT_DIGITS 2 + #define CURRENT_DECIMALS 2 #define ADC_CHA_IOUT_GOLDEN_VALUE (59) #define A_ADC_K (float)6.8403f #define A_ADC_C (float)-394.06f @@ -59,6 +79,8 @@ #ifndef CONFIG_DPS_MAX_CURRENT #define CONFIG_DPS_MAX_CURRENT (5000) #endif + #define CURRENT_DIGITS 1 + #define CURRENT_DECIMALS 3 #define ADC_CHA_IOUT_GOLDEN_VALUE (0x45) #define A_ADC_K (float)1.713f #define A_ADC_C (float)-118.51f @@ -72,6 +94,8 @@ #ifndef CONFIG_DPS_MAX_CURRENT #define CONFIG_DPS_MAX_CURRENT (5000) #endif + #define CURRENT_DIGITS 1 + #define CURRENT_DECIMALS 3 #define ADC_CHA_IOUT_GOLDEN_VALUE (0x45) #define A_DAC_K (float)0.6402f #define A_DAC_C (float)299.5518f @@ -85,6 +109,8 @@ #ifndef CONFIG_DPS_MAX_CURRENT #define CONFIG_DPS_MAX_CURRENT (5000) #endif + #define CURRENT_DIGITS 1 + #define CURRENT_DECIMALS 3 #define ADC_CHA_IOUT_GOLDEN_VALUE (0x00) #define A_ADC_K (float)1.751f #define A_ADC_C (float)-1.101f @@ -99,8 +125,13 @@ #endif // MODEL /** These are constant across all models currently but may require tuning for each model */ -#define VIN_ADC_K (float)16.746f -#define VIN_ADC_C (float)64.112f +#ifndef VIN_ADC_K + #define VIN_ADC_K (float)16.746f +#endif + +#ifndef VIN_ADC_C + #define VIN_ADC_C (float)64.112f +#endif #define VIN_VOUT_RATIO (float)1.1f /** (Vin / VIN_VOUT_RATIO) = Max Vout */ diff --git a/opendps/func_cc.c b/opendps/func_cc.c index 6febd983..218d12f6 100644 --- a/opendps/func_cc.c +++ b/opendps/func_cc.c @@ -104,8 +104,8 @@ ui_number_t cc_current = { .min = 0, .max = CONFIG_DPS_MAX_CURRENT, .si_prefix = si_milli, - .num_digits = 1, - .num_decimals = 3, + .num_digits = CURRENT_DIGITS, + .num_decimals = CURRENT_DECIMALS, .unit = unit_ampere, .changed = ¤t_changed, }; diff --git a/opendps/func_cl.c b/opendps/func_cl.c index c27c2431..d3e54c95 100644 --- a/opendps/func_cl.c +++ b/opendps/func_cl.c @@ -112,8 +112,8 @@ ui_number_t cl_current = { .min = 0, .max = CONFIG_DPS_MAX_CURRENT, .si_prefix = si_milli, - .num_digits = 1, - .num_decimals = 3, + .num_digits = CURRENT_DIGITS, + .num_decimals = CURRENT_DECIMALS, .unit = unit_ampere, .changed = ¤t_changed, }; diff --git a/opendps/func_cv.c b/opendps/func_cv.c index 4459528e..ed70077e 100644 --- a/opendps/func_cv.c +++ b/opendps/func_cv.c @@ -102,8 +102,8 @@ ui_number_t cv_current = { .min = 0, .max = CONFIG_DPS_MAX_CURRENT, .si_prefix = si_milli, - .num_digits = 1, - .num_decimals = 3, + .num_digits = CURRENT_DIGITS, + .num_decimals = CURRENT_DECIMALS, .unit = unit_ampere, .changed = ¤t_changed, }; diff --git a/opendps/hw.c b/opendps/hw.c index 6724d524..0b91ac70 100644 --- a/opendps/hw.c +++ b/opendps/hw.c @@ -645,7 +645,7 @@ static void gpio_init(void) // PC13 I 0 Flt // gpio_set_mode(GPIOC, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO13); -#ifdef DPS5015 +#if defined(DPS5015) || defined(DPS5020) gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO13); #endif diff --git a/opendps/pwrctl.c b/opendps/pwrctl.c index cf51ca1a..dc4be44b 100644 --- a/opendps/pwrctl.c +++ b/opendps/pwrctl.c @@ -204,7 +204,7 @@ void pwrctl_enable_vout(bool enable) if (v_out_enabled) { (void) pwrctl_set_vout(v_out); (void) pwrctl_set_iout(i_out); -#ifdef DPS5015 +#if defined(DPS5015) || defined(DPS5020) //gpio_clear(GPIOA, GPIO9); // this is power control on '5015 gpio_set(GPIOB, GPIO11); // B11 is fan control on '5015 gpio_clear(GPIOC, GPIO13); // C13 is power control on '5015 @@ -212,7 +212,7 @@ void pwrctl_enable_vout(bool enable) gpio_clear(GPIOB, GPIO11); // B11 is power control on '5005 #endif } else { -#ifdef DPS5015 +#if defined(DPS5015) || defined(DPS5020) //gpio_set(GPIOA, GPIO9); // gpio_set(GPIOB, GPIO11); gpio_clear(GPIOB, GPIO11); // B11 is fan control on '5015 gpio_set(GPIOC, GPIO13); // C13 is power control on '5015