增加了关于双步进电机同步运行

This commit is contained in:
xin
2020-09-10 17:22:43 +08:00
parent 495f947827
commit 93e9d8d222
14 changed files with 58 additions and 9 deletions

View File

@ -11,10 +11,16 @@ VinceControl::VinceControl(ProTools proto)
{
protools = proto;
initme();
}
void VinceControl::setSyncMode()
{
isSyncMotor = true;
}
VinceControl::~VinceControl()
{
if (protools == RS232 || protools == RS485)
@ -139,6 +145,10 @@ void VinceControl::SendCommandtoMotor(QString str)
}
else if (protools==NETTCP)
{
if (isSyncMotor)
{
str = "0 " + str;
}
if (tcpSocket.length() == 0)
{
return;
@ -160,6 +170,10 @@ void VinceControl::SendCommandtoMotor(QString str, QString modor)
}
if (protools!=NETTCP)
{
return;
}
int lenth = tcpSocket.length();
int lenthstring = Motorlist.length();
if (lenthstring!=lenth)
@ -170,6 +184,10 @@ void VinceControl::SendCommandtoMotor(QString str, QString modor)
{
if (Motorlist.at(i)==modor)
{
if (isSyncMotor)
{
str = "0 " + str;
}
tcpSocket[i]->write(str.toUtf8().data());
tcpSocket[i]->waitForBytesWritten(1000);
return;
@ -372,6 +390,7 @@ void VinceControl::initme()
RS485ID = "0";
Speednow = 0;
SpeedisSet = false;
isSyncMotor = false;
}