电池电量与电压映射关系的建立
unsigned int const bat_capacity_table[TABLE_SIZE][2]=
{
{4150, 100}, {4100, 96},
{4050, 92}, {4020, 88},
{3980, 83}, {3950, 79},
{3920, 75}, {3900, 71},
{3860, 67}, {3830, 63},
{3810, 58}, {3770, 50},
{3750, 42}, {3720, 33},
{3700, 25}, {3640, 17},
{3580, 8}, {3000, 0},
}
unsigned int charger_check_voltage(uint16 bat_voltage)
{
uint16 voltage_level = 0;
uint16 index = 0;
for(index = 0;index < TABLE_SIZE - 1;index++)
{
if(bat_voltage <= bat_capacity_table[index][0] &&
(bat_voltage > bat_capacity_table[index+1][0]))
{
voltage_level = bat_capacity_table[index+1][1]+
(bat_voltage-bat_capacity_table[index+1][0])/
(bat_capacity_table[index][0]-bat_capacity_table[index+1][0])*
(bat_capacity_table[index][1]-bat_capacity_table[index+1][1]);
break;
}
}
if(bat_voltage <= bat_capacity_table[TABLE_SIZE-1][0])
{
voltage_level = bat_capacity_table[TABLE_SIZE-1][0]);
}
if(bat_voltage >= bat_capacity_table[0][0])
{
voltage_level = bat_capacity_table[0][0]);
}
return voltage_level;
}
阅读(1478) | 评论(1) | 转发(1) |