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

New feature: battery profiles #2749

Merged
merged 2 commits into from Jun 13, 2018

Conversation

shellixyz
Copy link
Collaborator

@shellixyz shellixyz commented Feb 12, 2018

Feature request #2673

Summary

  • 3 battery profiles supported by default
  • Profiles can be switched by stick commands: THR-UP+YAW-LEFT + PIT-CENTER+ROLL-LEFT(1)/PIT-UP+ROLL-CENTER(2)/PIT-CENTER+ROLL-RIGHT(3)
  • Profiles can be switched and configured through CMS
  • Profiles can be switched automatically on power-up based on battery voltage
  • If a profile bat_cells is 0 the cell count is calculated based on vbat_max_cell_voltage
  • With default config it is working just as before

Profile autoswitch

Automatic profile switching can be enabled with the bat_profile_autoswitch setting. The profile is chosen among profiles with number of cells bat_cells set to a value > 0. The automatically selected profile can be overridden if necessary with a stick command or through the CMS.

Example config

set bat_profile_autoswitch = ON

# battery_profile
battery_profile 1

set bat_cells = 3
set vbat_max_cell_voltage = 421
set vbat_warning_cell_voltage = 350
set vbat_min_cell_voltage = 330

# battery_profile
battery_profile 2

set bat_cells = 3
set vbat_max_cell_voltage = 411
set vbat_warning_cell_voltage = 300
set vbat_min_cell_voltage = 280

# battery_profile
battery_profile 3

set bat_cells = 4
set vbat_max_cell_voltage = 421
set vbat_warning_cell_voltage = 350
set vbat_min_cell_voltage = 330

Profile 1 is for a 3S Li-Po pack, profile 2 for a 3S Li-Ion pack and profile 3 for a 4S Li-Po pack.
With this configuration if the battery plugged in is less than 12.33V the profile 2 will be automatically selected else if the battery voltage is less than 12.63V the profile 1 will be automatically selected else if the battery voltage is less 16.84V the profile 3 will be automatically selected. If a matching profile can't be found the last manually selected profile is used.

@shellixyz
Copy link
Collaborator Author

shellixyz commented Feb 12, 2018

I don't know why the checks failed the OMNIBUS target compiles fine on my machine. Well... I know why. GCC 7.1.0 seems better at optimizing the RAM usage. Are we already at the F3's limits !?

Using built-in specs.
COLLECT_GCC=arm-none-eabi-g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/arm-none-eabi/7.1.0/lto-wrapper
Target: arm-none-eabi
Configured with: ../gcc-7.1.0/configure --prefix=/usr --mandir=/usr/share/man --with-pkgversion='Fedora 7.1.0-2.fc26' --with-bugurl=https://bugzilla.redhat.com/ --infodir=/usr/share/info --target=arm-none-eabi --enable-interwork --enable-multilib --with-python-dir=share/arm-none-eabi/gcc-7.1.0/python --with-multilib-list=rmprofile --enable-plugins --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --enable-languages=c,c++ --with-newlib --disable-nls --disable-shared --disable-threads --with-gnu-as --with-gnu-ld --with-gmp --with-mpfr --with-mpc --with-headers=yes --with-system-zlib --with-sysroot=/usr/arm-none-eabi
Thread model: single
gcc version 7.1.0 (Fedora 7.1.0-2.fc26)

@shellixyz
Copy link
Collaborator Author

I disabled the external barometer support for OMNIBUS for the checks to pass. It is not necessary with the GCC version 7.1.0 but the OMNIBUS board has an on-board barometer so it is not needed anyway.

@giacomo892
Copy link
Collaborator

Neat feature!
I came up with something you can add if bat_profile_autoswitch is enabled:
A series of long beeps after gyro calibration beeps reporting the profile number so the pilot can have an immediate feedback on the profile detection.

Could be very nice to report, optionally, the current profile on the OSD via the system messages function before arming.

@digitalentity digitalentity added this to the 2.0 milestone Feb 12, 2018
@shellixyz
Copy link
Collaborator Author

@giacomo892 Good ideas. I thought about beeping the profile number it but I'm not familiar with how the beeper code is working yet I'll take a look at it.

@digitalentity digitalentity modified the milestones: 2.0, Future Apr 16, 2018
@shellixyz
Copy link
Collaborator Author

Would this be merged in 2.0 if I rebase this PR ?

@digitalentity
Copy link
Member

digitalentity commented Jun 8, 2018 via email

@shellixyz
Copy link
Collaborator Author

I'm asking because it was ready long before 1.9.1 so I was not sure why it was not merged earlier. I will rebase it.

@shellixyz
Copy link
Collaborator Author

Rebased and bench tested again. Ready to merge

@digitalentity
Copy link
Member

It would be nice to have a possibility to entirely disable the possibility to switch battery profiles via sticks (as we do to PID profiles) -to prevent accidental switching.

@shellixyz
Copy link
Collaborator Author

Good idea. Battery profile selection is now only possible when the TX_PROF_SEL feature is enabled. I also updated the documentation.

@digitalentity digitalentity modified the milestones: Future, 2.0 Jun 13, 2018
@digitalentity digitalentity merged commit 4e2a114 into iNavFlight:development Jun 13, 2018
@CpeDratDoPC
Copy link

It would be a good idea to have a Scale and Offset current sensor set in each profile.
I have a KakuteF7 and my voltage offset changes, 3S-6S.

@teckel12
Copy link
Contributor

@CpeDratDoPC I believe it's a voltage divider, it shouldn't change for hight voltages (maybe just be more precise).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants