Battery.c 1.74 KB
#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);
		
}