AllServoDrv.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #ifndef _ALLSERVODRV_H_
  2. #define _ALLSERVODRV_H_
  3. extern axis_object_t *axis_x;
  4. extern axis_object_t *axis_y;
  5. extern axis_object_t *axis_z;
  6. extern axis_object_t *axis_u;
  7. extern float XGearRatio;
  8. extern float YGearRatio;
  9. extern float ZGearRatio;
  10. #define X_AXIS 0x0000
  11. #define Y_AXIS 0x0001
  12. #define Z_AXIS 0x0004
  13. #define U_AXIS 0x0008
  14. //设置使能
  15. #define MOTOR_EN 0
  16. #define MOTOR_DISEN 1
  17. //
  18. #define X_DRV AXIS_IS_RUNNING(axis_x)
  19. #define Y_DRV AXIS_IS_RUNNING(axis_y)
  20. #define Z_DRV AXIS_IS_RUNNING(axis_z)
  21. #define U_DRV AXIS_IS_RUNNING(axis_u)
  22. //运动当中改变速度
  23. extern void AxisChangeSpeed(unsigned short axis,unsigned short speed);
  24. //固定减速距离停止
  25. extern void AxisDecStopPos(unsigned short axis,unsigned long pos);
  26. //减速停
  27. extern void AxisDecStop(unsigned short axis);
  28. //立即停止
  29. extern void AxisEgmStop(unsigned short axis);
  30. //移动绝对位置
  31. extern void AxisMovePoint(unsigned short axis,unsigned short speed,long pos);
  32. //移动绝对位置带加减速
  33. extern void AxisMovePointAccDec(unsigned short axis,unsigned short speed,long pos,
  34. unsigned short start_speed,unsigned short stop_speed,
  35. unsigned short acc_pulse,unsigned short dec_pulse);
  36. //移动距离
  37. extern void AxisMovePos(unsigned short axis,unsigned short speed,long pos);
  38. //移动距离带加减速
  39. extern void AxisMovePosAccDec(unsigned short axis,unsigned short speed,long pos,
  40. unsigned short start_speed,unsigned short stop_speed,
  41. unsigned short acc_pulse,unsigned short dec_pulse,long slowpos);
  42. //移动距离不停止
  43. extern void AxisMovePosAccDecNotStop(unsigned short axis,unsigned short speed,long pos,
  44. unsigned short start_speed,unsigned short lastspeed,
  45. unsigned short acc_pulse,unsigned short dec_pulse,long slowpos);
  46. //AxisMovePosAccDecNotStop(unsigned short axis,unsigned short speed,long pos,unsigned short start_speed,unsigned short lastspeed,unsigned short acc_pulse,unsigned short dec_pulse);
  47. //移动距离带加减速不停止
  48. extern void MoveAction_Pulse_AccDec_NotStop(unsigned short cAxisNo, long dwPosi, unsigned short cSpeed,unsigned short cStartSpeed,unsigned short cLastSpeed,unsigned short cAccPulse,unsigned short cDecPulse);
  49. //连续运动
  50. extern void AxisContinueMove(unsigned short axis,unsigned short speed,unsigned char dir);
  51. //连续运动带加减速参数--中途改变目标速度
  52. extern void AxisContinueMoveChangeSpeed(unsigned short axis,unsigned short speed,unsigned short stop_speed,
  53. unsigned short acc,unsigned short dec);
  54. //两段速度移动距离
  55. extern void AxisMoveTwoPos(unsigned short axis,unsigned short speed1,long pos1,
  56. unsigned short speed2,long pos2,int dir,
  57. unsigned short start_speed,unsigned short stop_speed,
  58. unsigned short acc_pulse,unsigned short dec_pulse);
  59. //三段速度移动距离
  60. extern void AxisMoveThreePos(unsigned short axis,unsigned short speed1,long pos1,unsigned short speed2,long pos2,unsigned short speed3,long pos3,int dir);
  61. //三段速度移动距离不停止
  62. extern void AxisMoveThreePosNoStop(unsigned short axis,unsigned short speed1,long pos1,unsigned short speed2,long pos2,unsigned short speed3,long pos3,int dir);
  63. //设置真实位置
  64. extern void SetPos(unsigned short axis, long pos);
  65. //读取真实位置
  66. extern long GetPos(unsigned short axis);
  67. //获取当前速度
  68. extern unsigned long GetCurSpeed(unsigned short axis);
  69. //获取设置速度
  70. extern unsigned long GetSetSpeed(unsigned short axis);
  71. //数控PP模式
  72. extern void SetStopSelect(unsigned short axis,unsigned short Select_Flag);
  73. extern unsigned long GetState(unsigned short axis);
  74. extern unsigned long GetRemainPulse(unsigned short axis);
  75. extern unsigned long SetPulse(unsigned short axis,unsigned long pulse);
  76. extern unsigned long SetState(unsigned short axis,unsigned short state);
  77. extern void SetStartSpeed(unsigned short axis,unsigned short speed);
  78. extern void SetMinSpeed(unsigned short axis,unsigned short speed);
  79. extern void SetAccTime(unsigned short axis,unsigned short acc_time);
  80. extern void SetDecTime(unsigned short axis,unsigned short dec_time);
  81. extern void SetDir(unsigned short axis, unsigned short dir);
  82. extern void SetEn(unsigned short axis, unsigned short enable);
  83. extern unsigned char GetEn(unsigned short axis);
  84. extern unsigned char GetDir(unsigned short axis);
  85. extern long PosToPulse(unsigned short axis, long pos);
  86. extern long PulseToPos(unsigned short axis, long pulse);
  87. extern void AxisContinueMoveAcc(unsigned short axis,unsigned short speed,unsigned char dir,
  88. unsigned short start_speed,unsigned short stop_speed,
  89. unsigned short acc,unsigned short dec);
  90. //数控到数不停止模式
  91. extern void MV_Pmove_CPU_Not_Stop(unsigned short cAxisNo, long dwPosi);
  92. extern void SetEnReverse(unsigned short axis, int value);
  93. extern void SetDirReverse(unsigned short axis, int value);
  94. extern void SetAlarmReverse(unsigned short axis, int value);
  95. extern void SetClr(unsigned short axis, unsigned short clr);
  96. extern unsigned char GetAlarm(unsigned short axis);
  97. extern void AxisChangeSpeedDirect(unsigned short axis,unsigned short speed);
  98. extern void AxisMoveTwoPosNoStop(unsigned short axis,unsigned short speed1,long pos1,
  99. unsigned short speed2,long pos2,int dir,
  100. unsigned short start_speed,unsigned short stop_speed,
  101. unsigned short acc_pulse,unsigned short dec_pulse);
  102. //软件限位
  103. extern void AxisEnableSoftwarelmt(unsigned short axis, int p_pos, int n_pos);
  104. extern void AxisDisableSoftwarelmt(unsigned short axis);
  105. extern unsigned char axis_x_com_alarm,axis_y_com_alarm,axis_z_com_alarm;
  106. //设置伺服的运行模式
  107. extern void Set_Servo_Runmode(unsigned short axis, unsigned short mode);
  108. //切换控制模式切换,转矩+位置模式
  109. extern void Set_Ctrlmode_trans(unsigned short axis, unsigned short mode);
  110. //获取转矩到达状态
  111. extern unsigned char GetTarr(unsigned short axis);
  112. #endif