Go Down

Topic: Dynamixel library with no additional hardware (Read 14823 times) previous topic - next topic

akira215

Mar 05, 2016, 04:02 pm Last Edit: Apr 23, 2016, 09:05 am by akira215
Hello to everyone,

I just finished to write a Dynamixel library for Arduino. There are many libraries to drive Dynamixel actuator, but i didn't find any that required no additional hardware (or they have some limitations).

Mine is just as simple as connecting one pin ! (take care that it should support change interrupt, see the readme file in SoftHalfDuplexSerial lib).


feel free to clone the github :
https://github.com/akira215/DynamixelArduino

This library inherits from SoftHalfDuplexSerial, available here :
https://github.com/akira215/HalfDuplexSerial-for-Arduino

I basically hack a little the "official" SoftwareSerial library to allow it to switch Tx and Rx on one pin. The timing is quite important during this kind of operation, unfortunately, my logic analyser die during the development (10$ chineese  one :smiley-confuse: ). I run it out with success at 115200bps, but I faced some communication errors at this speed, so I think that 57600bps is a great deal.

All the required hardware and software help is available in the github wiki page. There is an axemaple for each of the lib, you just have to clone in the arduinox-x-x/libraries folder and run it.

Basically to get it work, construct a dxl object, start com using dxl::begin method, and play with your servo !
Code: [Select]

dxl dxlCom(8); // Construct a dxl object using pin 8 to communicate
dxlCom.begin(57600); // Start Communication at 57600bps
dxlCom.setGoalPosition(1, 1000); // Servo ID 1 will move to 1000


As I have only one AX servo, all my tests have been carried out with one servo connected. I assume that it could work with many AX servo daisy-chained, please let me know if anyone can test that.

Hope that it will help.

Regards

PaulS

It seems strange to build a library that uses SoftwareSerial and then picture a Leonardo with the Serial1 port not being used.

akira215

That's beacause the softserial lib emulate a serial port on a digital pin. Pin 8 support change interrupts, that's why it is connected on the drawing.

PaulS

That's beacause the softserial lib emulate a serial port on a digital pin. Pin 8 support change interrupts, that's why it is connected on the drawing.
You should picture an Arduino for which SoftwareSerial IS necessary.

akira215

It is necessary to do this to drive dynamixel servo. There is unfortunately no way to communicate in half duplex mode using built in serial port, without any additional hardware. Tx & Rx buffer are separeted in Arduino ┬ÁC, so Tx & Rx pin should be connected, requiring a triple state external buffer.

Jujo


akira215

Hi, yes you can use it on Arduino UNO. Be sure to connect the data pin to a pin which support change interrupt (I think not on pin 2 or 3), and set the dynamixel servo baudrate to 57600 bps before starting.

t0gg1e4u

Hi

I was unable to make it work with your library. (I copied the source file of the SoftHalfDuplexSerial library into the DynamixelArduino library - otherwised it wouldnt compile).

I can communicate with the arduino through your protocoll, but the answer I get is usually:

" voltage out of range-angle out of range-overheating-cmd out of range-Tx CRC invalid-overload-undefined instruction-Tx No header-Rx No header-Tx error-Rx waiting-timeout-Rx CRC invalid-Wrong ID answered"

the connection diagram is straight forward and I dont think I did anything wrong there.

I am using an arduino MEGA and would have two AX12A, so I could actually test if your library works with daisychain.

any help would be appreciated

cheers

martin

akira215

Hi,

Sorry for the late answer, I was away.
I just updated the libs (the two ones). There was a mistake in the error routine, it was correted (in the example .ino file).

Please check what error you get with the new lib, it will be easier to help you.

Regards

mtete

Hello Akria,

Your libary gives this error, it misses the HardHalfDuplexSerial.h:


Code: [Select]

C:\Users\michel\Documents\Arduino\libraries\DynamixelArduino-master\examples\DynamixelMxMonitorBlock\DynamixelMxMonitorBlock.ino:32:34: fatal error: HardHalfDuplexSerial.h: No such file or directory

 #include <HardHalfDuplexSerial.h>

                                  ^

compilation terminated.

exit status 1
Error compiling.

akira215

Hello,

Before running the example, you have to paste the entire the library directory in your arduino folder (i.e. /opt/arduino-x.x.x/libraries on linux, I don't know the correct path on windows).

The include path of Arduino IDE is setup to seach header in this directory.

Regards

sonekaka

Hello Akira,

The second library isn't available, SoftHalfDuplexSerial.

Is it possible to re-upload the library.

thanks

akira215

Hi Sonekaka,

Sorry, I changed the name of the repository because I wrote an interface using an abstract class, to be more reliable.

You can clone this github :
https://github.com/akira215/HalfDuplexSerial-for-Arduino

Regards

mtete

Hi Akira,

The examples gives this error:

Code: [Select]
C:\Users\michel\Documents\Arduino\libraries\DynamixelArduino-master\examples\DynamixelMxMonitorBlock\DynamixelMxMonitorBlock.ino: In function 'void setup()':

DynamixelMxMonitorBlock:56: error: 'hdSerial1' was not declared in this scope

   hdSerial1.setDirPin(53);   // dirPin pin 53,

   ^

exit status 1
'hdSerial1' was not declared in this scope


How do I fix this? Thanks in advance!
Michel

akira215

Hi mtete,

Do you install halfDuplexSerial lib (see the first post of this topic) ?

In addition what board do you use ? Is there a Serial1 port on it ?

hdSerial1 is instanciate in halfDuplexSerial Lib, only if the board you are using have a Serial1 port.

Regards

Go Up