Dobot Demo for Second Development


#1

Developers can use Dobot for second development, achieving various functions. This tutorial is avaliable for simple second development by Arduino MEGA2560.
Regarding to second development, please connect MEGA2560 with control board withDobot main control board through the interface of Bluetooth modul. At the same time, dial main control board to Bluetooth mode. Here are the wiring diagram:

                          Figure 1 Connection Mode

Connection Mode:

1. Format of issued commands by client

Dobot communication instruction uses fixed frame format. Each frame of data has (2+4 * 10)=42bytes and includes packet head(0xA5), packet end(0x5A) and ten parameters. All these parameters are act as Dobot single precision floating point types(32-bit), among this each parameter is formed into 4 bytes, except voice control commands, packet head(0xB5) and packet end(0x5B). Here are as follows:

                          Figure 2 Instruction Format

Two arrays are defined as follows: One is 42 bytes sent to Dobot, another includes 10 floating point types. Therefore, we can control Dobot movement mode, velocity and acceleration through the 10 variables. Details are as follows:

// Send a 42 byte data packet to the dobot according to the communication protocol.
void cmd_str_42_send()
{
cmd_str_42[0] = 0xA5;
for( char i = 0; i < 10; i++ )
{
* ((float *)(cmd_str_42 + 1 + 4 *i)) = float( cmd_str_10[i] );
}
cmd_str_42[41] = 0x5A;

for( char i = 0; i < 42; i++ )
{
Serial1.write( cmd_str_42[i] );
}
}

Now we can send out commands by these two arrays at any time.


2. Parameter Configuration

We need send out commands before controlling Dobot, which is used for configuration of motion parameters . Now we will configure parameters using defined arrays above. According to protocol, motion parameters are shown when state=9, described as follows:

 Figure 3 Instruction of Parameter Configuration

For simplicity’s sake, here we choose Axis=0, and only has a configuration of uniaxial jog velocity and uniaxial jog acceleration, the rest remains the default. Program examples as follows:

//Set parameters of Dobot with state 9.
void dobot_cmd_3( int axis= 0, int Joint_jog_speed=0, int Joint_jog_acc=0){
for( char i = 0; i < 10; i++ ){
cmd_str_10[i] = 0;
}
// refer to protocal file for detail
cmd_str_10[0] = 9;
cmd_str_10[1] = axis;
cmd_str_10[2] = Joint_jog_speed;
cmd_str_10[3] = Joint_jog_acc;
cmd_str_42_send();
}

Then we enter into mode 9, and there is a configuration of uniaxial jog velocity and uniaxial jog acceleration. Also use the same way to select motion mode, then can control Dobot.


3. Demo of Jog Mode

Parameters of Jog Mode below:

                  Figure 4  Parameters Instruction of Jog Mode

Select state=2 as uniaxial controlling, and select button 3 or 4 to control rotational base. Program examples as follows:


/*
** demo that dobot controled by another Arduino MEGA 2560
** with dobot firmware V1.2.0
**
** connections:
** dobot side(Wireless port) | another Arduino side(UART1 port)
** GND ------ GND
** TX ------ TX1
** RX ------ RX1
** note: if another Arduino is self powered by USB or 12V, just connect above 3 lines is OK
** if another Arduino has no USB or 12V power, another connection between VCC ------ 5V is needed.
**
** 20160523
*/

static float cmd_str_10[10];
static unsigned char cmd_str_42[42];

// Send a 42 byte data packet to the dobot according to the communication protocol.
void cmd_str_42_send()
{
cmd_str_42[0] = 0xA5;
for( char i = 0; i < 10; i++ )
{
* ((float *)(cmd_str_42 + 1 + 4 *i)) = float( cmd_str_10[i] );
}
cmd_str_42[41] = 0x5A;

for( char i = 0; i < 42; i++ )
{
Serial1.write( cmd_str_42[i] );
}
}

//Set parameters of Dobot with state 9.
void dobot_cmd_3( int axis= 0, int Joint_jog_speed=0, int Joint_jog_acc=0){
for( char i = 0; i < 10; i++ ){
cmd_str_10[i] = 0;
}
// refer to protocal file for detail
cmd_str_10[0] = 9;
cmd_str_10[1] = axis;
cmd_str_10[2] = Joint_jog_speed;
cmd_str_10[3] = Joint_jog_acc;
cmd_str_42_send();
}

//Set joint jog mode with state 2.
void dobot_cmd_2( int axis= 0, int StartVe= 0 ){
for( char i = 0; i < 10; i++ ){
cmd_str_10[i] = 0;
}
// refer to protocal file for detail
cmd_str_10[0] = 2;
cmd_str_10[1] = axis;
cmd_str_10[7] = StartVe;
cmd_str_42_send();
}

void setup() {
// put your setup code here, to run once:
// Serial1 connected with dobot
Serial1.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
// wait dobot init…
delay( 1000 );
dobot_cmd_2( 0,0); // button released
dobot_cmd_3( 0,50,100); //configure the joint jog speed and the joint jog acceleration before controlling the dobot to move.

// move 3 loop
for( char i = 0; i < 2; i++ ){
dobot_cmd_2( 3,50); // joint1+(CCW)
// here just delay a few time between two cmd send simply
// for better performance, next cmd can be send out if a new frame on rxd is received
delay(1000);
dobot_cmd_2( 0,0);// button released
delay(1000); //decelerate
dobot_cmd_2( 4,50);//joint1-(CW)
delay(1000);
dobot_cmd_2( 0,0);// button released
delay(1000); //decelerate
}

//end
while(1);
}

Program above will make the base rotate back and forth three times, you can use Arduino to upload it to MEGA board and check the result. Similarly, select state=7, one can control Dobot coordinate jog, it is not described here.


4. Demo of Save and Playback Mode

At the same time, we can set a series of coordinate motion about Dobot according to communication protocols, making it playback automatically . Here we use visiual motion mode 3, enabling Dobot move back and forth three times on Z- axis direction. Program examples as follows:

/*
** demo that dobot controled by another Arduino MEGA 2560
** with dobot firmware V1.2.0
**
** connections:
** dobot side(Wireless port) | another Arduino side(UART1 port)
** GND ------ GND
** TX ------ TX1
** RX ------ RX1
** note: if another Arduino is self powered by USB or 12V, just connect above 3 lines is OK
** if another Arduino has no USB or 12V power, another connection between VCC ------ 5V is needed.
**
** 20160523
*/

static float cmd_str_10[10];
static unsigned char cmd_str_42[42];

// Send a 42 byte data packet to the dobot according to the communication protocol.
void cmd_str_42_send(){
cmd_str_42[0] = 0xA5;
for( char i = 0; i < 10; i++ ){
* ((float *)(cmd_str_42 + 1 + 4 *i)) = float( cmd_str_10[i] );
}
cmd_str_42[41] = 0x5A;

for( char i = 0; i < 42; i++ ){
Serial1.write( cmd_str_42[i] );
}
}

//Set target moving mode with state 3.
void dobot_cmd_3( float x = 260, float y = 0, float z = 0 ){
for( char i = 0; i < 10; i++ ){
cmd_str_10[i] = 0;
}
// Set the X/Y/Z coordinates of the end effector, please refer to protocal file for details.
cmd_str_10[0] = 3;
cmd_str_10[2] = x; //x
cmd_str_10[3] = y; //y
cmd_str_10[4] = z; //z
cmd_str_10[7] = 2; //MOVL

cmd_str_42_send();
}

void setup() {
// put your setup code here, to run once:
// Serial1 connected with dobot
Serial1.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
// wait dobot init…
delay( 2000 );
dobot_cmd_3( 260, 0, 30 ); // set the initial position of the end effector
// repeat 3 times
for( char i = 0; i < 3; i++ ){
dobot_cmd_3( 260, 0, 0 );//lower down the end effector
// here just delay a few time between two cmd send simply
// for better performance, next cmd can be send out if a new frame on rxd is received
delay(500);
dobot_cmd_3( 260, 0, 30 );// lift the end effector
delay(500);
}

// end
while(1);
}


The video for send development is here:
https://youtu.be/QGIbQJeDgCQ


Problem with dll files
Dobot机械臂二次开发Demo
Dobot Magician Second Development
#2

#3

I have been using this demonstration code using a Arduino and it works well. I am trying to understand the how each state relates to each joint however my question is about the demonstration code supplied and operating the two servos that control the gripper. I can see that state 11 and state 12 control the servos but I am unfamiliar with how to control it with only a TX and RX connection. In Arduino programming (C++) we call down a servo library, define a servo name, define the pin the servo is attached to and use C++ language to move the servo - myservo.write … Can you tell how you would control the movement using this configuration?


#4

As the firmware is not open sourced for now, so I don’t think you can do that at this time.


#5

Hi,

Is there any way to control doBot magician using Arduino?

I tried with with communication port available. Found RX, TX, VCC and GND pins of the same and connected to arduino.

1 - GND
2 -12V
9 - RX
10 - TX
11 - GND
12 - 5V
Nothing happend !!


#6

Yes you can do that, just connect arduino with dobot using these 4 pins here:


And upload the demo code for arduino board here:
http://www.dobot.cc/download-center/dobot-magician.html


#7

Hi, is there a way we can track dobot moves in a log file?


#8

Hi,
Im Reiza from Indonesia and I need some explanation about how to get a real time pose of dobot using arduino. I have been tried the protocol from the dobot to get the real time pose in my arduino and I dont really understand. In serial monitor of arduino, the params’s value of RX is changed when the dobot moves but the value that printed not perform as coordinate or joint values. Please help me, because I used Dobot for my last project on my college

thank you