source: trunk/fw_g473rct/SES/inc/sysdata.h@ 74

Last change on this file since 74 was 73, checked in by f.jahn, 32 hours ago

Delta Sigma ADC auf 10Channel geändert.

File size: 18.5 KB
Line 
1/*!
2 * \file : sysdata.h
3 * \brief : Header for sysdata.c file.
4 * This file contains the common defines of the application.
5 *
6 */
7
8#ifndef __SYS_DATA_H
9#define __SYS_DATA_H
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include "stdint.h"
16
17#define CONCAT(a, b) CONCAT_INNER(a, b) // These three macros
18#define CONCAT_INNER(a, b) a ## b // generate unique variables
19#define UNIQUE_NAME(base) CONCAT(base, __COUNTER__) // according to template "baseX", like "base1", "base2" and etc.
20
21#define SAMPLE_ARRAY_SIZE 64
22
23//------------------------------------------------------------------------------
24
25typedef union
26{
27 uint16_t w;
28 int16_t sw;
29 uint8_t b[2];
30 int8_t sb[2];
31} bword_t;
32
33//------------------------------------------------------------------------------
34// This structure must be aligned to 4-byte address
35typedef struct
36{
37 // Device spezifisch / Einstellungsbereich
38 uint16_t device_type; // 0 ECS interne Gertetyp Kennung (IHP 500 -> daher wird angedacht die Gerätekennung 500 zu nehmen)
39 uint16_t UNIQUE_NAME(reserved); // 1 Reserviert wg Alignement
40 uint32_t sn; // 2-3 Seriennummer Teil 1 -> wird bei der Produktion geschrieben
41
42 uint16_t fw_revision_major; // 4 Firmware Revision Major -> wird bei einer neuen Gertegeneration hochgezhlt
43 uint16_t fw_revision_minor; // 5 Firmware Revision Minor -> wird hochegezhlt, wenn nderungen in der Firmware auch nderungen in der Bedienungsanleitung zur Folge haben
44
45 uint16_t fw_revision_revision; // 6 Firmware Revision Revision -> wird bei jeder nderung der Firmware hochgezhlt
46 uint16_t UNIQUE_NAME(reserved); // 7 Reserviert wg Alignement
47
48 uint32_t baudrate; // 8-9 Die Modbus Baudrate (default 19200 Bit/s). Gltig im Bereich von 50 Bit/s bis 1000 000 Bit/s
49
50 uint16_t parityMode; // 10 UART Parity Mode (default EVEN) mgliche Werte 0=EVEN, 1=ODD, 2=NONE
51 uint16_t stopBit; // 11 UART Stop Bit Reserviert, Aktuell automatisch selektiert nach Modbus standart Bei Parity EVEN oder ODD 1, bei NONE werden 2 stopbits genutzt
52
53 uint16_t slave_address; // 12 Modbus Slave Adresse (default 1) mgliche Werte von 1 bis 247
54 uint16_t command; // 13 Kommando Word, das Schreiben bestimmter Werte in dieses Register fhrt bestimmte Aktionen aus
55
56 uint16_t ibn_day; // 14 Inbetriebnahme Datum: Tag
57 uint16_t ibn_month; // 15 Inbetriebnahme Datum: Monat
58 uint16_t ibn_year; // 16 Inbetriebnahme Datum: Jahr
59 uint16_t user_id; // 17 Freies Feld für eine Kunden ID oder ähnlich
60 uint16_t test[8]; // 18-25 RESERVIERT
61
62 //--- Konfiguration Schaltausgänge ---
63 uint16_t lvpStart; // 26 Spannung ab der die LOW Voltage Protection aktiv wird in [mV]
64 uint16_t lvpStop; // 27 Spannung ab der die LOW Voltage Protection wieder inaktiv wird [mV]
65
66 uint16_t ovpStart; // 28 Spannung ab der die OVER Voltage Protection aktiv wird in [mV]
67 uint16_t ovpStop; // 29 Spannung ab der die OVER Voltage Protection wieder inaktiv wird [mV]
68
69 int16_t loadCurrentLimit; // 30 maximaler Laststrom in A wenn der Strom grer ist als der eingestelle Wert dann wird die Laststrom Protection aktiv, darf nicht unsigned sein, da Entladestrom mit Minus angegeben [A] Default -500 A
70 int16_t chargeCurrentLimit; // 31 maximaler Ladestrom in A wenn der Strom grer ist als der eingestelle Wert dann wird die Ladestrom Protection aktiv [A] Default:500A
71
72
73 int16_t chargeStopHighTemperatureStart; // 32 Abschalttemperatur Ladung wegen zu hoher Temperatur [C * 100]
74 int16_t chargeStopHighTemperatureStop; // 33 Wiedereinschalttemperatur [C * 100]
75
76 int16_t chargeStopLowTemperatureStart; // 34 Abschalttemperatur Ladung wegen zu niedriger Temperatur [C * 100]
77 int16_t chargeStopLowTemperatureStop; // 35 Wiedereinschalttemperatur [C * 100]
78
79 int16_t dischargeStopHighTemperatureStart; // 36 Abschalttemperatur Entladung wegen zu hoher Temperatur [C * 100]
80 int16_t dischargeStopHighTemperatureStop; // 37 Wiedereinschalttemperatur[C * 100]
81
82 int16_t dischargeStopLowTemperatureStart; // 38 Abschalttemperatur EntLadung wegen zu niedriger Temperatur
83 int16_t dischargeStopLowTemperatureStop; // 39 Wiedereinschalttemperatur
84
85
86 //ah-Counter
87 uint16_t peukert; // 40 Peukert Faktor (Wert für den Exponent) * 100
88 uint16_t cef; // 41 Ladeeffektivitätsfaktor in %
89
90 uint16_t iBatFull; // 42 Strom in % ab dem die Zellen als voll erkannt werden (Strom muss für die Zeit timeBatFull unter den Wert fallen)
91 uint16_t tBatFull; // 43 Zeit in Sekunden ab dem die Zellen als voll erkannt werden (Strom muss unter dem Wert iBattFull liegen)
92
93 uint16_t uBatFull; // 44 Spannung für Erkennung Battery voll in [mV]
94 uint16_t uBatEmpty; // 45 Reserviert
95 uint32_t cellCapacity; // 46-47 Die Zellkapazität in mAh (bei parallel geschalteten Zellen wird die Kapazitt der Zellen addiert)
96 uint32_t battEnergy; // 48-49 Die Zellkapazität in mWh (Wh = mAh * Vnom)
97 uint16_t socCalcMode; // 50 SoC calculation method: 0 (simple - default) - based on Ah values; 1 (advanced) - based on Wh values
98 uint16_t UNIQUE_NAME(reserved); // 51 RESERVIERT
99 uint16_t cellRatedDischargeTime; // 52 Standard discharge time in h
100 int16_t uBatEmptyCompStartTemp; // 53 We start calculating uBatEmpty compensations only when cell temperature is lower than this value
101 int16_t uBatEmptyCompStopTemp; // 54 We stop calculating uBatEmpty compensations when cell temperature is lower than this value
102 uint16_t uBatEmptyCompStopVolt; // 55 uBatEmpty Voltage at temperatures lower than lvpCompStopTemp
103 int16_t extraDischargeStrom_mA; // 56
104 uint16_t cefW; // 57 CeF for Wh calculations
105 uint16_t lvpMode; // 58
106 uint16_t ovpMode; // 59
107 // ------- Calibration Parameter -----
108 int32_t batteryCurrentOffset; // 60-61 Offset bei Raumtemperatur ADC Schritte
109 int16_t batteryCurrentOffsetRefTemperatureShunt; // 62 gesicherte Shunt Temperatur zum Zeitpunkt der Kalibrierung
110 int16_t batteryCurrentOffsetRefTemperatureChip; // 63 gesicherte Chip Temperatur zum Zeitpunkt der Kalibrierung
111 int32_t batteryCurrentOffsetRefshuntVoltage; // 64-65 gesicherte Shunt Spannung zum Zeitpunkt der Kalibrierung
112
113 int32_t batteryCurrentOffsetCommonModeCalibrationVoltage; // 66-67 gesicherte Spannuung am Shunt für Common Mode Error Compensation
114 int32_t batteryCurrentOffsetCommonModeCompensationFactor; // 68-69 Common Mode Error Compensation Faktor Faktor pro mV Shuntspannungsnderung * 1000
115
116 int16_t batteryCurrentOffsetTemperatureCalibrationTemperature; // 70 gesicherte Temperatur zum Zeitput der Offset Temperatur Kompensation
117 int16_t UNIQUE_NAME(reserved); // 71 reserviert
118 int32_t batteryCurrentOffsetTemperatureCompensationFactor; // 72-73 Berechnete Temperatur Kompensation für Strom Offset
119
120 uint32_t batteryCurrentGainCorrectionFaktor; // 74-75 Gain Korrektur Faktor * 1000000
121 int16_t batteryCurrentGainRefTempShunt; // 76 Gesicherte Temperatur Shunts bei Gain Kallibrierung
122 int16_t batteryCurrentGainRefTempChip; // 77 Gesicherte Temperatur Chip bei Gain Kallibrierung
123 int32_t batteryCurrentGainRefCurrent; // 78-79 Referenz Strom für die Gain Kalibrierung, muss vor dem Start des Kal. Befehls hier eingegeben werden
124
125 int16_t batteryCurrentGainTemperatureCalibrationShuntTemperature; // 80 Gesicherte Shunt Temperatur bei Start der Gain Temperatur Kompensation
126 int16_t UNIQUE_NAME(reserved); // 81 reserviert
127 int32_t batteryCurrentGainTemperatureCompensationShuntFactor; // 82-83 Berechneter Faktor für Gain Temperatur kompensation. Pro 1/100 C * 1000000000
128 int16_t batteryCurrentGainTemperatureCalibrationChipTemperature; // 84 Gesicherte Chip Temperatur bei Start der Gain Temperatur Kompensation
129 int16_t shuntVoltageFastOffset; // 85 reserviert
130 int32_t batteryCurrentGainTemperatureCompensationChipFactor; // 86-87 zuszätzlicher Kalibrierungsfaktor, nicht in Verwendung
131 int32_t batteryCurrentOffsetFast; // 88-89 Korrektur in STM32 ADC Messung Gain, Strommessung
132 uint32_t batteryCurrentGainCorrectionFaktorFast; // 90-91 Korrektur in STM32 ADC Messung Gain, Strommessung
133 int16_t batteryEmptyDetectionMode; // 92 0= Alt, Nach Batteriespannungsmessung von greenmeter, 1= Neu Auto BMS Mode, Erkennung mit LVP Leitung, geht erst ab smartPro Hardware
134 uint16_t auxOutputMode; // 93 0=OFF, 1=MODE_HEATER, 2=MODE_SOC, 3=MODE_ALARM
135 uint16_t auxOutputSetpointOn; // 94 SOC in Prozent für SOC Mode
136 uint16_t auxOutputSetpointOff; // 95 SOC in Prozent für SOC mode
137 uint16_t auxOutputInverted; // 96 0= NORMAL, 1=INVERTED
138 int16_t batteryVoltageFastOffset; // 97 Offset für Spannungsmessung
139 int16_t batteryVoltageOffset; // 98 Offset für Spannungsmessung
140 int16_t shuntVoltageOffset; // 99 Offset für Spannungsmessung
141
142
143} device_parameter_t;
144
145//------------------------------------------------------------------------------
146// This structure must be aligned to 4-byte address
147typedef struct
148{ /*offset 0*/
149 /* 2 of 8 */ uint16_t voltageVref; // 100 Aktuelle Spannung der Referenzspannungsquelle des ADS1260 gemessen von dem STM32G0 [mV]
150 /* 4 of 8 */ uint16_t realVdd; // 101 Aktuelle Umrechnung von gemessene externe RefSpannung auf ADC Ref Spannung = Vdd, Vdd ist die Referenz des internen ADC. Diese wird jetzt als Referenz für die interne ADC Messungen verwendet [mV]
151 /* 6 of 8 */ int16_t chipTemperature; // 102 Chiptemperatur gemessen auf dem STM32G0 [C * 100]
152 /* 8 of 8 */ int16_t shuntTemperature; // 103 Gemessene Shunt Temperatur [C * 100]
153 /* 2 of 8 */ int16_t shuntTemperatureMax; // 104 Höchste Shunttemperatur seit Programmstart, kann durch Schreiben von Int16-Min (-32.768) in das Register zurückgesetzt werden
154 /* 4 of 8 */ int16_t shuntTemperatureMin; // 105 Niedrigste Shunttemperatur seit Programmstart, kann durch Schreiben von Int16_Max (+32.767) in das Register zurückgesetzt werden
155 /* 8 of 8 */ int32_t shuntVoltage; // 106-107 Shuntspannung in mV (Common Mode Voltage) gemessen von dem STM32G0. Spannung zwischen Shunt B und GND Versorgung
156 /* 4 of 8 */ int32_t batteryVoltage; // 108-109! Gemessenen Batteriespannung in mV. Es kann in beide Richtungen gemessen werden (mindestens von -60V bis +60V). Es muss darauf geachtet werden, dass die gemessen Spannung positiv ist (+ an Batterieplus und - an Batterieminus)
157 /* 8 of 8 */ int32_t batteryVoltageMax; // 110-111 Hchster Spannungswert in mV (Batteriespannung) seit Programmstart. Kann durch schreiben von int32-Min (-2,147,483,648) in das Register zurckgesetzt werden
158 /* 4 of 8 */ int32_t batteryVoltageMin; // 112-113 Niedrigster Spannungswert in mV (Batteriespannung) seit Programmstart. Kann durch Schreiben von int32-Max (2,147,483,647) in das Register zurckgesetzt werden
159 /* 8 of 8 */ int32_t batteryCurrent; // 114-115! Gemessener Batteriestrom in mA. Es kann in beide Richtungen gemessen werden, es muss darauf geachtet werden, dass der Stromsensor so eingebaut wird, dass der Ladestrom positiv gemessen wird und der Laststrom negativ, ansonsten falsche SOC Berechnung
160 /* 4 of 8 */ int32_t batteryCurrentMax; // 116-117 Hchster Batteriestrom seit Programmstart in mA. Kann durch Schreiben von Int32-Min (-2,147,483,648) in das Register zurückgesetzt werden
161 /* 8 of 8 */ int32_t batteryCurrentMin; // 118-119 Niedrigster Batteriestrom seit Programmstart in mA. Kkann durch Schreiben von Int32-Max (2,147,483,647) in das Register zurückgesetzt werden
162 /* 4 of 8 */ int32_t batteryCurrentCorrected; // 120-121! Gemessener Batteriestrom mit berücksichtitgten Peukert Faktor in mA
163 /* 8 of 8 */ int32_t mAhCounter; // 122-123 Kapazitätszähler in [mAh] umgerechnet von mAsCounter
164 /* 8 of 8 */ int64_t mAsCounter; // 124-127! Kapazitätszähler in mAhs, zählt den gemessenen Strom, positiv für Ladeströme und negativ für Lastströme (Mit Peukert und CEF)
165 /* 4 of 8 */ int32_t soc; // 128-129! State of Charge in % * 1000
166 /* 6 of 8 */ int16_t ovpState; // 130 Zustand Schaltausgang OVP
167 /* 8 of 8 */ int16_t lvpState; // 131 Zustand Schaltausgang LVP
168 /* 4 of 8 */ int32_t batteryPower; // 132-133! Leistung Batterie[mW]
169 /* 8 of 8 */ int32_t detectedCapacity; // 134-135 Festgestellte Kapazität [mAh]
170 /* 4 of 8 */ int32_t detectedEnergy; // 136-137 [mWh]
171 /* 6 of 8 */ int16_t SoH; // 138 [%]
172 /* 8 of 8 */ int16_t efficiency; // 139 [%]
173 /* 2 of 8 */ int16_t selfDischarge; // 140 [mA]
174 /* 4 of 8 */ int16_t selfDischargeAvg; // 141 [mA]
175 /* 6 of 8 */ int16_t esr_batt; // 142 [mOhm]
176 /* 8 of 8 */ int16_t esr_shunt; // 143 [mOhm]
177 /* 4 of 8 */ uint32_t lastTimeVbatFull; // 144-145 [s]
178 /* 8 of 8 */ uint32_t lastTimeVbatEmpty; // 146-147 [s]
179 /* 4 of 8 */ uint32_t onTime; // 148-149 [s] Runtime Zähler zum speichern der Statistik Werte im EEPROM und als Betriebszeitzähler
180 /* 8 of 8 */ uint32_t dischargeTotalAh; // 150-151 [Ah]
181 /* 4 of 8 */ uint32_t chargeTotalAh; // 152-153 [Ah]
182 /* 8 of 8 */ uint32_t dischargeTotalWh; // 154-155 [Wh]
183 /* 4 of 8 */ uint32_t chargeTotalWh; // 156-157 [Wh]
184 /* 6 of 8 */ uint16_t fullCyclesCnt; // 158
185 /* 8 of 8 */ uint16_t volatile UNIQUE_NAME(reserved); // 159
186 /* 4 of 8 */ int32_t mAh_AutoMode; // 160-161
187 /* 6 of 8 */ int16_t calculatedCEFAh; // 162
188 /* 8 of 8 */ int16_t calculatedCEFWh; // 163
189 /* 4 of 8 */ int32_t mWh_AutoMode; // 164-165
190 /* 6 of 8 */ int16_t overcurrentMeasurement; // 166
191 /* 8 of 8 */ int16_t overcurrentMaxValue; // 167 /reserviert
192 /* 2 of 8 */ uint16_t ovp_sense; // 168 reserviert
193 /* 4 of 8 */ uint16_t lvp_sense; // 169
194 /* 6 of 8 */ uint16_t overcurrentRetryCounter; // 170
195 /* 8 of 8 */ uint16_t overcurrentEventsTotal; // 171
196 /* 4 of 8 */ uint32_t detectedCapacityAtActualCRate; // 172,173
197 /* 8 of 8 */ uint32_t detectedEnergyAtActualCRate; // 174,175
198
199
200 // --- DEBUG WERTE
201 /* 8 of 8 */ int64_t mAs_AutoMode; // 176-179 [mWh]
202 /* 8 of 8 */ int64_t mWs_AutoMode; // 180-183 [mWh]
203 /* 8 of 8 */ int64_t mWsCounter; // 184-187 [mWs]
204 /* 4 of 8 */ int32_t mWhCounter; // 188-189 [mWh]
205 /* 8 of 8 */ int32_t correctedStromForChargeWhCnt; // 190-191 Reserviert
206 /* 2 of 8 */ uint16_t uBatEmptyTempComp; // 192 [mV]
207 /* 4 of 8 */ uint16_t adc_restarts; // 193
208 /* 8 of 8 */ int32_t power_Fast; // 194 Reserviert
209 /* 4 of 8 */ int32_t battryCurrentRaw; // 196-197 Gemessener Strom in ADC Schritte Ohne Korrekturen
210 /* 8 of 8 */ int32_t batteryCurrentOffsetCommonModeCorrectionADCSteps; // 198-199 Offset Korrektur Wert aufgrund Common Mode Error
211 /* 4 of 8 */ int32_t fast_current; // 200-201
212 /* 8 of 8 */ int32_t batteryVoltageFast; // 202-203
213 /* 2 of 8 */ int16_t esrCalcStatus; // 204
214 /* 4 of 8 */ uint16_t esrCalcTime; // 205
215 /* 6 of 8 */ int16_t selfDischargeStatus; // 206
216 /* 8 of 8 */ uint16_t selfDischargeTime; // 207
217 /* 8 of 8 */ uint8_t message[24]; // 208-219 ASCII-char message, limited to 20 letters
218 /* 8 of 8 */ int64_t mWsCounterUncorrected; // 220-223 [mWs]
219 /* 8 of 8 */ int64_t mAsCounterUncorrected; // 224-227 [mAs]
220 /* 4 of 8 */ int32_t mAhCounterUncorrected; // 228-229
221 /* 6 of 8 */ uint16_t soc0; // 230
222 /* 8 of 8 */ uint16_t soc1; // 231
223 /* 2 of 8 */ uint16_t soc2; // 232
224 /* 4 of 8 */ uint16_t soc3; // 233
225 /* 6 of 8 */ uint16_t soc4; // 234
226 /* 8 of 8 */ int16_t peukertRemoveCorrectionFaktor; // 235
227 /* 4 of 8 */ int32_t mAh_AutoModeU; // 236-237
228 /* 6 of 8 */ uint16_t ltc_charge_current; // 238
229 /* 8 of 8 */ uint16_t ltc_charge_current_max; // 239
230 /* 8 of 8 */ int64_t mAs_AutoModeU; // 240-243
231 /* 2 of 8 */ uint16_t ramCRCErrCnt; // 244
232 /* 4 of 8 */ int16_t UNIQUE_NAME(reserved); // 245
233
234 /* 8 of 8 */ int32_t shuntVoltageFast; // 246
235 /* 2 of 8 */ uint16_t ltc_discharge_current; // 248
236 /* 4 of 8 */ uint16_t ltc_discharge_current_max; // 249
237 /* 6 of 8 */ uint16_t UNIQUE_NAME(reserved); // 250
238 /* 8 of 8 */ int16_t pos_I_peak; // 251
239 /* 2 of 8 */ int16_t neg_I_peak; // 252
240 /* 4 of 8 */ int16_t pos_U_Batt_peak; // 253
241 /* 6 of 8 */ int16_t neg_U_Batt_peak; // 254
242 /* 8 of 8 */ int16_t pos_U_Shunt_peak; // 255
243 /* 2 of 8 */ int16_t neg_U_Shunt_peak; // 256
244 /* 4 of 8 */ uint16_t pos_I_Buffer_pos; // 257
245 /* 6 of 8 */ uint16_t neg_I_Buffer_pos; // 258
246 /* 8 of 8 */ uint16_t UNIQUE_NAME(reserved); // 259
247 /* 8 of 8 */ int16_t current_buffer[SAMPLE_ARRAY_SIZE]; // 260-323
248 /* 8 of 8 */ int16_t voltage_buffer_batt[SAMPLE_ARRAY_SIZE]; // 324-387
249 /* 8 of 8 */ int16_t voltage_buffer_shunt[SAMPLE_ARRAY_SIZE]; // 388-451
250
251} device_values_t;
252
253//------------------------------------------------------------------------------
254
255typedef struct
256{
257 device_parameter_t parameter; // 0-99
258 device_values_t values; // 100
259} sys_data_struct_t;
260
261//------------------------------------------------------------------------------
262typedef volatile union
263{
264 sys_data_struct_t s;
265 bword_t mb[sizeof(sys_data_struct_t) / 2];
266} sys_data_t;
267
268//------------------------------------------------------------------------------
269
270extern sys_data_t sys_data;
271
272//------------------------------------------------------------------------------
273
274void SYS_DATA_Init(void);
275
276#ifdef __cplusplus
277}
278#endif
279
280#endif // __SYS_DATA_H
Note: See TracBrowser for help on using the repository browser.