Skip to content

refactor(radio): unified battery and RTC voltage #6065

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

Merged
merged 2 commits into from
Apr 27, 2025
Merged

refactor(radio): unified battery and RTC voltage #6065

merged 2 commits into from
Apr 27, 2025

Conversation

raphaelcoeffic
Copy link
Member

Summary of changes:

  • use the same voltage conversion formula for all targets
  • fix RTC battery bridge on H7 targets

@philmoz
Copy link
Collaborator

philmoz commented Apr 7, 2025

😕

  • TX16S - 275.99V (should be 7.68V)
  • T15 - 358.14V (should be 8.02V)
  • EL18 - 527.08V (should be 4.13V)

@raphaelcoeffic
Copy link
Member Author

raphaelcoeffic commented Apr 7, 2025

Seems I forgot to adapt for how BATTERY_DIVIDER worked ($R1$ and $R2$ are unknown here):

$$BATTERY\_DIVIDER = ADC_{max} * \frac{R1}{R1 + R2} * \frac{10}{V_{ref}}$$

whereby $ADC_{max} = 2048$, as we're using filtered ADC values.

However, what we use now is something like this:

$$VBAT\_DIVIDER = \frac{R1 + R2}{R1}$$

So that gives us:

$$BATTERY\_DIVIDER = ADC_{max} * \frac{1}{VBAT\_DIVIDER} * \frac{10}{V_{ref}}$$

and finally:

$$VBAT\_DIVIDER = \frac{ADC_{max} * 10}{BATTERY\_DIVIDER * V_{ref}}$$

@raphaelcoeffic raphaelcoeffic added this to the 3.0 milestone Apr 8, 2025
@philmoz
Copy link
Collaborator

philmoz commented Apr 8, 2025

T15 is good now, haven't checked the others yet.

Copy link
Member

@pfeerick pfeerick left a comment

Choose a reason for hiding this comment

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

After minor rebase snaffu...
EL18 - unchanged
X9D+ - only minor vbat change (approx 0.3v), RTC unchanged
MT12 - only minor vbat change (approx 0.3v), RTC did go up, but is basically flat, so that could be some voltage bleed.
T14 - only minor vbat change (approx 0.2v), RTC unchanged
T15 - unchanged

@pfeerick pfeerick added enhancement ✨ New feature or request house keeping 🧹 Cleanup of code and house keeping and removed enhancement ✨ New feature or request labels Apr 27, 2025
@pfeerick pfeerick merged commit b52e771 into main Apr 27, 2025
53 checks passed
@pfeerick pfeerick deleted the adc-fixes branch April 27, 2025 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
house keeping 🧹 Cleanup of code and house keeping
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants