Skip to content

Commit

Permalink
feat(current): change current minimum threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
Tonidotpy committed Mar 6, 2024
1 parent 2f6b399 commit 564f63d
Show file tree
Hide file tree
Showing 4 changed files with 1,993 additions and 1,990 deletions.
5 changes: 0 additions & 5 deletions fenice_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ static const uint8_t TEMP_SENSOR_ADDRESS_CODING[TEMP_SENSORS_PER_STRIP] = {000,
*/
#define PACK_TEMP_COUNT (TEMP_SENSOR_COUNT * LTC6813_COUNT)

/**
* Max current. (A)
*/
#define PACK_MAX_CURRENT 180.0f


/**
* Cell's limit voltages (mV * 10)
Expand Down
4 changes: 4 additions & 0 deletions mainboard/Inc/pack/current.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
/** @brief Voltage values below this threshold are consider as the sensor is disconnected */
#define CURRENT_SENSOR_DISCONNECTED_THRESHOLD 0.25 // V

/** @brief Current limits in A */
#define CURRENT_MIN_THRESHOLD -24.f
#define CURRENT_MAX_THRESHOLD 180.f

enum CURRENT_SENSORS {
CURRENT_SENSOR_50 = 0,
CURRENT_SENSOR_300,
Expand Down
8 changes: 5 additions & 3 deletions mainboard/Src/pack/current.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ uint32_t current_read(float shunt_adc_val) {
current[CURRENT_SENSOR_SHUNT] = _current_convert_shunt(shunt_adc_val);

// Check for over-currents
error_toggle_check(fabsf(current_get_current()) > PACK_MAX_CURRENT, ERROR_OVER_CURRENT, 0);
error_toggle_check(current_get_current() < CURRENT_MIN_THRESHOLD, ERROR_OVER_CURRENT, 0);
error_toggle_check(current_get_current() > CURRENT_MAX_THRESHOLD, ERROR_OVER_CURRENT, 0);
return time;
}

Expand Down Expand Up @@ -109,8 +110,9 @@ current_t current_get_current_from_sensor(uint8_t sensor) {
}

void current_check_errors() {
current_t hall_300 = fabsf(current[CURRENT_SENSOR_300]);
error_toggle_check(hall_300 > PACK_MAX_CURRENT, ERROR_OVER_CURRENT, 0);
current_t hall_300 = current[CURRENT_SENSOR_300];
error_toggle_check(hall_300 < CURRENT_MIN_THRESHOLD, ERROR_OVER_CURRENT, 0);
error_toggle_check(hall_300 > CURRENT_MAX_THRESHOLD, ERROR_OVER_CURRENT, 0);

// Hall effect sensor disconnected
error_toggle_check(volt_300 < CURRENT_SENSOR_DISCONNECTED_THRESHOLD, ERROR_CONNECTOR_DISCONNECTED, 1);
Expand Down

0 comments on commit 564f63d

Please sign in to comment.