-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from Northeastern-Electric-Racing/main
merge
- Loading branch information
Showing
13 changed files
with
1,177 additions
and
345 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "Drivers/Embedded-Base"] | ||
path = Drivers/Embedded-Base | ||
url = https://github.com/Northeastern-Electric-Racing/Embedded-Base.git |
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,197 @@ | ||
#ifndef ANALYZER_H | ||
#define ANALYZER_H | ||
|
||
//#include <nerduino.h> Replace | ||
#include "datastructs.h" | ||
#include "segment.h" | ||
|
||
//We want to make sure we aren't doing useless analysis on the same set of data since we are backfilling segment data | ||
#define ANALYSIS_INTERVAL VOLTAGE_WAIT_TIME | ||
|
||
|
||
|
||
//#define MAX_SIZE_OF_HIST_QUEUE 300000U //bytes | ||
|
||
/** | ||
* @brief Resizable linked list queue for performing historical analysis | ||
* | ||
*/ | ||
class Analyzer | ||
{ | ||
private: | ||
|
||
Timer analysisTimer; | ||
Timer ocvTimer; | ||
|
||
bool is_first_reading_ = true; | ||
|
||
/** | ||
* @brief Mapping Cell temperature to the cell resistance based on the | ||
* nominal cell resistance curve profile of the Samsung 186500 INR in the | ||
* Orion BMS software utility app | ||
* | ||
* @note Units are in mOhms and indicies are in (degrees C)/5, stops at 65C | ||
* @note Resistance should be *interpolated* from these values (i.e. if we are | ||
* at 27C, we should take the resistance that is halfway between 25C and 30C) | ||
*/ | ||
const float TEMP_TO_CELL_RES[14] = | ||
{ | ||
5.52, 4.84, 4.27, 3.68, 3.16, 2.74, 2.4, | ||
2.12, 1.98, 1.92, 1.90, 1.90, 1.90, 1.90 | ||
}; | ||
|
||
/** | ||
* @brief Mapping Cell temperatue to the discharge current limit based on the | ||
* temperature discharge limit curve profile of the Samsung 186500 INR | ||
* in the Orion BMS software utility app | ||
* | ||
* @note Units are in Amps and indicies are in (degrees C)/5, stops at 65C | ||
* @note Limit should be *interpolated* from these values (i.e. if we are | ||
* at 27C, we should take the limit that is halfway between 25C and 30C) | ||
* | ||
*/ | ||
const uint8_t TEMP_TO_DCL[14] = | ||
{ | ||
110, 125, 140, 140, 140, 140, | ||
140, 140, 140, 100, 60, 20, 0, 0 | ||
}; | ||
|
||
/** | ||
* @brief Mapping Cell temperatue to the charge current limit based on the | ||
* temperature charge limit curve profile of the Samsung 186500 INR | ||
* in the Orion BMS software utility app | ||
* | ||
* @note Units are in Amps and indicies are in (degrees C)/5, stops at 65C | ||
* @note Limit should be *interpolated* from these values (i.e. if we are | ||
* at 27C, we should take the limit that is halfway between 25C and 30C) | ||
* | ||
*/ | ||
const uint8_t TEMP_TO_CCL[14] = | ||
{ | ||
0, 25, 25, 25, 25, 25, 25, 25, | ||
20, 15, 10, 5, 1, 1 | ||
}; | ||
|
||
/** | ||
* @brief Lookup table for State of Charge | ||
* | ||
* @note each index covers 0.1V increase (voltage range is 2.9V - 4.2V, deltaV = 1.3V, currently 13 data points) | ||
* @note values are unitless percentages that represent % charge | ||
* | ||
*/ | ||
const uint8_t STATE_OF_CHARGE_CURVE[18] = | ||
{ | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 15, 24, 56, 74, 85, 95, 98, 100 | ||
}; | ||
|
||
/** | ||
* @brief Mapping the Relevant Thermistors for each cell based on cell # | ||
* | ||
*/ | ||
const std::vector<int> RelevantThermMap[NUM_CELLS_PER_CHIP] = | ||
{ | ||
{17,18}, | ||
{17,18}, | ||
{17,18,19,20}, | ||
{19,20}, | ||
{19,20,21,22,23}, | ||
{21,22,23,24,25}, | ||
{24,25}, | ||
{24,25,26,27}, | ||
{26,27} | ||
}; | ||
|
||
/** | ||
* @brief Mapping desired fan speed PWM to the cell temperature | ||
* | ||
* @note Units are in PWM out of 255 and indicies are in (degrees C)/5, stops at 65C | ||
* @note Limit should be *interpolated* from these values (i.e. if we are | ||
* at 27C, we should take the limit that is halfway between 25C and 30C) | ||
* | ||
*/ | ||
const uint8_t FAN_CURVE[16] = | ||
{ | ||
0, 0, 0, 0, 0, 0, 0, 0, 32, 64, | ||
128, 255, 255, 255, 255, 255 | ||
}; | ||
|
||
/** | ||
* @brief Selecting thermistors to ignore | ||
* | ||
* @note True / 1 will disable the thermistor | ||
* | ||
*/ | ||
const uint8_t THERM_DISABLE[8][11] = | ||
{ | ||
{0,0,0,0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0,0,0,0}, | ||
{0,0,0,0,0,0,0,0,0,0,0} | ||
}; | ||
|
||
void calcPackVoltageStats(); | ||
|
||
void calcCellResistances(); | ||
|
||
void calcCellTemps(); | ||
|
||
void calcPackTemps(); | ||
|
||
void calcDCL(); | ||
|
||
void calcContDCL(); | ||
|
||
void calcCCL(); | ||
|
||
void calcContCCL(); | ||
|
||
void printData(); | ||
|
||
void calcOpenCellVoltage(); | ||
|
||
void disableTherms(); | ||
|
||
void calcStateOfCharge(); | ||
|
||
void highCurrThermCheck(); | ||
|
||
void diffCurrThermCheck(); | ||
|
||
|
||
|
||
public: | ||
Analyzer(); | ||
|
||
~Analyzer(); | ||
|
||
/** | ||
* @brief Pushes in a new data point if we have waited long enough | ||
* | ||
* @param data | ||
*/ | ||
void push(AccumulatorData_t *data); | ||
|
||
/** | ||
* @brief Calculates the PWM required to drive the fans at the current moment in time | ||
* | ||
* @param bmsdata | ||
* @return uint8_t | ||
*/ | ||
uint8_t calcFanPWM(); | ||
|
||
/** | ||
* @brief Pointer to the address of the most recent data point | ||
* | ||
*/ | ||
AccumulatorData_t *bmsdata; | ||
|
||
AccumulatorData_t *prevbmsdata; | ||
}; | ||
|
||
extern Analyzer analyzer; | ||
|
||
#endif |
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,56 @@ | ||
#ifndef BMS_CONFIG_H | ||
#define BMS_CONFIG_H | ||
|
||
// Hardware definition | ||
#define NUM_SEGMENTS 4 | ||
#define NUM_CHIPS NUM_SEGMENTS*2 | ||
#define NUM_CELLS_PER_CHIP 9 | ||
#define NUM_THERMS_PER_CHIP 32 | ||
|
||
// Firmware limits | ||
#define MAX_TEMP 65 //degrees C | ||
#define MIN_TEMP -15 // deg C | ||
#define MAX_VOLT_MEAS 65535 | ||
#define MIN_VOLT_MEAS 0 | ||
|
||
// Boosting Parameters | ||
#define BOOST_TIME 5 // seconds | ||
#define BOOST_RECHARGE_TIME 30 // seconds | ||
#define CONTDCL_MULTIPLIER 3 | ||
|
||
//cell limits | ||
#define MIN_VOLT 2.5 | ||
#define MAX_VOLT 4.2 | ||
#define MAX_CHARGE_VOLT 4.21 | ||
#define MAX_DELTA_V 0.015 | ||
#define BAL_MIN_V 4.00 | ||
#define MAX_CELL_TEMP 55 | ||
#define MAX_CELL_CURR 700 // Amps per BMS cell | ||
#define MAX_CELL_TEMP_BAL 45 | ||
#define MAX_CHG_CELL_CURR 20 | ||
|
||
// Algorithm settings | ||
#define CHARGE_TIMEOUT 300000 // 5 minutes, may need adjustment | ||
#define VOLT_SAG_MARGIN 0.45 // Volts above the minimum cell voltage we would like to aim for | ||
#define OCV_CURR_THRESH 1.5 | ||
|
||
#define OCV_AVG 3 | ||
|
||
#define MAX_STANDARD_DEV 3 // only used for standard deviation for therms calc | ||
|
||
//Fault times | ||
#define OVER_CURR_TIME 1500 //todo adjust these based on testing and/or counter values | ||
#define PRE_OVER_CURR_TIME 1000 | ||
#define OVER_CHG_CURR_TIME 1000 | ||
#define UNDER_VOLT_TIME 15000 | ||
#define PRE_UNDER_VOLT_TIME 12000 | ||
#define OVER_VOLT_TIME 15000 | ||
#define LOW_CELL_TIME 15000 | ||
#define HIGH_TEMP_TIME 60000 | ||
#define CURR_ERR_MARG 50 // in A * 10 | ||
|
||
#define DCDC_CURRENT_DRAW 2 // in A, this is generous | ||
|
||
#define CAN_MESSAGE_WAIT 10 | ||
|
||
#endif |
Oops, something went wrong.