MKR 485 Shield don't get a receive from Piezo Motor Controller via RS485

Hi,

I'm currently working on the following project:

I want to send and receive data to a Piezo driver via RS485.
For that purpose, I use this hardware:

The MKR 485 Shield is connected like that to the PMD401:

Y to Data+
Z to Data-
GND to GND

And jumper positions

  • FULL set to OFF
  • Z // Y set to ON

And here is my code:

#include <ArduinoRS485.h>

void setup() {
  RS485.begin(115200);
  Serial.begin(115200);
  RS485.receive();
}

int counter = 0;
byte rx_byte = 0;

void loop() {
  Serial.print("Count No: ");
  Serial.println(counter);
  RS485.beginTransmission();
  RS485.write("X1J20,0,150\r");
  RS485.write("X1E\r");
  Serial.flush();
  delay(500);
  while (RS485.available()) {
    // get a byte RS485
    rx_byte = RS485.read();
    // send the byte to the Monitor
    Serial.write(rx_byte);
  }
  RS485.endTransmission();
  Serial.println(" ");
  delay(10000);
  counter ++;
}

And the output from the terminal:

Count No: 1
X1J20,0,150X1E
Count No: 2
X1J20,0,150X1E 
Count No: 3
X1J20,0,150X1E

What I don't understand is the following:

If I send the command

RS485.write("X1J200,0,200\r");

The motor runs. -> so sending works, I think.

But if I send that command (like it is written in the manual page 2, point 7)

RS485.write("X1E\r");

I get no feedback at all. (like you see in the terminal)

So what do I have to do, that the Controller gives me feedback from the encoder? I tried a lot of different commands from the manual, but nothing works.... :frowning: It just reads the last sent commands.

You probably should read the response from the driver after the first command before you send the next command. Remember, RS-485 is (in most cases) a half-duplex connection. If you send the second command while the device sends you an answer it will be lost.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.