PDA

View Full Version : Serial Comunication and AX12A



DVS
07-09-2013, 08:49 AM
Hi everyone, for some reason I cannot write my PC through the serial port of my Arduino Mega 2560 when using my dynamixel Ax12A servos.
I am now able to move the servo to my desired angles (through hardcoding them atleast).
My servos data line is connnected to the TX1 and RX1 data lines of the Arduino, so TX0 and RX0 should be able to still write and read uart data, or am incorrect?
Thanks alot



// need to include header files, you can do this in the Arduino IDE, by selecting Sketch|Import Library|Bioloid.
#include <ax12.h>
#include <BioloidController.h>
// we always need to create an instance of the bioloid control, usually with baud = 1Mbps.
BioloidController bioloid = BioloidController(57600);

void setup(){
Serial.begin(9600);
ax12SetRegister(2,AX_ID,1);
delay(20);
ax12SetRegister(1,AX_BAUD_RATE,34);
delay(20);
}

void loop(){
// set AX-12 servo with ID=1, to position i, where 0=<i<1024
float servoPosition;
float anglePosition=75;
servoPosition = round((abs( anglePosition - 210) - 60 ) / 0.293);
SetPosition(1,servoPosition);
delay(50);
Serial.println("Why doesnt this work");


}