修改moving backzero

This commit is contained in:
2022-02-14 11:10:02 +08:00
parent 9277b1aedd
commit 9c4a54f935
4 changed files with 115 additions and 29 deletions

View File

@ -422,7 +422,7 @@ bool CVSMD12XControl::StartBackZero()
{
return false;
}
return IsMotionFinished();
bool bFlagIsStopped = false;
while (!bFlagIsStopped)
{
@ -438,6 +438,49 @@ bool CVSMD12XControl::StartBackZero()
return true;
// return ParseReturnedString(strRecv, -1);
}
bool CVSMD12XControl::IsMotionFinished()
{
//true means stopped
//false means unknown status
int iCountTotal = 0;
int iCountStopped = 0;
bool bFlagIsStopped = false;
while (!bFlagIsStopped)
{
iCountTotal++;
QThread::msleep(200);
//Delay_MSec(200);
GetStatus(m_stuMSInfo);
ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
ucFlag = ucFlag & 0x10;
if (m_stuMSInfo.fVelocity == 0)
{
iCountStopped++;
}
if (ucFlag == 0x10 && m_stuMSInfo.fVelocity == 0)
{
bFlagIsStopped = true;
return true;
}
if (iCountStopped>=50)
{
qDebug() <<"Warning.Motion Err,should be stopped already.checking register and retry...";
qDebug() <<"motion status:"<<ucFlag<<"all status:"<<QString::number(m_stuMSInfo.uiFlags,2);
bFlagIsStopped = true;
return false;
}
if (iCountTotal>1000)
{
qDebug() << "Err.Motor Hardware Err,should be stopped already";
qDebug() << "motion status:" << ucFlag << "all status:" << QString::number(m_stuMSInfo.uiFlags, 2);
bFlagIsStopped = true;
return false;
}
}
return false;
}
bool CVSMD12XControl::StopBackZero()