현재 저는 아두이노 Uno와 Dynamixel Shield를 사용하여 Dynamixel RX-64에 대해 공부하고 있습니다. Arduino IDE와 필요한 라이브러리(Dynamixel2Arduino, Dynamixel Shield)를 다운로드했고연습 → DynamixelShield → basic → position_mode 예제를 열었습니다.
모든 다이나믹셀이 다른 시리얼 번호, 버전 및 ID를 가지고 있다는 블로그에서 봐서일부 코드를 변경했습니다.
(DXL_ID를 1에서 3으로 변경,
DXL_PROTOCOL_VERSION을 2.0에서 1.0으로 변경,
dxl.begin(57600)는 동일한 상태로 유지합니다. RX-64를 사용하려고 합니다)
그러나, 다이나믹셀이 작동하지 않는데 혹시 도와주실 수 있을까요?
예제 코드도 보냅니다.
/*******************************************************************************
- Copyright 2016 ROBOTIS CO., LTD.
- Licensed under the Apache License, Version 2.0 (the “License”);
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an “AS IS” BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
*******************************************************************************/
#include <DynamixelShield.h>
#if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_MEGA2560)
#include <SoftwareSerial.h>
SoftwareSerial soft_serial(7, 8); // DYNAMIXELShield UART RX/TX
#define DEBUG_SERIAL soft_serial
#elif defined(ARDUINO_SAM_DUE) || defined(ARDUINO_SAM_ZERO)
#define DEBUG_SERIAL SerialUSB
#else
#define DEBUG_SERIAL Serial
#endif
const uint8_t DXL_ID = 3;
const float DXL_PROTOCOL_VERSION = 1.0;
DynamixelShield dxl;
//This namespace is required to use Control table item names
using namespace ControlTableItem;
void setup() {
// put your setup code here, to run once:
// For Uno, Nano, Mini, and Mega, use UART port of DYNAMIXEL Shield to debug.
DEBUG_SERIAL.begin(115200);
// Set Port baudrate to 57600bps. This has to match with DYNAMIXEL baudrate.
dxl.begin(57600);
// Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.
dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION);
// Get DYNAMIXEL information
dxl.ping(DXL_ID);
// Turn off torque when configuring items in EEPROM area
dxl.torqueOff(DXL_ID);
dxl.setOperatingMode(DXL_ID, OP_POSITION);
dxl.torqueOn(DXL_ID);
}
void loop() {
// put your main code here, to run repeatedly:
// Please refer to e-Manual(DYNAMIXEL Shield) for available range of value.
// Set Goal Position in RAW value
dxl.setGoalPosition(DXL_ID, 512);
delay(1000);
// Print present position in raw value
DEBUG_SERIAL.print("Present Position(raw) : ");
DEBUG_SERIAL.println(dxl.getPresentPosition(DXL_ID));
delay(1000);
// Set Goal Position in DEGREE value
dxl.setGoalPosition(DXL_ID, 5.7, UNIT_DEGREE);
delay(1000);
// Print present position in degree value
DEBUG_SERIAL.print("Present Position(degree) : ");
DEBUG_SERIAL.println(dxl.getPresentPosition(DXL_ID, UNIT_DEGREE));
delay(1000);
}