Go Down

Topic: Need help in connecting Arduino with Dynamixel RX-64 (Read 2 times) previous topic - next topic

AWOL

Quote
I only obtain the data FFFFFF from the motor.

That suggest to me that you haven't fixed your code, and that you're reading -1 == "No serial data available" from your port.
Please post your code.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

fr3dd3v1l

#6
Jan 21, 2013, 03:44 am Last Edit: Jan 21, 2013, 04:02 am by fr3dd3v1l Reason: 1

Quote
I only obtain the data FFFFFF from the motor.

That suggest to me that you haven't fixed your code, and that you're reading -1 == "No serial data available" from your port.
Please post your code.


Hi AWOL,

I fixed the code already.

Code: [Select]
//___________________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Initial condition
//___________________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

const int RTS = 4;   //1= transmit, 0 =receive
byte ping  =0x01;
byte READ  =0x02;
byte WRITE =0x03;
byte REG   =0x04;
byte ACTION=0x05;
byte RESET =0x06;
byte SYNC  =0x83;
byte BEGIN =0xff;
int incomingByte = 0;


//___________________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Setup Function
//___________________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void setup () {
 pinMode(RTS, OUTPUT);
 Serial.begin(57600);
 Serial1.begin(57600);

}

// Main function
void loop()
{
 byte notchecksum;
 byte motor_ID=0x01;
 byte length=0x02;
 digitalWrite(RTS,HIGH);
 delay (5);
 notchecksum=~(motor_ID + length + ping);
 Serial1.write(BEGIN);
 Serial1.write(BEGIN);
 Serial1.write(motor_ID);
 Serial1.write(length);
 Serial1.write(ping);
 Serial1.write(notchecksum);
 digitalWrite(RTS,LOW);
 // send data only when you receive data:
while (Serial1.available() == 0)
{
    incomingByte = Serial1.read();
 }
 incomingByte = Serial1.read();
 Serial.print(Serial1.available(),HEX);
 delay(1000);
}//This is program to send data to servo


Now, is the serial monitor does not give any display. I suspect that it keep stuck inside the WHILE loop.
Now, I am wondering if my Dynamixel motor does not send any data or, My 485 breakout circuit does not send me any data.
Do you have any idea?


Thanks

AWOL

Code: [Select]
while (Serial1.available() == 0)
{
     incomingByte = Serial1.read();
  }

So, while there is no data available, read the data that isn't there?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

fr3dd3v1l

Yup.
Just in case that I miss the data transmitted.
However, I do not get any result out. As I expected when the serial1 received the data, it should go out of the loop and print the value that is stored at "inbyte"

AWOL

Quote
Just in case that I miss the data transmitted.

I'd say you're pretty much guaranteeing that you will miss data, in very nasty, creative ways.

Think.

Test if there's a character available.
An interrupt happens to occur before the "read", and character is put in the receive buffer.
Interrupt returns, and you read the character, 'cos that's what your loop does.
Test to see if there's a character available.
Oops.

Don't do anything in the "while" loop.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up