Hi,
I'm working on a project with an Arduino MKR 485 Shield (stacked on a MKR 1010 Wifi) and a PMD401 Motor controller (Manual https://piezomotor.com/wp-content/uploads/2019/03/150025_PMD401_Technical_Manual.pdf).
They comunicate via RS485 and ASCII.
The problem I have is, that I can send a command, the motor runs, but I can't get any data from the controller.
With the command I use, it just repeats the commands I sent before. Normally the "X1E" command should give me the position of the motor like "X1E:20" (see manual page 5, point 7).
How can I fix this?
Here is my code:
#include <ArduinoRS485.h>
void setup() {
RS485.begin(115200);
Serial.begin(115200);
RS485.receive();
}
int counter = 0;
byte RS485_byte = 0;
void loop() {
Serial.print("Count No: ");
Serial.println(counter);
RS485.beginTransmission();
RS485.write("X1J20,0,150\r"); // run the motor
RS485.write("X1E\r"); // get the location of the encoder
Serial.flush();
delay(20);
while (RS485.available()) {
RS485_byte = RS485.read(); // get a byte RS485
Serial.write(RS485_byte); // send the byte to the Monitor
}
RS485.endTransmission();
Serial.println(" ");
delay(10000);
counter ++;
}
And the terminal output:
Count No: 1
X1J20,0,150X1E
Count No: 2
X1J20,0,150X1E
Count No: 3
X1J20,0,150X1E