发表于:2006-04-21 09:57:00
楼主
固高GT控制器+富士RYC101D3-VVT2伺服放大器+伺服电机
可以使伺服电机轴锁住(处于控制状态),但不能让伺服电机轴转动 ,是什么原因?
运行下面程序后,输出Status:0301 Status:0701
#include "GT400.h"
#include "stdio.h"
void error(short eno)
{
unsigned short msg;
switch(eno)
{
case -1:
printf("Error:Communication error!\n");
break;
case 0:
/*no error*/
break;
case 1:
GT_GetCmdSts(&msg);
printf("Error: Command Error with message: %04x\n", msg);
case 2:
case 3:
case 4:
case 5:
case 7:
printf("Error: Parameter Error.\n");
break;
case 6:
printf("Error: Map is Error.\n");
break;
default:
break;
}
}
void GTInitial()
{
short rtn;
rtn = GT_Open();
error(rtn);
rtn = GT_Reset();
error(rtn);
rtn = GT_SwitchtoCardNo(0);
error(rtn);
rtn = GT_SetSmplTm(200);
error(rtn);
for(int i=1; i<3; i++)
{
rtn = GT_Axis(i);
rtn = GT_SetIntrMsk(0);
}
}
void InputCfg()
{
short rtn;
unsigned int enc_sense = 0xF;
rtn = GT_EncSns(enc_sense); error(rtn);
}
void AxisInitial()
{
short rtn;
rtn = GT_Axis(1); error(rtn); //set the current axis
rtn =GT_LmtsOff();error(rtn);
rtn = GT_ClrSts(); error(rtn); //clear error status
rtn = GT_CtrlMode(0); error(rtn); //set the output method, voltage or pulse
rtn = GT_CloseLp(); error(rtn); //set the close loop control method
//rtn = GT_OpenLp(); error(rtn);
rtn = GT_SetKp(20); error(rtn);
rtn = GT_SetKi(0); error(rtn);
rtn = GT_SetKd(10); error(rtn);
rtn = GT_SetKvff(0); error(rtn);
rtn = GT_SetKaff(0); error(rtn);
rtn = GT_SetMtrBias(10); error(rtn);
rtn = GT_Update(); error(rtn);
rtn = GT_AxisOn(); error(rtn);
}
void VMotion()
{
short rtn;
unsigned short status;
long pos;
rtn = GT_GetSts(&status);error(rtn);
printf("Status: %04x\n", status);
rtn = GT_GetPosErr(&status);error(rtn);
printf("Position error: %d\n", status);
rtn = GT_GetAtlPos(&pos);error(rtn);
printf("Current Position: %ld\n", pos);
rtn = GT_PrflV(); error(rtn);
rtn = GT_SetAcc(0.01); error(rtn);
rtn = GT_SetVel(1); error(rtn);
rtn = GT_Update(); error(rtn);
rtn = GT_GetSts(&status);error(rtn);
printf("Status: %04x\n", status);
rtn = GT_GetAtlPos(&pos);error(rtn);
printf("Current Position: %ld\n", pos);
}
void main()
{unsigned short status;
int d;
short rtn = 0;
GTInitial();
InputCfg();
AxisInitial();
VMotion();
scanf("%d", &d);
GT_AxisOff();
GT_Close();
}