我正在使用一个由 Arduino 控制的 Zaber 线性平台,该平台使用 Zaber 盾牌。我尝试做与这个问题类似的事情(Track position of a Zaber device as it move),但使用 Arduino 语言而不是 Labview。
在答案中提供了 3 个选项:从起点和终点进行插值,使用计时器轮询位置,或打开每 250 毫秒报告一次位置的设备模式。
我的舞台(X-LSQ-075B-E01)似乎不存在设备模式,我不想依赖插值。载物台配有编码器,我可以很容易地获得准确位置的回读;我只是不知道如何在移动时轮询舞台。我想出了下面的代码(有点简化),但它相对较慢,只给出了第一阶段的回读(我们实际上使用的是第二阶段),并且向两者发送命令并没有真正起作用。
#include <ZaberAscii.h>
ZaberShield shield(ZABERSHIELD_ADDRESS_AA);
ZaberAscii za(shield);
void setup() {
shield.begin(115200);
Serial.begin(115200);
za.send(1, 1, "move rel", 20000);
za.receive();
while (za.isIdle(1) == false) {
za.send(1, "get encoder.pos");
ZaberAscii::reply reply = za.receive();
if (!reply.isReply) {
Serial.println("*** Received a non-reply message from device " + String(reply.deviceNumber) + ".");
}
else if (reply.isRejected) {
Serial.println("*** A command was rejected by device " + String(reply.deviceNumber) + ".");
}
else {
Serial.println( String(reply.deviceNumber) + ": " + String(reply.responseData));
}
delay(5);
}
za.pollUntilIdle(1);
Serial.println("1 finished");
za.send(2, 1, "move rel", 20000);
while (za.isIdle(2) == false) {
za.send(2, "get encoder.pos");
Serial.println("Device 2 not idle");
ZaberAscii::reply reply = za.receive();
if (!reply.isReply) {
Serial.println("*** Received a non-reply message from device " + String(reply.deviceNumber) + ".");
}
else if (reply.isRejected) {
Serial.println("*** A command was rejected by device " + String(reply.deviceNumber) + ".");
}
else {
Serial.println( String(reply.deviceNumber) + ": " + String(reply.responseData));
}
//delay(10);
}
Serial.println("2 finished");
}
void loop() {}