RS-485 Encoder Integration Problem on T6M80-1000H2A1-M23

this is my last code:

#include <SoftwareSerial.h>

#define RO_pin 10  
#define DI_pin 9   
#define RE_DE_pin 11  

SoftwareSerial RS485Serial(RO_pin, DI_pin); 

void setup() {
  pinMode(RE_DE_pin, OUTPUT);
  digitalWrite(RE_DE_pin, LOW); 
  Serial.begin(9600); 
  RS485Serial.begin(9600); 
  
  Serial.println("Inizializzazione completata. Pronto per ricevere dati dall'encoder.");
}

void loop() {
  if (RS485Serial.available()) {
    Serial.println("Ricezione dati dall'encoder:");
    
    while (RS485Serial.available()) {
      byte receivedByte = RS485Serial.read();  
      Serial.print("Byte ricevuto: 0x");
      Serial.println(receivedByte, HEX);
    }
  }
  delay(500);
}

With this code serial not working at all... don't print anything

What about your real wiring?

1 Like

Encoder GND to Arduino GND
Encoder VCC5V to Arduino 5V
Encoder SD+ to RS485 A
Encoder SD- to RS485 B

RS485 GND to Arduino GND
RS485 VCC to Arduino 5V
RS485 DI to Arduino PIN9
RS485 DE and RE to Arduino PIN11
RS485 RO to Arduino PIN10

You need to be sure of the way the encoder data is serialised. I don't think it is going to be output as a bunch of UART compatible bytes. If that's the case, then you can't read the data using a standard serial port.

I would wait and see what you get back from your tech support query.

I did find what may be a single sheet drawing of the motor you are using and have attached it. Does your motor look like the one in the drawing. Note the pinout of the encoder connector.

Is your motor different to this as you mentioned in an earlier post that you only had vcc, gnd, sd+ and sd-.

T6M80-1000H2A1-M23.pdf (184.6 KB)

1 Like

The motor is exactly the one you found. Unfortunately, I'm not sure about the communication protocol of this encoder. I haven't been able to find any material to understand what type of encoder it is. I only know that it's a 23-bit absolute encoder with four pins: two for power supply, one SD+, and one SD-.
I hope Leadshine will reply soon to clarify this.

Rs485 standard defines A- and B+. Often implemented otherwise round, but try "standard" as well. Would be step ahead to get "anything" out from that data line.

1 Like

You could use one of the cheap USB logic analyzers to look at the data stream. I would guess it to be 23 bits separated by some constant gap and maybe an encoding scheme that takes repeating 1s and 0s into account since there is no clock.

2 Likes

I also tried swapping A with B, but unfortunately I’m still getting the same result. Do you have any other suggestions?

That sounds like a great idea! I’ll try to capture the data stream to check if the bits are separated by a constant gap and if there’s any encoding for the sequences of 1s and 0s. I found a cheap logic analyzer on Amazon , do you think it would be suitable for this kind of work?

Can you tell actually what is the result?

1 Like

Unfortunately, the serial doesn't print anything. It's completely blank.

what the heck is that baudrate???
Also, according to your documentation, what should the baud rate be? Can you link the documentation.
Also what are you actually powering from your breadboard with black and red wires?
If you don't get even "inzializzazione completata" in serial monitor, it means your arduino/serial doesn't even work!

Upload a sketch to verify your arduino first:

void setup() {
  Serial.begin(9600); // open the serial port at 9600 bps:
}

void loop() {

Serial.println("test");  
delay(1000);
}
1 Like

With great pleasure, the company provided me with this pdf about the encoder.
It applies to the 17bit encoder, mine is 23, I think you just have to adapt the code maybe. Having said that I think rs485 is the correct communication, I see 2.5mbps... Mmm...
38M17 en.pdf (2,1 MB)

You can't make it work with softwareserial at 2.5Mbps, so you need to use another board that has more than one uart port (micro doesn't)
Actually, I doubt that you even find arduino board that can handle that serial speed.

1 Like

You are absolutely right, 2.5Mbps is too high for SoftwareSerial, and I'm actually considering switching to an Arduino Mega or a Teensy 4.1. Both have multiple hardware UART ports, and the Teensy, with its much faster clock speed, should be able to handle this baud rate without any issues.

ok, that might work.
Also, that protocol sheet doesn't tell anywhere that encoder is transmitting data without request...

1 Like

2.5Mbaud, thats right at the MAX485 IC limit.

1 Like

Yes. There is free software that allows you to use it with most computer platforms too.

1 Like

Complete with wire color descriptions like "pornographic" and "staring coldly"

yes indeed the translation of that document is really funny... I don't understand why they haven't given me the official document yet but a translated document :person_facepalming:but it's already a great thing that they answered something... I thought they wouldn't even answer me... anyway I just asked for another untranslated official document of the 23 bit version