foxBMS - Unit Tests  1.3.0
The foxBMS Unit Tests API Documentation
redundancy.h File Reference

Header fileS for handling redundancy between redundant cell voltage and cell temperature measurements. More...

#include "general.h"
#include "database.h"
Include dependency graph for redundancy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  MRC_STATE_s
 

Macros

#define MRC_CURRENT_MEASUREMENT_PERIOD_TIMEOUT_ms   (250u)
 
#define MRC_AFE_MEASUREMENT_PERIOD_TIMEOUT_ms   (250u)
 
#define MRC_CURRENT_SENSOR_MEASUREMENT_TIMEOUT_ms   (300u)
 
#define MRC_ALLOWED_NUMBER_OF_INVALID_CELL_VOLTAGES   (5u)
 

Functions

STD_RETURN_TYPE_e MRC_Initialize (void)
 Function to initalize redundancy module. More...
 
STD_RETURN_TYPE_e MRC_ValidateAfeMeasurement (void)
 Function to validate the measurement between redundant measurement values for cell voltage and cell temperature. More...
 
STD_RETURN_TYPE_e MRC_ValidatePackMeasurement (void)
 Function to validate the measurements of pack values (string values, pack values) More...
 
bool TEST_MRC_MeasurementUpdatedAtLeastOnce (uint32_t timestamp, uint32_t previousTimestamp)
 
STD_RETURN_TYPE_e TEST_MRC_MeasurementUpdatedRecently (uint32_t timestamp, uint32_t previousTimestamp, uint32_t timeInterval)
 
bool TEST_MRC_ValidateCellVoltageMeasurement (DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageBase, DATA_BLOCK_CELL_VOLTAGE_s *pCellVoltageRedundancy0)
 
bool TEST_MRC_ValidateCellTemperatureMeasurement (DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperatureBase, DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperatureRedundancy0)
 
void TEST_MRC_ValidateCurrentMeasurement (DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor)
 
void TEST_MRC_ValidatePowerMeasurement (DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor)
 
void TEST_MRC_ValidateStringVoltageMeasurement (DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor, DATA_BLOCK_CELL_VOLTAGE_s *pTableCellVoltage)
 
void TEST_MRC_ValidateBatteryVoltageMeasurement (void)
 
void TEST_MRC_ValidateHighVoltageMeasurement (DATA_BLOCK_CURRENT_SENSOR_s *pTableCurrentSensor)
 
STD_RETURN_TYPE_e TEST_MRC_CalculateCellVoltageMinMaxAverage (DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages, DATA_BLOCK_MIN_MAX_s *pMinMaxAverageValues)
 
STD_RETURN_TYPE_e TEST_MRC_CalculateCellTemperatureMinMaxAverage (DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperatures, DATA_BLOCK_MIN_MAX_s *pMinMaxAverageValues)
 
STD_RETURN_TYPE_e TEST_MRC_ValidateCellVoltage (DATA_BLOCK_CELL_VOLTAGE_s *pCellvoltageBase, DATA_BLOCK_CELL_VOLTAGE_s *pCellvoltageRedundancy0, DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages)
 
STD_RETURN_TYPE_e TEST_MRC_UpdateCellVoltageValidation (DATA_BLOCK_CELL_VOLTAGE_s *pCellvoltage, DATA_BLOCK_CELL_VOLTAGE_s *pValidatedVoltages)
 
STD_RETURN_TYPE_e TEST_MRC_ValidateCellTemperature (DATA_BLOCK_CELL_TEMPERATURE_s *pCelltemperatureBase, DATA_BLOCK_CELL_TEMPERATURE_s *pCelltemperatureRedundancy0, DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperatures)
 
STD_RETURN_TYPE_e TEST_MRC_UpdateCellTemperatureValidation (DATA_BLOCK_CELL_TEMPERATURE_s *pCellTemperature, DATA_BLOCK_CELL_TEMPERATURE_s *pValidatedTemperature)
 

Detailed Description

Header fileS for handling redundancy between redundant cell voltage and cell temperature measurements.

SPDX-License-Identifier: BSD-3-Clause

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:

  • ″This product uses parts of foxBMS®″
  • ″This product includes parts of foxBMS®″
  • ″This product is derived from foxBMS®″
Author
foxBMS Team
Date
2020-07-31 (date of creation)
Updated
2022-05-30 (date of last update)
Version
v1.3.0
Prefix
MRC

Definition in file redundancy.h.

Macro Definition Documentation

◆ MRC_AFE_MEASUREMENT_PERIOD_TIMEOUT_ms

#define MRC_AFE_MEASUREMENT_PERIOD_TIMEOUT_ms   (250u)

Maximum time between AFE measurements before the redundancy module raises an error because a measurement is not updated anymore.

The redundancy module will wait a maximum of this time for new values from the base AFE measurement and AFE redundant measurements. If no new values are updated from both measurement sources within this timeframe it will validate the measurement values it has up to this point if possible.

Definition at line 88 of file redundancy.h.

◆ MRC_ALLOWED_NUMBER_OF_INVALID_CELL_VOLTAGES

#define MRC_ALLOWED_NUMBER_OF_INVALID_CELL_VOLTAGES   (5u)

If both, the current sensor and the AFE measurement have no valid values we try to construct the string voltage by replacing invalid cell voltage measurements with the average cell voltage in this string. The result of this estimation will be flagged as invalid if more than the number of allowed invalid cell voltages are detected. The result will be markes as valid if less then this number of cells are detected as invalid.

Definition at line 111 of file redundancy.h.

◆ MRC_CURRENT_MEASUREMENT_PERIOD_TIMEOUT_ms

#define MRC_CURRENT_MEASUREMENT_PERIOD_TIMEOUT_ms   (250u)

Maximum time between measurements before the redundancy module raises an error because a measurement is not updated anymore.

The redundancy module will wait a maximum of this time for new current values. If no new values are updated within this timeframe it will invalidate the measurement values.

Definition at line 74 of file redundancy.h.

◆ MRC_CURRENT_SENSOR_MEASUREMENT_TIMEOUT_ms

#define MRC_CURRENT_SENSOR_MEASUREMENT_TIMEOUT_ms   (300u)

Maximum time between current sensor high voltage, current and power measurements before the redundancy module raises an error because a measurement is not updated anymore.

The redundancy module will wait a maximum of this time for new values from the current sensor. If no new values are updated within this timeframe it will validate the measurement values it has up to this point if possible.

Definition at line 101 of file redundancy.h.

Function Documentation

◆ MRC_Initialize()

STD_RETURN_TYPE_e MRC_Initialize ( void  )

Function to initalize redundancy module.

Returns
STD_OK if module has been initialized successfully, otherwise STD_NOT_OK

< bitmask if current is valid. 0->valid, 1->invalid

< bitmask if voltage is valid. 0->valid, 1->invalid

< bitmask if voltage is valid. 0->valid, 1->invalid

< bitmask if power is valid. 0->valid, 1->invalid

Definition at line 1087 of file redundancy.c.

◆ MRC_ValidateAfeMeasurement()

STD_RETURN_TYPE_e MRC_ValidateAfeMeasurement ( void  )

Function to validate the measurement between redundant measurement values for cell voltage and cell temperature.

Returns
STD_OK if measurement has been validated successfully, otherwise i.e. if no new values have been measured since the last call STD_NOT_OK

Definition at line 1112 of file redundancy.c.

Here is the call graph for this function:

◆ MRC_ValidatePackMeasurement()

STD_RETURN_TYPE_e MRC_ValidatePackMeasurement ( void  )

Function to validate the measurements of pack values (string values, pack values)

Returns
STD_OK if measurement has been validated successfully, otherwise i.e. if no new values have been measured since the last call STD_NOT_OK

Definition at line 1153 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_CalculateCellTemperatureMinMaxAverage()

STD_RETURN_TYPE_e TEST_MRC_CalculateCellTemperatureMinMaxAverage ( DATA_BLOCK_CELL_TEMPERATURE_s pValidatedTemperatures,
DATA_BLOCK_MIN_MAX_s pMinMaxAverageValues 
)

Definition at line 1215 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_CalculateCellVoltageMinMaxAverage()

STD_RETURN_TYPE_e TEST_MRC_CalculateCellVoltageMinMaxAverage ( DATA_BLOCK_CELL_VOLTAGE_s pValidatedVoltages,
DATA_BLOCK_MIN_MAX_s pMinMaxAverageValues 
)

Definition at line 1210 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_MeasurementUpdatedAtLeastOnce()

bool TEST_MRC_MeasurementUpdatedAtLeastOnce ( uint32_t  timestamp,
uint32_t  previousTimestamp 
)

Definition at line 1172 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_MeasurementUpdatedRecently()

STD_RETURN_TYPE_e TEST_MRC_MeasurementUpdatedRecently ( uint32_t  timestamp,
uint32_t  previousTimestamp,
uint32_t  timeInterval 
)

Definition at line 1175 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_UpdateCellTemperatureValidation()

STD_RETURN_TYPE_e TEST_MRC_UpdateCellTemperatureValidation ( DATA_BLOCK_CELL_TEMPERATURE_s pCellTemperature,
DATA_BLOCK_CELL_TEMPERATURE_s pValidatedTemperature 
)

Definition at line 1237 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_UpdateCellVoltageValidation()

STD_RETURN_TYPE_e TEST_MRC_UpdateCellVoltageValidation ( DATA_BLOCK_CELL_VOLTAGE_s pCellvoltage,
DATA_BLOCK_CELL_VOLTAGE_s pValidatedVoltages 
)

Definition at line 1226 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_ValidateBatteryVoltageMeasurement()

void TEST_MRC_ValidateBatteryVoltageMeasurement ( void  )

Definition at line 1204 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_ValidateCellTemperature()

STD_RETURN_TYPE_e TEST_MRC_ValidateCellTemperature ( DATA_BLOCK_CELL_TEMPERATURE_s pCelltemperatureBase,
DATA_BLOCK_CELL_TEMPERATURE_s pCelltemperatureRedundancy0,
DATA_BLOCK_CELL_TEMPERATURE_s pValidatedTemperatures 
)

Definition at line 1231 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_ValidateCellTemperatureMeasurement()

bool TEST_MRC_ValidateCellTemperatureMeasurement ( DATA_BLOCK_CELL_TEMPERATURE_s pCellTemperatureBase,
DATA_BLOCK_CELL_TEMPERATURE_s pCellTemperatureRedundancy0 
)

Definition at line 1186 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_ValidateCellVoltage()

STD_RETURN_TYPE_e TEST_MRC_ValidateCellVoltage ( DATA_BLOCK_CELL_VOLTAGE_s pCellvoltageBase,
DATA_BLOCK_CELL_VOLTAGE_s pCellvoltageRedundancy0,
DATA_BLOCK_CELL_VOLTAGE_s pValidatedVoltages 
)

Definition at line 1220 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_ValidateCellVoltageMeasurement()

bool TEST_MRC_ValidateCellVoltageMeasurement ( DATA_BLOCK_CELL_VOLTAGE_s pCellVoltageBase,
DATA_BLOCK_CELL_VOLTAGE_s pCellVoltageRedundancy0 
)

Definition at line 1181 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_ValidateCurrentMeasurement()

void TEST_MRC_ValidateCurrentMeasurement ( DATA_BLOCK_CURRENT_SENSOR_s pTableCurrentSensor)

Definition at line 1192 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_ValidateHighVoltageMeasurement()

void TEST_MRC_ValidateHighVoltageMeasurement ( DATA_BLOCK_CURRENT_SENSOR_s pTableCurrentSensor)

Definition at line 1207 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_ValidatePowerMeasurement()

void TEST_MRC_ValidatePowerMeasurement ( DATA_BLOCK_CURRENT_SENSOR_s pTableCurrentSensor)

Definition at line 1196 of file redundancy.c.

Here is the call graph for this function:

◆ TEST_MRC_ValidateStringVoltageMeasurement()

void TEST_MRC_ValidateStringVoltageMeasurement ( DATA_BLOCK_CURRENT_SENSOR_s pTableCurrentSensor,
DATA_BLOCK_CELL_VOLTAGE_s pTableCellVoltage 
)

Definition at line 1199 of file redundancy.c.

Here is the call graph for this function: