1.判断电池电压0值的计算
This commit is contained in:
parent
8b7bf1b137
commit
62b0540034
|
@ -104,7 +104,10 @@ UINT32 sf_battery_voltage_convert(UINT32 resistanceGnd, UINT32 resistanceVin, UI
|
||||||
|
|
||||||
//volt = 27 * adcVal * (resistanceGnd + resistanceVin) / resistanceGnd / 511;
|
//volt = 27 * adcVal * (resistanceGnd + resistanceVin) / resistanceGnd / 511;
|
||||||
//volt = 27 * adcVal * (resistanceGnd + resistanceVin) / resistanceGnd / 2696;
|
//volt = 27 * adcVal * (resistanceGnd + resistanceVin) / resistanceGnd / 2696;
|
||||||
volt = (27 * adcVal + 554) / 539;
|
if(adcVal)
|
||||||
|
{
|
||||||
|
volt = (27 * adcVal + 554) / 539;
|
||||||
|
}
|
||||||
return volt;
|
return volt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +129,10 @@ UINT32 sf_aa_battery_voltage_convert(UINT32 resistanceGnd, UINT32 resistanceVin,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//volt = 27 * adcVal * (resistanceGnd + resistanceVin) / resistanceGnd / 511;
|
//volt = 27 * adcVal * (resistanceGnd + resistanceVin) / resistanceGnd / 511;
|
||||||
volt = (27 * adcVal + 3097) / 531;
|
if(adcVal)
|
||||||
|
{
|
||||||
|
volt = (27 * adcVal + 3097) / 531;
|
||||||
|
}
|
||||||
return volt;
|
return volt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +142,10 @@ UINT32 sf_battery_convert_to_adc(UINT32 resistanceGnd, UINT32 resistanceVin, UIN
|
||||||
|
|
||||||
//adcVal = volt * resistanceGnd * 511 / 27 / (resistanceGnd + resistanceVin);
|
//adcVal = volt * resistanceGnd * 511 / 27 / (resistanceGnd + resistanceVin);
|
||||||
//adcVal = volt * resistanceGnd * 2696 / 27 / (resistanceGnd + resistanceVin);
|
//adcVal = volt * resistanceGnd * 2696 / 27 / (resistanceGnd + resistanceVin);
|
||||||
adcVal = (volt * 539 - 554) / 27;
|
if(volt)
|
||||||
|
{
|
||||||
|
adcVal = (volt * 539 - 554) / 27;
|
||||||
|
}
|
||||||
return adcVal;
|
return adcVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +155,10 @@ UINT32 sf_aa_battery_convert_to_adc(UINT32 resistanceGnd, UINT32 resistanceVin,
|
||||||
|
|
||||||
//adcVal = volt * resistanceGnd * 511 / 27 / (resistanceGnd + resistanceVin);
|
//adcVal = volt * resistanceGnd * 511 / 27 / (resistanceGnd + resistanceVin);
|
||||||
//adcVal = volt * resistanceGnd * 2696 / 27 / (resistanceGnd + resistanceVin);
|
//adcVal = volt * resistanceGnd * 2696 / 27 / (resistanceGnd + resistanceVin);
|
||||||
adcVal = (volt * 531 - 3097) / 27;
|
if(volt)
|
||||||
|
{
|
||||||
|
adcVal = (volt * 531 - 3097) / 27;
|
||||||
|
}
|
||||||
return adcVal;
|
return adcVal;
|
||||||
}
|
}
|
||||||
UINT32 sf_get_max_value(UINT32 *_ValueList)
|
UINT32 sf_get_max_value(UINT32 *_ValueList)
|
||||||
|
|
|
@ -108,7 +108,10 @@ UINT32 sf_battery_voltage_convert(UINT32 resistanceGnd, UINT32 resistanceVin, UI
|
||||||
|
|
||||||
//volt = 27 * adcVal * (resistanceGnd + resistanceVin) / resistanceGnd / 511;
|
//volt = 27 * adcVal * (resistanceGnd + resistanceVin) / resistanceGnd / 511;
|
||||||
//volt = 27 * adcVal * (resistanceGnd + resistanceVin) / resistanceGnd / 2696;
|
//volt = 27 * adcVal * (resistanceGnd + resistanceVin) / resistanceGnd / 2696;
|
||||||
volt = (27 * adcVal + 554) / 539;
|
if(adcVal)
|
||||||
|
{
|
||||||
|
volt = (27 * adcVal + 554) / 539;
|
||||||
|
}
|
||||||
return volt;
|
return volt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +133,10 @@ UINT32 sf_aa_battery_voltage_convert(UINT32 resistanceGnd, UINT32 resistanceVin,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//volt = 27 * adcVal * (resistanceGnd + resistanceVin) / resistanceGnd / 511;
|
//volt = 27 * adcVal * (resistanceGnd + resistanceVin) / resistanceGnd / 511;
|
||||||
volt = (27 * adcVal + 3097) / 531;
|
if(adcVal)
|
||||||
|
{
|
||||||
|
volt = (27 * adcVal + 3097) / 531;
|
||||||
|
}
|
||||||
return volt;
|
return volt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +146,10 @@ UINT32 sf_battery_convert_to_adc(UINT32 resistanceGnd, UINT32 resistanceVin, UIN
|
||||||
|
|
||||||
//adcVal = volt * resistanceGnd * 511 / 27 / (resistanceGnd + resistanceVin);
|
//adcVal = volt * resistanceGnd * 511 / 27 / (resistanceGnd + resistanceVin);
|
||||||
//adcVal = volt * resistanceGnd * 2696 / 27 / (resistanceGnd + resistanceVin);
|
//adcVal = volt * resistanceGnd * 2696 / 27 / (resistanceGnd + resistanceVin);
|
||||||
adcVal = (volt * 539 - 554) / 27;
|
if(volt)
|
||||||
|
{
|
||||||
|
adcVal = (volt * 539 - 554) / 27;
|
||||||
|
}
|
||||||
return adcVal;
|
return adcVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +159,10 @@ UINT32 sf_aa_battery_convert_to_adc(UINT32 resistanceGnd, UINT32 resistanceVin,
|
||||||
|
|
||||||
//adcVal = volt * resistanceGnd * 511 / 27 / (resistanceGnd + resistanceVin);
|
//adcVal = volt * resistanceGnd * 511 / 27 / (resistanceGnd + resistanceVin);
|
||||||
//adcVal = volt * resistanceGnd * 2696 / 27 / (resistanceGnd + resistanceVin);
|
//adcVal = volt * resistanceGnd * 2696 / 27 / (resistanceGnd + resistanceVin);
|
||||||
adcVal = (volt * 531 - 3097) / 27;
|
if(volt)
|
||||||
|
{
|
||||||
|
adcVal = (volt * 531 - 3097) / 27;
|
||||||
|
}
|
||||||
return adcVal;
|
return adcVal;
|
||||||
}
|
}
|
||||||
UINT32 sf_get_max_value(UINT32 *_ValueList)
|
UINT32 sf_get_max_value(UINT32 *_ValueList)
|
||||||
|
@ -1659,9 +1671,14 @@ void sf_BatteryInfoSave(char *name, FST_FILE fd)
|
||||||
}*/
|
}*/
|
||||||
//printf("fileName:%s\n",SF_BATTERY_TEST_FILE);
|
//printf("fileName:%s\n",SF_BATTERY_TEST_FILE);
|
||||||
//fd = FileSys_OpenFile(SF_BATTERY_TEST_FILE, FST_OPEN_ALWAYS | FST_OPEN_WRITE);
|
//fd = FileSys_OpenFile(SF_BATTERY_TEST_FILE, FST_OPEN_ALWAYS | FST_OPEN_WRITE);
|
||||||
|
if(LiPolymerVoltageValTest)
|
||||||
LibatAdc = sf_battery_convert_to_adc(24, 100, LiPolymerVoltageValTest);
|
{
|
||||||
batAdc = sf_battery_convert_to_adc(24, 100, BatVoltageValTest);
|
LibatAdc = sf_battery_convert_to_adc(24, 100, LiPolymerVoltageValTest);
|
||||||
|
}
|
||||||
|
if(BatVoltageValTest)
|
||||||
|
{
|
||||||
|
batAdc = sf_aa_battery_convert_to_adc(24, 100, BatVoltageValTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sprintf(tmpBuf, "%s BatAdc=%lu BatVal=%lu LiBatAdc=%lu LiBatVal=%lu TemperAdc=%lu\r\n", name, batAdc, BatVoltageValTest, LibatAdc, LiPolymerVoltageValTest, TemperAdc);
|
sprintf(tmpBuf, "%s BatAdc=%lu BatVal=%lu LiBatAdc=%lu LiBatVal=%lu TemperAdc=%lu\r\n", name, batAdc, BatVoltageValTest, LibatAdc, LiPolymerVoltageValTest, TemperAdc);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user