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

Improvement: Send cellmV when cell events are raised #298

Closed
wants to merge 1 commit into from

Conversation

dalathegreat
Copy link
Owner

@dalathegreat dalathegreat commented May 12, 2024

What

This PR makes the cell over/under/deviation events easier to troubleshoot. Added to all battery types that were missing this.

Why

Now when for instance a cell overvoltage event is raised, it is hard to know what the value of the cell was when it occured.

How

Since the event can only get an u8 parsed (0-255), we shrink the cellvoltage by 20, and when reviewing the events you can simply add *20 to the value. (4250mV sent as 4250/20 = 212)

@@ -455,36 +455,36 @@ void update_values_battery() { //This function maps all the values fetched via

// Start checking safeties. First up, cellvoltages!
if (battery_cell_deviation_mV > MAX_CELL_DEVIATION_MV) {
set_event(EVENT_CELL_DEVIATION_HIGH, 0);
set_event(EVENT_CELL_DEVIATION_HIGH, battery_cell_deviation_mV);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If (for some erroneous reason) min-cell voltage is 0, you will not see it here as the value will wrap around.
Perhaps some function to make value here somewhat logarithmic. Like 0-240 is mV difference and from 241 and up it is increasing value with 1 means 20mV for each. Another option is to make event values 16 bit?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I think this is good enough, until we get the event value 16bit. Better than a 0, and sure, the edge cases wont be handled perfectly, but better than before atleast :)

@dalathegreat
Copy link
Owner Author

Scrapping this PR, will rewrite it as a general safety handler to get rid of battery specific implementations!

@dalathegreat dalathegreat deleted the bugfix/leaf-cellvoltage-alert branch May 12, 2024 21:05
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.

2 participants