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

Enable BATTx_options for AP_Periph builds if useful - Battery summing on a node #28630

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AlfieLockrey
Copy link

This PR adds a condition for the options parameter to be included in the build for AP_Periph firmware if AP_BATTERY_SUM_ENABLED is true.

This is a niche use case where a user is using a battery monitor sum of other monitor(s) and may want to be able to set the voltage source as minimum rather than average. Current builds do not include this options parameter as it is kept out of AP_Periph builds.

This has been tested on a MATEK L431 Periph CAN Node with the hwdef.dat file modified. I have verified that the options are included when define AP_BATTERY_SUM_ENABLED 1 is included and are not present when removed from the hwdef.dat.

Current hardware definitions for the L431 don't have these in by default however it may be beneficial to include them if they don't hinder other functionality. The inclusion of 4 adcs allows for voltage and current to be measured from two battery sources and combining them may be helpful for more complex or non-standard vehicles.

I have included the defined(HAL_BUILD_AP_PERIPH) as I was unsure of any consequences if the parameter is defined twice.

Enable the options parameter for the battery monitor on AP_Periph devices if they could be useful - ie, battery summing is enabled and in use on a node with more than one source for battery inputs.
Single definition for non periph builds or if AP_BATTERY_SUM_ENABLED
Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

Please squash all commits together and prefix with AP_Battery:

So perhaps

AP_Battery: include OPTIONS parameter on boards with SUM backend

It might be we actually just want to set it to (!defined(HAL_BUILD_AP_PERIPH)` and let the person creating the Perioph hwdef set the option in that hwdef.


#if !defined(HAL_BUILD_AP_PERIPH) || AP_BATTERY_SUM_ENABLED
Copy link
Contributor

Choose a reason for hiding this comment

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

Please create a fresh define name in AP_Battery_config.h.

// @Param: OPTIONS
// @DisplayName: Battery monitor options
// @Description: This sets options to change the behaviour of the battery monitor
// @Bitmask: 0:Ignore DroneCAN SoC, 1:MPPT reports input voltage and current, 2:MPPT Powered off when disarmed, 3:MPPT Powered on when armed, 4:MPPT Powered off at boot, 5:MPPT Powered on at boot, 6:Send resistance compensated voltage to GCS, 7:Allow DroneCAN InfoAux to be from a different CAN node, 9:Sum monitor measures minimum voltage instead of average
// @User: Advanced
AP_GROUPINFO("OPTIONS", 21, AP_BattMonitor_Params, _options, 0),
#endif // HAL_BUILD_AP_PERIPH
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

include the new define name on this line too

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.

3 participants