修改电机驱动
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -8,37 +8,34 @@ extern "C"
|
||||
|
||||
#include "app_config.h"
|
||||
|
||||
#define SPEED_MODE 0x0C
|
||||
#define THROTTLE_MODE 0x05
|
||||
#define TORQUE_MODE 0x0A
|
||||
#define SPEED_MODE 0x01
|
||||
#define TORQUE_MODE 0x02
|
||||
|
||||
#define MOTOR_MODE THROTTLE_MODE
|
||||
#define MOTOR_MODE TORQUE_MODE
|
||||
|
||||
#define SPEED_PID_MODE 0
|
||||
#define THROTTLE_PID_MODE 1
|
||||
|
||||
|
||||
|
||||
|
||||
#define TORQUE_HYSTERESIS_THRESHOLD 0.3f
|
||||
|
||||
#define SWITCH_SPEED 20.0f
|
||||
|
||||
|
||||
#define DIFF_SPEED 20.0f
|
||||
|
||||
|
||||
// 状态机内部状态
|
||||
typedef enum
|
||||
{
|
||||
STATE_INIT, ///< 初始状态(转速为0且等待扭矩方向判定)
|
||||
STATE_FORWARD, ///< 正向旋转状态
|
||||
STATE_BACKWARD, ///< 反向旋转状态
|
||||
DEC_FORWARD, ///< 正向减速状态
|
||||
DEC_FORWARD2, ///< 正向溜坡状态
|
||||
DEC_BACKWARD, ///< 反向减速状态
|
||||
DEC_BACKWARD2 ///< 反向溜坡状态
|
||||
|
||||
STATE_FORWARD, ///< 前进
|
||||
STATE_BACKWARD, ///< 后退
|
||||
} MotorState;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MODE_MANUAL, // 手动模式
|
||||
MODE_AUTO // 自动模式
|
||||
} ControlMode;
|
||||
|
||||
// 状态机内部状态
|
||||
typedef enum
|
||||
@@ -55,67 +52,47 @@ typedef enum
|
||||
} MotorDir;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MODE_MANUAL, // 手动模式
|
||||
MODE_AUTO // 自动模式
|
||||
} ControlMode;
|
||||
|
||||
typedef struct DiffData
|
||||
{
|
||||
ControlMode mode ; // 控制模式
|
||||
MotorState state; //当前状态机状态
|
||||
MotorDir motor_dir; // 当前车辆方向
|
||||
DirState dir_state;
|
||||
|
||||
float desired_speed; // 期望速度
|
||||
MotorState motor_state[4]; //当前车辆状态
|
||||
float desired_speed; // 期望速度
|
||||
float desired_curvature; // 期望曲率
|
||||
float left_motor_speed; // 当前左电机速度
|
||||
float right_motor_speed; // 当前右电机速度
|
||||
|
||||
float left_front_motor_speed; // 当前左前电机速度
|
||||
float right_front_motor_speed; // 当前右前电机速度
|
||||
float left_rear_motor_speed; // 当前左后电机速度
|
||||
float right_rear_motor_speed; // 当前右后电机速度
|
||||
|
||||
uint8_t out_motor_dir; // 电机状态
|
||||
|
||||
float speed_last; // 速度过去值
|
||||
float torq_last; // 扭矩过去值
|
||||
uint8_t counter; // 方向判断计数器
|
||||
float left_front_motor_speed; // 当前左前电机速度
|
||||
float right_front_motor_speed; // 当前右前电机速度
|
||||
float left_rear_motor_speed; // 当前左后电机速度
|
||||
float right_rear_motor_speed; // 当前右后电机速度
|
||||
float speed; // 当前车速
|
||||
float curvature; // 当前曲率
|
||||
float yaw_rate; // 当前角速度
|
||||
float desired_yaw_rate; // 期望角速度
|
||||
float acceleration; // 当前加速度
|
||||
float deceleration; // 当前减速度
|
||||
float max_speed; // 最大速度
|
||||
float desired_acceleration; // 期望加速度
|
||||
float desired_deceleration; // 期望减速度
|
||||
uint8_t emergency_stop_switch; // 急停开关
|
||||
uint8_t remote_emergency_stop; // 遥控器急停开关
|
||||
uint8_t emergency_stop_state; // 急停状态
|
||||
float out_left_motor_speed; // 输出左电机速度
|
||||
float out_right_motor_speed; // 输出右电机速度
|
||||
float out_torq[4]; //4个电机扭矩
|
||||
float max_Torq; // 最大扭矩限制
|
||||
float min_Torq; // 最小扭矩限制
|
||||
|
||||
float left_speed_diff; // 左侧转速差
|
||||
float right_speed_diff; // 右侧转速差
|
||||
|
||||
float left_diff_touue; // 左侧扭矩差
|
||||
float right_diff_touue; // 右侧扭矩差
|
||||
|
||||
float right_diff_touue; // 右侧扭矩差
|
||||
float diff_dead_zone; // 差速速度死区
|
||||
|
||||
|
||||
float out_motor_speed[4];
|
||||
float speed; // 当前车速
|
||||
float curvature; // 当前曲率
|
||||
float yaw_rate; // 当前角速度
|
||||
float desired_yaw_rate; // 期望角速度
|
||||
float acceleration; // 当前加速度
|
||||
float deceleration; // 当前减速度
|
||||
float max_speed; // 最大速度
|
||||
float desired_acceleration; // 期望加速度
|
||||
float desired_deceleration; // 期望减速度
|
||||
uint8_t emergency_stop_switch; // 急停开关
|
||||
uint8_t remote_emergency_stop; // 遥控器急停开关
|
||||
uint8_t emergency_stop_state; // 急停状态
|
||||
float out_left_motor_speed; // 输出左电机速度
|
||||
float out_right_motor_speed; // 输出右电机速度
|
||||
uint16_t max_Torq; // 最大扭矩限制
|
||||
uint16_t speed_inter;
|
||||
|
||||
|
||||
} DiffData;
|
||||
|
||||
|
||||
|
||||
// 声明外部变量
|
||||
extern DiffData diff_data;
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ static void processRequestframe(uint16_t id)
|
||||
static uint8_t VehicleStaACC2 = 0;
|
||||
static uint8_t VehicleStaACC3 = 0;
|
||||
|
||||
uint16_t RgExchangeTemp = 0;
|
||||
uint32_t Rg32ExchangeTemp = 0;
|
||||
//-----------------------------------------------------------
|
||||
// printf("request_read_id:%d\n",id);
|
||||
@@ -43,7 +42,7 @@ static void processRequestframe(uint16_t id)
|
||||
un_motor_status_output.bit_data.frame_type = 0x2100;//帧类型
|
||||
un_motor_status_output.bit_data.frame_length = 0x1E00;//帧长
|
||||
un_motor_status_output.bit_data.accumulated = VehicleStaACC1++;//累加值
|
||||
RgExchangeTemp = ( (uint16_t)getParam("maxTorq") + 300 ) *100 ;
|
||||
// RgExchangeTemp = ( (uint16_t)getParam("maxTorq") + 300 ) *100 ;
|
||||
// un_motor_status_output.bit_data.left_torque_limit = ((RgExchangeTemp << 8) | (RgExchangeTemp >> 8));//左侧扭矩限制
|
||||
// un_motor_status_output.bit_data.right_torque_limit = ((RgExchangeTemp << 8) | (RgExchangeTemp >> 8));//右侧扭矩限制
|
||||
// un_motor_status_output.bit_data.left_power_in = (((uint16_t)getParam("feedPwr") << 8) | ((uint16_t)getParam("feedPwr") >> 8));//左侧馈电功率
|
||||
@@ -253,20 +252,20 @@ static void requestInput(void *signal_id)
|
||||
request16_temp = (uint16_t)(int16_t)(diff_data.right_diff_touue * 10000.0);
|
||||
un_vehicle_Info_output.bit_data.curvature = ((request16_temp << 8) | (request16_temp >> 8));//当前曲率
|
||||
|
||||
request16_temp = (uint16_t)(int16_t)(diff_data.out_motor_speed[0]);//
|
||||
request16_temp = (uint16_t)(int16_t)(diff_data.left_front_motor_speed);//
|
||||
un_vehicle_Info_output.bit_data.set_left_speed = ((request16_temp << 8) | (request16_temp >> 8));//左前
|
||||
|
||||
request16_temp = (uint16_t)(int16_t)(diff_data.out_motor_speed[1]);//out_right_motor_speed
|
||||
request16_temp = (uint16_t)(int16_t)(diff_data.right_front_motor_speed);//out_right_motor_speed
|
||||
un_vehicle_Info_output.bit_data.set_right_speed = ((request16_temp << 8) | (request16_temp >> 8));//右前
|
||||
|
||||
request16_temp = (uint16_t)(int16_t)(diff_data.out_motor_speed[2]);//
|
||||
request16_temp = (uint16_t)(int16_t)(diff_data.left_rear_motor_speed);//
|
||||
un_motor_status_output.bit_data.left_power_in = ((request16_temp << 8) | (request16_temp >> 8));//左后
|
||||
|
||||
request16_temp = (uint16_t)(int16_t)(diff_data.out_motor_speed[3]);//out_right_motor_speed
|
||||
request16_temp = (uint16_t)(int16_t)(diff_data.right_rear_motor_speed);//out_right_motor_speed
|
||||
un_motor_status_output.bit_data.right_power_in = ((request16_temp << 8) | (request16_temp >> 8));//右后
|
||||
|
||||
un_vehicle_Info_output.bit_data.vehicle_fault_state = diff_data.state;
|
||||
un_vehicle_Info_output.bit_data.battery_soc = diff_data.motor_dir;
|
||||
un_vehicle_Info_output.bit_data.vehicle_fault_state = diff_data.motor_state[0];
|
||||
un_vehicle_Info_output.bit_data.battery_soc = diff_data.motor_state[1];
|
||||
|
||||
request16_temp = (uint16_t)(int16_t)(diff_data.left_rear_motor_speed + 30000);
|
||||
un_motor_status_output.bit_data.left_wheel_speed = ((request16_temp << 8) | (request16_temp >> 8));;//左侧后轮速
|
||||
|
||||
10
interface.c
10
interface.c
@@ -7,6 +7,15 @@ UnMotorInput un_motor_input2 ;//电机控制器2
|
||||
UnMotorInput un_motor_input3 ;//电机控制器1 左后侧
|
||||
UnMotorInput un_motor_input4 ;//电机控制器2 右后侧
|
||||
|
||||
|
||||
UnMotorTempInput un_motor_temp1 ;//电机控制器1 左前侧
|
||||
UnMotorTempInput un_motor_temp2 ;//电机控制器2 右前侧
|
||||
UnMotorTempInput un_motor_temp3 ;//电机控制器3 左后侧
|
||||
UnMotorTempInput un_motor_temp4 ;//电机控制器4 右后侧
|
||||
|
||||
|
||||
|
||||
|
||||
UnBmsInput un_bms_input ;//BMS接收数据
|
||||
UnTempModuleInput un_temp_module_input ;//温度采集模块
|
||||
|
||||
@@ -69,6 +78,7 @@ UnAutoControlOutput un_auto_control_output ;// 自动控制数
|
||||
|
||||
|
||||
|
||||
UnCanDebugOutput un_can_debug_output;//调试输出
|
||||
|
||||
|
||||
|
||||
|
||||
241
interface.h
241
interface.h
@@ -22,38 +22,57 @@
|
||||
#define NORMAL 1
|
||||
|
||||
|
||||
//-----CAN----------------------------------------------------------------
|
||||
// 接收电机控制器输入
|
||||
//typedef struct _StrMotorInput
|
||||
//{
|
||||
////-----接收数据0x10F90708----------------------------------------------
|
||||
// unsigned int control_data3 : 16; // 读取的控制数据
|
||||
// unsigned int torque : 16; // 当前扭矩
|
||||
// unsigned int phase_current : 16; // 当前相电流
|
||||
// unsigned int speed : 16; // 当前转速
|
||||
//
|
||||
// unsigned int gear : 2; // 反馈档位
|
||||
// unsigned int speed_gear : 3; // 当前扭矩
|
||||
// unsigned int reserve1 : 1; // 保留
|
||||
// unsigned int reserve2 : 1; // 保留
|
||||
// unsigned int reserve3 : 1; // 保留
|
||||
//
|
||||
// unsigned int reserve4 : 8; // 保留
|
||||
//
|
||||
// unsigned int ready : 1; // Bit0: READY, 0-有告警不能行驶, 1-工作正常可行驶
|
||||
// unsigned int reserved1 : 1; // Bit1: ECO状态(预留)
|
||||
// unsigned int eabs : 1; // Bit2: EABS, 0-停止或驱动行驶, 1-能量回收状态
|
||||
// unsigned int boost : 1; // Bit3: BOOST状态, 0-正常驱动, 1-BOOST驱动
|
||||
// unsigned int reserved2 : 1; // Bit4: 预留
|
||||
// unsigned int rotation_dir : 1; // Bit5: 转动方向, 0-电机逆时针转, 1-电机顺时针转
|
||||
// unsigned int motor_dir : 1; // Bit6: 电机方向, 0-电机右置, 1-电机左置
|
||||
// unsigned int main_relay : 1; // Bit7: 主继电器, 0-断开, 1-闭合
|
||||
//
|
||||
// unsigned int reserve5 : 16; // 保留
|
||||
// unsigned int reserve6 : 16; // 保留
|
||||
// unsigned int reserve7 : 16; // 保留
|
||||
//} StrMotorInput;
|
||||
//
|
||||
//typedef union _UnMotorInput
|
||||
//{
|
||||
// StrMotorInput bit_data; // 使用定义的结构体变量名
|
||||
// uint8_t arr[sizeof(StrMotorInput)]; // 通过结构体类型确定大小
|
||||
//} UnMotorInput;
|
||||
|
||||
|
||||
//-----CAN----------------------------------------------------------------
|
||||
// 接收电机控制器输入
|
||||
typedef struct _StrMotorInput
|
||||
{
|
||||
//-----接收数据0x10F90708----------------------------------------------
|
||||
unsigned int control_data3 : 16; // 读取的控制数据
|
||||
unsigned int torque : 16; // 当前扭矩
|
||||
unsigned int phase_current : 16; // 当前相电流
|
||||
unsigned int speed : 16; // 当前转速
|
||||
//-----接收数据0x101或者0x201----------------------------------------------
|
||||
unsigned int speed : 16; // 转速 偏移量 -30000
|
||||
unsigned int bus_voltage : 16; // 母线电压 系数 0.1 偏移量 -3000
|
||||
unsigned int torque : 16; // 扭矩 系数 0.01 偏移量 -300 实际物理量=数据×系数+偏移量
|
||||
unsigned int fault_code : 8; // 故障码
|
||||
unsigned int heartbeat : 8; // 心跳
|
||||
|
||||
unsigned int gear : 2; // 反馈档位
|
||||
unsigned int speed_gear : 3; // 当前扭矩
|
||||
unsigned int reserve1 : 1; // 保留
|
||||
unsigned int reserve2 : 1; // 保留
|
||||
unsigned int reserve3 : 1; // 保留
|
||||
|
||||
unsigned int reserve4 : 8; // 保留
|
||||
|
||||
unsigned int ready : 1; // Bit0: READY, 0-有告警不能行驶, 1-工作正常可行驶
|
||||
unsigned int reserved1 : 1; // Bit1: ECO状态(预留)
|
||||
unsigned int eabs : 1; // Bit2: EABS, 0-停止或驱动行驶, 1-能量回收状态
|
||||
unsigned int boost : 1; // Bit3: BOOST状态, 0-正常驱动, 1-BOOST驱动
|
||||
unsigned int reserved2 : 1; // Bit4: 预留
|
||||
unsigned int rotation_dir : 1; // Bit5: 转动方向, 0-电机逆时针转, 1-电机顺时针转
|
||||
unsigned int motor_dir : 1; // Bit6: 电机方向, 0-电机右置, 1-电机左置
|
||||
unsigned int main_relay : 1; // Bit7: 主继电器, 0-断开, 1-闭合
|
||||
|
||||
unsigned int reserve5 : 16; // 保留
|
||||
unsigned int reserve6 : 16; // 保留
|
||||
unsigned int reserve7 : 16; // 保留
|
||||
} StrMotorInput;
|
||||
|
||||
typedef union _UnMotorInput
|
||||
{
|
||||
StrMotorInput bit_data; // 使用定义的结构体变量名
|
||||
@@ -62,10 +81,43 @@ typedef union _UnMotorInput
|
||||
|
||||
|
||||
|
||||
// 接收电机控制器输入
|
||||
typedef struct _StrCanDebugOutput
|
||||
{
|
||||
uint8_t speed;
|
||||
uint8_t desired_speed;
|
||||
uint8_t curvature;
|
||||
uint8_t desired_curvature;
|
||||
uint16_t set_left_out;
|
||||
uint16_t set_right_out;
|
||||
} StrCanDebugOutput;
|
||||
|
||||
typedef union _UnCanDebugOutput
|
||||
{
|
||||
StrCanDebugOutput bit_data; // 使用定义的结构体变量名
|
||||
uint8_t arr[sizeof(StrCanDebugOutput)]; // 通过结构体类型确定大小
|
||||
} UnCanDebugOutput;
|
||||
|
||||
|
||||
|
||||
typedef struct _StrMotorTempInput
|
||||
{
|
||||
//-----接收数据0x103或者0x104----------------------------------------------
|
||||
unsigned int controller_temp : 8; // 控制器温度 偏移量 -40
|
||||
unsigned int motor_temp : 8; // 电机温度 偏移量 -40
|
||||
unsigned int motor_max_torque: 16; // 电机最大扭矩 系数 0.01 偏移量 -300 实际物理量=数据×系数+偏移量
|
||||
unsigned int reserved_1 : 8; // 保留1
|
||||
unsigned int reserved_2 : 8; // 保留2
|
||||
unsigned int reserved_3 : 8; // 保留3
|
||||
unsigned int heartbeat2 : 8; // 心跳
|
||||
|
||||
} StrMotorTempInput;
|
||||
|
||||
typedef union _UnMotorTempInput
|
||||
{
|
||||
StrMotorTempInput bit_data; // 使用定义的结构体变量名
|
||||
uint8_t arr[sizeof(StrMotorInput)]; // 通过结构体类型确定大小
|
||||
} UnMotorTempInput;
|
||||
|
||||
|
||||
|
||||
@@ -280,27 +332,27 @@ typedef union _UnSwSample
|
||||
//-----输出数据结构---------------------------------------------------------------
|
||||
//-----CAN----------------------------------------------------------------
|
||||
// 输出到电机控制器
|
||||
//typedef struct _StrMotorOutput
|
||||
//{
|
||||
////-----发送数据0x201或者0x202----------------------------------------------
|
||||
// unsigned int mode : 8; // 模式 0x1恒速模式,0x2恒扭模式,其他无效
|
||||
// unsigned int gear : 8; // 档位 0x0空挡模式,0x1前进挡,0x2倒退档,其他无效
|
||||
// unsigned int set_torque : 16; // 给定扭矩 系数 0.01 偏移量 -300 实际物理量=数据×系数+偏移量
|
||||
// unsigned int set_rotation_speed : 16; // 给定转速 偏移量 -30000
|
||||
// unsigned int fault_code : 8; // 故障码
|
||||
// unsigned int heartbeat : 8; // 心跳
|
||||
////-----发送数据0x401或者0x402----------------------------------------------
|
||||
// unsigned int feed_power : 16; // 馈电功率 单位为 W 最大为10KW
|
||||
// unsigned int discharge_power : 16; // 放电功率 单位为 W 最大为15kW
|
||||
// unsigned int reserve1 : 16; // 保留
|
||||
// unsigned int reserve2 : 16; // 保留
|
||||
//} StrMotorOutput;
|
||||
//
|
||||
//typedef union _UnMotorOutput
|
||||
//{
|
||||
// StrMotorOutput bit_data; // 使用定义的结构体变量名
|
||||
// uint8_t arr[sizeof(StrMotorOutput)]; // 通过结构体类型确定大小
|
||||
//} UnMotorOutput;
|
||||
typedef struct _StrMotorOutput
|
||||
{
|
||||
//-----发送数据0x201或者0x202----------------------------------------------
|
||||
unsigned int mode : 8; // 模式 0x1恒速模式,0x2恒扭模式,其他无效
|
||||
unsigned int gear : 8; // 档位 0x0空挡模式,0x1前进挡,0x2倒退档,其他无效
|
||||
unsigned int set_torque : 16; // 给定扭矩 系数 0.01 偏移量 -300 实际物理量=数据×系数+偏移量
|
||||
unsigned int set_rotation_speed : 16; // 给定转速 偏移量 -30000
|
||||
unsigned int fault_code : 8; // 故障码
|
||||
unsigned int heartbeat : 8; // 心跳
|
||||
//-----发送数据0x401或者0x402----------------------------------------------
|
||||
unsigned int feed_power : 16; // 馈电功率 单位为 W 最大为10KW
|
||||
unsigned int discharge_power : 16; // 放电功率 单位为 W 最大为15kW
|
||||
unsigned int reserve1 : 16; // 保留
|
||||
unsigned int reserve2 : 16; // 保留
|
||||
} StrMotorOutput;
|
||||
|
||||
typedef union _UnMotorOutput
|
||||
{
|
||||
StrMotorOutput bit_data; // 使用定义的结构体变量名
|
||||
uint8_t arr[sizeof(StrMotorOutput)]; // 通过结构体类型确定大小
|
||||
} UnMotorOutput;
|
||||
|
||||
|
||||
|
||||
@@ -357,50 +409,50 @@ typedef union _UnGatherOutput
|
||||
|
||||
|
||||
|
||||
typedef struct _StrMotorOutput
|
||||
{
|
||||
//-----发送数据0x10F80807----------------------------------------------
|
||||
unsigned int gear : 2; // 0 表示空挡,1 表示前进,2 表示后退
|
||||
unsigned int can_gear : 1; // 0-无效 1-有效。无效时 BIT10 的挡位无效,以线路控制挡位为准
|
||||
unsigned int can_break : 1; // 0:不刹车,1-刹车(刹车时才能启动电子刹车)
|
||||
unsigned int reserve1 : 1; // 0-只有高速档 1-可以通过接线切换 123 档。
|
||||
unsigned int reserve2 : 1; // 0-无效 1-有效:线控防盗使能
|
||||
unsigned int reserve3 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
unsigned int reserve4 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
|
||||
unsigned int reserve5 : 1; // 0-无效 1-有效:线控边撑使能
|
||||
unsigned int reserve6 : 1; // 0-无效 1-有效:线控防盗使能
|
||||
unsigned int reserve7 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
unsigned int reserve8 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
unsigned int reserve9 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
unsigned int reserve10 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
unsigned int reserve11 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
unsigned int reserve12 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
|
||||
unsigned int reserve13 : 1; // 0-无效 1-有效:线控边撑使能
|
||||
unsigned int reserve14 : 1; // 0-无效 1-有效:线控防盗使能
|
||||
unsigned int reserve15 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
unsigned int reserve16 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
unsigned int reserve17 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
unsigned int reserve18 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
unsigned int motor_direction : 1; // 0 和 1 (静止空闲状态设置有效,在油门、 转矩、转速模式下允许设置,否则使用控制器 内部保存的参数控制电机方向)
|
||||
unsigned int Contactor : 1; // 0-断开 1-闭合,(部分控制器支持)
|
||||
|
||||
unsigned int reserve19 : 1; // 0-无效 1-有效:线控边撑使能
|
||||
unsigned int reserve20 : 1; // 0-无效 1-有效:线控防盗使能
|
||||
unsigned int reserve21 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
unsigned int reserve22 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
unsigned int mode : 4; //0x0:转把控制,0x5:油门模式,0xA:转矩模式, 0xC:转速模式,其它无效停机。在这三种模式下,电机方向设置有效。只允许在停机状态下设置控制模式。
|
||||
|
||||
unsigned int control_data1 : 16; // 油门-256~+256:(0~+256 表示最大油门,-256 表 示最大电子刹车力度。转矩 -256~10000,(正数 驱 动 扭 矩 0~1000.0Nm,负数表示刹车,-256 表示最大电子刹车力度)转速-256~12000,(正数表示转速 0~12000rpm, 负数表示刹车,-256 最大刹车力度)
|
||||
unsigned int control_data2 : 16; // 控制数据和上一个一样
|
||||
} StrMotorOutput;
|
||||
|
||||
typedef union _UnMotorOutput
|
||||
{
|
||||
StrMotorOutput bit_data; // 使用定义的结构体变量名
|
||||
uint8_t arr[sizeof(StrMotorOutput)]; // 通过结构体类型确定大小
|
||||
} UnMotorOutput;
|
||||
//typedef struct _StrMotorOutput
|
||||
//{
|
||||
////-----发送数据0x10F80807----------------------------------------------
|
||||
// unsigned int gear : 2; // 0 表示空挡,1 表示前进,2 表示后退
|
||||
// unsigned int can_gear : 1; // 0-无效 1-有效。无效时 BIT10 的挡位无效,以线路控制挡位为准
|
||||
// unsigned int can_break : 1; // 0:不刹车,1-刹车(刹车时才能启动电子刹车)
|
||||
// unsigned int reserve1 : 1; // 0-只有高速档 1-可以通过接线切换 123 档。
|
||||
// unsigned int reserve2 : 1; // 0-无效 1-有效:线控防盗使能
|
||||
// unsigned int reserve3 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
// unsigned int reserve4 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
//
|
||||
// unsigned int reserve5 : 1; // 0-无效 1-有效:线控边撑使能
|
||||
// unsigned int reserve6 : 1; // 0-无效 1-有效:线控防盗使能
|
||||
// unsigned int reserve7 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
// unsigned int reserve8 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
// unsigned int reserve9 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
// unsigned int reserve10 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
// unsigned int reserve11 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
// unsigned int reserve12 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
//
|
||||
// unsigned int reserve13 : 1; // 0-无效 1-有效:线控边撑使能
|
||||
// unsigned int reserve14 : 1; // 0-无效 1-有效:线控防盗使能
|
||||
// unsigned int reserve15 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
// unsigned int reserve16 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
// unsigned int reserve17 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
// unsigned int reserve18 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
// unsigned int motor_direction : 1; // 0 和 1 (静止空闲状态设置有效,在油门、 转矩、转速模式下允许设置,否则使用控制器 内部保存的参数控制电机方向)
|
||||
// unsigned int Contactor : 1; // 0-断开 1-闭合,(部分控制器支持)
|
||||
//
|
||||
// unsigned int reserve19 : 1; // 0-无效 1-有效:线控边撑使能
|
||||
// unsigned int reserve20 : 1; // 0-无效 1-有效:线控防盗使能
|
||||
// unsigned int reserve21 : 1; // 0-无效 1-有效:线控巡航使能
|
||||
// unsigned int reserve22 : 1; // 0-无效 1-有效:线控座桶使能
|
||||
// unsigned int mode : 4; //0x0:转把控制,0x5:油门模式,0xA:转矩模式, 0xC:转速模式,其它无效停机。在这三种模式下,电机方向设置有效。只允许在停机状态下设置控制模式。
|
||||
//
|
||||
// unsigned int control_data1 : 16; // 油门-256~+256:(0~+256 表示最大油门,-256 表 示最大电子刹车力度。转矩 -256~10000,(正数 驱 动 扭 矩 0~1000.0Nm,负数表示刹车,-256 表示最大电子刹车力度)转速-256~12000,(正数表示转速 0~12000rpm, 负数表示刹车,-256 最大刹车力度)
|
||||
// unsigned int control_data2 : 16; // 控制数据和上一个一样
|
||||
//} StrMotorOutput;
|
||||
//
|
||||
//typedef union _UnMotorOutput
|
||||
//{
|
||||
// StrMotorOutput bit_data; // 使用定义的结构体变量名
|
||||
// uint8_t arr[sizeof(StrMotorOutput)]; // 通过结构体类型确定大小
|
||||
//} UnMotorOutput;
|
||||
|
||||
|
||||
|
||||
@@ -865,6 +917,11 @@ extern UnMotorOutput un_motor_output1; //电机输
|
||||
extern UnMotorOutput un_motor_output2; //电机输出
|
||||
extern UnMotorOutput un_motor_output3; //电机输出
|
||||
extern UnMotorOutput un_motor_output4; //电机输出
|
||||
extern UnMotorTempInput un_motor_temp1; //电机控制器1 温度
|
||||
extern UnMotorTempInput un_motor_temp2; //电机控制器2 温度
|
||||
extern UnMotorTempInput un_motor_temp3; //电机控制器3 左后侧
|
||||
extern UnMotorTempInput un_motor_temp4; //电机控制器4 右后侧
|
||||
|
||||
extern UnInfCanKGFOutput un_inf_can_kgf_output1;
|
||||
extern UnInfCanKGFOutput un_inf_can_kgf_output2;
|
||||
extern UnHBridgeOutput un_h_bridge_output;
|
||||
@@ -909,7 +966,7 @@ extern UnSdoOutput un_sdo_output ;//转向电机输出
|
||||
//变量
|
||||
extern uint8_t test_app[26];
|
||||
|
||||
|
||||
extern UnCanDebugOutput un_can_debug_output;//调试输出
|
||||
|
||||
|
||||
//函数
|
||||
|
||||
194
interface_can.c
194
interface_can.c
@@ -287,8 +287,7 @@ void flexcan_Receive_callback_1(flexcan_handle_t *handle,
|
||||
{
|
||||
flexcan_frame_t *buf = (flexcan_frame_t *)userData;
|
||||
|
||||
uint8_t i = 0;
|
||||
static uint32_t start_time = 0;
|
||||
uint8_t i = 0;
|
||||
//--------------------------------------------------------------
|
||||
switch (status)
|
||||
{
|
||||
@@ -296,51 +295,45 @@ void flexcan_Receive_callback_1(flexcan_handle_t *handle,
|
||||
break;
|
||||
|
||||
case FLEXCAN_RX_FIFO_IDLE:
|
||||
if(MOTOR_INPUT_ID_1 == (buf->id))//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1
|
||||
{
|
||||
time_elapsed = getCurrentTime() - start_time;
|
||||
start_time = getCurrentTime();
|
||||
|
||||
if(LEFT_FRONT_MOTOR_INPUT1 == (buf->id))
|
||||
{
|
||||
can_fault_info.bit_data.motor1_count ++;
|
||||
for(i = 0; i < (buf->length); i++)
|
||||
{
|
||||
un_motor_input1.arr[i] = buf->dataBuffer[i];
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
publishMessage(&un_motor_input1, 1);
|
||||
|
||||
// CAN_Send_Msg(&can_handle_1, 0x11111111, FLEXCAN_EXTEND_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_input1, 8, 18);//
|
||||
}
|
||||
else if(MOTOR_INPUT_ID_3 == (buf->id))
|
||||
publishMessage(&un_motor_input1, 1);
|
||||
}
|
||||
else if( LEFT_FRONT_MOTOR_INPUT2 == (buf->id) )
|
||||
{
|
||||
// can_fault_info.bit_data.motor1_count ++;
|
||||
for(i = 0; i < (buf->length); i++)
|
||||
{
|
||||
un_motor_temp1.arr[i] = buf->dataBuffer[i];
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
publishMessage(&un_motor_temp1, 1);//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
}
|
||||
else if( LEFT_REAR_MOTOR2_INPUT1 == (buf->id) )//
|
||||
{
|
||||
can_fault_info.bit_data.motor3_count ++;
|
||||
for(i = 0; i < (buf->length); i++)
|
||||
{
|
||||
un_motor_input3.arr[i] = buf->dataBuffer[i];
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
publishMessage(&un_motor_input3, 1);
|
||||
// CAN_Send_Msg(&can_handle_1, 0x11111113, FLEXCAN_EXTEND_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_input3, 8, 18);//
|
||||
}
|
||||
else if(MOTOR_INPUT_ID_5 == (buf->id))//<2F><><EFBFBD>յ<EFBFBD>λ
|
||||
// publishMessage(&un_motor_input3, 1); //<2F><EFBFBD>Ϊ
|
||||
}
|
||||
else if( LEFT_REAR_MOTOR2_INPUT2 == (buf->id) )
|
||||
{
|
||||
for(i = 0; i < (buf->length); i++)
|
||||
{
|
||||
un_motor_input1.arr[i+8] = buf->dataBuffer[i];
|
||||
}
|
||||
// CAN_Send_Msg(&can_handle_1, 0x11111115, FLEXCAN_EXTEND_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_input1.arr[8], 8, 18);//
|
||||
|
||||
}
|
||||
else if(MOTOR_INPUT_ID_7 == (buf->id))//<2F><><EFBFBD>յ<EFBFBD>λ
|
||||
{
|
||||
for(i = 0; i < (buf->length); i++)
|
||||
{
|
||||
un_motor_input3.arr[i+8] = buf->dataBuffer[i];
|
||||
|
||||
// CAN_Send_Msg(&can_handle_1, 0x11111117, FLEXCAN_EXTEND_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_input3.arr[8], 8, 18);//
|
||||
}
|
||||
un_motor_temp3.arr[i] = buf->dataBuffer[i];
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
publishMessage(&un_motor_temp3, 1);//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
}
|
||||
else{}
|
||||
else{}
|
||||
break;
|
||||
|
||||
case FLEXCAN_TX_IDLE:
|
||||
@@ -387,55 +380,45 @@ void flexcan_Receive_callback_2(flexcan_handle_t *handle,
|
||||
break;
|
||||
|
||||
case FLEXCAN_RX_FIFO_IDLE:
|
||||
if(MOTOR_INPUT_ID_2 == (buf->id))//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2
|
||||
{
|
||||
time_elapsed1 = getCurrentTime() - start_time1;
|
||||
start_time1 = getCurrentTime();
|
||||
|
||||
if(RIGHT_FRONT_MOTOR_INPUT1 == (buf->id))
|
||||
{
|
||||
can_fault_info.bit_data.motor2_count ++;
|
||||
for(i = 0; i < (buf->length); i++)
|
||||
{
|
||||
un_motor_input2.arr[i] = buf->dataBuffer[i];
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
publishMessage(&un_motor_input2, 1);
|
||||
|
||||
// CAN_Send_Msg(&can_handle_2, 0x11111112, FLEXCAN_EXTEND_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_input2, 8, 18);//
|
||||
|
||||
}
|
||||
else if(MOTOR_INPUT_ID_4 == (buf->id))
|
||||
publishMessage(&un_motor_input2, 1);
|
||||
}
|
||||
else if( RIGHT_FRONT_MOTOR_INPUT2 == (buf->id) )
|
||||
{
|
||||
|
||||
for(i = 0; i < (buf->length); i++)
|
||||
{
|
||||
un_motor_temp2.arr[i] = buf->dataBuffer[i];
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
publishMessage(&un_motor_temp2, 1);//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
}
|
||||
else if( RIGHT_REAR_MOTOR_INPUT1 == (buf->id) )//
|
||||
{
|
||||
can_fault_info.bit_data.motor4_count ++;
|
||||
for(i = 0; i < (buf->length); i++)
|
||||
{
|
||||
un_motor_input4.arr[i] = buf->dataBuffer[i];
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
publishMessage(&un_motor_input4, 1);
|
||||
|
||||
// CAN_Send_Msg(&can_handle_2, 0x11111114, FLEXCAN_EXTEND_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_input4, 8, 18);//
|
||||
|
||||
}
|
||||
else if(MOTOR_INPUT_ID_6 == (buf->id))//<2F><><EFBFBD>յ<EFBFBD>λ
|
||||
publishMessage(&un_motor_input4, 1);
|
||||
}
|
||||
else if( RIGHT_REAR_MOTOR_INPUT2 == (buf->id) )
|
||||
{
|
||||
for(i = 0; i < (buf->length); i++)
|
||||
{
|
||||
un_motor_input2.arr[i+8] = buf->dataBuffer[i];
|
||||
}
|
||||
|
||||
// CAN_Send_Msg(&can_handle_2, 0x11111116, FLEXCAN_EXTEND_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_input2.arr[8], 8, 18);//
|
||||
|
||||
}
|
||||
else if(MOTOR_INPUT_ID_8 == (buf->id))//<2F><><EFBFBD>յ<EFBFBD>λ
|
||||
{
|
||||
for(i = 0; i < (buf->length); i++)
|
||||
{
|
||||
un_motor_input4.arr[i+8] = buf->dataBuffer[i];
|
||||
un_motor_temp4.arr[i] = buf->dataBuffer[i];
|
||||
}
|
||||
// CAN_Send_Msg(&can_handle_2, 0x11111118, FLEXCAN_EXTEND_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_input4.arr[8], 8, 18);//
|
||||
|
||||
}
|
||||
else{}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
publishMessage(&un_motor_temp4, 1);//<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
||||
}
|
||||
else{}
|
||||
break;
|
||||
|
||||
case FLEXCAN_TX_IDLE:
|
||||
@@ -1135,18 +1118,35 @@ static void processSdoOutput8(void *signal_id)
|
||||
|
||||
static void processMotorOutput1(void *signal_id)
|
||||
{
|
||||
(void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CAN_Send_Msg(&can_handle_1, 0x10F81807, FLEXCAN_EXTEND_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_output1, 8, 15);//<2F><><EFBFBD><EFBFBD>1Ť<31>غ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CAN_Send_Msg(&can_handle_1, 0x10F83807, FLEXCAN_EXTEND_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_output3, 8, 16);//
|
||||
(void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CAN_Send_Msg(&can_handle_1, LEFT_FRONT_MOTOR_OUTPUT1, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_output1, 8, 15);//<2F><><EFBFBD><EFBFBD>1Ť<31>غ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CAN_Send_Msg(&can_handle_1, LEFT_REAR_MOTOR_OUTPUT1, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_output3, 8, 16);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1Ť<EFBFBD>غ<EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
static void processMotorOutput2(void *signal_id)
|
||||
{
|
||||
(void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CAN_Send_Msg(&can_handle_2, 0x10F82807, FLEXCAN_EXTEND_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_output2, 8, 15);//<2F><><EFBFBD><EFBFBD>2Ť<32><EFBFBD> <20><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CAN_Send_Msg(&can_handle_2, 0x10F84807, FLEXCAN_EXTEND_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_output4, 8, 16);//
|
||||
(void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CAN_Send_Msg(&can_handle_2, RIGHT_FRONT_MOTOR_OUTPUT1, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_output2, 8, 15);//<2F><><EFBFBD><EFBFBD>2Ť<32>غ<EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CAN_Send_Msg(&can_handle_2, RIGHT_REAR_MOTOR_OUTPUT1, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_output4, 8, 16);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2Ť<EFBFBD>غ<EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
//static void processMotorOutput3(void *signal_id)
|
||||
//{
|
||||
// (void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//
|
||||
// CAN_Send_Msg(&can_handle_1, LEFT_FRONT_MOTOR_OUTPUT2, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_output1.arr[8], 8, 17);//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// CAN_Send_Msg(&can_handle_1, LEFT_REAR_MOTOR_OUTPUT2, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_output3.arr[8], 8, 18);//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//
|
||||
//}
|
||||
//
|
||||
//static void processMotorOutput4(void *signal_id)
|
||||
//{
|
||||
// (void)signal_id; // <20><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>Ϊ<EFBFBD><CEAA>ʹ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// CAN_Send_Msg(&can_handle_2, RIGHT_FRONT_MOTOR_OUTPUT2, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_output2.arr[8], 8, 17);//<2F><><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// CAN_Send_Msg(&can_handle_2, RIGHT_REAR_MOTOR_OUTPUT2, FLEXCAN_STANDARD_FRAME, FLEXCAN_FrameTypeData, (uint8_t *)&un_motor_output4.arr[8], 8, 18);//<2F><><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//}
|
||||
|
||||
|
||||
|
||||
static void processKgfOutput1(void *signal_id)
|
||||
{
|
||||
@@ -1342,33 +1342,33 @@ void canInterfaceInit(void)
|
||||
memset(&un_motor_output1, 0, sizeof(UnMotorOutput));
|
||||
memset(&un_motor_output2, 0, sizeof(UnMotorOutput));
|
||||
|
||||
un_motor_output1.bit_data.mode = 0x05;
|
||||
un_motor_output1.bit_data.gear = 0x01;
|
||||
un_motor_output1.bit_data.can_gear = 0x01;
|
||||
un_motor_output1.bit_data.motor_direction = 0x01;
|
||||
un_motor_output1.bit_data.control_data1 = 0x0;
|
||||
un_motor_output1.bit_data.control_data2 = 0x0;
|
||||
|
||||
un_motor_output2.bit_data.mode = 0x05;
|
||||
un_motor_output2.bit_data.gear = 0x01;
|
||||
un_motor_output2.bit_data.can_gear = 0x01;
|
||||
un_motor_output2.bit_data.motor_direction = 0x00;
|
||||
un_motor_output2.bit_data.control_data1 = 0x0;
|
||||
un_motor_output2.bit_data.control_data2 = 0x0;
|
||||
|
||||
un_motor_output3.bit_data.mode = 0x05;
|
||||
un_motor_output3.bit_data.gear = 0x01;
|
||||
un_motor_output3.bit_data.can_gear = 0x01;
|
||||
un_motor_output3.bit_data.motor_direction = 0x01;
|
||||
un_motor_output3.bit_data.control_data1 = 0x0;
|
||||
un_motor_output3.bit_data.control_data2 = 0x0;
|
||||
|
||||
un_motor_output4.bit_data.mode = 0x05;
|
||||
un_motor_output4.bit_data.gear = 0x01;
|
||||
un_motor_output4.bit_data.can_gear = 0x01;
|
||||
un_motor_output4.bit_data.motor_direction = 0x00;
|
||||
un_motor_output4.bit_data.control_data1 = 0x0;
|
||||
un_motor_output4.bit_data.control_data2 = 0x0;
|
||||
// un_motor_output1.bit_data.mode = 0x05;
|
||||
// un_motor_output1.bit_data.gear = 0x01;
|
||||
// un_motor_output1.bit_data.can_gear = 0x01;
|
||||
// un_motor_output1.bit_data.motor_direction = 0x01;
|
||||
// un_motor_output1.bit_data.control_data1 = 0x0;
|
||||
// un_motor_output1.bit_data.control_data2 = 0x0;
|
||||
//
|
||||
// un_motor_output2.bit_data.mode = 0x05;
|
||||
// un_motor_output2.bit_data.gear = 0x01;
|
||||
// un_motor_output2.bit_data.can_gear = 0x01;
|
||||
// un_motor_output2.bit_data.motor_direction = 0x00;
|
||||
// un_motor_output2.bit_data.control_data1 = 0x0;
|
||||
// un_motor_output2.bit_data.control_data2 = 0x0;
|
||||
//
|
||||
// un_motor_output3.bit_data.mode = 0x05;
|
||||
// un_motor_output3.bit_data.gear = 0x01;
|
||||
// un_motor_output3.bit_data.can_gear = 0x01;
|
||||
// un_motor_output3.bit_data.motor_direction = 0x01;
|
||||
// un_motor_output3.bit_data.control_data1 = 0x0;
|
||||
// un_motor_output3.bit_data.control_data2 = 0x0;
|
||||
//
|
||||
// un_motor_output4.bit_data.mode = 0x05;
|
||||
// un_motor_output4.bit_data.gear = 0x01;
|
||||
// un_motor_output4.bit_data.can_gear = 0x01;
|
||||
// un_motor_output4.bit_data.motor_direction = 0x00;
|
||||
// un_motor_output4.bit_data.control_data1 = 0x0;
|
||||
// un_motor_output4.bit_data.control_data2 = 0x0;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,14 +20,33 @@
|
||||
|
||||
#define TX_MB_INDEX (USED_MB_FOR_FIFO)
|
||||
|
||||
#define LEFT_FRONT_MOTOR_INPUT1 0x101
|
||||
#define LEFT_FRONT_MOTOR_INPUT2 0x103//<2F>¶<EFBFBD>
|
||||
|
||||
//#define MOTOR_INPUT_ID_1 0x101
|
||||
//#define MOTOR_INPUT_ID_2 0x102
|
||||
|
||||
#define MOTOR_INPUT_ID_1 0x10F91708//<2F><>ǰ ת<><D7AA>
|
||||
#define MOTOR_INPUT_ID_2 0x10F92708//<2F><>ǰ
|
||||
#define MOTOR_INPUT_ID_3 0x10F93708//<2F><><EFBFBD><EFBFBD>
|
||||
#define MOTOR_INPUT_ID_4 0x10F94708//<2F>Һ<EFBFBD>
|
||||
#define LEFT_REAR_MOTOR2_INPUT1 0x102
|
||||
#define LEFT_REAR_MOTOR2_INPUT2 0x104//<2F>¶<EFBFBD>
|
||||
|
||||
|
||||
#define RIGHT_FRONT_MOTOR_INPUT1 0x101
|
||||
#define RIGHT_FRONT_MOTOR_INPUT2 0x103//<2F>¶<EFBFBD>
|
||||
|
||||
|
||||
#define RIGHT_REAR_MOTOR_INPUT1 0x102
|
||||
#define RIGHT_REAR_MOTOR_INPUT2 0x104//<2F>¶<EFBFBD>
|
||||
|
||||
|
||||
#define LEFT_FRONT_MOTOR_OUTPUT1 0x201
|
||||
#define LEFT_FRONT_MOTOR_OUTPUT2 0x401
|
||||
|
||||
#define LEFT_REAR_MOTOR_OUTPUT1 0x202
|
||||
#define LEFT_REAR_MOTOR_OUTPUT2 0x402
|
||||
|
||||
#define RIGHT_FRONT_MOTOR_OUTPUT1 0x201
|
||||
#define RIGHT_FRONT_MOTOR_OUTPUT2 0x401
|
||||
|
||||
#define RIGHT_REAR_MOTOR_OUTPUT1 0x202
|
||||
#define RIGHT_REAR_MOTOR_OUTPUT2 0x402
|
||||
|
||||
|
||||
#define MOTOR_INPUT_ID_5 0x10F81708//<2F><>ǰ <20><>λ
|
||||
@@ -73,7 +92,10 @@ typedef struct _StrCanFault
|
||||
{
|
||||
uint8_t navigator_count; //<2F><><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t motor1_count; //<2F>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t motor2_count; //<2F>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t motor2_count; //<2F>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t motor3_count; //<2F>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t motor4_count; //<2F>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
uint8_t bms_count; //bms<6D><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t temperature_count; //<2F>¶ȼ<C2B6><C8BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t remote_count; //ң<>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
@@ -81,6 +103,8 @@ typedef struct _StrCanFault
|
||||
uint8_t navigator_state; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
uint8_t motor1_state; //<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>״̬
|
||||
uint8_t motor2_state; //<2F><><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>״̬
|
||||
uint8_t motor3_state; //<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>״̬
|
||||
uint8_t motor4_state; //<2F><><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>״̬
|
||||
uint8_t bms_state; //bms״̬
|
||||
uint8_t temperature_state; //<2F>¶ȼ<C2B6><C8BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t remote_state; //ң<><D2A3>״̬
|
||||
@@ -95,7 +119,6 @@ typedef union _UnCanFault
|
||||
|
||||
|
||||
|
||||
|
||||
// can<61><6E><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
||||
typedef struct _StrCanBuffer
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user