I have an AX-12A
I am using an AVR128DA28 mcu
16mh clock
I am able to Turn on and turn off the LED
I get responses back about 900 us
I am unable to make the servo move
I tried a factory reset, I am putting the commands in an array.
So communication is working, My Oscilloscope shows clean signals.
Here are the commands i am working with
volatile char chk0 = ChecksumCalc(1+2+6);
volatile char DynamixelReset[] = {0xFF,0xFF,0x01,0x02,0x06,chk0}; // chk0 = 246
volatile char chk = ChecksumCalc(1+4+3+25+0);
volatile char LedOff[] = {0xFF,0xFF,0x01,0x04,0x03,25,0x00,chk}; // chk = 222
volatile char chk1 = ChecksumCalc(1+4+3+25+1);
char LedOn[] = {0xFF,0xFF,0x01,0x04,0x03,25,0x01,chk1}; // chk1 = 221
volatile char LedOnETorque[] = {0xFF,0xFF,0x01,0x05,0x03,0X18,0x01,0X01,220};
volatile char pos=100;
volatile char chk2 = ChecksumCalc(1+7+3+30+pos+0+44+1);
volatile char Pos512_30pcentSpeed[] = {0xFF,0xFF,0x01,0x07,0x03,0X1E,pos,0X00,0X2C,0X01,chk2}; // chk2 = 70
volatile char PingCommand[] = {0xFF,0xFF,0x01,0x02,0x01,0xFB};
Here are the commands being sent
SendCommand(DynamixelReset);
_delay_us(1200); // waiting for Servo reply status
SendCommand(LedOnETorque);
_delay_us(1200); // waiting for Servo reply status
SendCommand(Pos512_30pcentSpeed);
_delay_us(1200); // waiting for Servo reply status
SendCommand(PingCommand);
_delay_us(1200); // waiting for Servo reply status
Here is the checksum calculator
char ChecksumCalc(uint16_t seed)
{
volatile char CheckSum = 0;
volatile uint8_t highbyte=0;
volatile uint8_t lowbyte=0;
highbyte = seed>>7;
lowbyte = seed & 0xFF;
CheckSum = (~lowbyte)+highbyte;
tmp++;
return CheckSum;
}
Here is the SendCommand method I use the 4th byte (length) and add 4 for number of bytes to send.
void SendCommand(char *cmd)
{
PORTA.DIRSET |= PIN0_bm;
_delay_ms(1);
char lencmd = cmd[3];
for(int i = 0; i < lencmd+4; i++)
{
USART0_sendChar(cmd[i]);
}
while(!(USART0_STATUS & USART_TXCIF_bm))
{
tmp++;
_delay_us(10);
}
PORTA.DIRCLR |= PIN0_bm;
}
I am using volatile for debugging purposes…
I have been working with Atmel microcontrollers for 30 years
I will attempt to slow down the Baud rate, perhaps signals are not perfect and the move command has more data it sends. The AVR128DA has a fractional baud rate clock that is very precise.
I have A new Sealeae Logic 8 on the way so i can better define the USART data. Half Duplex is available on this chip and seems to be working at least for LED on and LED off. The example command LedOnETorque above does set the LED on.
Anyone see what I may be doing wrong?
I will work on receiving the data sent back from the servo, right now i am just using the scope to see that data is being sent but not deciphering it yet, that could solve this so i will work on that while I await() a response.
Thank You;