#ifndef __CPMOTOR_H #define __CPMOTOR_H #ifdef __cplusplus extern "C" { #endif #ifndef CPMOTOR_API #ifdef CPMOTOR_API_EXPORTS #define CPMOTOR_API extern "C" __declspec(dllexport) #else #define CPMOTOR_API extern "C" __declspec(dllimport) #endif #endif // CANopen Master Error Code Define #define CPM_NoError 0 #define CPM_DriverErr 1 #define CPM_ActiveError 2 #define CPM_OpenComErr 2 #define CPM_MasterIDErr 3 #define CPM_ComPortErr 3 #define CPM_MasterFull 4 #define CPM_ConfigErr 5 #define CPM_MasterInitErr 6 #define CPM_MasterNotInit 7 #define CPM_ListenMode 8 #define CPM_NodeErr 9 #define CPM_NodeExist 10 #define CPM_TxBusy 12 #define CPM_UnknowCmd 13 #define CPM_CmdReceErr 14 #define CPM_DataEmpty 15 #define CPM_MemAllocErr 16 #define CPM_SendCycMsgErr 17 #define CPM_StatusErr 18 #define CPM_SetGuardErr 20 #define CPM_SetHbeatErr 21 #define CPM_SegLenErr 22 #define CPM_SegToggleErr 23 #define CPM_SegWriteErr 24 #define CPM_Abort 25 #define CPM_PDOLenErr 26 #define CPM_COBIDErr 27 #define CPM_PDOInstErr 28 #define CPM_PDODynaErr 29 #define CPM_PDONumErr 30 #define CPM_PDOSetErr 31 #define CPM_PDOEntryErr 32 #define CPM_SetCobIdErr 33 #define CPM_CycFullErr 34 #define CPM_Timeout 35 #define CPM_DataLenErr 36 #define CPM_SendLose 38 #define CPM_SendCmdErr 39 #define CPM_Wait 40 #define CPM_Processing 41 #define CPM_LoadEDSErr 50 #define CPM_EDSFormatErr 51 /// CANopen Motion Error Code #define CPM_MT_NoError 0 #define CPM_MT_Timeout 35 #define CPM_MT_CtrlNotSupport 101 // The control code is not supported #define CPM_MT_GetOperateModeErr 102 // Get Operating Mode error (Position, Homing,...) #define CPM_MT_SetOperateModeErr 103 // Set Operating Mode error (Position, Homing,...) #define CPM_MT_OperateModeChkErr 104 // Operating Mode check error #define CPM_MT_GetPositionErr 105 // Get position error #define CPM_MT_SetPositionErr 106 // Set position error #define CPM_MT_GetVelocityErr 107 // Get velocity error #define CPM_MT_SetVelocityErr 108 // Set velocity error #define CPM_MT_GetTorqueErr 109 // Get Torque error #define CPM_MT_SetTorqueErr 110 // Set Torque error #define CPM_MT_GetAccelerationErr 111 // Get acceleration error #define CPM_MT_SetAccelerationErr 112 // Set acceleration error #define CPM_MT_GetDecelerationErr 113 // Get deceleration error #define CPM_MT_SetDecelerationErr 114 // Set deceleration error #define CPM_MT_SetTorqueSlope 115 // Set Torque slope error #define CPM_MT_MethodSelectErr 116 // Motion method select error or not support #define CPM_MT_GetStatusErr 117 // Get any status error #define CPM_MT_SetStatusErr 118 // Set any status error #define CPM_MT_GetParameterErr 119 // Read Parameter error #define CPM_MT_SetParameterErr 120 // Parameter set over range #define CPM_MT_KeypadIndexErr 121 #define CPM_MT_KeypadSubIndexErr 122 #define CPM_MT_KeypadDataLenErr 123 #define CPM_MT_HeartbeatTimeout 124 #define CPM_MT_MotorNodeError 125 #define CPMotor_MasterModuleError 10000 #define CPMotor_LoadMasterDLLError 20000 #define CPMotor_ManufacturerNotSupport 30000 #define CPMotor_HSIP_StepNumError 30001 //for CPMotor_InitMaster() MasterModule parameter #define MASTER_MODULE_I7565CPM 1 #define MASTER_MODULE_PISOCPM100U 2 #define MASTER_MODULE_I8123W 3 //for CPMotor_InitMaster() CAN Baud Rate #define CANBaud_10K 0 #define CANBaud_20K 1 #define CANBaud_50K 2 #define CANBaud_125K 3 #define CANBaud_250K 4 #define CANBaud_500K 5 #define CANBaud_800K 6 #define CANBaud_1M 7 //for CPMotor_AddMotor() Motor_Manufacturer parameter #define Manufact_GeneralMotor 0 //for General CiA 402 Motor #define Manufact_Delta_A2_Motor 1 //for Delta ASDA-A2 Motor #define Manufact_SANYO_R2_Motor 2 //for SANYO R2 Motor #define Manufact_Schneider_LXM23A_Motor 3 //for Schneider LXM23A Motor #define Manufact_Festo_Motor 4 //for FESTO CMMS-ST, CMMP-AS Motor //=============================================================/ // Common Command //=============================================================/ CPMOTOR_API WORD CALLBACK CPMotor_DLLVersion(WORD *Ver); CPMOTOR_API WORD CALLBACK CPMotor_InitMaster(BYTE MasterModule, BYTE ModuleID, BYTE BaudRate); CPMOTOR_API WORD CALLBACK CPMotor_ShutdownMaster(BYTE ModuleID); CPMOTOR_API WORD CALLBACK CPMotor_AddMotor(BYTE ModuleID, BYTE Node, WORD DelayTime = 1, WORD ResTimeout = 200, WORD Motor_Manufacturer = Manufact_Delta_A2_Motor); CPMOTOR_API WORD CALLBACK CPMotor_CloseMotor(BYTE ModuleID, BYTE Node); CPMOTOR_API WORD CALLBACK CPMotor_InitMotor(BYTE ModuleID, BYTE Node, WORD PDOTimer = 10); CPMOTOR_API WORD CALLBACK CPMotor_Servo_ON_OFF(BYTE ModuleID, BYTE Node, BYTE ServoFlag); CPMOTOR_API WORD CALLBACK CPMotor_IsServoON(BYTE ModuleID, BYTE Node, BYTE *IsServoON); CPMOTOR_API WORD CALLBACK CPMotor_Servo_Reset(BYTE ModuleID, BYTE Node, BYTE ResetType = 0); CPMOTOR_API WORD CALLBACK CPMotor_MotorStatus(BYTE ModuleID, BYTE Node, BYTE *CurrMode, BYTE *IsServoReady, BYTE *IsFault, BYTE *IsWarning, BYTE *IsDone, WORD *Statusword); CPMOTOR_API WORD CALLBACK CPMotor_MotionStop(BYTE ModuleID, BYTE Node, DWORD DecVal); CPMOTOR_API WORD CALLBACK CPMotor_HM_HomeMove(BYTE ModuleID, BYTE Node, BYTE HomeMethod, DWORD MaxV, DWORD FinalV, DWORD Acceleration); //=============================================================/ // Position Command //=============================================================/ CPMOTOR_API WORD CALLBACK CPMotor_PP_CurrentPosition(BYTE ModuleID, BYTE Node, long *PositionVal); CPMOTOR_API WORD CALLBACK CPMotor_PP_MotionMove(BYTE ModuleID, BYTE Node, BYTE IsChangeImmediately, BYTE IsAbsolute, long TargetPosition, DWORD AccVal, DWORD Velocity, DWORD DecVal); CPMOTOR_API WORD CALLBACK CPMotor_PP_SetVelocity(BYTE ModuleID, BYTE Node, DWORD AccVal, DWORD Velocity, DWORD DecVal); CPMOTOR_API WORD CALLBACK CPMotor_PP_JOGMove(BYTE ModuleID, BYTE Node, long JogPulse, DWORD ACCVal, DWORD JogVelocity, DWORD DECVal); CPMOTOR_API WORD CALLBACK CPMotor_PV_JOGMove(BYTE ModuleID, BYTE Node, DWORD ACCVal, long JogVelocity, DWORD DECVal); //=============================================================/ // Velocity Command //=============================================================/ CPMOTOR_API WORD CALLBACK CPMotor_PV_CurrentVelocity(BYTE ModuleID, BYTE Node, long *VelocityVal); CPMOTOR_API WORD CALLBACK CPMotor_PV_MotionMove(BYTE ModuleID, BYTE Node, DWORD AccVal, long TargetVelocity, DWORD DecVal); //=============================================================/ // Torque Command //=============================================================/ CPMOTOR_API WORD CALLBACK CPMotor_PT_CurrentTorque(BYTE ModuleID, BYTE Node, long *TorqueVal); CPMOTOR_API WORD CALLBACK CPMotor_PT_MotionMove(BYTE ModuleID, BYTE Node, DWORD TorqueSlope, long TargetTorque); //=============================================================/ // Synchronous Motion Command //=============================================================/ CPMOTOR_API WORD CALLBACK CPMotor_SYNCInitial(BYTE ModuleID, BYTE Node); //CPMOTOR_API WORD CALLBACK CPMotor_SYNCMove_Ex(BYTE ModuleID, BYTE NodeNum, BYTE* Node_IDs, long* TargetPositions, DWORD MaxVelocity, BYTE IsAbsolute); CPMOTOR_API WORD CALLBACK CPMotor_SYNCMove_Ex(BYTE ModuleID, BYTE NodeNum, BYTE* Node_IDs, long* TargetPosition, DWORD AccVal, DWORD MaxVelocity, DWORD DecVal, BYTE IsAbsolute); CPMOTOR_API WORD CALLBACK CPMotor_SYNCMove(BYTE ModuleID, BYTE NodeNum, BYTE* Node_IDs, long* TargetPositions, DWORD* AccVals, DWORD* Velocities, DWORD* DecVals, BYTE IsAbsolute); CPMOTOR_API WORD CALLBACK CPMotor_SYNCStop(BYTE ModuleID, BYTE NodeNum, BYTE* Node_IDs); //=============================================================/ // Command for Delta ASDA-A2 and Schneider LXM23A motor //=============================================================/ CPMOTOR_API WORD CALLBACK CPMotor_ServoDOStatus(BYTE ModuleID, BYTE Node, DWORD *DO_Status); CPMOTOR_API WORD CALLBACK CPMotor_GetServoAlarm(BYTE ModuleID, BYTE Node, DWORD *AlarmCode); CPMOTOR_API WORD CALLBACK CPMotor_TorqueLimit(BYTE ModuleID, BYTE Node, WORD TorqueLimit); CPMOTOR_API WORD CALLBACK CPMotor_SetKeypad(BYTE ModuleID, BYTE Node, BYTE ParamIndex, BYTE ParamSubIndex, BYTE DataLen, DWORD SetParamData); CPMOTOR_API WORD CALLBACK CPMotor_GetKeypad(BYTE ModuleID, BYTE Node, BYTE ParamIndex, BYTE ParamSubIndex, BYTE *DataLen, DWORD *GetParamData); //=============================================================/ // Linear interpolation Command //=============================================================/ CPMOTOR_API WORD CALLBACK CPMotor_IPInitial(BYTE ModuleID, BYTE Node); CPMOTOR_API WORD CALLBACK CPMotor_IP_LineMove(BYTE ModuleID, BYTE NodeNum, BYTE Node_IDs[], long Node_TargetPos[], BYTE Rel_Abs[], DWORD Velocity, DWORD AccTime, DWORD DecTime, BYTE IsWaitForPreviousMoving); CPMOTOR_API WORD CALLBACK CPMotor_IP_PathMove(BYTE ModuleID, BYTE NodeNum, BYTE Node_IDs[], BYTE Rel_Abs[], long StepNum, long Node_PathSteps[], BYTE IsWaitForPreviousMoving); //CPMOTOR_API WORD CALLBACK CPMotor_IP_PathMove(BYTE ModuleID, BYTE NodeNum, BYTE Node_IDs[], BYTE Rel_Abs[], long StepNum, long *Node_PathSteps[], BYTE IsWaitForPreviousMoving); CPMOTOR_API WORD CALLBACK CPMotor_IP_Stop(BYTE ModuleID, DWORD DecTime); CPMOTOR_API WORD CALLBACK CPMotor_IP_PositionCompare(BYTE ModuleID, BYTE Node, BYTE Position_Cnt, long* Position_Array, BYTE Target_Node, BYTE* Trigger_Bit); CPMOTOR_API WORD CALLBACK CPMotor_SetUserObject_1(BYTE ModuleID, BYTE Node, BYTE Obj_Num, BYTE Obj_Len[], WORD Obj_Idx[], BYTE Obj_Subidx[]); CPMOTOR_API WORD CALLBACK CPMotor_GetUserData_1(BYTE ModuleID, BYTE Node, BYTE* DLen, BYTE RData[]); CPMOTOR_API WORD CALLBACK CPMotor_SetUserObject_2(BYTE ModuleID, BYTE Node, BYTE Obj_Num, BYTE Obj_Len[], WORD Obj_Idx[], BYTE Obj_Subidx[]); CPMOTOR_API WORD CALLBACK CPMotor_GetUserData_2(BYTE ModuleID, BYTE Node, BYTE* DLen, BYTE RData[]); #define CPMotor_IP_SetUserObject_1 CPMotor_SetUserObject_1 #define CPMotor_IP_GetUserData_1 CPMotor_GetUserData_1 #define CPMotor_IP_SetUserObject_2 CPMotor_SetUserObject_2 #define CPMotor_IP_GetUserData_2 CPMotor_GetUserData_2 //=============================================================/ // High Speed Interpolation Command //=============================================================/ CPMOTOR_API WORD CALLBACK CPMotor_HSIP_Initial(BYTE ModuleID, BYTE NodeNum, BYTE Node_IDs[]); CPMOTOR_API WORD CALLBACK CPMotor_HSIP_PathMove(BYTE ModuleID, BYTE NodeNum, BYTE Node_IDs[], long StepNum, long Node_PathSteps[]); CPMOTOR_API WORD CALLBACK CPMotor_HSIP_Stop(BYTE ModuleID, BYTE NodeNum, BYTE Node_IDs[]); //=============================================================/ // Misc. Command //=============================================================/ CPMOTOR_API WORD CALLBACK CPMotor_ClearPulse(BYTE ModuleID, BYTE Node, long ZeroPosition); CPMOTOR_API WORD CALLBACK CPMotor_ResetAlarm(BYTE ModuleID, BYTE Node); CPMOTOR_API WORD CALLBACK CPMotor_SDOReadData(BYTE ModuleID, BYTE Node, WORD Index, BYTE SubIndex, DWORD *DataLen, BYTE bData[]); CPMOTOR_API WORD CALLBACK CPMotor_SDOWriteData(BYTE ModuleID, BYTE Node, WORD Index, BYTE SubIndex, DWORD DataLen, BYTE bData[]); #ifdef __cplusplus } #endif #endif // __CPMOTOR_H