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

Show magADC values without re-scaling in Sensors Tab #3593

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

ctzsnooze
Copy link
Member

@ctzsnooze ctzsnooze commented Oct 1, 2023

Changes:

  • the Mag value shown in Configurator's Sensors tab now shows the un-modified magADC[axis] value, without any scaling. Previously the magADC values were divided by 1090, the LSB/Gauss sensitivity value for the HMC5883L. This sensitivity factor was applied to all mag units, regardless of their individual sensitivity factor. For example, the sensitivity for the QMC5883L is 3000 LSB/Gauss, and for the IST Mag, it is 330 LSB/Gauss. Using 1090 for these Mags resulted in incorrect Gauss values
  • removed the text - Ga from the title of the Mag data, since the value is no longer Gauss.
  • increased the available Y axis ranges, from 100 to 10,000. With a QMC, the default of 3000 LSB/Gauss results in peak magADC values of around 1700 or higher. Previously these peak values would have been clipped. Now the incoming Mag values can be visualised in their full range, even if the QMC is set to its maximum sensitivity of 12000 LSB/Gauss.

Fixes:

  • an issue where with a QMC5883L, the highest graph scaling option of 1.0 clipped the magnetic field strength values in the Sensors Mag graph, making it difficult to visualise the max and min values.
  • an issue where the reported value was supposed to be in Gauss, but the reported value was in fact only accurate in Gauss for the HMC5883L, for all other Mag units the reported value was incorrect.

Notes:

Using un-scaled magADC values greatly simplifies the calculation of the Mag Cal value to be used for a given axis.

If the user points a given axis directly into (parallel to) the field, it will return its most positive, or Maximum, value when the values of the other two axes are zero.

The Minimum value can be found by rotating the quad 180 degrees until it points directly away from (anti-parallel to) the field, and seeking out the most negative value, which again will be when the other two axes read zero.

The Cal value to use for that axis is the simple average of the two values, ie ((Max + Min)/2). For instance, if the Max value was 1800 and the Min was -1400, the cal value for the axis would be ((1800 - 1400)/2), or 200.

Once that calibration value is applied, a check can be made that the Max and Min values are numerically equal, by repeating the above test. In the above example, after applying a Cal value for the axis of 200, a re-check should show the Max of 1600 (1800 - 200) and the Min of -1600 (-1400 - 200).

As a simple check of an existing calibration, the Cal factor is correct when Max = -Min for each axis.

@sonarcloud
Copy link

sonarcloud bot commented Oct 1, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
3.5% 3.5% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@github-actions

This comment has been minimized.

@blckmn
Copy link
Member

blckmn commented Oct 2, 2023

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> FAIL
  • assigned to a milestone -> FAIL
  • cooling off period lapsed -> PASS
  • commit count less or equal to three -> PASS
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> FAIL
  • Tested label found -> FAIL
  • assigned to an approver -> FAIL
  • approver count at least three -> FAIL

@McGiverGim
Copy link
Member

The code is ok, but I think is better to "normalize" the data in the firmware part if possible. In this way the MSP command will always return Gauss.
Is there some benefit to return the raw data without normalize for the user?

@ctzsnooze ctzsnooze mentioned this pull request Oct 10, 2023
Copy link
Contributor

github-actions bot commented Nov 3, 2023

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within a week.

Copy link
Contributor

Pull request closed automatically as inactive.

@github-actions github-actions bot closed this Nov 10, 2023
@ctzsnooze ctzsnooze self-assigned this Nov 10, 2023
@ctzsnooze ctzsnooze reopened this Nov 10, 2023
Copy link

sonarcloud bot commented Nov 10, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
3.5% 3.5% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@ctzsnooze
Copy link
Member Author

Hi @McGiverGim - yes, there is benefit in using un-scaled values, because they are the values that are used to calculate the 'cal' values. So if, for instance, the min and max values on a given axis, when added and divided by two, are wrong by say -30, the cal value needs to be reduced by 30.

@ctzsnooze
Copy link
Member Author

I am re-opening because this should be merged.

Copy link
Contributor

Do you want to test this code? Here you have an automated build:
Betaflight-Configurator-Android
Betaflight-Configurator-Linux
Betaflight-Configurator-macOS
Betaflight-Configurator-Windows
WARNING: It may be unstable and result in corrupted configurations or data loss. Use only for testing!

@nerdCopter
Copy link
Member

Please post screenshots for those of us unable to test Mag

Copy link
Member

@nerdCopter nerdCopter left a comment

Choose a reason for hiding this comment

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

  • approving -- code visually reviewed only; i cannot test Mag

@haslinghuis haslinghuis added this to the 10.10.0 milestone Nov 10, 2023
@haslinghuis haslinghuis merged commit f65ea96 into betaflight:master Nov 10, 2023
13 of 14 checks passed
chmelevskij pushed a commit to chmelevskij/betaflight-configurator that referenced this pull request Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

5 participants