Battery.c
1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "includes.h"
#include "hardware.h"
#include "all_value.h"
Str_Battery BatteryVa;
void BatteryData_Ananlysis(CanRxMsg *Message)//电池数据分析
{
u16 Vau16;
switch(Message->StdId)
{
case 0x200:
BatteryVa.Voltage=(Message->Data[0]<<8) +(Message->Data[1]);
BatteryVa.Current=(Message->Data[2]<<8) +(Message->Data[3]);
Vau16=(Message->Data[4]<<8) +(Message->Data[5]);
BatteryVa.Vol_SingelMin=Vau16/100;
Vau16=(Message->Data[6]<<8) +(Message->Data[7]);
BatteryVa.Vol_SingelMax=Vau16/100;
Tim5_Battery1Nums=0;
break;
case 0x201:
BatteryVa.EnergyYL=((Message->Data[0])<<8) +(Message->Data[1]);
BatteryVa.FullNums=((Message->Data[4])<<8) +(Message->Data[5]);
BatteryVa.Energy=((Message->Data[6])<<8) +(Message->Data[7]);
Tim5_Battery1Nums=0;
break;
case 0x202:
BatteryVa.ErrTap=((Message->Data[0])<<8) +(Message->Data[1]);
BatteryVa.MOSStatus=Message->Data[3];
Vau16=((Message->Data[4])<<8) +(Message->Data[5]);
BatteryVa.Temperature_Max=(s8)((float)Vau16*0.1f-273.16f);
Vau16=((Message->Data[6])<<8) +(Message->Data[7]);//0.1K;
BatteryVa.Temperature_Min=(s8)((float)Vau16*0.1f-273.16f);
Tim5_Battery1Nums=0;
break;
default:
break;
}
}
u8 Tim5_Battery1Nums;
#define LowBaEnConec 10u
void Battery_Pro(void)
{
if( (BatteryVa.Energy>=LowBaEnConec&&Tim5_Battery1Nums>3)|(BatteryVa.Energy<LowBaEnConec&&Tim5_Battery1Nums>200))
{ VaIndexW_W(&NodeOnLine,7,0);}
else VaIndexW_W(&NodeOnLine,7,1);
if ( (VaIndexW_R(&NodeOnLine,7)) &&(BatteryVa.Energy<BatLowEVa)&&(BatteryVa.Voltage<4950) )//电池在线且电量低于设定值
VaIndexB_W(&AGV.OtheSta,6,1);
else VaIndexB_W(&AGV.OtheSta,6,0);
}