forked from gary/BCU
2
0
Fork 0

fix shunt

This commit is contained in:
guzz 2025-04-22 18:20:14 +08:00
parent da78eb8f86
commit 7e580ed58c
6 changed files with 1872713 additions and 3261 deletions

View File

@ -196,7 +196,7 @@ int16_t bms_caculate_current(uint32_t base_time)
{
case kCurSensor_Shunt:
// 分流器 cur_hv_item.cur_volt_avg / cur_prop.shunt_volt * cur_prop.cur_scale;
current = (int32_t)cur_hv_item.value[kAdIc_Cur] * prop->scale / cur_item.shunt_volt;
current = (int32_t)cur_hv_item.value[kAdIc_Cur] * prop->scale / cur_item.shunt_volt / 100;
//current = HighResCurTrans(cur_hv_item.value[kAdIc_Cur]);
break;
case kCurSensor_SigHall:
@ -247,7 +247,7 @@ int16_t bms_caculate_current(uint32_t base_time)
//调试
bms_integral_soc(current, base_time);
cur_hv_item.current = current / 10;//转为 0.1
cur_hv_item.current = current * 10;
#if CUR_FILTER_ENABLE
dly += base_time;
@ -373,8 +373,10 @@ void get_ad_sample(void)
//ad = ad - adIc_adjust_value[i].zero;
//ad = (ad * 5120 * 10 / (0x01 << 15)) / 82; //单位是mv
temp_calc = (int64_t)ad * 2560 * 10 * 100 / (0x01 << 15);
ad = temp_calc / 82; //单位是0.1 mv
// temp_calc = (int64_t)ad * 15625 / 10000;
// ad = temp_calc / 100; //单位是0.1 mv
ad = (ad * 2560 * 10 * 100 / (0x01 << 15)) / 82; //单位是0.1 mv
// 防止eeprom中没有设置电压校准系数
if (get_eeprom_data(kEep_Volt1CalFactor, kEepromDataType_Full) <= 900 || get_eeprom_data(kEep_Volt1CalFactor, kEepromDataType_Full) >= 1100)

View File

@ -592,15 +592,13 @@ void bms_integral_soc(int32_t current, uint16_t base_time)
{
//单位Ams
//公式 (current / 100 * integral_time) * (sox_item.chg_adjust_rate / 100)
//tmp_32u = current * integral_time * sox_item.chg_adjust_rate / 10000;
tmp_32u = current * integral_time * sox_item.chg_adjust_rate / 100;
tmp_32u = current * integral_time * sox_item.chg_adjust_rate / 10000;
if (tmp_32u > SOX_MAX_SIGNAL_INTEGRAL)
tmp_32u = SOX_MAX_SIGNAL_INTEGRAL;
sox_item.tmp_chg_cap += tmp_32u;
//单位 kWms
//tmp_32少除了100这里应该多除个100--2.20
sox_item.tmp_chg_energy += tmp_32u * total_volt / 1000000;
sox_item.tmp_chg_energy += tmp_32u * total_volt / 10000;
if(sox_item.calculate_cap < sox_item.rated_cap)
{
@ -640,13 +638,13 @@ void bms_integral_soc(int32_t current, uint16_t base_time)
//放电积分
if(current < 0)
{
tmp_32u = KIT_ABS(current) * integral_time * sox_item.dis_adjust_rate / 100;
tmp_32u = KIT_ABS(current) * integral_time * sox_item.dis_adjust_rate / 10000;
if (tmp_32u > SOX_MAX_SIGNAL_INTEGRAL)
tmp_32u = SOX_MAX_SIGNAL_INTEGRAL;
sox_item.tmp_dis_cap += tmp_32u;
//单位 kWms
sox_item.tmp_dis_energy += tmp_32u * total_volt / 1000000;
//单位 kWms--
sox_item.tmp_dis_energy += tmp_32u * total_volt / 10000;
if(sox_item.calculate_cap > 0)
{

File diff suppressed because one or more lines are too long

View File

@ -10,15 +10,15 @@
<TargetName>stm32f407</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pArmCC>5050106::V5.05 update 1 (build 106)::ARMCC</pArmCC>
<pCCUsed>5050106::V5.05 update 1 (build 106)::ARMCC</pCCUsed>
<pArmCC>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pArmCC>
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>STM32F407ZGTx</Device>
<Vendor>STMicroelectronics</Vendor>
<PackID>Keil.STM32F4xx_DFP.2.16.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<PackID>Keil.STM32F4xx_DFP.3.0.0</PackID>
<PackURL>https://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00010000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>
@ -81,7 +81,7 @@
<nStopB2X>0</nStopB2X>
</BeforeMake>
<AfterMake>
<RunUserProg1>1</RunUserProg1>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name>D:\CodeCompare\BCU\app\stm32fxxx_app\hex2bin.exe D:\CodeCompare\BCU\app\stm32fxxx_app\prj\Objects\BCU5.hex</UserProg1Name>
<UserProg2Name></UserProg2Name>
@ -1145,8 +1145,8 @@
<TargetCommonOption>
<Device>STM32F407VGTx</Device>
<Vendor>STMicroelectronics</Vendor>
<PackID>Keil.STM32F4xx_DFP.2.16.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<PackID>Keil.STM32F4xx_DFP.3.0.0</PackID>
<PackURL>https://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00010000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>

File diff suppressed because it is too large Load Diff

View File

@ -283,7 +283,7 @@ void bcu_send_0x42100000(can_dev_e can)
tmp_16u = bms_get_statistic_data(kStatisticData_TotalVolt);
WRITE_LT_INT16U(buf, len, tmp_16u);
//电池组充/放电总电流
tmp_16u = bms_get_current();
tmp_16u = (bms_get_current()* 10 + 3000);
WRITE_LT_INT16U(buf, len, tmp_16u);
//主控温度--我们点表中没有,用单体平均温度替代
tmp_16u = bms_get_statistic_data(kStatisticData_AvgTemp);