I'm working on a project with an Arduino and a T6M80-1000H2A1-M23 motor, which has a 23-bit magnetic encoder. I'm using an RS-485 module (max485) to interface the encoder with the Arduino, but I'm having trouble reading the position data. Despite following the technical specifications, I'm not getting any output.
I've used this code:
#include <SoftwareSerial.h>
// Pin definiti per la comunicazione RS-485
#define RO_pin 10 // Pin dove è connesso RO (Receive Output)
#define RE_DE_pin 11 // Pin per gestire RE (Receive Enable) e DE (Driver Enable)
SoftwareSerial RS485Serial(RO_pin, RE_DE_pin); // Creiamo una comunicazione seriale via software
void setup() {
pinMode(RE_DE_pin, OUTPUT);
digitalWrite(RE_DE_pin, LOW); // Abilita ricezione
Serial.begin(9600); // Comunicazione seriale su PC
RS485Serial.begin(9600); // Comunicazione seriale RS485
}
void loop() {
if (RS485Serial.available()) {
int pos = 0;
// Leggi i dati inviati dall'encoder
while (RS485Serial.available()) {
pos = RS485Serial.read(); // Legge i dati dalla linea RS485
Serial.println(pos); // Visualizza i dati nel monitor seriale
}
}
delay(500); // Pausa tra letture
}
But this code cannot read position of this encoder...
Has anyone successfully interfaced this encoder or a similar one via RS-485? I would greatly appreciate any tips, code examples, or guidance on the communication protocol (baud rate, timing, resistors, etc.) needed for proper integration. I’ve double-checked the wiring and configuration, but I might be missing something.
Any help would be amazing! Thanks in advance for your support.
Thank you so much for your previous answer, I found it really helpful. I've made some changes to my code based on your suggestions, but I'm still having trouble getting the encoder communication to work properly.
I was wondering if you could give me some more advice on how to fix my code or point out what mistakes I might have made. Here's my updated code:
#include <SoftwareSerial.h>
// Pin definiti per la comunicazione RS-485
#define RO_pin 10 // Pin per ricezione (RO - Receiver Output)
#define DI_pin 11 // Pin per trasmissione (DI - Driver Input)
#define RE_DE_pin 12 // Pin per gestire RE (Receive Enable) e DE (Driver Enable)
SoftwareSerial RS485Serial(DI_pin, RO_pin); // Configura comunicazione seriale via software
void setup() {
// Imposta il pin RE/DE come output
pinMode(RE_DE_pin, OUTPUT);
// Imposta RE/DE basso (ricezione inizialmente)
digitalWrite(RE_DE_pin, LOW);
// Inizializza la comunicazione seriale
Serial.begin(9600); // Comunicazione seriale su PC
RS485Serial.begin(9600); // Comunicazione seriale RS-485
}
void loop() {
// Abilita la ricezione
digitalWrite(RE_DE_pin, LOW); // Imposta RE e DE su LOW per ricevere
if (RS485Serial.available()) {
int pos = 0;
// Leggi i dati inviati dall'encoder
while (RS485Serial.available()) {
pos = RS485Serial.read(); // Legge i dati dalla linea RS-485
Serial.println(pos); // Visualizza i dati nel monitor seriale
}
}
delay(500); // Pausa tra letture
}
However, with this code, the Serial Monitor remains completely empty, as if it’s not receiving anything at all from the encoder.
Any feedback or suggestions on how to improve my approach would be really appreciated.
I thought you were refering to the driver output and not the motor output.
The motor output may well be RS485 or RS422.
The protocol as far as I can tell is async SSI
How to read the data, I'm not sure.
Thank you very much for your reply. The problem I am facing is that I am making my own servo drive. So the servo drive that it is sold with, I will put aside. I will manage everything with Arduino at first and then move on to teenzy. So I want to read the signal directly from the encoder so I can then increment all the calculations for the Foc. Only as a last part of the project I will do the ESC part.
Thank you very much for your reply. I see that the encoders you are talking about, that is, the ssi type ones... have six cables... vcc gnd clock+ clock- data+ and data-...
in my encoder instead it has only four wires: vcc gnd sd+ and sd-...
How do I interface it with Arduino without having those two Clock cables?
Thank you very much, Jim-p, for your reply! I'm now wondering what is the correct way to read the SD+ and SD- signals. I have done some research, and even when searching for 'asynchronous SSI encoder,' many results point to using RS-485, but unfortunately, I’m not getting any results from the tests I’m running. Do you have any suggestions on how to correctly read these signals?
Thank you very much, Jim-p, for your reply. You’re absolutely right, I’m also having huge difficulties with this setup. I’ve already opened a support ticket with Leadshine and I’m waiting for their response. In the meantime, I’ll keep testing and searching for possible solutions. I’ll keep you posted if I manage to solve it!
Yes, I corrected the code and ran the tests, but unfortunately, the serial is not communicating anything. I’m trying to figure out if it’s a hardware issue or if there’s some other setting I might have missed. Thanks for the suggestion anyway!
I also tried disassembling the encoder to see if I could find anything written on the chips... and I discovered that unfortunately, they were "scratched" to prevent anyone from reading them.
I noticed that there’s "38m23m" written on the encoder. Maybe this could help.
Look, you can post your latest code and your wiring. Maybe we can find more errors there.
If you want to try to "hack" some unknown IC on your device, you need skills and equipment.