YK8A04运动控制卡VC快速搭建软件平台
//
1YK8A04打开运动控制卡
cardID = yk8000_Open();
if (cardID > 0)
{
cardID = GetCardInfo(buf);
mm.Format("%s",buf);
while (mm.GetLength() > 0)
{
AfxMessageBox(mm);
i = mm.Find(';');
if (i > 0)
{
tempStr = mm.Left(i);
k++;
mm = mm.Right(mm.GetLength() - i -1);
}
else
{
break;
}
}
SetTimer( 1, 100, NULL );
}
else
{
GetLassErrorMess(buf);
mm.Format("%s",buf);
AfxMessageBox(mm);
}
2正方向运动
/*******************************************************/
/* 编程第二步---正方向移动指定的脉冲
/*1:指定卡和轴 S形速度曲线设置函数:yk8000_Set_S_Profile
/*2:设置控制电机移动指定的脉冲:yk8000_DMC_HS_PMove (1:正方向)
/********************************************************/
void Yk8000Fun_ex1Dlg::OnForwardPmove()
{
long mstep = 0;
mstep = abs(atoi(mPOS1));
yk8000_Set_S_Profile(cardID,(Curr_Sel_Acex+1),atol(mLSPEED1),atol(mHSPEED1),atol(mAtime1),atol(mDTIME1),0.3*atol(mHSPEED1),(1-0.3)*atol(mHSPEED1));
yk8000_DMC_HS_PMove(cardID,(Curr_Sel_Acex+1),mstep,0);
UpdateData(false);
}
3 反方向运动设置
/*******************************************************/
/* 编程第二步---反方向移动指定的脉冲
/*1:指定卡和轴S形速度曲线设置函数:yk8000_Set_S_Profile
/*2:设置控制电机移动指定的脉冲:yk8000_DMC_HS_PMove (1:正方向)
/********************************************************/
void Yk8000Fun_ex1Dlg::OnNegativePmove()
{
long mstep = 0;
mstep = -(atoi(mPOS1));
yk8000_Set_S_Profile(cardID,(Curr_Sel_Acex+1),atol(mLSPEED1),atol(mHSPEED1),atol(mAtime1),atol(mDTIME1),0.3*atol(mHSPEED1),(1-0.3)*atol(mHSPEED1));
yk8000_DMC_HS_PMove(cardID,(Curr_Sel_Acex+1),mstep,0);
UpdateData(false);
}
4 急停模块
/********************************************************/
/* 急停设置
/*1:指定卡和轴立即停止:yk8000_Imd_Stop
/*********************************************************/
{
yk8000_Imd_Stop(cardID,(Curr_Sel_Acex+1));
// TODO: Add your control notification handler code here
}
5 关闭模块
void Yk8000Fun_ex1Dlg::OnExitStop()
{
yk8000_Close();
CDialog::OnCancel();
}