96 lines
2.5 KiB
C
96 lines
2.5 KiB
C
|
|
|
|||
|
|
#ifndef __STEPMOTOS_H__
|
|||
|
|
#define __STEPMOTOS_H__
|
|||
|
|
|
|||
|
|
#include "config.h"
|
|||
|
|
#include "sintable.h"
|
|||
|
|
|
|||
|
|
//------------------------------------------------------------------------
|
|||
|
|
#ifndef STEP_MOTOS_NUM
|
|||
|
|
#define STEP_MOTOS_NUM 0
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if (STEP_MOTOS_NUM > 4)
|
|||
|
|
#undef STEP_MOTOS_NUM
|
|||
|
|
#define STEP_MOTOS_NUM 4
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
//------------------------------------------------------------------------
|
|||
|
|
|
|||
|
|
#ifndef MOTO1_CCWDIR
|
|||
|
|
#define MOTO1_CCWDIR CCWDIR_POSI
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef MOTO2_CCWDIR
|
|||
|
|
#define MOTO2_CCWDIR CCWDIR_POSI
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef MOTO3_CCWDIR
|
|||
|
|
#define MOTO3_CCWDIR CCWDIR_POSI
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef MOTO4_CCWDIR
|
|||
|
|
#define MOTO4_CCWDIR CCWDIR_POSI
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
//------------------------------------------------------------------------
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ಽ<EFBFBD><E0B2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ, <20>ų<EFBFBD><C5B3><EFBFBD>90<39><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, A+, A-, B+, B-
|
|||
|
|
// <20><>Ϊ50<35><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 7.2<EFBFBD><EFBFBD>
|
|||
|
|
// һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD>ڷ<EFBFBD><DAB7><EFBFBD> 1024 <20><>4096<39><36> <20><>, <20><>Ӧһ<D3A6><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>sintable<6C><65>)
|
|||
|
|
|
|||
|
|
#define MOTO_NOPP (50) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
#define MOTO_PPC (MOTO_NOPP*SIN_TAB_SIZE) // <20><><EFBFBD><EFBFBD>ÿȦ<C3BF>ɿ<EFBFBD>λ<EFBFBD><CEBB> (50 * 4K = 200K)
|
|||
|
|
|
|||
|
|
#define MAX_OUT_LEV 240 // 320 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>pwmռ<6D>ձȣ<D5B1>
|
|||
|
|
|
|||
|
|
#define FULL_STEP_PPC 200 // <20><><EFBFBD><EFBFBD>/Ȧ
|
|||
|
|
|
|||
|
|
#ifndef MICO_STEP_PPC
|
|||
|
|
#define MICO_STEP_PPC 1000 // <><CEA2>/Ȧ
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#define PHASE_MUTI ((1.0f*MOTO_NOPP*SIN_TAB_SIZE)/(MOTO_PPC))
|
|||
|
|
|
|||
|
|
#define MAX_ABPOS_CIRCLE (1024*10) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȧ<EFBFBD><C8A6>
|
|||
|
|
|
|||
|
|
#define MAX_MOTO_POS (MAX_ABPOS_CIRCLE*MOTO_PPC) //
|
|||
|
|
|
|||
|
|
#define MAX_ADVANCE (MOTO_PPC/FULL_STEP_PPC) // 1.8<EFBFBD><EFBFBD>
|
|||
|
|
#define MIN_ADVANCE (MOTO_PPC/FULL_STEP_PPC/10) // 0.18<EFBFBD><EFBFBD>
|
|||
|
|
#define MICO_ADVANCE (MAX_ADVANCE/5) // 0.36<EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
//------------------------------------------------------------------------
|
|||
|
|
|
|||
|
|
#define CCWDIR_POSI 1 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#define CCWDIR_NEGA -1 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>뷴<EFBFBD><EBB7B4>
|
|||
|
|
|
|||
|
|
//------------------------------------------------------------------------
|
|||
|
|
|
|||
|
|
#define POS_TYPE float
|
|||
|
|
typedef void(*MotoCoilPwm)(int);
|
|||
|
|
typedef void(*MotoCoilCtrl)(void);
|
|||
|
|
|
|||
|
|
//------------------------------------------------------------------------
|
|||
|
|
|
|||
|
|
void InitStepMotos(void);
|
|||
|
|
|
|||
|
|
void SetMotoCtrlFuncs(int motoIdx,
|
|||
|
|
MotoCoilPwm coilapwm, MotoCoilCtrl acpon, MotoCoilCtrl acpoff, MotoCoilCtrl acnon, MotoCoilCtrl acnoff,
|
|||
|
|
MotoCoilPwm coilbpwm, MotoCoilCtrl bcpon, MotoCoilCtrl bcpoff, MotoCoilCtrl bcnon, MotoCoilCtrl bcnoff);
|
|||
|
|
|
|||
|
|
void SetMotoCCWDir(int motoIdx, int dir);
|
|||
|
|
|
|||
|
|
void ResetMotoPos(int motoIdx, int eff);
|
|||
|
|
void SetMotoEnable(int motoIdx, int eff);
|
|||
|
|
void SetMotoPosTo(int motoIdx, POS_TYPE pos, int eff);
|
|||
|
|
POS_TYPE GetMotoPos(int motoIdx);
|
|||
|
|
int MotoOneFullStep(int motoIdx, int dir, int eff);
|
|||
|
|
int MotoOneMicoStep(int motoIdx, int dir, int eff);
|
|||
|
|
|
|||
|
|
//------------------------------------------------------------------------
|
|||
|
|
|
|||
|
|
#endif
|