You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.0 KiB

/******************************************************************************
(C), 2018-2099, Radkil
******************************************************************************
: msp_motor_leisai.h
: 稿
: radkil
: 2026713
:
: ISV2电机CAN协议实现
:
1. : 2026713
: radkil
:
******************************************************************************/
#ifndef __MOTOR_LEISAI_H__
#define __MOTOR_LEISAI_H__
#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif /* __cplusplus */
/*==============================================*
* include header files *
*----------------------------------------------*/
#include "motor_manager.h"
/*==============================================*
* constants or macros define *
*----------------------------------------------*/
// SDO命令字
#define LEISAI_SDO_CMD_READ 0x40
#define LEISAI_SDO_CMD_WRITE_1B 0x2F
#define LEISAI_SDO_CMD_WRITE_2B 0x2B
#define LEISAI_SDO_CMD_WRITE_3B 0x27
#define LEISAI_SDO_CMD_WRITE_4B 0x23
// CANopen 对象字典索引
#define LEISAI_OD_CONTROL_WORD 0x6040
#define LEISAI_OD_STATUS_WORD 0x6041
#define LEISAI_OD_MODE_OF_OPERATION 0x6060
#define LEISAI_OD_POSITION_ACTUAL 0x6064
#define LEISAI_OD_VELOCITY_ACTUAL 0x606C
#define LEISAI_OD_TORQUE_ACTUAL 0x6077
#define LEISAI_OD_TARGET_VELOCITY 0x60FF
#define LEISAI_OD_TARGET_POSITION 0x607A
#define LEISAI_OD_ACCELERATION 0x6083
#define LEISAI_OD_DECELERATION 0x6084
#define LEISAI_OD_FAULT_CODE 0x603F
#define LEISAI_OD_HOMING_METHOD 0x6098
#define LEISAI_OD_WATCHDOG_TIME 0x5004
// 操作模式
#define LEISAI_MODE_PROFILE_POS 0x01
#define LEISAI_MODE_PROFILE_VEL 0x03
#define LEISAI_MODE_HOMING 0x06
// 控制字命令
#define LEISAI_CTRL_SHUTDOWN 0x06
#define LEISAI_CTRL_SWITCH_ON 0x07
#define LEISAI_CTRL_ENABLE 0x0F
#define LEISAI_CTRL_START_MOVE 0x5F
#define LEISAI_CTRL_RELATIVE_MOVE 0x4F
/*==============================================*
* data structures *
*----------------------------------------------*/
/*==============================================*
* project-wide global variables *
*----------------------------------------------*/
// 雷赛协议操作函数表(全局单例)
extern const Motor_Protocol_t g_stLeiSaiProtocol;
/*==============================================*
* routines' or functions' implementations *
*----------------------------------------------*/
/**
* @brief
* @return
*/
const Motor_Protocol_t* LeiSai_GetProtocol(void);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* __MOTOR_LEISAI_H__ */