대학교 과제의 일환으로 해당 애드온을 사용해, 아두이노 우노 R3 만으로 EX-106+ 와 연결을 시도하고 있습니다. 다이나믹셀 쉴드는 사용하지 않습니다.
U2D2를 이용해서 Dynamixel Wizard로 ID와 Baud rate 를 본 결과입니다.
// Test motor joint mode
#include "DynamixelMotor.h"
// id of the motor
const uint8_t id=1;
// speed, between 0 and 1023
int16_t speed=512;
// communication baudrate
const long unsigned int baudrate = 57600;
// hardware serial without tristate buffer
// see blink_led example, and adapt to your configuration
HardwareDynamixelInterface interface(Serial);
DynamixelMotor motor(interface, id);
void setup()
{
interface.begin(baudrate);
delay(100);
// check if we can communicate with the motor
// if not, we turn the led on and stop here
uint8_t status=motor.init();
if(status!=DYN_STATUS_OK)
{
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
while(1);
}
motor.enableTorque();
// set to joint mode, with a 180° angle range
// see robotis doc to compute angle values
motor.jointMode(204, 820);
motor.speed(speed);
}
void loop()
{
// go to middle position
motor.goalPosition(512);
delay(500);
// move 45° CCW
motor.goalPosition(666);
delay(500);
// go to middle position
motor.goalPosition(512);
delay(500);
// move 45° CW
motor.goalPosition(358);
delay(500);
}
아두이노에 입력한 코드입니다 . ID와 baud rate를 맞춰주었습니다.
// direction pin, if you use tristate buffer
#define DIR_PIN 2
// software serial pins, if you use software serial
#define SOFT_RX_PIN 3
#define SOFT_TX_PIN 4
// Use this for hardware serial without tristate buffer
HardwareDynamixelInterface interface(Serial);
// Use this for hardware serial with tristate buffer
//HardwareDynamixelInterface interface(Serial, DIR_PIN);
// Use this for software serial without tristate buffer
//SoftwareDynamixelInterface interface(SOFT_RX_PIN, SOFT_TX_PIN);
// Use this for software serial with tristate buffer
//SoftwareDynamixelInterface interface(SOFT_RX_PIN, SOFT_TX_PIN, DIR_PIN);
이건 예제인 blink_led에 있는 코드 일부입니다. 저는 hardware serial without tristate buffer 이기에 HardwareDynamixelInterface interface(Serial); 를 사용하고 있습니다.
하지만 Dynamixel에 전원이 들어왔을때 LED가 깜빡일 뿐이고, 첫번째 코드를 실행시켰을 때
// check if we can communicate with the motor
// if not, we turn the led on and stop here
uint8_t status=motor.init();
if(status!=DYN_STATUS_OK)
{
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
while(1);
}
해당 코드 안에서 돕니다(UNO의 LED가 계속 ON되어있습니다.). 즉 모터와 연결이 안 됐다는 뜻입니다.
혹 방법을 아는 분이 계실까요?