I am trying to control a Dynamixel AX-18A servo using Teensy 4.1 via Serial2 (TX: pin 8, RX: pin 7). For half-duplex communication, I am using IC HD74LS241P as a buffer between Teensy and Dynamixel.
However, I ran into a problem where the servo did not respond to the commands I sent. I've tested the same code on Blackpill's STM32F4, and there the servo can move correctly.
The following are some of the things that I have checked:
Here's the circuit
I have also tried some other libraries such as Dynamixel Serial from :
Dynamixel Serial Zach Shiner
and BioloidSerial from :
BioloidSerial KurtE
but it doesn't work either, where my dynamixel servo doesn't move.
does anyone have any Library suggestions and examples of the code used and how the circuit you used.
However, I ran into a problem where the servo did not respond to the commands I sent. I've tested the same code on Blackpill's STM32F4, and there the servo can move correctly.
The following are some of the things that I have checked:
- Baudrate is set to 1,000,000 bps.
- IC HD74LS241P:
I used HD74LS241P to set up half-duplex communication.
The DIR (direction control) pin is controlled for switching between TX and RX.
Power Supply for Dynamixel is enough (using 12V 5A adapter).
Code to send commands to the servo:
C++:
#include <Dynamixel2Arduino.h>
#define DXL_SERIAL Serial2
#define DEBUG_SERIAL Serial // Make sure this corresponds to the debugging port
const uint8_t DXL_DIR_PIN = 27;
const float DXL_PROTOCOL_VERSION = 1.0;
Dynamixel2Arduino dxl(DXL_SERIAL, DXL_DIR_PIN);
void setup() {
DEBUG_SERIAL.begin(115200);
while (!DEBUG_SERIAL);
dxl.begin(1000000);
dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION);
// Wait a few seconds to make sure everything is ready
delay(3000);
// Make sure the servo is in the correct mode
dxl.torqueOff(19);
dxl.setOperatingMode(19, OP_POSITION);
dxl.torqueOn(19);
// Try to set the initial position
if (dxl.setGoalPosition(19, 63, UNIT_DEGREE)) {
DEBUG_SERIAL.println("Starting position successfully set to 63 degrees");
} else {
DEBUG_SERIAL.println("Failed to set the starting position");
}
}
void loop() {
delay(3000);
if (dxl.setGoalPosition(19, 63, UNIT_DEGREE)) {
DEBUG_SERIAL.println("Successfully set position to 63 degrees");
} else {
DEBUG_SERIAL.println("Failed to set position to 63 degrees");
}
delay(3000);
if (dxl.setGoalPosition(19, 165, UNIT_DEGREE)) {
DEBUG_SERIAL.println("Successfully set position to 165 degrees");
} else {
DEBUG_SERIAL.println("Failed to set position to 165 degrees");
}
}
Here's the circuit
I have also tried some other libraries such as Dynamixel Serial from :
Dynamixel Serial Zach Shiner
and BioloidSerial from :
BioloidSerial KurtE
but it doesn't work either, where my dynamixel servo doesn't move.
does anyone have any Library suggestions and examples of the code used and how the circuit you used.