Documentation ¶
Overview ¶
Package lgresustatus provides routines to decode LG Resu 10 LV CANBus messages and generate the 'keep alive' message (typically send from an CANBus enabled device (for example the Schneider Conext Bridge or directly from an inverter) to the LG Resu 10 LV. The decoded result can be converted into a JSON message.
Note:
Not all messages can currently be decoded. Support for alarm bits (message id 0x359) and CANBus message id 0x354 is missing.
CANBus BMS Message format specifications:
1) Lithiumate BMS CANBus message format specification:
http://lithiumate.elithion.com/php/controller_can_specs.php
2) LG Resu 10 LV CANBus message format specification:
Index ¶
Constants ¶
const ( INV_KEEP_ALIVE uint32 = 0x305 BMS_LIMITS uint32 = 0x351 BMS_SERIAL_NUM uint32 = 0x354 BMS_SOC_SOH uint32 = 0x355 BMS_VOLT_AMP_TEMP uint32 = 0x356 BMS_WARN_ALARM uint32 = 0x359 )
Definition of the LG Resu 10 CANBus message id's
Variables ¶
var AlarmBitValues = []BitValue{
{"UNKNOWN_ALARM", 0xffff},
}
AlarmBitValues defines 16 alarm bits (currently unknown).
Raw CANBus message format:
00000359 8 ww WW aa AA 00 00 00 00
aa0-7 UNKNOWN AA0-7 UNKNOWN
var WarningBitValues = []BitValue{
{"WRN_ONLY_SUB_RELAY_COMMAND", 0x0001},
{"BATTERY_HIGH_VOLTAGE", 0x0002},
{"BATTERY_LOW_VOLTAGE", 0x0004},
{"BATTERY_HIGH_TEMP", 0x0008},
{"BATTERY_LOW_TEMP", 0x0010},
{"UNKNOWN_ww5", 0x0020},
{"UNKNOWN_ww6", 0x0040},
{"BATTERY_HIGH_CURRENT_DISCHARGE", 0x0080},
{"BATTERY_HIGH_CURRENT_CHARGE", 0x0100},
{"UNKNOWN_WW1", 0x0200},
{"UNKNOWN_WW2", 0x0400},
{"BMS_INTERNAL", 0x0800},
{"CELL_IMBALANCE", 0x1000},
{"ALARM_SUB_PACK2_ERROR", 0x2000},
{"ALARM_SUB_PACK1_ERROR", 0x4000},
{"UNKNOWN_WW7", 0x8000},
}
WarningBitValues defines 16 warning bits.
Raw CANBus message format:
00000359 8 ww WW aa AA 00 00 00 00
ww0 WRN_ONLY_SUB_RELAY_COMMAND ww1 BATTERY_HIGH_VOLTAGE ww2 BATTERY_LOW_VOLTAGE ww3 BATTERY_HIGH_TEMP ww4 BATTERY_LOW_TEMP ww5 UNKNOWN ww6 UNKNOWN ww7 BATTERY_HIGH_CURRENT_DISCHARGE WW0 BATTERY_HIGH_CURRENT_CHARGE WW1 UNKNOWN WW2 UNKNOWN WW3 BMS_INTERNAL WW4 CELL_IMBALANCE WW5 ALARM_SUB_PACK2_ERROR WW6 ALARM_SUB_PACK1_ERROR WW7 UNKNOWN
Note: Bitmasks are applied after converting the littleEndian representation of the first 2 bytes to the bigEndian representation.
Functions ¶
func CsvRecordHeader ¶
func CsvRecordHeader() (csvRecordHeader string)
CsvRecordHeader return a string containing the header for the CSV data record created with CsvRecord().
Types ¶
type LgResuStatus ¶
type LgResuStatus struct { // State Of Charge Soc uint16 `json:"soc"` // State Of Health Soh uint16 `json:"soh"` // Current battery voltage Voltage float32 `json:"voltage"` // Current battery current (positive value: battery charge current, // negative value: battery discharge current) Current float32 `json:"current"` // Battery temperature Temp float32 `json:"temp"` // Battery voltage limit (LG Resu 10 LV is a 14S battery, indiv. cell voltage allowed is // 4.12V -> 14 * 4.12V = 57.7V) MaxVoltage float32 `json:"maxVoltage"` // Maximal battery charge current (LG Resu 10 LV is a C = 189Ah battery, C/2 is approx. 90A) MaxChargeCurrent float32 `json:"maxChargeCurrent"` // Maximal battery discharge current (LG Resu 10 is a C = 189Ah battery, C/2 is approx. 90A) MaxDischargeCurrent float32 `json:"maxDischargeCurrent"` Warnings []string `json:"warnings"` Alarms []string `json:"alarms"` }
LgResuStatus contains metrics send by the LG Resu 10 LV.
func (*LgResuStatus) CreateKeepAliveMessage ¶
func (lgResu *LgResuStatus) CreateKeepAliveMessage() (id uint32, s []byte)
CreateKeepAliveMessage creates one 'keep alive' message (to be send to the LG Resu 10 LV).
func (*LgResuStatus) CsvRecord ¶
func (lgResu *LgResuStatus) CsvRecord(t time.Time) (csvRecord string)
CsvRecord return a string containing the key metrics (Timestamp, SOC, Voltage, Current) as CSV values.
func (*LgResuStatus) DecodeLgResuCanbusMessage ¶
func (lgResu *LgResuStatus) DecodeLgResuCanbusMessage(id uint32, s []byte)
DecodeLgResuCanbusMessage decodes messages send by the LG Resu 10 LV BMS and updates lgResu with new metric values.