增加电压采集
This commit is contained in:
@@ -836,8 +836,6 @@ void diffParametersInit(void *signal_id)
|
|||||||
diff_data.diff_dead_zone = (float)getParam("diff_sp");//参数读取设定最大扭矩
|
diff_data.diff_dead_zone = (float)getParam("diff_sp");//参数读取设定最大扭矩
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
diff_data.min_Torq = (uint16_t)getParam("minTorq");//参数读取设定最大扭矩
|
diff_data.min_Torq = (uint16_t)getParam("minTorq");//参数读取设定最大扭矩
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -336,8 +336,10 @@ void bmsProcess(void *signal_id)//读取电压
|
|||||||
{
|
{
|
||||||
(void)signal_id;
|
(void)signal_id;
|
||||||
|
|
||||||
power_data.high_battery_voltage = (float)un_bms_input.bit_data.bus_voltage / 100.0;
|
power_data.high_battery_voltage = (float)SWAP_ENDIAN_16(un_bms_input.bit_data.bus_voltage) / 100.0;
|
||||||
power_data.low_battery_voltage = (float)un_bms_input.bit_data.low_voltage / 100.0;
|
power_data.low_battery_voltage = (float)SWAP_ENDIAN_16(un_bms_input.bit_data.low_voltage) / 100.0;
|
||||||
|
|
||||||
|
printf("high_vol = %f, low_vol = %f\n", power_data.high_battery_voltage, power_data.low_battery_voltage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ extern "C" {
|
|||||||
#include "app_frm_signal.h"
|
#include "app_frm_signal.h"
|
||||||
#include "app_frm_timer.h"
|
#include "app_frm_timer.h"
|
||||||
|
|
||||||
|
#define SWAP_ENDIAN_16(x) ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))
|
||||||
|
#define SWAP_ENDIAN_32(x) (((x) << 24) | (((x) & 0xFF00) << 8) | (((x) >> 8) & 0xFF00) | ((x) >> 24))
|
||||||
|
|
||||||
|
|
||||||
// 定义电源状态枚举
|
// 定义电源状态枚举
|
||||||
typedef enum {
|
typedef enum {
|
||||||
POWER_STANDBY,
|
POWER_STANDBY,
|
||||||
|
|||||||
@@ -126,10 +126,10 @@ typedef struct _StrBmsInput
|
|||||||
{
|
{
|
||||||
//----接收0x301----------------------------------
|
//----接收0x301----------------------------------
|
||||||
// 多字节数据,高位在前,低位在后
|
// 多字节数据,高位在前,低位在后
|
||||||
uint16_t bus_voltage ; // 母线电压 单位为0.01V
|
uint16_t low_voltage ; // 电池电压 单位为0.01V
|
||||||
uint16_t low_voltage ; // 母线电流 单位为0.01V
|
uint16_t chanel1 ; //
|
||||||
uint16_t channel3 ; // 保留通道
|
uint16_t bus_voltage ; // 母线 单位为0.01V
|
||||||
uint16_t crc1 ; //
|
uint16_t chanel2 ; //
|
||||||
} StrBmsInput;
|
} StrBmsInput;
|
||||||
|
|
||||||
typedef union _UnBmsInput
|
typedef union _UnBmsInput
|
||||||
|
|||||||
@@ -385,8 +385,8 @@ void flexcan_Receive_callback_3(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;
|
// uint8_t i = 0;
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
@@ -395,30 +395,30 @@ void flexcan_Receive_callback_3(flexcan_handle_t *handle,
|
|||||||
|
|
||||||
case FLEXCAN_RX_FIFO_IDLE:
|
case FLEXCAN_RX_FIFO_IDLE:
|
||||||
|
|
||||||
if(BMS_INPUT_ID1 == (buf->id))//BMS
|
// if(BMS_INPUT_ID1 == (buf->id))//BMS
|
||||||
{
|
// {
|
||||||
can_fault_info.bit_data.bms_count ++;
|
// can_fault_info.bit_data.bms_count ++;
|
||||||
for(i = 0; i < (buf->length); i++)
|
// for(i = 0; i < (buf->length); i++)
|
||||||
{
|
// {
|
||||||
un_bms_input.arr[i] = buf->dataBuffer[i];
|
// un_bms_input.arr[i] = buf->dataBuffer[i];
|
||||||
}
|
// }
|
||||||
publishMessage(&un_bms_input, 1);
|
// publishMessage(&un_bms_input, 1);
|
||||||
}
|
// }
|
||||||
else if(BMS_INPUT_ID2 == (buf->id))//BMS
|
// else if(BMS_INPUT_ID2 == (buf->id))//BMS
|
||||||
{
|
// {
|
||||||
for(i = 0; i < (buf->length); i++)
|
// for(i = 0; i < (buf->length); i++)
|
||||||
{
|
// {
|
||||||
un_bms_input.arr[i+8] = buf->dataBuffer[i];
|
// un_bms_input.arr[i+8] = buf->dataBuffer[i];
|
||||||
}
|
// }
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
// //<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||||
publishMessage(&un_bms_input, 1);
|
// publishMessage(&un_bms_input, 1);
|
||||||
}
|
// }
|
||||||
// else if(0x701 == (buf->id))//ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>ᷢһ֡0x701
|
// else if(0x701 == (buf->id))//ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>ᷢһ֡0x701
|
||||||
// {
|
// {
|
||||||
// un_sdo_output6.bit_data.cmd = 1;
|
// un_sdo_output6.bit_data.cmd = 1;
|
||||||
// publishMessage(&un_sdo_output6, 1);
|
// publishMessage(&un_sdo_output6, 1);
|
||||||
// }
|
// }
|
||||||
else{}
|
// else{}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -560,11 +560,11 @@ 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
|
else if(BMS_INPUT_ID2 == (buf->id))//<2F><><EFBFBD>յ<EFBFBD>ι<EFBFBD><CEB9>ID
|
||||||
{
|
{
|
||||||
for(i = 0; i < (buf->length); i++)
|
for(i = 0; i < (buf->length); i++)
|
||||||
{
|
{
|
||||||
un_bms_input.arr[i+8] = buf->dataBuffer[i];
|
un_bms_input.arr[i] = buf->dataBuffer[i];
|
||||||
}
|
}
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||||
publishMessage(&un_bms_input, 1);
|
publishMessage(&un_bms_input, 1);
|
||||||
@@ -1179,7 +1179,7 @@ void canSendAll(void *signal_id)
|
|||||||
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>
|
CAN_Send_Msg(&can_handle_6, BMS_OUTPUT_ID1, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData,CanData, 8, 17);//BMS <20><><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,8 +72,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define BMS_INPUT_ID1 0x301
|
#define BMS_OUTPUT_ID1 0x301
|
||||||
#define BMS_INPUT_ID2 0x101
|
#define BMS_INPUT_ID2 0x302
|
||||||
#define REMOTE_ID 0x12000023
|
#define REMOTE_ID 0x12000023
|
||||||
//#define TEMP_MODULE_INPUT_ID_1 0x301
|
//#define TEMP_MODULE_INPUT_ID_1 0x301
|
||||||
#define TEMP_MODULE_INPUT_ID_1 0x15000003
|
#define TEMP_MODULE_INPUT_ID_1 0x15000003
|
||||||
|
|||||||
Reference in New Issue
Block a user