diff --git a/include/param_prj.h b/include/param_prj.h index f4ac6f4..c6b113c 100644 --- a/include/param_prj.h +++ b/include/param_prj.h @@ -39,14 +39,14 @@ */ //Define a version string of your firmware here -#define VER 1.19.R +#define VER 1.20.R /* Entries must be ordered as follows: 1. Saveable parameters (id != 0) 2. Temporary parameters (id = 0) 3. Display values */ -//Next param id (increase when adding new parameter!): 23 +//Next param id (increase when adding new parameter!): 24 //Next value Id: 2051 /* category name unit min max default id */ #define PARAM_LIST \ @@ -63,6 +63,7 @@ PARAM_ENTRY(CAT_CHARGER, enablepol, POLARITIES,0, 1, 0, 18 ) \ PARAM_ENTRY(CAT_CHARGER, idckp, "", 0, 10000, 1, 20 ) \ PARAM_ENTRY(CAT_CHARGER, idcki, "", 0, 10000, 10, 21 ) \ + PARAM_ENTRY(CAT_CHARGER, vcuchglim, "%", 20, 100, 80, 23 ) \ VALUE_ENTRY(state, STATES, 2043 ) \ VALUE_ENTRY(uptime, "s", 2048 ) \ VALUE_ENTRY(lasterr, errorListString, 2002 ) \ @@ -125,9 +126,9 @@ #define CAT_COMM "Communication" // SKUDAK customization suffix: bump on every Skudak-side change so the OpenInverter -// web UI shows a distinct version (e.g. "4=1.19.R-S2") and we can visually confirm +// web UI shows a distinct version (e.g. "4=1.20.R-S3") and we can visually confirm // the right firmware is flashed. Match the stm32-sine -S convention. -#define VERSTR STRINGIFY(4=VER-S2) +#define VERSTR STRINGIFY(4=VER-S3) /***** enums ******/ diff --git a/src/chargercan.cpp b/src/chargercan.cpp index f289c29..c52f086 100644 --- a/src/chargercan.cpp +++ b/src/chargercan.cpp @@ -100,6 +100,13 @@ void ChargerCAN::MapMessages(CanMap* can) can->AddSend(Param::idc, 0x109, 24, 16, 1); can->AddSend(Param::opmode, 0x109, 40, 3, 5); //Set charging and connlock at once + /***** SKUDAK VCU command RX (0x212) — SKUDAK-516 user ChargeLimit *****/ + // Byte 0: ChargeLimit_pct (0-100). Bytes 1-7 reserved 0x00. + // Param::Change(vcuchglim) translates % to udcspnt setpoint (see src/main.cpp). + // VCU broadcasts every 200 ms once teslacharger detected; charger holds last + // value if VCU goes silent. + can->AddRecv(Param::vcuchglim, 0x212, 0, 8, 1); + /***** SKUDAK VCU telemetry (0x211) — SKUDAK-448 expanded charger telemetry *****/ // Byte 0: state (0=Off, 1=WaitStart, 2=Enable, 3=Activate, 4=Run, 5=Stop) // Bytes 1-2: udc (V, gain=1) diff --git a/src/main.cpp b/src/main.cpp index 188d487..24ab944 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,6 +114,27 @@ void Param::Change(Param::PARAM_NUM paramNum) spnt = MIN(Param::Get(Param::idcspnt), Param::Get(Param::idclim)); dcCurController.SetRef(spnt); break; + case Param::vcuchglim: + { + // SKUDAK-516: VCU sends user-set ChargeLimit_pct on CAN 0x212. Translate + // percentage to udcspnt (DC voltage setpoint) using a linear cell-voltage + // ramp. 96-cell pack (Tesla LDU / VW MEB compatible): + // pct=20 → 3.30 V/cell × 96 = 316.8 V (storage / deep-cycle floor) + // pct=80 → 3.94 V/cell × 96 = 378.0 V (recommended daily ceiling) + // pct=100 → 4.15 V/cell × 96 = 398.4 V (matches existing udclim default) + // Endpoints chosen to be safe across Tesla/VW/Volt2 chemistries — adjust + // here if a particular pack needs a tighter range. The VCU validates 20-100 + // before transmit so out-of-range values never arrive. + int pct = Param::GetInt(Param::vcuchglim); + if (pct < 20) pct = 20; + if (pct > 100) pct = 100; + const float CELL_LOW_V = 3.30f; + const float CELL_HIGH_V = 4.15f; + const float CELL_COUNT = 96.0f; + float cell_target = CELL_LOW_V + (CELL_HIGH_V - CELL_LOW_V) * (pct - 20) / 80.0f; + Param::SetFloat(Param::udcspnt, cell_target * CELL_COUNT); + break; + } default: //Handle general parameter changes here. Add paramNum labels for handling specific parameters break;