by Al_f » Tue Nov 24, 2009 3:40 pm
by Al_f
Tue Nov 24, 2009 3:40 pm
hi all,
I built an arduino based robot that communicated via an xbee radio to matlab on my pc, the servos were simple pwm based ones.
Recently i decided to go for the dynamixel servos (rx-64) for the strength, compliance and feedback. This is where my problems began! I've asked this question on the arduino forum but i think not many of them use these servos.
So the rx-64 uses RS485 for comms, fine, I bought a couple of Max485's and tested the packet creation with an Arduino- Arduino network, the messages come through fine.
Power up the servo and run the simplest program- turning the LED on and off...nothing.
The program seems super simple and as far as I can tell I have sone what the manual said, i'm now stuck! I have looked at the other posts on the forum, but nothing has helped.
Could anyone point me in the right direction, baud I'm using is 57600 on arduino and rx-64 (i believe it is default speed)
Here's the led test code. Any assitance would be massively appreciated.
- Code: Select all
//___________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Arduino to dynamixel via rs485
//___________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Define/preallocate parameters
int i = 0;
byte startAddress;
byte servoID = 0xFE; // 0xFE is broadcast to all servos
byte ledOn = 0x01;
byte ledOff = 0x00;
//___________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Run setup Function
void setup() {
Serial.begin(57600);
}
//___________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Run main Function
void loop() {
//Transmission section
if (i%2 ==0){
activateServos(servoID, ledOn);
delay(200);
}else{
activateServos(servoID, ledOff);
delay(200);
}
i++;
if (i>1000){
i=1;
}
}
//___________________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//Function Definitions
//___________________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void activateServos (byte servoID, byte newValue){
unsigned int checksum_ACK;
byte notchecksum;
//startAddress = 0X18; // Enabling torque for first time
startAddress = 0X19; // Turning on led
checksum_ACK = servoID + 0x03 + 0x03 + startAddress + newValue;
notchecksum = ~checksum_ACK;
digitalWrite(2,HIGH); // Notify max485 transciever to accept tx
delay(5); // Allow this to take effect
Serial.print(0xFF,BYTE); // 1.These 2 bytes are 'start message'
Serial.print(0xFF,BYTE); // 2.These 2 bytes are 'start message'
Serial.print(servoID,BYTE); // 3.ID is target servo or 0xfe which is broadcast mode
Serial.print(0x03,BYTE); // 4.Length of string
Serial.print(0x03,BYTE); // 5.Ping read write or syncwrite 0x01,2,3,83
Serial.print(startAddress,BYTE); // 6.Start address for data to be written
Serial.print(newValue,BYTE); // 7.Turning on signal
Serial.print(notchecksum,BYTE); //8. the notchecksum
delay(200); // allow last byte to go through
digitalWrite(2,LOW); // Notify max485 transciever to recieve
}
hi all,
I built an arduino based robot that communicated via an xbee radio to matlab on my pc, the servos were simple pwm based ones.
Recently i decided to go for the dynamixel servos (rx-64) for the strength, compliance and feedback. This is where my problems began! I've asked this question on the arduino forum but i think not many of them use these servos.
So the rx-64 uses RS485 for comms, fine, I bought a couple of Max485's and tested the packet creation with an Arduino- Arduino network, the messages come through fine.
Power up the servo and run the simplest program- turning the LED on and off...nothing.
The program seems super simple and as far as I can tell I have sone what the manual said, i'm now stuck! I have looked at the other posts on the forum, but nothing has helped.
Could anyone point me in the right direction, baud I'm using is 57600 on arduino and rx-64 (i believe it is default speed)
Here's the led test code. Any assitance would be massively appreciated.
- Code: Select all
//___________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Arduino to dynamixel via rs485
//___________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Define/preallocate parameters
int i = 0;
byte startAddress;
byte servoID = 0xFE; // 0xFE is broadcast to all servos
byte ledOn = 0x01;
byte ledOff = 0x00;
//___________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Run setup Function
void setup() {
Serial.begin(57600);
}
//___________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Run main Function
void loop() {
//Transmission section
if (i%2 ==0){
activateServos(servoID, ledOn);
delay(200);
}else{
activateServos(servoID, ledOff);
delay(200);
}
i++;
if (i>1000){
i=1;
}
}
//___________________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//Function Definitions
//___________________________________________________________________
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void activateServos (byte servoID, byte newValue){
unsigned int checksum_ACK;
byte notchecksum;
//startAddress = 0X18; // Enabling torque for first time
startAddress = 0X19; // Turning on led
checksum_ACK = servoID + 0x03 + 0x03 + startAddress + newValue;
notchecksum = ~checksum_ACK;
digitalWrite(2,HIGH); // Notify max485 transciever to accept tx
delay(5); // Allow this to take effect
Serial.print(0xFF,BYTE); // 1.These 2 bytes are 'start message'
Serial.print(0xFF,BYTE); // 2.These 2 bytes are 'start message'
Serial.print(servoID,BYTE); // 3.ID is target servo or 0xfe which is broadcast mode
Serial.print(0x03,BYTE); // 4.Length of string
Serial.print(0x03,BYTE); // 5.Ping read write or syncwrite 0x01,2,3,83
Serial.print(startAddress,BYTE); // 6.Start address for data to be written
Serial.print(newValue,BYTE); // 7.Turning on signal
Serial.print(notchecksum,BYTE); //8. the notchecksum
delay(200); // allow last byte to go through
digitalWrite(2,LOW); // Notify max485 transciever to recieve
}