大家好,我用雷塞智能的2410控制卡,控制步进电机带动z轴上下运动的时候会出现,运动速度突然变慢或运动突然停止的现象,我的代码如下大家看看是否有问题。
bool Test_z = false;
int nZStep = 0;
bool zGoHOme = false;
bool zMoveIng = false;
private void backgroundWorkerSingleStep_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
while (worker.CancellationPending == false)
{
if (bAlam || bEMGStop)
{
continue;
}
float curZ = 0;
if (Test_z)
{
if (zMoveIng)
{
if (CheckAxisDone(AxisName.ZAxis))
{
zMoveIng = false;
if (!zGoHOme)
{
zGoHOme = true;
}
else
{
zGoHOme = false;
}
continue;
}
else
{
Thread.Sleep(10);
continue;
}
}
if (zGoHOme)
{
Dmc2410.d2410_set_st_profile((ushort)AxisName.ZAxis, ZAxisMinSpeed, ZAxisRunSpeed, ZAxisTAcc, ZAxisTAcc, ZAxisTAcc, ZAxisTAcc);
Dmc2410.d2410_s_pmove((ushort)AxisName.ZAxis, (int)0, 1);
zMoveIng = true;
continue;
}
else
{
curZ = (float)leftAccessory.ZXB;
Dmc2410.d2410_set_st_profile((ushort)AxisName.ZAxis, ZAxisMinSpeed, ZAxisRunSpeed, ZAxisTAcc, ZAxisTAcc, ZAxisTAcc, ZAxisTAcc);
Dmc2410.d2410_s_pmove((ushort)AxisName.ZAxis, (int)curZ, 1);
zMoveIng = true;
continue;
}
}
}
}