修改电机驱动
This commit is contained in:
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;//调试输出
|
||||
|
||||
|
||||
//函数
|
||||
|
||||
Reference in New Issue
Block a user