增加采集电池电压
This commit is contained in:
@@ -39,7 +39,6 @@ void setMotorOutput(float *out_torq, float max_torque, uint16_t feed_power, uint
|
|||||||
|
|
||||||
un_motor_output1.bit_data.MotCon_1Signal4 = (uint16_t)(-abs_left_front_speed);
|
un_motor_output1.bit_data.MotCon_1Signal4 = (uint16_t)(-abs_left_front_speed);
|
||||||
un_motor_output2.bit_data.MotCon_1Signal3 = (uint16_t)(abs_left_rear_speed);
|
un_motor_output2.bit_data.MotCon_1Signal3 = (uint16_t)(abs_left_rear_speed);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -171,13 +170,13 @@ void distributeTorque(float rpm1, float rpm2, float total_torque, float* torque1
|
|||||||
if (fabs(total_torque) < 0.001f) {
|
if (fabs(total_torque) < 0.001f) {
|
||||||
*torque1 = 0.0f;
|
*torque1 = 0.0f;
|
||||||
*torque2 = 0.0f;
|
*torque2 = 0.0f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // 保护条件:当两电机均静止时采用平均分配策略
|
// // 保护条件:当两电机均静止时采用平均分配策略
|
||||||
// if (fabs(rpm1) < 0.001f && fabs(rpm2) < 0.001f) {
|
// if (fabs(rpm1) < 0.001f && fabs(rpm2) < 0.001f) {
|
||||||
// *torque1 = total_torque / 2.0f;
|
// *torque1 = total_torque / 2.0f;
|
||||||
// *torque2 = total_torque / 2.0f;
|
// *torque2 = total_torque / 2.0f;
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@@ -624,17 +623,17 @@ static void diffInput(void *signal_id)
|
|||||||
diff_data.desired_speed = diff_data.desired_speed * 0.01f;
|
diff_data.desired_speed = diff_data.desired_speed * 0.01f;
|
||||||
diff_data.desired_curvature = diff_data.desired_curvature * 0.0001f;
|
diff_data.desired_curvature = diff_data.desired_curvature * 0.0001f;
|
||||||
// 遥控器速度映射,参数含义为:输入速度,死区,最大输入,最大输出,低速输入,低速输出
|
// 遥控器速度映射,参数含义为:输入速度,死区,最大输入,最大输出,低速输入,低速输出
|
||||||
diff_data.desired_speed = mapRemoteControlSpeed(diff_data.desired_speed, 0.1, 20, 5, 5, 0.5);
|
diff_data.desired_speed = mapRemoteControlSpeed(diff_data.desired_speed, 0.5, 20, 5, 5, 0.5);
|
||||||
diff_data.desired_curvature = mapRemoteControlSpeed(diff_data.desired_curvature, 0.1, 2, 2, 1, 0.5);
|
diff_data.desired_curvature = mapRemoteControlSpeed(diff_data.desired_curvature, 0.1, 2, 2, 1, 0.5);
|
||||||
|
|
||||||
if(diff_data.desired_speed >= 0)//20250320 增加根据速度大小来决定方向,解决后退时转弯反向的问题
|
// if(diff_data.desired_speed >= 0)//20250320 增加根据速度大小来决定方向,解决后退时转弯反向的问题 基站车不需要加换相,转向方式和比亚迪一样
|
||||||
{
|
// {
|
||||||
diff_data.desired_curvature = diff_data.desired_curvature;
|
// diff_data.desired_curvature = diff_data.desired_curvature;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
diff_data.desired_curvature = -diff_data.desired_curvature;
|
// diff_data.desired_curvature = -diff_data.desired_curvature;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( (signal_id == &un_manual_computer_input) && (diff_data.mode == MODE_AUTO) )
|
else if ( (signal_id == &un_manual_computer_input) && (diff_data.mode == MODE_AUTO) )
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ typedef struct {
|
|||||||
uint8_t is_power_on;
|
uint8_t is_power_on;
|
||||||
Timer timer;
|
Timer timer;
|
||||||
uint8_t old_is_power_on;
|
uint8_t old_is_power_on;
|
||||||
Timer timer1;
|
Timer timer1;
|
||||||
} PowerButton;
|
} PowerButton;
|
||||||
|
|
||||||
// 全局变量
|
// 全局变量
|
||||||
@@ -332,6 +332,15 @@ static void powerInput(void *signal_id)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bmsProcess(void *signal_id)//读取电压
|
||||||
|
{
|
||||||
|
(void)signal_id;
|
||||||
|
|
||||||
|
power_data.high_battery_voltage = (float)un_bms_input.bit_data.bus_voltage / 100.0;
|
||||||
|
power_data.low_battery_voltage = (float)un_bms_input.bit_data.low_voltage / 100.0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// APP模块的初始化
|
// APP模块的初始化
|
||||||
void powerAppInit(void)
|
void powerAppInit(void)
|
||||||
@@ -357,6 +366,9 @@ void powerAppInit(void)
|
|||||||
timerInit(&power_data.timer1);
|
timerInit(&power_data.timer1);
|
||||||
subscribe(&power_data.timer1, wakeupProcess);
|
subscribe(&power_data.timer1, wakeupProcess);
|
||||||
timerStart(&power_data.timer1, 500, 1); // 周期调用
|
timerStart(&power_data.timer1, 500, 1); // 周期调用
|
||||||
|
|
||||||
|
subscribe(&un_bms_input, bmsProcess);
|
||||||
|
|
||||||
|
|
||||||
//预充定时器
|
//预充定时器
|
||||||
timerInit(&power_data.timer_pre_charge);
|
timerInit(&power_data.timer_pre_charge);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ typedef struct {
|
|||||||
Timer timer; // 定时器
|
Timer timer; // 定时器
|
||||||
Timer timer1;
|
Timer timer1;
|
||||||
Timer timer_pre_charge; // 预充定时器
|
Timer timer_pre_charge; // 预充定时器
|
||||||
|
Timer timer2; //请求采集电源时间
|
||||||
PowerState last_state; // 上一次状态
|
PowerState last_state; // 上一次状态
|
||||||
uint8_t emergency_stop_switch; // 急停开关
|
uint8_t emergency_stop_switch; // 急停开关
|
||||||
uint8_t high_voltage_switch; // 高压开关
|
uint8_t high_voltage_switch; // 高压开关
|
||||||
@@ -39,6 +40,10 @@ typedef struct {
|
|||||||
uint8_t emergency_stop; // 急停状态
|
uint8_t emergency_stop; // 急停状态
|
||||||
uint8_t pre_charge_finish; // 预充完成标志位
|
uint8_t pre_charge_finish; // 预充完成标志位
|
||||||
uint8_t old_state; // 上一次状态
|
uint8_t old_state; // 上一次状态
|
||||||
|
|
||||||
|
float low_battery_voltage; // 低压电池电压,单位V
|
||||||
|
float high_battery_voltage; // 高压电池电压,单位V
|
||||||
|
|
||||||
} PowerSystem;
|
} PowerSystem;
|
||||||
|
|
||||||
// 声明外部变量
|
// 声明外部变量
|
||||||
|
|||||||
@@ -293,9 +293,9 @@ static void requestInput(void *signal_id)
|
|||||||
}
|
}
|
||||||
else if(signal_id == &un_bms_input)
|
else if(signal_id == &un_bms_input)
|
||||||
{
|
{
|
||||||
un_vehicle_Info_output.bit_data.battery_voltage = un_bms_input.bit_data.bus_voltage/10;//电池电压读取得的10mV,所以输出的是100mV单位,所以缩小10倍
|
// un_vehicle_Info_output.bit_data.battery_voltage = un_bms_input.bit_data.bus_voltage/10;//电池电压读取得的10mV,所以输出的是100mV单位,所以缩小10倍
|
||||||
un_vehicle_Info_output.bit_data.battery_soc = un_bms_input.bit_data.soc;//SOC
|
// un_vehicle_Info_output.bit_data.battery_soc = un_bms_input.bit_data.soc;//SOC
|
||||||
un_vehicle_Info_output.bit_data.battery_current = un_bms_input.bit_data.bus_current;//电池电流
|
// un_vehicle_Info_output.bit_data.battery_current = un_bms_input.bit_data.bus_current;//电池电流
|
||||||
}
|
}
|
||||||
else if(signal_id == &un_motor_input1)
|
else if(signal_id == &un_motor_input1)
|
||||||
{
|
{
|
||||||
@@ -322,7 +322,7 @@ static void requestInput(void *signal_id)
|
|||||||
}
|
}
|
||||||
else if(signal_id == &un_manual_computer_input)
|
else if(signal_id == &un_manual_computer_input)
|
||||||
{
|
{
|
||||||
memcpy(&un_manual_control_output.arr[0],&(un_manual_computer_input.arr[0]),12);//手柄拷贝
|
// memcpy(&un_manual_control_output.arr[0],&(un_manual_computer_input.arr[0]),12);//手柄拷贝
|
||||||
}
|
}
|
||||||
else if(signal_id == ðernet_fault_Info)
|
else if(signal_id == ðernet_fault_Info)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ UnSdoOutput un_sdo_output8 ;//设定右电机
|
|||||||
|
|
||||||
UnSdoOutput un_sdo_output9 ;//输入
|
UnSdoOutput un_sdo_output9 ;//输入
|
||||||
UnSdoOutput un_sdo_output10 ;//输入
|
UnSdoOutput un_sdo_output10 ;//输入
|
||||||
|
|
||||||
|
UnBMSRequest un_bms_request ;//BMS 请求
|
||||||
|
|
||||||
//IO口
|
//IO口
|
||||||
UnSwSample un_sw_sample ;//采集
|
UnSwSample un_sw_sample ;//采集
|
||||||
|
|
||||||
|
|||||||
@@ -124,18 +124,12 @@ typedef union _UnMotorTempInput
|
|||||||
// 接收BMS输入
|
// 接收BMS输入
|
||||||
typedef struct _StrBmsInput
|
typedef struct _StrBmsInput
|
||||||
{
|
{
|
||||||
//----接收0x100----------------------------------
|
//----接收0x301----------------------------------
|
||||||
// 多字节数据,高位在前,低位在后
|
// 多字节数据,高位在前,低位在后
|
||||||
unsigned int bus_voltage : 16; // 母线电压 单位为10mV
|
uint16_t bus_voltage ; // 母线电压 单位为0.01V
|
||||||
unsigned int bus_current : 16; // 母线电流 单位为10mA
|
uint16_t low_voltage ; // 母线电流 单位为0.01V
|
||||||
unsigned int remainder_capacity : 16; // 剩余容量 单位为10mAh 充电为正,放电为负
|
uint16_t channel3 ; // 保留通道
|
||||||
unsigned int crc1 : 16; //crc
|
uint16_t crc1 ; //
|
||||||
//----接收0x101----------------------------------
|
|
||||||
// 多字节数据,高位在前,低位在后
|
|
||||||
unsigned int full_capacity : 16; // 充满容量 单位为10mAh
|
|
||||||
unsigned int Discharge_times : 16; // 放电循环次数 单位为1次
|
|
||||||
unsigned int soc : 16; // soc 1%
|
|
||||||
unsigned int crc2 : 16; //crc
|
|
||||||
} StrBmsInput;
|
} StrBmsInput;
|
||||||
|
|
||||||
typedef union _UnBmsInput
|
typedef union _UnBmsInput
|
||||||
@@ -667,6 +661,37 @@ typedef union _UnComputerOutput
|
|||||||
} UnComputerOutput;
|
} UnComputerOutput;
|
||||||
|
|
||||||
|
|
||||||
|
// BMS数据请求结构体
|
||||||
|
typedef struct _StrBMSRequest
|
||||||
|
{
|
||||||
|
uint16_t reserved1;
|
||||||
|
uint16_t reserved2;
|
||||||
|
uint16_t reserved3;
|
||||||
|
uint16_t reserved4;
|
||||||
|
} StrBMSRequest;
|
||||||
|
|
||||||
|
typedef union _UnBMSRequest
|
||||||
|
{
|
||||||
|
StrBMSRequest bit_data; // 使用定义的结构体变量名
|
||||||
|
uint8_t arr[sizeof(StrBMSRequest)]; // 通过结构体类型确定大小
|
||||||
|
} UnBMSRequest;
|
||||||
|
|
||||||
|
|
||||||
|
//// BMS数据输入结构体
|
||||||
|
//typedef struct _StrBMSIntput
|
||||||
|
//{
|
||||||
|
// uint16_t reserved1;
|
||||||
|
// uint16_t reserved2;
|
||||||
|
// uint16_t reserved3;
|
||||||
|
// uint16_t reserved4;
|
||||||
|
//} StrBMSIntput;
|
||||||
|
//
|
||||||
|
//typedef union _UnBMSRequest
|
||||||
|
//{
|
||||||
|
// StrBMSIntput bit_data; // 使用定义的结构体变量名
|
||||||
|
// uint8_t arr[sizeof(StrBMSIntput)]; // 通过结构体类型确定大小
|
||||||
|
//} UnBMSIntput;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 车辆信息,输出给上位机
|
// 车辆信息,输出给上位机
|
||||||
@@ -886,6 +911,13 @@ typedef union _UnAutoControlOutput
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-----IO口---------------------------------------------------------------
|
//-----IO口---------------------------------------------------------------
|
||||||
// 电压信号输出,到遥控器
|
// 电压信号输出,到遥控器
|
||||||
typedef struct _StrVoltageSignalOutput
|
typedef struct _StrVoltageSignalOutput
|
||||||
@@ -942,6 +974,7 @@ extern UnSdoOutput un_sdo_output6 ;//设定右
|
|||||||
extern UnSdoOutput un_sdo_output7 ;//使能右电机
|
extern UnSdoOutput un_sdo_output7 ;//使能右电机
|
||||||
extern UnSdoOutput un_sdo_output8 ;//设定右电机模式
|
extern UnSdoOutput un_sdo_output8 ;//设定右电机模式
|
||||||
|
|
||||||
|
extern UnBMSRequest un_bms_request ;//BMS 请求
|
||||||
|
|
||||||
//串口
|
//串口
|
||||||
extern UnRemoteControlInput un_remote_control_input; //遥控器输入
|
extern UnRemoteControlInput un_remote_control_input; //遥控器输入
|
||||||
|
|||||||
@@ -538,7 +538,8 @@ void flexcan_Receive_callback_6(flexcan_handle_t *handle,
|
|||||||
flexcan_status_e status, uint32_t result,
|
flexcan_status_e status, uint32_t result,
|
||||||
void *userData)
|
void *userData)
|
||||||
{
|
{
|
||||||
flexcan_frame_t *buf = (flexcan_frame_t *)userData;
|
flexcan_frame_t *buf = (flexcan_frame_t *)userData;
|
||||||
|
uint8_t i = 0;
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
@@ -559,6 +560,16 @@ void flexcan_Receive_callback_6(flexcan_handle_t *handle,
|
|||||||
printf("Feed dog flag received %d\n",getCurrentTime());
|
printf("Feed dog flag received %d\n",getCurrentTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(BMS_INPUT_ID1 == (buf->id))//<2F><><EFBFBD>յ<EFBFBD>ι<EFBFBD><CEB9>ID
|
||||||
|
{
|
||||||
|
for(i = 0; i < (buf->length); i++)
|
||||||
|
{
|
||||||
|
un_bms_input.arr[i+8] = buf->dataBuffer[i];
|
||||||
|
}
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||||
|
publishMessage(&un_bms_input, 1);
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1166,7 +1177,10 @@ void canSendAll(void *signal_id)
|
|||||||
CanData[5] = 0xFF;
|
CanData[5] = 0xFF;
|
||||||
|
|
||||||
CAN_Send_Msg(&can_handle_1, MOTOR_OUTPUT_ID_1, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData,CanData, 8, 17);//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
CAN_Send_Msg(&can_handle_1, MOTOR_OUTPUT_ID_1, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData,CanData, 8, 17);//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
CAN_Send_Msg(&can_handle_2, MOTOR_OUTPUT_ID_2, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData,CanData, 8, 17);//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
CAN_Send_Msg(&can_handle_2, MOTOR_OUTPUT_ID_2, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData,CanData, 8, 17);//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
CAN_Send_Msg(&can_handle_6, BMS_INPUT_ID1, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData,CanData, 8, 17);//BMS <20><><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1344,9 +1358,7 @@ void canInterfaceInit(void)
|
|||||||
subscribe(&un_sdo_output5, processSdoOutput5);
|
subscribe(&un_sdo_output5, processSdoOutput5);
|
||||||
subscribe(&un_sdo_output6, processSdoOutput6);
|
subscribe(&un_sdo_output6, processSdoOutput6);
|
||||||
subscribe(&un_sdo_output7, processSdoOutput7);
|
subscribe(&un_sdo_output7, processSdoOutput7);
|
||||||
subscribe(&un_sdo_output8, processSdoOutput8);
|
subscribe(&un_sdo_output8, processSdoOutput8);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
timerStart(&can_timer_interface1,10,1);//1ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
timerStart(&can_timer_interface1,10,1);//1ms<6D><73><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define BMS_INPUT_ID1 0x100
|
#define BMS_INPUT_ID1 0x301
|
||||||
#define BMS_INPUT_ID2 0x101
|
#define BMS_INPUT_ID2 0x101
|
||||||
#define REMOTE_ID 0x12000023
|
#define REMOTE_ID 0x12000023
|
||||||
//#define TEMP_MODULE_INPUT_ID_1 0x301
|
//#define TEMP_MODULE_INPUT_ID_1 0x301
|
||||||
|
|||||||
Reference in New Issue
Block a user