servostep.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #ifndef _SERVOSTEP_H
  2. #define _SERVOSTEP_H
  3. typedef struct
  4. {
  5. unsigned short cAxisNo; //
  6. unsigned short cSetSpeed;
  7. unsigned short cCurSpeed;
  8. unsigned short cCalSpeed;
  9. unsigned short cSetAccVal;
  10. unsigned short cSetDecVal;
  11. unsigned short cCalAccPulse;
  12. unsigned short cCalDecPulse;
  13. unsigned short cSetStartSpeed;
  14. unsigned short cAccDecVal;
  15. unsigned short cMinSpeed;
  16. unsigned short cMaxSpeed;
  17. unsigned short cRstStep;
  18. unsigned short cZeroFilter;
  19. unsigned short State;
  20. unsigned short bAuto_Mov;
  21. unsigned short FirstLowSpeed;
  22. long FirstAccPulse;
  23. long LowSpeedPulse;
  24. long HighSpeedPulse;
  25. long PulseOffset;// 反向补偿脉冲数
  26. long cCurRealPosi;
  27. long cRealPosi;
  28. long cDestPosi;
  29. unsigned long cPmovPulse;
  30. long cMinPulse;
  31. long cMaxPulse;
  32. } StepperDataInfo;
  33. #define bLimitAlarmEn_X cAxisDriveState.bits.b4
  34. #define bLimitAlarmEn_Y cAxisDriveState.bits.b5
  35. #define bXDir_Old cAxisDriveState.bits.b8
  36. #define bYDir_Old cAxisDriveState.bits.b9
  37. #define bXDir_Flag cAxisDriveState.bits.b12
  38. #define bYDir_Flag cAxisDriveState.bits.b13
  39. #define bXDirction hw_pwm_get_dir(axis_x->axis_no)
  40. #define bYDirction hw_pwm_get_dir(axis_y->axis_no)
  41. #define MAX_FREQ 30000
  42. #define MIN_FREQ 4000
  43. #define MAX_SPEED 50
  44. #define FLEXIBLE 4//2~15数值越大中间越陡刚启动和越接近最高速越平滑
  45. #define ACC_DEC_TIME 150
  46. extern StepperDataInfo tXAxisStepper;
  47. extern StepperDataInfo tYAxisStepper;
  48. extern void XAxis_PWMProc(void);
  49. extern void YAxis_PWMProc(void);
  50. extern void CalRunPulse(StepperDataInfo *tCurSetStpper);
  51. extern void MV_Set_Startv_CPU(unsigned short cAxisNo, unsigned short cSpeed);
  52. extern void MV_Set_Speed_CPU(unsigned short cAxisNo, unsigned short cSpeed);
  53. extern long MV_Get_Command_Pos_CPU(unsigned short cAxisNo);
  54. extern void MV_Set_Command_Pos_CPU(unsigned short cAxisNo,long pos);
  55. extern void MV_Set_Command_SlMTP_CPU(unsigned short cAxisNo, unsigned long dwMaxLen);
  56. extern void MV_Set_Command_SlMTN_CPU(unsigned short cAxisNo, unsigned long dwMinLen);
  57. extern void StartPWM(unsigned short cAxisNo);
  58. extern void ReadAxisStatus(void);
  59. extern void MV_Sudden_Stop_CPU(unsigned short cAxisNo);
  60. extern void MV_Dec_Stop_CPU(unsigned short cAxisNo);
  61. extern void MV_Move_To_Position(unsigned short axis, long position);
  62. extern void MV_Pmove_CPU(unsigned short cAxisNo, long dwPosi);
  63. extern void MV_AccDec_Set_CPU(unsigned short cAxisNo, unsigned short cSetAcc, unsigned short cSetDec);
  64. extern void MV_Set_Acc_CPU(unsigned short cAxisNo, unsigned short cSetAcc);
  65. extern void MV_Set_Dec_CPU(unsigned short cAxisNo, unsigned short cSetAcc);
  66. extern void MoveAction_Pulse(unsigned short cAxisNo, long dwPosi, unsigned short cSpeed);
  67. extern void MV_Continue_Move_CPU(unsigned short cAxisNo, unsigned short dir);
  68. extern void MoveAction_Pulse2(unsigned short cAxisNo, long dwPosi,long lowpos,long back_lowpos,unsigned short cSpeed,unsigned short low_speed);
  69. extern void ReadAxisStatus_CPU(unsigned short cAxisNo);
  70. extern void ServoInit(void);
  71. extern void ResetServoDrv_CPU(unsigned short axis);
  72. extern void MoveAction_Const_Stop(unsigned short cAxisNo, unsigned short dir, unsigned short cSpeed);
  73. extern void MoveChangSpeed(unsigned short cAxisNo, unsigned short cSpeed);
  74. extern void MoveAction_Const(unsigned short cAxisNo, unsigned short dir, unsigned short cSpeed);
  75. extern void MoveAction_Pulse(unsigned short cAxisNo, long dwPosi, unsigned short cSpeed);
  76. extern void MoveAction_Dist(unsigned short cAxisNo, unsigned long dwPosi, unsigned short cSpeed);
  77. extern void MoveChangSpeedPos(unsigned short cAxisNo, unsigned short cSpeed,long pulse);
  78. extern void SetPulse_X(unsigned short startv, unsigned short cSpeed, long dwPosi);
  79. extern void SetPulse_Y(unsigned short startv, unsigned short cSpeed, long dwPosi);
  80. extern void MV_Suddent_Stop(unsigned short cAxisNo);
  81. extern unsigned long MV_Cal_Dec_pulse(unsigned short high_speed,unsigned short low_speed,unsigned short dec_time);
  82. extern void MoveAction_Const_Back(unsigned short cAxisNo, unsigned short dir, unsigned short cSpeed,unsigned short low_speed,unsigned long pulse);
  83. extern void CalculateSModelLine(unsigned short *fre,float len, float fre_max, float fre_min, float flexible);
  84. extern void SetRemainLength(unsigned short cAxisNo, long dwPosi,unsigned short set_speed);
  85. extern void MoveAction_Const_Stop_AccDec(unsigned short cAxisNo, unsigned short dir, unsigned short cSpeed,unsigned short cStartSpeed,unsigned short cAccPulse,unsigned short cDecPulse);
  86. extern void MoveAction_Const_Back_AccDec(unsigned short cAxisNo, unsigned short dir, unsigned short cSpeed,unsigned short low_speed,unsigned long pulse,unsigned short start_speed,unsigned short cAccPulse,unsigned short cDecPulse);
  87. extern void MoveAction_Pulse_AccDec(unsigned short cAxisNo, long dwPosi, unsigned short cSpeed,unsigned short cStartSpeed,unsigned short cAccPulse,unsigned short cDecPulse);
  88. extern void CalFreqTab_X_Free(unsigned char divide_var);
  89. extern void MoveAction_Pulse2_AccDec(unsigned short cAxisNo, long dwPosi,long lowpos,long back_lowpos, unsigned short cSpeed,unsigned short low_speed,unsigned short start_speed, unsigned short acc_pulse,unsigned short dec_pulse);
  90. extern void MoveAction_Const_AccDec(unsigned short cAxisNo, unsigned short dir, unsigned short cSpeed,unsigned short start_speed,unsigned short accpulse,unsigned short dec_pulse);
  91. extern unsigned short FreqTab_X[];
  92. extern const unsigned long FreqTab_XX[];
  93. extern void CalFreqTab_X_Free_JY(unsigned char divide_var);
  94. #endif