Skip to content

Commit

Permalink
Update platformio.ini
Browse files Browse the repository at this point in the history
Add requested VECT_TABLE_OFFSET for all .ini file.
Update all platformio.ini;
Check compile and working module for master and slave with stima_v4#stable.
Fix bug MPPT working signal (critical_power) without battery.
  • Loading branch information
digitecomg committed Nov 6, 2023
1 parent bc406c3 commit 9f21675
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 13 deletions.
1 change: 1 addition & 0 deletions platformio/stima_v4/master/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ board = stimav4_master
board_build.ldscript = $PROJECT_DIR/user_custom/bootloader.ld
; debug_build_flags = -O0 -ggdb3 -g3
build_flags =
-DVECT_TAB_OFFSET=0xB000
-DPIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-DUSB_PRODUCT_STRING="\"Stima V4 Master\""
-DINIT_PARAMETER=false
Expand Down
2 changes: 1 addition & 1 deletion platformio/stima_v4/master/src/tasks/can_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2300,7 +2300,7 @@ void CanTask::Run() {
param.system_status->flags.power_critical = retPwrData->is_power_critical;
// Remove critical power flag if error measure occurs: prevent error sending data (disable modem when critical power)
// This command don't remove flags sending to RMAP Server
if((retPwrData->MPP.battery_charge.val.value == 0) || (retPwrData->MPP.battery_charge.val.value > rmap_tableb_B25192_1_0_MAX)) {
if((retPwrData->MPP.battery_charge.val.value == 0) || (retPwrData->MPP.battery_charge.val.value > rmap_tableb_B25192_1_0_MAX)) {
param.system_status->flags.power_critical = false;
}
param.system_status->data_slave[queueId].bit8StateFlag = bit8Flag;
Expand Down
7 changes: 7 additions & 0 deletions platformio/stima_v4/slave-mppt/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define POWER_BATTERY_CURRENT_MULT (1000)
#define POWER_INPUT_CURRENT_MULT (1000)

#define BATTERY_CHARGE_MIN_FULL (70)
#define BATTERY_CHARGE_MIN_WARNING (40)
#define BATTERY_CHARGE_MIN_CRITICAL (20)
#define BATTERY_CHARGE_MIN_POWERDOWN (4)
#define INPUT_VOLTAGE_MIN_FULL (15.5 * POWER_BATTERY_VOLTAGE_MULT)
#define INPUT_VOLTAGE_MIN_POWERDOWN (11.5 * POWER_BATTERY_VOLTAGE_MULT)

#endif
5 changes: 4 additions & 1 deletion platformio/stima_v4/slave-mppt/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ lib_ldf_mode = deep
lib_archive = no
monitor_speed = 115200
board_build.variants_dir = ../../custom_variants
platform_packages =
framework-arduinoststm32 @ https://github.com/r-map/Arduino_Core_STM32_stimav4.git#stimav4_stable

[env:stimav4_slave]
board = stimav4_slave
board_build.ldscript = $PROJECT_DIR/user_custom/bootloader.ld
build_flags =
-DVECT_TAB_OFFSET=0xB000
-DINIT_PARAMETER=false
-DFIXED_CONFIGURATION=false
-DUSE_DEBUG=true
-DUSE_DEBUG=false
-fexceptions
-fno-common
-Wall
Expand Down
7 changes: 2 additions & 5 deletions platformio/stima_v4/slave-mppt/src/drivers/mppt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ float Mppt::get_I_IN(bool *is_ok) {
/// @return Power battery istant value
float Mppt::get_P_CHG(bool *is_ok) {
uint16_t data;
float pChg;
float pChg = 0.0;
float vBatt = get_V_BAT(is_ok);
if(*is_ok) {
if(vBatt>13.45) pChg = 100.0;
Expand All @@ -188,13 +188,10 @@ float Mppt::get_P_CHG(bool *is_ok) {
else if(vBatt>11.50) { pChg = 14.54347826 + ((vBatt - 11.50) * 11.82241949); }
else if(vBatt>11.15) { pChg = 9.713518356 + ((vBatt - 11.15) * 16.09986635); }
else if(vBatt>10.85) { pChg = 4.838709677 + ((vBatt - 10.85) * 13.9280248); }
else pChg = 0.0;
return pChg;
}
else return 0;
return pChg;
}


// ****************************************************************************************
// ******************************* PRIVATE FUNCTION ***************************************
// ****************************************************************************************
Expand Down
19 changes: 14 additions & 5 deletions platformio/stima_v4/slave-mppt/src/tasks/mppt_sensor_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void MpptSensorTask::Run() {
bool is_power_full = false;
bool is_power_critical = true;
bool is_power_warning = true;
bool is_power_down = true;
bool is_measure_done = true;
bool is_error_measure = false;

Expand Down Expand Up @@ -159,6 +160,7 @@ void MpptSensorTask::Run() {
is_power_full = false;
is_power_critical = true;
is_power_warning = true;
is_power_down = true;
is_measure_done = true;
is_error_measure = false;

Expand All @@ -167,9 +169,10 @@ void MpptSensorTask::Run() {
is_error_measure |= !is_measure_done;
// Power % > 70% (Full OK)
// Power % > 30% (No Critical)
if(edata.value > 70) is_power_full = true;
if(edata.value > 40) is_power_warning = false;
if(edata.value > 20) is_power_critical = false;
if(edata.value > BATTERY_CHARGE_MIN_FULL) is_power_full = true;
if(edata.value > BATTERY_CHARGE_MIN_WARNING) is_power_warning = false;
if(edata.value > BATTERY_CHARGE_MIN_CRITICAL) is_power_critical = false;
if(edata.value > BATTERY_CHARGE_MIN_POWERDOWN) is_power_down = false;
edata.index = POWER_BATTERY_CHARGE_INDEX;
param.elaborateDataQueue->Enqueue(&edata, Ticks::MsToTicks(WAIT_QUEUE_REQUEST_PUSHDATA_MS));

Expand All @@ -180,8 +183,14 @@ void MpptSensorTask::Run() {

edata.value = param.mpptIC->get_V_IN(&is_measure_done) * POWER_INPUT_VOLTAGE_MULT;
is_error_measure |= !is_measure_done;
// VIn > 15.5 V (Full OK)
if(edata.value > 155) {
// VIn > INPUT_VOLTAGE_MIN_FULL (Full OK)
if(edata.value > INPUT_VOLTAGE_MIN_FULL) {
is_power_full = true;
is_power_warning = false;
is_power_critical = false;
}
// VIn Without VBAT (Full OK). Powered from external alim.
if((edata.value > INPUT_VOLTAGE_MIN_POWERDOWN) && (is_power_down)) {
is_power_full = true;
is_power_warning = false;
is_power_critical = false;
Expand Down
3 changes: 3 additions & 0 deletions platformio/stima_v4/slave-radiation/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ lib_ldf_mode = deep
lib_archive = no
monitor_speed = 115200
board_build.variants_dir = ../../custom_variants
platform_packages =
framework-arduinoststm32 @ https://github.com/r-map/Arduino_Core_STM32_stimav4.git#stimav4_stable

[env:stimav4_slave]
board = stimav4_slave
board_build.ldscript = $PROJECT_DIR/user_custom/bootloader.ld
build_flags =
-DVECT_TAB_OFFSET=0xB000
-DINIT_PARAMETER=false
-DFIXED_CONFIGURATION=false
-DUSE_DEBUG=false
Expand Down
5 changes: 4 additions & 1 deletion platformio/stima_v4/slave-rain/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ lib_ldf_mode = deep
lib_archive = no
monitor_speed = 115200
board_build.variants_dir = ../../custom_variants
platform_packages =
framework-arduinoststm32 @ https://github.com/r-map/Arduino_Core_STM32_stimav4.git#stimav4_stable

[env:stimav4_slave]
board = stimav4_slave
board_build.ldscript = $PROJECT_DIR/user_custom/bootloader.ld
build_flags =
-DVECT_TAB_OFFSET=0xB000
-DINIT_PARAMETER=false
-DFIXED_CONFIGURATION=false
-DUSE_DEBUG=true
-DUSE_DEBUG=false
-fexceptions
-fno-common
-Wall
Expand Down
3 changes: 3 additions & 0 deletions platformio/stima_v4/slave-th/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ lib_ldf_mode = deep
lib_archive = no
monitor_speed = 115200
board_build.variants_dir = ../../custom_variants
platform_packages =
framework-arduinoststm32 @ https://github.com/r-map/Arduino_Core_STM32_stimav4.git#stimav4_stable

[env:stimav4_slave]
board = stimav4_slave
board_build.ldscript = $PROJECT_DIR/user_custom/bootloader.ld
build_flags =
-DVECT_TAB_OFFSET=0xB000
-DINIT_PARAMETER=false
-DFIXED_CONFIGURATION=false
-DUSE_DEBUG=false
Expand Down
3 changes: 3 additions & 0 deletions platformio/stima_v4/slave-vwc/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ lib_ldf_mode = deep
lib_archive = no
monitor_speed = 115200
board_build.variants_dir = ../../custom_variants
platform_packages =
framework-arduinoststm32 @ https://github.com/r-map/Arduino_Core_STM32_stimav4.git#stimav4_stable

[env:stimav4_slave]
board = stimav4_slave
board_build.ldscript = $PROJECT_DIR/user_custom/bootloader.ld
build_flags =
-DVECT_TAB_OFFSET=0xB000
-DINIT_PARAMETER=false
-DFIXED_CONFIGURATION=false
-DUSE_DEBUG=false
Expand Down
3 changes: 3 additions & 0 deletions platformio/stima_v4/slave-wind/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ lib_ldf_mode = deep
lib_archive = no
monitor_speed = 115200
board_build.variants_dir = ../../custom_variants
platform_packages =
framework-arduinoststm32 @ https://github.com/r-map/Arduino_Core_STM32_stimav4.git#stimav4_stable

[env:stimav4_slave]
board = stimav4_slave
board_build.ldscript = $PROJECT_DIR/user_custom/bootloader.ld
build_flags =
-DVECT_TAB_OFFSET=0xB000
-DINIT_PARAMETER=false
-DFIXED_CONFIGURATION=false
-DUSE_DEBUG=false
Expand Down

0 comments on commit 9f21675

Please sign in to comment.