Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teensy 3.2 with RS485 Breakout and MX-28AR #113

Open
lyehezkel opened this issue Nov 17, 2022 · 0 comments
Open

Teensy 3.2 with RS485 Breakout and MX-28AR #113

lyehezkel opened this issue Nov 17, 2022 · 0 comments

Comments

@lyehezkel
Copy link

lyehezkel commented Nov 17, 2022

Hello,
I am having trouble with connecting the following together and getting data from my mx-28ar DYNAMIXEL.
i have a teensy 3.2, which is connected to the computer through micro-usb.
the teensy is connected to my RS485 Breakout through 4 pins:
teensy 3.2 <---> RS485:

  • 3.3 [V] <---> 3-5 [V] (pin 1)
  • TX2 (pin 10) <---> RX-I (pin 2)
  • pin 2 <---> RTS (pin 4)
  • GND <---> GND (pin 5)

the RS485 is connected to the MX-28AR through 3 pins:
RS485 <---> MX-28AR

  • G (pin 3) <---> GND (pin 1)
  • A (pin 2) <---> DATA+ (pin 3)
  • B (pin 1) <---> DATA- (pin 4)

and the mx-28ar is connected to a 12V power supply through smps2dynamixel

My problem is that i cant get any information from the mx-28ar with the teensy, i tried to use the "ping" example from the arduino2dynamixel library and in my monitor i get the "error 3" (which i dont understand at the moment).
my mx-28ar is set to 57600 baud and his id is 3, protocol 2.0 - Double checked it via DYNAMIXEL wizard
I'm using the following code:

#include <Dynamixel2Arduino.h>
//#include <SoftwareSerial.h>
  //SoftwareSerial soft_serial(9, 10); // DYNAMIXELShield UART RX/TX
  #define DXL_SERIAL   Serial2
  const int DXL_DIR_PIN = 2; // DYNAMIXEL Shield DIR PIN
 #define DEBUG_SERIAL Serial

const uint8_t DXL_ID = 3;
const float DXL_PROTOCOL_VERSION = 2.0;

Dynamixel2Arduino dxl(DXL_SERIAL, DXL_DIR_PIN);

//This namespace is required to use Control table item names
using namespace ControlTableItem;

void setup() {
  // put your setup code here, to run once:
  
  // Use Serial to debug.
  DEBUG_SERIAL.begin(115200);

  // Set Port baudrate to 57600bps. This has to match with DYNAMIXEL baudrate.
  dxl.begin(57600);
  // Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.
  dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION);
}

void loop() {
  // put your main code here, to run repeatedly:

  DEBUG_SERIAL.print("PROTOCOL ");
  DEBUG_SERIAL.print(DXL_PROTOCOL_VERSION, 1);
  DEBUG_SERIAL.print(", ID ");
  DEBUG_SERIAL.print(DXL_ID);
  DEBUG_SERIAL.print(": ");
  if(dxl.ping(DXL_ID) == true){
    DEBUG_SERIAL.print("ping succeeded!");
    DEBUG_SERIAL.print(", Model Number: ");
    DEBUG_SERIAL.println(dxl.getModelNumber(DXL_ID));
  }else{
    DEBUG_SERIAL.print("ping failed!, err code: ");
    DEBUG_SERIAL.println(dxl.getLastLibErrCode());
  }
  delay(500);

  FindServos();
}


DYNAMIXEL::InfoFromPing_t ping_info[32];
void FindServos(void) {
  Serial.println("  Try Protocol 2 - broadcast ping: ");
  Serial.flush(); // flush it as ping may take awhile... 
      
  if (uint8_t count_pinged = dxl.ping(DXL_BROADCAST_ID, ping_info, 
    sizeof(ping_info)/sizeof(ping_info[0]))) {
    Serial.print("Detected Dynamixel : \n");
    for (int i = 0; i < count_pinged; i++)
    {
      Serial.print("    ");
      Serial.print(ping_info[i].id, DEC);
      Serial.print(", Model:");
      Serial.print(ping_info[i].model_number);
      Serial.print(", Ver:");
      Serial.println(ping_info[i].firmware_version, DEC);
      //g_servo_protocol[i] = 2;
    }
  }else{
    Serial.print("Broadcast returned no items : ");
    Serial.println(dxl.getLastLibErrCode());
  }
}```
@lyehezkel lyehezkel changed the title Teensy 3.2 with RS485 Breakout and mx28ar Teensy 3.2 with RS485 Breakout and MX-28AR Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant