From 66b9795b9e3e28a86ec23f625709b53d3212c709 Mon Sep 17 00:00:00 2001 From: kkkjtr Date: Tue, 16 Dec 2025 16:15:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=93=85=E9=85=B8=E7=94=B5?= =?UTF-8?q?=E6=B1=A0=E7=94=B5=E9=87=8F=E6=8D=A2=E7=AE=97=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E9=94=82=E7=94=B5=E6=B1=A0=E5=90=8E=E7=BB=AD=E5=BE=85?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom/control_out/src/control_out.c | 55 +++++++++++++++++--------- custom/jt808/inc/jt808_set_TermParam.h | 4 ++ custom/jt808/src/jt808_set_TermParam.c | 12 ++++++ 3 files changed, 53 insertions(+), 18 deletions(-) diff --git a/custom/control_out/src/control_out.c b/custom/control_out/src/control_out.c index 0c529b1..72584fc 100644 --- a/custom/control_out/src/control_out.c +++ b/custom/control_out/src/control_out.c @@ -110,34 +110,53 @@ void set_out_acc_percent(uint8_t percent){//1000000设置频率为10KHz // } // } -const uint16_t coulomp_voltage_table[11] = { - BAT_LEVEL_0PERCENT_VOLT, - BAT_LEVEL_10PERCENT_VOLT, - BAT_LEVEL_20PERCENT_VOLT, - BAT_LEVEL_30PERCENT_VOLT, - BAT_LEVEL_40PERCENT_VOLT, - BAT_LEVEL_50PERCENT_VOLT, - BAT_LEVEL_60PERCENT_VOLT, - BAT_LEVEL_70PERCENT_VOLT, - BAT_LEVEL_80PERCENT_VOLT, - BAT_LEVEL_90PERCENT_VOLT, - BAT_LEVEL_100PERCENT_VOLT, +const float coulomp_voltage_tablesSLA[3][21] = { + { // 4串 + 420.0f, 423.6f, 427.2f, 430.8f, 434.4f, 438.0f, 441.6f, 445.2f, 448.8f, 452.4f, + 456.0f, 459.6f, 463.2f, 466.8f, 470.4f, 474.0f, 477.6f, 481.2f, 484.8f, 488.4f, 492.0f + }, + { // 5串 + 525.0f, 529.5f, 534.0f, 538.5f, 543.0f, 547.5f, 552.0f, 556.5f, 561.0f, 565.5f, + 570.0f, 574.5f, 579.0f, 583.5f, 588.0f, 592.5f, 597.0f, 601.5f, 606.0f, 610.5f, 615.0f + }, + { // 6串 + 630.0f, 635.4f, 640.8f, 646.2f, 651.6f, 657.0f, 662.4f, 667.8f, 673.2f, 678.6f, + 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 i, percent; 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; } - if((volt >= coulomp_voltage_table[10])){ + if((volt >= voltage_table[20])){ return 100; } - for (i = 0; i < 10; i++) { - if((volt < coulomp_voltage_table[i+1]) && (volt >= coulomp_voltage_table[i])){ - step = (coulomp_voltage_table[i+1] - coulomp_voltage_table[i]) / 10.0; - base = coulomp_voltage_table[i]; + for (i = 0; i < 20; i++) { + if((volt < voltage_table[i+1]) && (volt >= voltage_table[i])){ + step = (voltage_table[i+1] - voltage_table[i]) / 10.0; + base = voltage_table[i]; 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); return (uint8_t)percent; diff --git a/custom/jt808/inc/jt808_set_TermParam.h b/custom/jt808/inc/jt808_set_TermParam.h index 2791d43..d878252 100644 --- a/custom/jt808/inc/jt808_set_TermParam.h +++ b/custom/jt808/inc/jt808_set_TermParam.h @@ -39,6 +39,8 @@ typedef enum { ID_SpeedCutLimit_B = 0xF007, //WORD 后退自动减速刹车距离 ID_Ban_Fence_Polygon_Delay_OFF = 0xF008, //BYTE 禁止围栏延时关闭时间, 单位秒 ID_RadarEN = 0xF009, //BYTE 雷达使能位, 0 代表关闭, 1 代表开启 2代表临时关闭 + ID_BatType = 0xF00A, //BYTE 电池类型,0代表铅酸电池,1代表锂电池 + ID_BatPack = 0xF00B, //DWORD 电池包电压,可设置成48v,60v,72v,或其他需要的电压 }set_TermParamID_t; typedef struct{ uint32_t HeartBeatInterval;// DWORD, 终端心跳发送间隔(s) @@ -53,6 +55,7 @@ typedef struct{ uint8_t CarPlateColor;//车牌颜色,按照 JT/T415-2006 的 5.4.12 uint8_t RadarEN; // 雷达使能位, 0 代表关闭, 1 代表开启 + uint8_t BatType; // 电池类型,0代表铅酸电池,1代表锂电池 uint32_t ManagerACC; // 管理员模式油门0~100% uint32_t TouristACC; // 游客模式油门0~100% uint32_t SpeedCutACC; // 自动减速油门0~100% @@ -60,6 +63,7 @@ typedef struct{ uint32_t SpeedCutLimit; // 前进自动减速刹车距离 uint32_t BrakeLimit_B; // 后退刹车距离 uint32_t SpeedCutLimit_B; // 后退自动减速刹车距离 + uint32_t BatPack_V; // 电池包电压,可设置成48v,60v,72v,或其他需要的电压 uint8_t Ban_Fence_Polygon_Delay_OFF; // 禁止围栏延时关闭时间, 单位秒 }set_TermParam_t; diff --git a/custom/jt808/src/jt808_set_TermParam.c b/custom/jt808/src/jt808_set_TermParam.c index e762286..80a747a 100644 --- a/custom/jt808/src/jt808_set_TermParam.c +++ b/custom/jt808/src/jt808_set_TermParam.c @@ -51,6 +51,8 @@ static const ParamDescriptor param_descriptors[] = { {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_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; 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:{ // TODO: 未知参数 return -1;