-
Notifications
You must be signed in to change notification settings - Fork 0
/
fenice_config.h
250 lines (203 loc) · 7.61 KB
/
fenice_config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/**
* @file fenice_config.h
* @brief This file contains configuration settings for Fenice
*
* @date Oct 07, 2019
*
* @author Matteo Bonora [[email protected]]
* @author Simone Ruffini [[email protected]]
* @author Antonio Gelain [[email protected]]
*/
#ifndef FENICE_CONFIG_H
#define FENICE_CONFIG_H
#include <inttypes.h>
//===========================================================================
//=================================== General ===============================
//===========================================================================
#define DISCHARGE_R 10 //Ohm
#define CELL_CAPACITY 3.9 //Ah
/**
* Maximum can payload. for CAN 2.0A is 8 bytes
*/
#define CAN_MAX_PAYLOAD_LENGTH 8
/**
* Number of daisy chained LTCs
*/
#define CELLBOARD_COUNT 6
/**
* Number of cells a single IC controls. Refer to cell_distribution for
* configuration
*/
#define CELLBOARD_CELL_COUNT 18
// Voltage value in mV * 10
typedef uint16_t voltage_t;
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b)) // Get the maximum between two values
#endif // MAX(a, b)
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b)) // Get the minimum between two values
#endif // MIN(a, b)
//===========================================================================
//=================================== LTC6813 ===============================
//===========================================================================
#define LTC6813_PERIPHERAL hspi1
/**
* Number of daisy chained LTCs
*/
#define LTC6813_COUNT 6
/**
* Number of cells a single IC controls. Refer to cell_distribution for
* configuration
*/
#define LTC6813_CELL_COUNT 18
/**
* Number of registers for each LTC
*/
#define LTC6813_REG_COUNT 6
/**
* Number of cells handled by a register
*/
#define LTC6813_REG_CELL_COUNT 3
#define LTC6813_TEMP_ADDRESS 69
//===========================================================================
//================================= Temperature =============================
//===========================================================================
/**
* Temperature measurement interval (ms)
*/
#define TEMP_READ_INTERVAL 100
/**
* How many temperatures to average together
*/
#define TEMP_SAMPLE_COUNT 4
/**
* How many I2C buses are used to address all the sensors
*/
#define TEMP_BUS_COUNT 1
/**
* How many strips in each bus
*/
#define TEMP_STRIPS_PER_BUS 6
/**
* How many sensors are on a strip
*/
#define TEMP_SENSORS_PER_STRIP 6
/**
* How many sensors on each cellboard
*/
#define TEMP_SENSOR_COUNT (TEMP_BUS_COUNT * TEMP_STRIPS_PER_BUS * TEMP_SENSORS_PER_STRIP)
/**
* The address pin coding for each sensor in a strip. The LSB must be changed
* from [0-2] to differentiate between each strip.
*/
static const uint8_t TEMP_SENSOR_ADDRESS_CODING[TEMP_SENSORS_PER_STRIP] = {000, 100, 010, 110, 020, 120};
//===========================================================================
//================================ Pack Settings ============================
//===========================================================================
/**
* Total number of cells in series
*/
#define PACK_CELL_COUNT (LTC6813_COUNT * LTC6813_CELL_COUNT)
/**
* How many temperature sensors in the pack
*/
#define PACK_TEMP_COUNT (TEMP_SENSOR_COUNT * LTC6813_COUNT)
/**
* Cell's limit voltages (mV * 10)
*/
#define CELL_MIN_VOLTAGE 25000
#define CELL_WARN_VOLTAGE 30000
#define CELL_MAX_VOLTAGE 42000
/**
* Minimum cell temperature (°C)
*/
#define CELL_MIN_TEMPERATURE -20.0
/**
* Maximum cell temperature (°C)
*/
#define CELL_MAX_TEMPERATURE 60.0
/**
* Cell nominal energy (Wh * 10)
*/
#define CELL_ENERGY_NOMINAL 576
/**
* Pack nominal energy (Wh * 10)
*/
#define PACK_ENERGY_NOMINAL (CELL_ENERGY_NOMINAL * PACK_CELL_COUNT)
#define AIRN_CHECK_TIMEOUT 1000
#define PRECHARGE_TIMEOUT 20000 // 13000 // ms
#define AIRP_CHECK_TIMEOUT 1000
#define CELLBOARD_COMM_TIMEOUT 100
// How much does a balancing cycle last (ms)
#define BAL_CYCLE_LENGTH 30000
#define BAL_TIME_ON 1000
#define BAL_TIME_OFF 1000
// How much to wait for voltages to stabilize after a balancing cycle [ms]
#define BAL_COOLDOWN_DELAY 5000
#define DISCHARGE_DUTY_CYCLE (((float)BAL_CYCLE_LENGTH*BAL_TIME_ON/(BAL_TIME_ON+BAL_TIME_OFF))/(BAL_CYCLE_LENGTH+BAL_COOLDOWN_DELAY))
/** @brief Multiplexer feedbacks */
typedef enum {
FEEDBACK_IMPLAUSIBILITY_DETECTED_POS = 0, // That's impossible!!!
FEEDBACK_IMD_COCKPIT_POS, // HV and LV are isolated
FEEDBACK_TSAL_GREEN_FAULT_LATCHED_POS,
FEEDBACK_BMS_COCKPIT_POS,
FEEDBACK_EXT_LATCHED_POS,
FEEDBACK_TSAL_GREEN_POS,
FEEDBACK_TS_OVER_60V_STATUS_POS,
FEEDBACK_AIRN_STATUS_POS,
FEEDBACK_AIRP_STATUS_POS,
FEEDBACK_AIRP_GATE_POS,
FEEDBACK_AIRN_GATE_POS,
FEEDBACK_PRECHARGE_STATUS_POS,
FEEDBACK_TSP_OVER_60V_STATUS_POS,
FEEDBACK_IMD_FAULT_POS,
FEEDBACK_CHECK_MUX_POS,
FEEDBACK_SD_END_POS,
FEEDBACK_MUX_N
} MUX_FEEDBACK;
/** @brief Shutdown feedbacks */
typedef enum {
FEEDBACK_SD_OUT_POS = FEEDBACK_MUX_N,
FEEDBACK_SD_IN_POS,
FEEDBACK_SD_BMS_POS,
FEEDBACK_SD_IMD_POS,
FEEDBACK_N
} SD_FEEDBACK;
// Multiplexer feedbacks
#define FEEDBACK_NULL 0
#define FEEDBACK_IMPLAUSIBILITY_DETECTED ((feedback_t)1 << FEEDBACK_IMPLAUSIBILITY_DETECTED_POS)
#define FEEDBACK_IMD_COCKPIT ((feedback_t)1 << FEEDBACK_IMD_COCKPIT_POS)
#define FEEDBACK_TSAL_GREEN_FAULT_LATCHED ((feedback_t)1 << FEEDBACK_TSAL_GREEN_FAULT_LATCHED_POS)
#define FEEDBACK_BMS_COCKPIT ((feedback_t)1 << FEEDBACK_BMS_COCKPIT_POS)
#define FEEDBACK_EXT_LATCHED ((feedback_t)1 << FEEDBACK_EXT_LATCHED_POS)
#define FEEDBACK_TSAL_GREEN ((feedback_t)1 << FEEDBACK_TSAL_GREEN_POS)
#define FEEDBACK_TS_OVER_60V_STATUS ((feedback_t)1 << FEEDBACK_TS_OVER_60V_STATUS_POS)
#define FEEDBACK_AIRN_STATUS ((feedback_t)1 << FEEDBACK_AIRN_STATUS_POS)
#define FEEDBACK_AIRP_STATUS ((feedback_t)1 << FEEDBACK_AIRP_STATUS_POS)
#define FEEDBACK_AIRP_GATE ((feedback_t)1 << FEEDBACK_AIRP_GATE_POS)
#define FEEDBACK_AIRN_GATE ((feedback_t)1 << FEEDBACK_AIRN_GATE_POS)
#define FEEDBACK_PRECHARGE_STATUS ((feedback_t)1 << FEEDBACK_PRECHARGE_STATUS_POS)
#define FEEDBACK_TSP_OVER_60V_STATUS ((feedback_t)1 << FEEDBACK_TSP_OVER_60V_STATUS_POS)
#define FEEDBACK_IMD_FAULT ((feedback_t)1 << FEEDBACK_IMD_FAULT_POS)
#define FEEDBACK_CHECK_MUX ((feedback_t)1 << FEEDBACK_CHECK_MUX_POS)
#define FEEDBACK_SD_END ((feedback_t)1 << FEEDBACK_SD_END_POS)
#define FEEDBACK_ALL (feedback_t)(((feedback_t)1 << (FEEDBACK_N)) - 1)
// Shutdown feedbacks
#define FEEDBACK_SD_OUT ((feedback_t)1 << FEEDBACK_SD_OUT_POS)
#define FEEDBACK_SD_IN ((feedback_t)1 << FEEDBACK_SD_IN_POS)
#define FEEDBACK_SD_BMS ((feedback_t)1 << FEEDBACK_SD_BMS_POS)
#define FEEDBACK_SD_IMD ((feedback_t)1 << FEEDBACK_SD_IMD_POS)
//===========================================================================
//=========================== S160 current transducer =======================
//===========================================================================
// 0A voltage level
#define S160_OFFSET (3.33 / 2)
// Sensitivity of the 50A sensor
#define S160_50A_SENS 6.67
//Sensitivity of the 300A sensor
#define S160_300A_SENS 40
/*
* If the cli should echo the input
*/
#define CLI_ECHO 1
#endif /* FENICE_CONFIG_H_ */