GithubHelp home page GithubHelp logo

ardyno's Introduction

ardyno

Arduino library for dynamixel servos. Only Dynamixel 1.0 protocol is supported for now.

This library allows you to control the Robotis servo motors that use a custom half-duplex serial protocol. You can control TTL models directly from Arduino, without any additional hardware, using hardware or software UART. Communication speed up to 1 MBd is supported with hardware serial. The most useful functions (speed, position, wheel/joint mode, ...) are provided via a very simple high level interface (see test_motor example), but other operations can be done using the generic read/write functions (see test_led example).

Installation

Ardyno is available in the Arduino Library Manager, or you can get it directly from github repository if you want last version (may be unstable)

Usage

To control TTL motors, without any additionnal hardware: You can use a 9V or 12V power supply to power the arduino and motors. Connect GND and VIN pins of the arduino to the GND and VCC pins of your dynamixel device, and tx and rx pins of the arduino to the data pin of your dynamixel device (see image here). However, be carrefull that the current you can draw from arduino VIN pin is limited by the protection diode (specified at 1 amp max, for Arduino Uno), so if you use several motors, or put them under a significant load, it is better to connect the power supply separately to the motors. Also note that this is only valid for 5V boards. 3.3V boards may work in practice if they are 5V tolerant, but it is not recommended.

To control TTL/RS485 motors, with an additionnal hardware buffer: See Robotis documentation

Troubleshooting

  • If the servo is configured to answer immediatly to commands, the response packet may come back too fast and be missed by the arduino, and communication may become unstable or even impossible. To fix this, you have to write the value of the "Return Delay Time" register back to its orginal value (register 0x05, value 250).

ardyno's People

Contributors

descampsa avatar eecharlie avatar per1234 avatar romainreignier avatar sylvaing19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ardyno's Issues

cannot upload the program which following the same wire connection

Hi descampsa,

I am trying the dynamixel wheel mode example code using Arduino Mega 2560. We found that if we connect our motor to serial 0 (TX0 and RX0, wich are pin 0 and 1), the Arduino code cannot be uploaded successfully (with the error message: avrdude: stk500v2_command(): unknown status 0x01 avrdude: stk500v2_disable(): failed to leave programming mode). Then, if we connect to serial 2,3, or 4 (TX1&RX1, TX2&RX2, TX3&RX3), the code can be uploaded successfully, but the motor does not run. So we tried to upload the program with connecting the motor to serial 2, 3, or 4, and after uploading, we switch the wires to serial 1, then the motor works. So I want to ask that how can we enable the same serial with which the program can be uploaded successfully and the motor can work. Besides, since I want to connect multiple motors, how can I make all of the serials work?

Thanks a lot!

AX12a won't respond after changing id

Hi there!
Recently I've been playing around with my Dynamixel AX-12as which have worked fine until I executed
the following command:

device.write(0x03, 0x05);

which should change the id of the connected dynamixel to 5

However, after doing this, the motor won't respond to anything at all.
I would be glad if someone could help me out.
Thanks.

(Btw I am quite new to the Dynamixel series)

Can i apply this code to XL430?

Hi
I want to apply this code to XL430
I wrote the code about AX12 myself but I had to write adress of dynamixel (such as ID, baudrate, CWangle, etc.)
However i couldn't find about that so i just change the baudrates in ino file which doesn't work.
Is there anything i missed for XL430?
Please tell me details about what i have to do
Thank you

Mega board cannot communicate with Dynamixel MX28T

Hello Sir,
I am new to the Dynamixel Motors. I followed the instructions as You have given in documentation. I uploaded the joint mode code to my Arduino mega, but nothing happens. Only led of the dynamixel motor blinks. I went through the code, and realized that there is no communication between the motor and the board. Can you please help me know where i am going wrong and the problem. I have set the baudrate and id too.

Cannot use DynamixelMotor::speed() function to control the motor speed

Hi descampsa,

In your example code joint_mode.ino inside had mentioned that in order to change the motor speed. we can just use the DynamixelMotor::speed() to increase or decrease the motor speed. But in my case, I had tried to change the speed value. but my motor moving speed still moving as same, for example, I changed from 1000 to 400, the moving speed did not change anything.

May I check with you that the jointMode(angle_range) will also take effect for speed change?

Thank you so much

Improving library usability and robustness

I've found it a bit confusing to jump in and use the library, partly navigating the different classes to find the relevant one, but mostly because there are very few convenience functions and what they do is a bit limited. Suggestions (that I am happy to begin implementing if we are on the same page):

-More getter/setter functions for basic tasks, like changing drive parameters, avoiding normal need to use read() and write()
-All getters & setters are clearly named as such (e.g. setGoalPosition and getCurrentPosition)
-All getters and setters return a boolean that's true if communication was successful
-Getters pass in an argument by reference that they write the requested value to

Controlling different types of servomotors with arduino méga

Hi sir Adrien Descamps
When I use the following function .

DynamixelInterface &interface=*createSerialInterface(Serial);

It means I was busy TX0/RX0 for arduino méga, but I want to control four different types of servomotors
How can I open ports? TX1,2,3 and RX1,2,3 . At the same time
If you do not mind send me the code

getting started troubleshooting - led example not working

I'm in a bit of a hello world situation, using your library to use Dynamixel servos for the first time.

I have an Arduino UNO hooked up to an AX-12W per your wiring diagram, and I've experimented with both the speed example and the led example.

Neither is producing any activity from the motor. I modified the speed example to use broadcast address 254, and I see that the led example is already set to write to the broadcast address.

Troubleshooting: The AX12-W led blinks once on power-up as it should. Shorting rx and tx per your wiring diagram prevents serial comm with the host PC, so I connect it only after downloading the program. Is this really correct?
I can confirm with an oscilliscope that there are is a periodic burst of activity on the data line, which is otherwise at 5v.
I don't believe any settings, such as bus ID, have been changed on these servos, but if there is some factory memory reset function that would nice to try.

Any suggestions? It would be nice to include a complete and clear hello-world example in your repo, and I think the LED example is nearly that but it's not working for me.

Thanks!

Can't communicate with RX-28 after changing baudrate

Hello,
I recently got ahold of a Dynamixel RX-28 actuator/servo, I managed to make the led blink and move the arms through Arduino Nano hardware serial. But I wanted to communicate through USART while moving the servo, so I tried to lower the baudrate of RX-28 to 7534, which seemed to be the lowest possible bitrate, so I could use software serial. Afterwards I couldn't get contact with the servo anymore, I changed the baudrate in the code also to 7534. I tried to reset RX-28, but nothing I did worked anymore.
If anyone has any ideas or solutions, they would be appreciated.
Thanks,
A
Fixed it by using a code, which tried every possible baudrate and wrote it over with 1000000 baudrate

#include "DynamixelMotor.h"

// motor id
const uint8_t id=7;

unsigned long baudrate_before=1000000;
const unsigned long baudrate_after=1000000;

// hardware serial without tristate buffer
// see blink_led example, and adapt to your configuration
HardwareDynamixelInterface interface(Serial);

DynamixelMotor motor(interface, id);

// the led should blink twice
void setup() 
{
  for(int b=1;b<0xFF; b++){
  baudrate_before = 2000000/(b+1);
  // start communication at old baudrate
  interface.begin(baudrate_before);
  delay(100);
  
  // make the motor led blink once
  motor.init();
  motor.led(HIGH);
  delay(1000);
  motor.led(LOW);
  delay(1000);
  
  // set motor baudrate to new baudrate
  motor.communicationSpeed(baudrate_after);
  
  // set arduino baudrate at new baudrate
  delay(100);
  interface.begin(baudrate_after);
  
  // make the motor led blink once
  motor.led(HIGH);
  delay(1000);
  motor.led(LOW);
  delay(1000);
  }
  
}

void loop(){}

mDirectionPin==NO_DIR_PORT

Hi,

In DynamixelInterface.h lines 24 and 37, shouldn't be

if(mDirectionPin!=NO_DIR_PORT)

instead of:
if(mDirectionPin==NO_DIR_PORT)

Incorrect position reporting and strange reset behavior

Here is a minimal example that reveals 2 problems:

  1. When I read the motor position, it's always returned as 0.
  2. When I run this code that simply sets the goal position and then queries it, it resets the Arduino after a few iterations through the main loop.

Note that I'm using a MEGA ADK and Serial1 as the AX-12 interface. I am using an external power supply in addition to USB to the Arduino, so even if the AX-12 drew significant current, it shouldn't be able to brown-out the Arduino.

I should mention that the motor does move roughly consistently with the goal commands, so it's not simply a total communication failure. I've also included an ISR trap to catch any uncaught interrupts, but it hasn't been triggered.

An even simpler version of this code that never sends a goalPosition() command, just calls currentPosition(), also crashes after a few iterations.

Typical Output:

Starting...
0 target/actual 0
10 target/actual 0
20 target/actual 0
30 target/actual 0
40 target/actual 0
Starting...
Starting...
0 target/actual Starting...
Starting...

Code:

#include "DynamixelMotor.h"
#include <SoftwareSerial.h>

const uint8_t id=1;
int16_t pos=0;

HardwareDynamixelInterface interface(Serial1);
// Use this if you use a direction pin with 3-state buffer
//HardwareDynamixelInterface interface(Serial, 2);
// Use this if you want a sofware serial interface (communication speed will be limited)
//SoftwareDynamixelInterface interface(2,3);

DynamixelMotor motor(interface, id);

//http://stackoverflow.com/questions/23377948/arduino-avr-atmega-microcontroller-random-resets-jumps-or-variable-data-corrup
ISR(BADISR_vect)
{
    for (;;) UDR0='!';
}

void setup()
{ 
  Serial.begin(57600);
  delay(100);
  Serial.println("Starting...");
  
  interface.begin(1000000);
  delay(100);
  
  motor.init();
  motor.enableTorque();
  
  // reset to 0 position
  motor.jointMode();
  motor.speed(256);
  motor.goalPosition(pos);
  delay(1000);
}

void loop() 
{
  motor.goalPosition(pos);
  Serial.print(pos);
  Serial.print(" target/actual ");
  Serial.println(motor.currentPosition());
  pos+=20;
  if (pos >= 1000) { pos = 0; }
  delay(1000);
}

listen() ist missing

I use this library with a MX-28R and with SoftwareSerial and a TriStateBuffer.

I could send commands to the servo, but always got 129 as reply (= DYN_STATUS_COM_ERROR + DYN_STATUS_TIMEOUT).

After a long search, I found a issue in DynamixelInterfaceArduinoImpl.cpp:
transaction(true) calls readMode() and writemode().
There the direction of the buffer changes, but the software serial is not switched from listen() to stopListening(). This happens only in setReadMode(), but this function is not called, when mDirectionPin is defined.

I changed the code to the following and now everything works very nice! :-)

template<class T>
void DynamixelInterfaceImpl<T>::readMode()
{
	if(mDirectionPin!=NO_DIR_PORT)
	{
		digitalWrite(mDirectionPin, LOW);
                //enable listen() here:
		setReadMode(mStream, mTxPin);  //new line
	}
	else
	{
		setReadMode(mStream, mTxPin);
	}
}

template<class T>
void DynamixelInterfaceImpl<T>::writeMode()
{
	if(mDirectionPin!=NO_DIR_PORT)
	{
		digitalWrite(mDirectionPin, HIGH);
                //disable listen() here:
		setWriteMode(mStream, mTxPin);  //new line
	}
	else
	{
		setWriteMode(mStream, mTxPin);
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.