-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
ADC driver report back vref alone with sample count #14136
ADC driver report back vref alone with sample count #14136
Conversation
Addition: Why ADC should report vref instead of lsb voltage: And what is current status of ADC: |
1641807
to
7e8f1ea
Compare
ba39b0e
to
b0f6b42
Compare
I have done it through the second way. It is able to merge as currently it has no effect on anything. The actual vref can be provided in any time. Before it is provided, hard-coded value should work. But, I still need some conformation about default vref value of each boards, which is marked with TODO. |
b0f6b42
to
9cfd1c1
Compare
Back to the first commit again. |
b5e5700
to
147adea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SalimTerryLi - Thank you this is great. See inline comments.
A board_config represents the wiring of the SOC per board. This includes what ADC channels are used and what the ref voltage is.
Therefore that constant needs to come form board_common.h and be overridden by the board that do not use the default in board_config.h
Please add that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SalimTerryLi - can we kill off?
#ifndef BOARD_ADC_POS_REF_V_FOR_CURRENT_CHAN
#define BOARD_ADC_POS_REF_V_FOR_CURRENT_CHAN (3.3f) // Reference voltage for reading out the current channel #define BOARD_ADC_POS_REF_V_FOR_CURRENT_CHAN (3.3f) // Reference voltage for reading out the current channel
#endif #endif
#ifndef BOARD_ADC_POS_REF_V_FOR_VOLTAGE_CHAN #ifndef BOARD_ADC_POS_REF_V_FOR_VOLTAGE_CHAN
#define BOARD_ADC_POS_REF_V_FOR_VOLTAGE_CHAN (3.3f) // Reference voltage for reading out the voltage channel #define BOARD_ADC_POS_REF_V_FOR_VOLTAGE_CHAN (3.3f) // Reference voltage for reading out the voltage channel
#endif #endif
I'll do that in the next PR #14087. |
This reverts commit 93691fbbd55a1b8da8c190e225b318067d90399b.
This reverts commit 9cfd1c173cda51495f766a3f678c2202d67725fd.
This reverts commit edb7f7603e4471163ffb0fc6fc62ad2e30336e91.
Co-Authored-By: David Sidrane <[email protected]>
Co-Authored-By: David Sidrane <[email protected]>
047f400
to
f6cd24f
Compare
Describe problem solved by this pull request
Current ADC system does not provide reference voltage in any way. This PR focuses on introduce the v_ref in to ADC, potentially improve the ADC accuracy.
Describe your solution
I'm adding this new arch side function
float px4_arch_adc_reference_v(unsigned channel)
to get vref properly provided.This function should be implemented differently on each board. On the side of stm32, this function should sample the internal 1.2V reference and apply factory calibration to get the true vref level.
Describe possible alternatives
In short term a fixed value can be set to calculate ADC results, but dynamically calculated value helps improving ADC accuracy.
vref would be provided within
px4_arch_adc_sample
.Test data / coverage
An idea around system structure. No test available.
Additional context
This is another forward dependency of #14087
If this idea has certain advanced nature that is worth to introduce, I'm ask for help from someone who is experienced in stm32 development to implement that function on stm32_common and stm32h7 platforms.