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

Improve battery voltage sag compensation / power supply impedance calculation #3364

Merged
merged 3 commits into from Jun 21, 2018

Conversation

Projects
None yet
3 participants
@shellixyz
Copy link
Collaborator

commented Jun 13, 2018

02

03

04

{
static timeUs_t recordTimestamp = 0;
static int32_t amperageRecord;
static uint16_t vbatRecord;
static uint8_t impedanceSampleCount = 0;
static pt1Filter_t impedanceFilterState = PT1_FILTER_INITIALIZER;

This comment has been minimized.

Copy link
@digitalentity

digitalentity Jun 15, 2018

Member

Initializing filter with RC = 0 doesn't make much sense. I don't see where in the code filter is properly initialized with cutoff frequency.

This comment has been minimized.

Copy link
@shellixyz

shellixyz Jun 15, 2018

Author Collaborator

It is done line 401
sagCompVBatFilterState.RC = sagCompensatedVBatSample < sagCompVBatFilterState.state ? 40 : 500;

I will add functions to access the time constant and last value.

}

if (impedanceSampleCount > IMPEDANCE_STABLE_SAMPLE_COUNT_THRESH) {
powerSupplyImpedance = lrintf(impedanceFilterState.state);

This comment has been minimized.

Copy link
@digitalentity

digitalentity Jun 15, 2018

Member

This should be made more generic. Accessing filter internal structure is unreasonable and inherently unsafe. Please consider adding a pr1FilterGetLastOutput API or similar.

@digitalentity digitalentity added this to the 2.0 milestone Jun 15, 2018

@digitalentity

This comment has been minimized.

Copy link
Member

commented Jun 15, 2018

Maybe we can also expose calculated battery impedance as an OSD value or log it in a slow blackbox frame?

@shellixyz

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 15, 2018

Sure why not.

@shellixyz shellixyz force-pushed the shellixyz:sag_comp_bat_voltage_improved branch from 35876db to ce47940 Jun 15, 2018

@shellixyz

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 15, 2018

I made the requested changes. How would you like the impedance to be formatted on the OSD ? Should we add an ohm symbol ?

@shellixyz

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 15, 2018

Please merge #2863 to avoid conflicts when adding OSD items

@shellixyz shellixyz force-pushed the shellixyz:sag_comp_bat_voltage_improved branch 5 times, most recently from 76bf18a to 2407fd7 Jun 15, 2018

@shellixyz shellixyz force-pushed the shellixyz:sag_comp_bat_voltage_improved branch from 2407fd7 to 65b7ccc Jun 19, 2018

@fiam fiam merged commit 6ec336c into iNavFlight:development Jun 21, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.