I’ve been working for almost two weeks on a control solution for a Deye SUN-20 K.
Discharging is now more or less under control:
Select external power-limit mode 142 → 2
Enable Time-of-Use block 146 → 255 (all weekdays on)
Time-slot start 148 → 0 (00 : 00)
Time-slot end 149 → 2355 (23:55, single all-day slot)
Battery discharge-current limit 109 value in A
Power limit for the slot 154 value in W
Minimum SoC for the slot 166 → 5 %
Allow PV export (solar sell) 145 → 1
That setup basically works, but:
The Deye can’t cope with many Modbus writes.
With my 1 s cycle time I have to insert a 3-cycle pause after every write or the command is ignored.
There is a noticeable gap between Battery power (reg 590) and the target power set in reg 154.
The offset has to be adjusted dynamically.
Charging:
Setting 166 (SoC target) to its maximum does make the inverter accept charge commands, but the battery rarely draws more than ≈ 500 W.
There is obviously an internal control loop that I haven’t figured out yet.
You can force higher charge power by throttling the maximum export power with reg 143.
The battery then absorbs more PV power — but if the battery can’t take the full PV output, the inverter starts clipping PV.
I couldn’t find a reliable way to detect when the PV is actually clipping, so I can’t regulate right at the clipping point.
The SUN-20 K is a very touchy piece of hardware – poorly documented and, in my opinion, partly buggy.
Otherwise I can’t explain the behaviour shown in the attached image. There is actually no load (consumption) active