Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kostal: more debug output to get better understanding of temporal behaviour #644

Merged
merged 2 commits into from
Jan 12, 2025

Conversation

lewurm
Copy link
Collaborator

@lewurm lewurm commented Nov 27, 2024

Example:

FAKE Values going to inverter
SOH%: 99% , SOC%: 52% , Voltage: 370V , Max discharge power: 5000W , Max charge power: 5000W , Max temp: 6°C , Min temp: 5°C , Max cell voltage: 3596mV , Min cell voltage: 3500mV
[28357 ms] RX (dropped): 07 63 FF 02 FF 29 5E 02 16 00
FAKE Values going to inverter
SOH%: 99% , SOC%: 52% , Voltage: 370V , Max discharge power: 5000W , Max charge power: 5000W , Max temp: 6°C , Min temp: 5°C , Max cell voltage: 3596mV , Min cell voltage: 3500mV
[29177 ms] RX (dropped): 07 63 FF 02 FF 29 5E 02 16 00
[29997 ms] RX (dropped): 07 63 FF 02 FF 29 5E 02 16 00
FAKE Values going to inverter
SOH%: 99% , SOC%: 52% , Voltage: 370V , Max discharge power: 5000W , Max charge power: 5000W , Max temp: 6°C , Min temp: 5°C , Max cell voltage: 3596mV , Min cell voltage: 3500mV
[30817 ms] RX (dropped): 07 63 FF 02 FF 29 5E 02 16 00
FAKE Values going to inverter
SOH%: 99% , SOC%: 52% , Voltage: 370V , Max discharge power: 5000W , Max charge power: 5000W , Max temp: 6°C , Min temp: 5°C , Max cell voltage: 3596mV , Min cell voltage: 3500mV
[31637 ms] RX (dropped): 07 63 FF 02 FF 29 5E 02 16 00
FAKE Values going to inverter
SOH%: 99% , SOC%: 52% , Voltage: 370V , Max discharge power: 5000W , Max charge power: 5000W , Max temp: 6°C , Min temp: 5°C , Max cell voltage: 3596mV , Min cell voltage: 3500mV
[32458 ms] RX (dropped): 07 63 FF 02 FF 29 5E 02 16 00
FAKE Values going to inverter
SOH%: 99% , SOC%: 52% , Voltage: 370V , Max discharge power: 5000W , Max charge power: 5000W , Max temp: 6°C , Min temp: 5°C , Max cell voltage: 3596mV , Min cell voltage: 3500mV
[33278 ms] RX (dropped): 07 63 FF 02 FF 29 5E 02 16 00
FAKE Values going to inverter
SOH%: 99% , SOC%: 52% , Voltage: 370V , Max discharge power: 5000W , Max charge power: 5000W , Max temp: 6°C , Min temp: 5°C , Max cell voltage: 3596mV , Min cell voltage: 3500mV
[34100 ms] RX: 09 62 FF 02 FF 29 4A 08 23 00
[34100 ms] TX: 06 E2 FF 02 FF 29 01 08 A2 43 E4 70 8A 5C B5 02 D3 01 01 05 C8 41 C2 18 01 03 59 42 01 01 01 02 05 02 A0 01 01 02 2B 00

@lewurm lewurm force-pushed the kostal-rs485-more-debug branch from 68deed9 to def942e Compare November 27, 2024 19:32
#ifndef DEBUG_KOSTAL_RS485_DATA
#define DEBUG_KOSTAL_RS485_DATA
#endif
#endif
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should just drop DEBUG_KOSTAL_RS485_DATA and use DEBUG_VIA_USB for everything.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we have still heavy debugging going on, i prefer keeping DEBUG_KOSTAL_RS485_DATA and DEBUG_VIA_USB separated.

But that drop dropped is good, as i just figured out, that we must replace zero bytes of RX frame before rx processing, as otherwise we don't process eg. this: if (RS485_RXFRAME[6] == 0x5E) when RXFRAME[7] is 0x00

Also rx frame length may be more than 10 bytes, as there is sent EPOCH timestamp on one frame (actually never seen that, but seen on BYD code that)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that drop dropped is good, as i just figured out, that we must replace zero bytes of RX frame before rx processing, as otherwise we don't process eg. this: if (RS485_RXFRAME[6] == 0x5E) when RXFRAME[7] is 0x00

Yes, I'm handling that in my WIP branch: https://github.com/lewurm/Battery-Emulator/blob/1df27f4444ec0cfac8822256208db3e5ff780c06/Software/src/inverter/KOSTAL-RS485.cpp#L244-L249 and https://github.com/lewurm/Battery-Emulator/blob/1df27f4444ec0cfac8822256208db3e5ff780c06/Software/src/inverter/KOSTAL-RS485.cpp#L492-L497

But I don't want to submit that change just yet, because apparently some people have success with the current state and I want to understand why by adding additional logging. I suspect that it works by chance, because we send the right answer after a timeout:

if ((currentMillis - B1_last_millis) > INTERVAL_1_S) {
send_kostal(frameB1b, 8);
B1_delay = false;

Also rx frame length may be more than 10 bytes, as there is sent EPOCH timestamp on one frame (actually never seen that, but seen on BYD code that)

That should be covered by the dump_rs485_data_rx(" (!RX_allow)"); case, at least it would print it in several steps then. But indeed, I haven't seen it in any traces yet.

@lewurm lewurm force-pushed the kostal-rs485-more-debug branch from def942e to 0e4ec96 Compare November 27, 2024 19:38
@lewurm
Copy link
Collaborator Author

lewurm commented Dec 2, 2024

@dalathegreat this has been tested on a bmw i3+kostal setup. are you fine with the non-kostal changes?

@lewurm lewurm requested a review from dalathegreat December 4, 2024 14:05
@lenvm
Copy link
Collaborator

lenvm commented Dec 12, 2024

@lewurm, to get this PR approved more quickly, please remove the changes that are done in the battery file Software/src/battery/BMW-I3-BATTERY.cpp, and only leave the changes related to Kostal inverter.

@dalathegreat
Copy link
Owner

@lewurm , could you use the new logging method that the rest of the code uses? That would enable easier debugging, no need for the USB cable anymore!

Software/Software.ino Outdated Show resolved Hide resolved
@lewurm lewurm force-pushed the kostal-rs485-more-debug branch from a278d73 to 61f5bc6 Compare January 8, 2025 20:49
@lewurm lewurm requested a review from dalathegreat January 8, 2025 20:58
@lewurm
Copy link
Collaborator Author

lewurm commented Jan 8, 2025

Thanks! Please have another look @lenvm and @dalathegreat

Copy link
Owner

@dalathegreat dalathegreat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Hope this helps Kostal!

@dalathegreat dalathegreat merged commit 9afa16c into dalathegreat:main Jan 12, 2025
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants