@@ -50,21 +50,19 @@ const float current_source_exp_lookup[] = {1.0, 4.0, 16.0, 64.0};
50
50
#define ADCVALUE_TO_FLOAT_VOLTAGE (value ) (5.0 /65536 * (float ) value)
51
51
#define NTC_MEASUREMENT_TO_R (value,r_temp_filter ) ((2.0 *(value&0x03FF )*current_source_exp_lookup[(value>>11 )&0x03 ])/(1024 *0.000320 ) - r_temp_filter)
52
52
#define VOLTAGE_TO_OC_UC_LIMIT (voltage ) ((uint16_t ) ((voltage/5.0 ) * 1024 ))
53
+ #define VOLTAGE_TO_OV_UV_LIMIT (voltage ) ((uint16_t ) ((voltage/5.0 ) * 1024 ))
53
54
#define VOLTAGE_TO_OL_THRESHOLD (voltage ) ((uint8_t ) voltage/0.0195 ) // note max input voltage should not exceed ~1.2285V
54
55
#define ADCVALUE_TO_FLOAT_BLOCKVOLTAGE (value ) (60.0 /65536 * (float ) value)
55
56
#define INTERNAL_IC_TEMP_TO_DEGREE (value ) (-0.6624 * (float ) (value & 0x3FF ) + 547.3 ) // Kelvin/degree conversion already included?
56
57
#define DEGREE_TO_IC_TEMP_LIMIT (degree ) (((uint16_t )((degree - 547.3 )/(-0.6624 )))&0x3FF ) // Kelvin/degree conversion already included?
57
58
58
-
59
59
// -----------------------------------------------------------------------------
60
60
// Defines for Lib functions
61
61
// -----------------------------------------------------------------------------
62
62
63
63
#define WRITECOMMAND 0x80
64
64
#define BROADCAST_ID 0x3F
65
65
66
-
67
-
68
66
// -----------------------------------------------------------------------------
69
67
// Typedefs start here
70
68
// -----------------------------------------------------------------------------
@@ -120,12 +118,13 @@ typedef struct
120
118
121
119
/* * Data structure to describe properties for NTC Resistors. The current model
122
120
* uses a base resistance and a b value to calculate temperature following the formula
123
- * B*(T-TR)/(T*TR ) = ln(RR/RT )
121
+ * T(R ) = 1/(( ln(R/ntc_resistance)/ntc_b_value) + (1/basetemp) )
124
122
*/
125
123
typedef struct
126
124
{
127
- float ntc_resistance;
128
- float ntc_b_value;
125
+ float ntc_resistance; // Base Value of the NTC
126
+ float ntc_b_value; // Beta value of the NTC
127
+ float basetemp; // Temperature of the NTC at specified resistance in Kelvin
129
128
} ntc_config_t ;
130
129
131
130
/* *
@@ -148,8 +147,10 @@ typedef struct
148
147
uint16_t cell_voltages[12 ]; /* *< Array that hold up to 12 cell voltages that can be measured */
149
148
uint16_t block_voltage; /* *< Block Voltage of the complete stack */
150
149
uint16_t ntc_resistances[5 ]; /* *< Measured NTC Resistance */
150
+ uint8_t ntc_results_valid;
151
151
uint16_t chiptemperature1; /* *< Temperature of internal Temperature Sensor Nr. 1 */
152
152
uint16_t chiptemperature2; /* *< Temperature of internal Temperature Sensor Nr. 2 */
153
+ uint8_t chiptemperatures_valid;
153
154
uint16_t mailbox_register; /* *< Content of the Mailbox Register */
154
155
uint16_t scvm_high; /* *< Highest value measured by the secondary measurement path */
155
156
uint16_t scvm_low; /* *< Lowest value measured by the secondary measurement path */
@@ -334,6 +335,7 @@ typedef struct
334
335
void readTemperatures (uint8_t nodeID);
335
336
void setNumberofCells (uint8_t nodeID, uint8_t n_cells);
336
337
void setTempSensorsConfig (uint8_t nodeID, uint8_t n_temp_sensors,ntc_config_t sensorconfig);
338
+ void readChipTemperatures (uint8_t nodeID);
337
339
338
340
// Watchdog and Power state handling
339
341
void activateSleep ();
@@ -349,7 +351,7 @@ typedef struct
349
351
350
352
351
353
// Error checking and handling
352
- void checkDiagnoseResistor (uint8_t nodeID);
354
+ uint8_t checkDiagnoseResistor (uint8_t nodeID);
353
355
void attachErrorHandler (tle9012_error_t errortype, void (*errorhandler)(uint8_t , uint16_t ));
354
356
void checkErrors (uint8_t nodeID);
355
357
void resetErrors (uint8_t nodeID);
0 commit comments