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

analog_battery: add option for filter #23987

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AlexKlimaj
Copy link
Member

This adds the option to filter the adc output of voltage and current.

When pulling voltage from the on board voltage divider and current from an ESC current shunt, the noise can be very high.

https://review.px4.io/plot_app?log=96629307-87c9-4f68-a112-b49e2abe34ac#Nav-Power

Raw voltage vs moving average of 10.
image

Raw current vs on board battery lib average current. And ESC reported current from the same shunt vs moving average of 25.
image

@AlexKlimaj AlexKlimaj requested a review from dagar November 20, 2024 00:29
@dagar
Copy link
Member

dagar commented Nov 20, 2024

What about tuning the existing filters already in Battery (AnalogBattery inherits) instead?

const float expected_filter_dt = static_cast<float>(sample_interval_us) / 1_s;
_current_average_filter_a.setParameters(expected_filter_dt, 50.f);
_ocv_filter_v.setParameters(expected_filter_dt, 1.f);
_cell_voltage_filter_v.setParameters(expected_filter_dt, 1.f);

@AlexKlimaj
Copy link
Member Author

Hm, those filters won't adjust the current or voltage reading.

This would still be the data.
image
image

@AlexKlimaj AlexKlimaj force-pushed the pr-adc-battery-filter branch from cdc6fc4 to a0196ae Compare November 20, 2024 22:16
@dagar
Copy link
Member

dagar commented Nov 21, 2024

I would do this with an actual AlphaFilter.

AlphaFilter<float> _cell_voltage_filter_v;

I can help you do it quickly if it's not clear.

@AlexKlimaj AlexKlimaj force-pushed the pr-adc-battery-filter branch from a0196ae to 8bd9e34 Compare November 21, 2024 21:03
@AlexKlimaj
Copy link
Member Author

@AlexKlimaj
Copy link
Member Author

I can probably use a much shorter filter window.

@mrpollo mrpollo force-pushed the pr-adc-battery-filter branch from 8bd9e34 to 0c53dac Compare November 22, 2024 15:40
@AlexKlimaj AlexKlimaj force-pushed the pr-adc-battery-filter branch from 0c53dac to 1484982 Compare November 22, 2024 18:04
@AlexKlimaj
Copy link
Member Author

@dagar any more input?

@AlexKlimaj AlexKlimaj force-pushed the pr-adc-battery-filter branch from 1484982 to 42f705b Compare December 18, 2024 16:48
@AlexKlimaj AlexKlimaj force-pushed the pr-adc-battery-filter branch from 42f705b to 3dfb36e Compare December 18, 2024 16:49
@AlexKlimaj
Copy link
Member Author

Updated with the new per update dt.

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