更新铅酸电池电量换算方式,锂电池后续待更新
This commit is contained in:
parent
c7c116f16f
commit
66b9795b9e
|
|
@ -110,34 +110,53 @@ void set_out_acc_percent(uint8_t percent){//1000000设置频率为10KHz
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const uint16_t coulomp_voltage_table[11] = {
|
const float coulomp_voltage_tablesSLA[3][21] = {
|
||||||
BAT_LEVEL_0PERCENT_VOLT,
|
{ // 4串
|
||||||
BAT_LEVEL_10PERCENT_VOLT,
|
420.0f, 423.6f, 427.2f, 430.8f, 434.4f, 438.0f, 441.6f, 445.2f, 448.8f, 452.4f,
|
||||||
BAT_LEVEL_20PERCENT_VOLT,
|
456.0f, 459.6f, 463.2f, 466.8f, 470.4f, 474.0f, 477.6f, 481.2f, 484.8f, 488.4f, 492.0f
|
||||||
BAT_LEVEL_30PERCENT_VOLT,
|
},
|
||||||
BAT_LEVEL_40PERCENT_VOLT,
|
{ // 5串
|
||||||
BAT_LEVEL_50PERCENT_VOLT,
|
525.0f, 529.5f, 534.0f, 538.5f, 543.0f, 547.5f, 552.0f, 556.5f, 561.0f, 565.5f,
|
||||||
BAT_LEVEL_60PERCENT_VOLT,
|
570.0f, 574.5f, 579.0f, 583.5f, 588.0f, 592.5f, 597.0f, 601.5f, 606.0f, 610.5f, 615.0f
|
||||||
BAT_LEVEL_70PERCENT_VOLT,
|
},
|
||||||
BAT_LEVEL_80PERCENT_VOLT,
|
{ // 6串
|
||||||
BAT_LEVEL_90PERCENT_VOLT,
|
630.0f, 635.4f, 640.8f, 646.2f, 651.6f, 657.0f, 662.4f, 667.8f, 673.2f, 678.6f,
|
||||||
BAT_LEVEL_100PERCENT_VOLT,
|
684.0f, 689.4f, 694.8f, 700.2f, 705.6f, 711.0f, 716.4f, 721.8f, 727.2f, 732.6f, 738.0f
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const float coulomp_voltage_tablesLi[3][21] = {
|
||||||
|
{ // 4串
|
||||||
|
|
||||||
|
},
|
||||||
|
{ // 5串
|
||||||
|
|
||||||
|
},
|
||||||
|
{ // 6串
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t pmu_voltage_to_percent(uint32_t volt){//电压转百分比
|
uint8_t pmu_voltage_to_percent(uint32_t volt){//电压转百分比
|
||||||
uint8_t i, percent;
|
uint8_t i, percent;
|
||||||
float step, base;
|
float step, base;
|
||||||
if((volt < coulomp_voltage_table[0])){
|
uint32_t table_index;
|
||||||
|
table_index = jt808_term_param_item.set_term_param.BatPack_V;
|
||||||
|
const float* voltage_table = coulomp_voltage_tablesSLA[table_index];
|
||||||
|
|
||||||
|
if((volt < voltage_table[0])){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if((volt >= coulomp_voltage_table[10])){
|
if((volt >= voltage_table[20])){
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 10; i++) {
|
for (i = 0; i < 20; i++) {
|
||||||
if((volt < coulomp_voltage_table[i+1]) && (volt >= coulomp_voltage_table[i])){
|
if((volt < voltage_table[i+1]) && (volt >= voltage_table[i])){
|
||||||
step = (coulomp_voltage_table[i+1] - coulomp_voltage_table[i]) / 10.0;
|
step = (voltage_table[i+1] - voltage_table[i]) / 10.0;
|
||||||
base = coulomp_voltage_table[i];
|
base = voltage_table[i];
|
||||||
percent = (10 * i) + (volt - base) / step;
|
percent = (10 * i) + (volt - base) / step;
|
||||||
// DEBUG("\n\ni:%d,volt:%d,step:%02.2f,base:%02.2f,percent:%d\n\n",i,volt,step,base,percent);
|
// DEBUG("\n\ni:%d,volt:%d,step:%02.2f,base:%02.2f,percent:%d\n\n",i,volt,step,base,percent);
|
||||||
return (uint8_t)percent;
|
return (uint8_t)percent;
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ typedef enum {
|
||||||
ID_SpeedCutLimit_B = 0xF007, //WORD 后退自动减速刹车距离
|
ID_SpeedCutLimit_B = 0xF007, //WORD 后退自动减速刹车距离
|
||||||
ID_Ban_Fence_Polygon_Delay_OFF = 0xF008, //BYTE 禁止围栏延时关闭时间, 单位秒
|
ID_Ban_Fence_Polygon_Delay_OFF = 0xF008, //BYTE 禁止围栏延时关闭时间, 单位秒
|
||||||
ID_RadarEN = 0xF009, //BYTE 雷达使能位, 0 代表关闭, 1 代表开启 2代表临时关闭
|
ID_RadarEN = 0xF009, //BYTE 雷达使能位, 0 代表关闭, 1 代表开启 2代表临时关闭
|
||||||
|
ID_BatType = 0xF00A, //BYTE 电池类型,0代表铅酸电池,1代表锂电池
|
||||||
|
ID_BatPack = 0xF00B, //DWORD 电池包电压,可设置成48v,60v,72v,或其他需要的电压
|
||||||
}set_TermParamID_t;
|
}set_TermParamID_t;
|
||||||
typedef struct{
|
typedef struct{
|
||||||
uint32_t HeartBeatInterval;// DWORD, 终端心跳发送间隔(s)
|
uint32_t HeartBeatInterval;// DWORD, 终端心跳发送间隔(s)
|
||||||
|
|
@ -53,6 +55,7 @@ typedef struct{
|
||||||
uint8_t CarPlateColor;//车牌颜色,按照 JT/T415-2006 的 5.4.12
|
uint8_t CarPlateColor;//车牌颜色,按照 JT/T415-2006 的 5.4.12
|
||||||
|
|
||||||
uint8_t RadarEN; // 雷达使能位, 0 代表关闭, 1 代表开启
|
uint8_t RadarEN; // 雷达使能位, 0 代表关闭, 1 代表开启
|
||||||
|
uint8_t BatType; // 电池类型,0代表铅酸电池,1代表锂电池
|
||||||
uint32_t ManagerACC; // 管理员模式油门0~100%
|
uint32_t ManagerACC; // 管理员模式油门0~100%
|
||||||
uint32_t TouristACC; // 游客模式油门0~100%
|
uint32_t TouristACC; // 游客模式油门0~100%
|
||||||
uint32_t SpeedCutACC; // 自动减速油门0~100%
|
uint32_t SpeedCutACC; // 自动减速油门0~100%
|
||||||
|
|
@ -60,6 +63,7 @@ typedef struct{
|
||||||
uint32_t SpeedCutLimit; // 前进自动减速刹车距离
|
uint32_t SpeedCutLimit; // 前进自动减速刹车距离
|
||||||
uint32_t BrakeLimit_B; // 后退刹车距离
|
uint32_t BrakeLimit_B; // 后退刹车距离
|
||||||
uint32_t SpeedCutLimit_B; // 后退自动减速刹车距离
|
uint32_t SpeedCutLimit_B; // 后退自动减速刹车距离
|
||||||
|
uint32_t BatPack_V; // 电池包电压,可设置成48v,60v,72v,或其他需要的电压
|
||||||
uint8_t Ban_Fence_Polygon_Delay_OFF; // 禁止围栏延时关闭时间, 单位秒
|
uint8_t Ban_Fence_Polygon_Delay_OFF; // 禁止围栏延时关闭时间, 单位秒
|
||||||
}set_TermParam_t;
|
}set_TermParam_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,8 @@ static const ParamDescriptor param_descriptors[] = {
|
||||||
{ID_BrakeLimit_B, offsetof(set_TermParam_t, BrakeLimit_B), sizeof(uint32_t), 1},
|
{ID_BrakeLimit_B, offsetof(set_TermParam_t, BrakeLimit_B), sizeof(uint32_t), 1},
|
||||||
{ID_SpeedCutLimit_B, offsetof(set_TermParam_t, SpeedCutLimit_B), sizeof(uint32_t), 1},
|
{ID_SpeedCutLimit_B, offsetof(set_TermParam_t, SpeedCutLimit_B), sizeof(uint32_t), 1},
|
||||||
{ID_Ban_Fence_Polygon_Delay_OFF, offsetof(set_TermParam_t, Ban_Fence_Polygon_Delay_OFF), sizeof(uint8_t), 0},
|
{ID_Ban_Fence_Polygon_Delay_OFF, offsetof(set_TermParam_t, Ban_Fence_Polygon_Delay_OFF), sizeof(uint8_t), 0},
|
||||||
|
{ID_BatType, offsetof(set_TermParam_t, BatType), sizeof(uint8_t), 0},
|
||||||
|
{ID_BatPack, offsetof(set_TermParam_t, BatPack_V), sizeof(uint32_t), 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
// 释放参数链表
|
// 释放参数链表
|
||||||
|
|
@ -497,6 +499,16 @@ int jt808_setTermParam(set_TermParamID_t param_id, void *param, uint8_t param_le
|
||||||
jt808_term_param_item.set_term_param.RadarEN = param_val32 & 0xFF;
|
jt808_term_param_item.set_term_param.RadarEN = param_val32 & 0xFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ID_BatType:{// TODO: 电池种类
|
||||||
|
// JT808_DEBUG("RadarEN=%d", radar_en);
|
||||||
|
jt808_term_param_item.set_term_param.BatType = param_val32 & 0xFF;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ID_BatPack:{// TODO: 电池电压
|
||||||
|
// JT808_DEBUG("RadarEN=%d", radar_en);
|
||||||
|
jt808_term_param_item.set_term_param.BatPack_V = param_val32 ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:{
|
default:{
|
||||||
// TODO: 未知参数
|
// TODO: 未知参数
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue