-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BMS Refactor + State of Charge #292
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d30bd26
initial algo
Akashem06 e482c71
perdict ocv func
Akashem06 b173204
state of charge tests
Akashem06 8747b49
STATE OF CHARGE WITH LUT
Akashem06 f564db7
PASS ALL TESTS. NEEDS INTEGRATION TESTING ON HARDWARE
Akashem06 1e15190
REFACTOR DONE
Akashem06 e063e68
formatting
Akashem06 a53004a
formatting
Akashem06 b7107c5
applied changes
Akashem06 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,8 @@ | |
"master", | ||
"ms-drivers" | ||
], | ||
"can": true | ||
"can": true, | ||
"mocks": { | ||
"test_state_of_charge": ["xTaskGetTickCount"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
#pragma once | ||
|
||
#include "adc.h" | ||
#include "bms.h" | ||
#include "bms_carrier_getters.h" | ||
#include "bms_carrier_setters.h" | ||
#include "gpio.h" | ||
|
||
#define R2_OHMS 10000 | ||
#define R1_OHMS 47000 | ||
|
||
typedef struct AuxStorage { | ||
uint16_t aux_battery_voltage; | ||
} AuxStorage; | ||
|
||
StatusCode aux_sense_init(AuxStorage *aux_storage); | ||
StatusCode aux_sense_init(BmsStorage *storage); | ||
|
||
StatusCode aux_sense_run(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
|
||
#include "bms.h" | ||
#include "bms_carrier_getters.h" | ||
#include "bms_carrier_setters.h" | ||
#include "status.h" | ||
|
||
#define CELL_INTERNAL_RESISTANCE_mOHMS 22 | ||
#define PACK_INTERNAL_RESISTANCE_mOHMS \ | ||
(CELL_INTERNAL_RESISTANCE_mOHMS * 9 * 4) / 8 // 9 modules, each module is 8P4S | ||
#define VOLTS_TO_mV 1000 | ||
#define LUT_SIZE 41 | ||
|
||
typedef struct { | ||
uint32_t last_time; | ||
float i_soc; | ||
float v_soc; | ||
float averaged_soc; | ||
|
||
int32_t last_current; | ||
} StateOfChargeStorage; | ||
|
||
void coulomb_counting_soc(); | ||
float perdict_ocv_voltage(); | ||
void ocv_voltage_soc(); | ||
|
||
StatusCode state_of_charge_init(BmsStorage *bms_storage); | ||
|
||
StatusCode update_state_of_chrage(); | ||
|
||
// TEST FUNCTIONS | ||
void ramp_voltage_weight(); | ||
|
||
void set_last_time(uint32_t last_time); | ||
void set_i_soc(float i_soc); | ||
void set_v_soc(float v_soc); | ||
void set_averaged_soc(float averaged_soc); | ||
void set_last_current(int32_t last_current); | ||
|
||
uint32_t get_last_time(void); | ||
float get_i_soc(void); | ||
float get_v_soc(void); | ||
float get_averaged_soc(void); | ||
int32_t get_last_current(void); | ||
float get_voltage_weight(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
cell_sense_run()
also be prv? Also again maybe don't inline this. I remember the justification being Jarvis saying it'll save us some memory but did this fix anything? It's probably best to leave it to the compiler.