Error in ADC driver
Hi there,
thanks for this project. Very well structured.
Ever wondered why ADC measurements are off? And can get negative? The ADC equation in the TI TRM is formulated backwards (adc counts as function of input voltage). It has been implemented like this in adc.c. That is wrong. The function needs to be inverted first, so:
static float ADC_ConvertToVoltage(u16 adcCounts)
{
/** For details to equation see Equation 32 in Technical Reference Manual SPNU563A - March 2018 page 852 */
float result_mV = (((adcCounts + 0.5f) * (ADC_VREFHIGH_mV - ADC_VREFLOW_mV)) / ADC_CONV_FACTOR_12BIT) + ADC_VREFLOW_mV;
return result_mV;
}
I have also removed the cast in the call to ADC_ConvertToVoltage and renamed that function appropriately.
What is your policy on pull requests? Do you like reports like this or would you rather have a PR?
Best
Dear @juleq,
many thanks for pointing us to that. We will have a look at this and come back, as soon as we have news.
What is your policy on pull requests? Do you like reports like this or would you rather have a PR?
We currently do not accept Pull requests in this project (see .github/PULL_REQUEST_TEMPLATE.md), but we try to fix the reported issues on GitHub as soon as possible.
Best regards, The foxBMS Team
Dear @juleq,
We have verified, that this is indeed a bug. Thanks again for creating this issue!
We have internally fixed this bug and this fix will be part of the upcoming release.
Best regards, The foxBMS Team
Thanks for your feedback. Great project 👌.
Dear @juleq ,
thanks again for pointing us to that issue. We fixed it in the release v1.4.1.
Best regards, The foxBMS Team