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

Last change on this file since 31 was 28, checked in by f.jahn, 3 months ago
File size: 17.7 KB
RevLine 
[20]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
[26]21#define SAMPLE_ARRAY_SIZE 64
[20]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
[23]35typedef struct
[20]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
[26]60 uint16_t test[8]; // 18-25 RESERVIERT
[20]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
[26]105 uint16_t lvpMode; // 58
106 uint16_t ovpMode; // 59
[20]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
[26]120 uint32_t batteryCurrentGainCorrectionFaktor; // 74-75 Gain Korrektur Faktor * 1000000
[20]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 UNIQUE_NAME(reserved); // 85 reserviert
[26]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
[28]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 uint16_t UNIQUE_NAME(reserved)[3];
[20]139
140} device_parameter_t;
141
142//------------------------------------------------------------------------------
143// This structure must be aligned to 4-byte address
144typedef struct
145{ /*offset 0*/
146 /* 2 of 8 */ uint16_t voltageVref; // 100 Aktuelle Spannung der Referenzspannungsquelle des ADS1260 gemessen von dem STM32G0 [mV]
147 /* 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]
148 /* 6 of 8 */ int16_t chipTemperature; // 102 Chiptemperatur gemessen auf dem STM32G0 [C * 100]
149 /* 8 of 8 */ int16_t shuntTemperature; // 103 Gemessene Shunt Temperatur [C * 100]
150 /* 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
151 /* 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
152 /* 8 of 8 */ uint32_t shuntVoltage; // 106-107 Shuntspannung in mV (Common Mode Voltage) gemessen von dem STM32G0. Spannung zwischen Shunt B und GND Versorgung
153 /* 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)
154 /* 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
155 /* 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
156 /* 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
157 /* 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
158 /* 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
159 /* 4 of 8 */ int32_t batteryCurrentCorrected; // 120-121! Gemessener Batteriestrom mit berücksichtitgten Peukert Faktor in mA
160 /* 8 of 8 */ int32_t mAhCounter; // 122-123 Kapazitätszähler in [mAh] umgerechnet von mAsCounter
161 /* 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)
162 /* 4 of 8 */ int32_t soc; // 128-129! State of Charge in % * 1000
163 /* 6 of 8 */ int16_t ovpState; // 130 Zustand Schaltausgang OVP
164 /* 8 of 8 */ int16_t lvpState; // 131 Zustand Schaltausgang LVP
165 /* 4 of 8 */ int32_t batteryPower; // 132-133! Leistung Batterie[mW]
166 /* 8 of 8 */ int32_t detectedCapacity; // 134-135 Festgestellte Kapazität [mAh]
167 /* 4 of 8 */ int32_t detectedEnergy; // 136-137 [mWh]
168 /* 6 of 8 */ int16_t SoH; // 138 [%]
169 /* 8 of 8 */ int16_t efficiency; // 139 [%]
170 /* 2 of 8 */ int16_t selfDischarge; // 140 [mA]
171 /* 4 of 8 */ int16_t selfDischargeAvg; // 141 [mA]
172 /* 6 of 8 */ int16_t esr; // 142 [mOhm]
173 /* 8 of 8 */ int16_t esr_fast; // 143 [mOhm]
174 /* 6 of 8 */ uint32_t lastTimeVbatFull; // 144-145 [s]
175 /* 8 of 8 */ uint32_t lastTimeVbatEmpty; // 146-147 [s]
176 /* 4 of 8 */ uint32_t onTime; // 148-149 [s] Runtime Zähler zum speichern der Statistik Werte im EEPROM und als Betriebszeitzähler
[25]177 /* 8 of 8 */ uint32_t dischargeTotalAh; // 150-151 [Ah]
178 /* 4 of 8 */ uint32_t chargeTotalAh; // 152-153 [Ah]
179 /* 8 of 8 */ uint32_t dischargeTotalWh; // 154-155 [Wh]
180 /* 4 of 8 */ uint32_t chargeTotalWh; // 156-157 [Wh]
[20]181 /* 6 of 8 */ uint16_t fullCyclesCnt; // 158
[25]182 /* 8 of 8 */ uint16_t volatile UNIQUE_NAME(reserved); // 159
183 /* 4 of 8 */ int32_t mAh_AutoMode; // 160-161
[28]184 /* 6 of 8 */ uint16_t calculatedCEFAh; // 162
185 /* 8 of 8 */ uint16_t calculatedCEFWh; // 163
[25]186 /* 4 of 8 */ int32_t mWh_AutoMode; // 164-165
187 /* 6 of 8 */ uint16_t UNIQUE_NAME(reserved); // 166
[26]188 /* 8 of 8 */ uint16_t UNIQUE_NAME(reserved); // 167r
[25]189 /* 2 of 8 */ uint16_t ovp_sense; // 168
190 /* 4 of 8 */ uint16_t lvp_sense; // 169
[20]191 /* 6 of 8 */ uint16_t UNIQUE_NAME(reserved); // 170
192 /* 8 of 8 */ uint16_t UNIQUE_NAME(reserved); // 171
193 /* 2 of 8 */ uint16_t UNIQUE_NAME(reserved); // 172
194 /* 4 of 8 */ uint16_t UNIQUE_NAME(reserved); // 173
195 /* 6 of 8 */ uint16_t UNIQUE_NAME(reserved); // 174
196 /* 8 of 8 */ uint16_t UNIQUE_NAME(reserved); // 175
197
[25]198
[20]199 // --- DEBUG WERTE
[25]200 /* 8 of 8 */ int64_t mAs_AutoMode; // 176-179 [mWh]
201 /* 8 of 8 */ int64_t mWs_AutoMode; // 180-183 [mWh]
[20]202 /* 8 of 8 */ int64_t mWsCounter; // 184-187 [mWs]
203 /* 4 of 8 */ int32_t mWhCounter; // 188-189 [mWh]
204 /* 8 of 8 */ int32_t correctedStromForChargeWhCnt; // 190-191 Reserviert
205 /* 2 of 8 */ uint16_t uBatEmptyTempComp; // 192 [mV]
206 /* 4 of 8 */ uint16_t adc_restarts; // 193
[28]207 /* 8 of 8 */ int32_t power_Fast; // 194 Reserviert
[20]208 /* 4 of 8 */ int32_t battryCurrentRaw; // 196-197 Gemessener Strom in ADC Schritte Ohne Korrekturen
209 /* 8 of 8 */ int32_t batteryCurrentOffsetCommonModeCorrectionADCSteps; // 198-199 Offset Korrektur Wert aufgrund Common Mode Error
210 /* 4 of 8 */ int32_t fast_current; // 200-201
[28]211 /* 4 of 8 */ int32_t fast_voltage; // 202-203
[20]212 /* 8 of 8 */ int16_t esrCalcStatus; // 204
213 /* 2 of 8 */ uint16_t esrCalcTime; // 205
214 /* 4 of 8 */ int16_t selfDischargeStatus; // 206
215 /* 6 of 8 */ uint16_t selfDischargeTime; // 207
[28]216 /* 8 of 8 */ uint8_t message[24]; // 208-219 ASCII-char message, limited to 20 letters
217 /* 8 of 8 */ int64_t whCounterCEF_AutoMode; // 220-223 [mWs]
218 /* 8 of 8 */ int64_t ahCounterCEF_AutoMode; // 224-227 [mAs]
219 /* 2 of 8 */ uint16_t UNIQUE_NAME(reserved); // 228
220 /* 4 of 8 */ uint16_t UNIQUE_NAME(reserved); // 229
221 /* 6 of 8 */ uint16_t UNIQUE_NAME(reserved); // 230
222 /* 8 of 8 */ uint16_t UNIQUE_NAME(reserved); // 231
223 /* 2 of 8 */ uint16_t UNIQUE_NAME(reserved); // 232
224 /* 4 of 8 */ uint16_t UNIQUE_NAME(reserved); // 233
225 /* 6 of 8 */ uint16_t UNIQUE_NAME(reserved); // 234
226 /* 8 of 8 */ uint16_t UNIQUE_NAME(reserved); // 235
227 /* 2 of 8 */ uint16_t UNIQUE_NAME(reserved); // 236
228 /* 4 of 8 */ uint16_t UNIQUE_NAME(reserved); // 237
229 /* 6 of 8 */ uint16_t UNIQUE_NAME(reserved); // 238
230 /* 8 of 8 */ uint16_t UNIQUE_NAME(reserved); // 239
231 /* 8 of 8 */ int16_t current_buffer[SAMPLE_ARRAY_SIZE]; // 220-283
[26]232 /* 8 of 8 */ int16_t voltage_buffer[SAMPLE_ARRAY_SIZE]; // 284-347
[28]233 /* 8 of 8 */ int16_t current_buffer_fast[SAMPLE_ARRAY_SIZE]; // 348-411
[26]234 /* 8 of 8 */ int16_t voltage_buffer_fast[SAMPLE_ARRAY_SIZE]; // 412-475
[20]235
236} device_values_t;
237
238//------------------------------------------------------------------------------
239
240typedef struct
241{
242 device_parameter_t parameter; // 0-99
243 device_values_t values; // 100
244} sys_data_struct_t;
245
246//------------------------------------------------------------------------------
247typedef volatile union
248{
249 sys_data_struct_t s;
250 bword_t mb[sizeof(sys_data_struct_t) / 2];
251} sys_data_t;
252
253//------------------------------------------------------------------------------
254
255extern sys_data_t sys_data;
256
257//------------------------------------------------------------------------------
258
259void SYS_DATA_Init(void);
260
261#ifdef __cplusplus
262}
263#endif
264
265#endif // __SYS_DATA_H
Note: See TracBrowser for help on using the repository browser.