AX-12A Direct register commands no Library

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

	_delay_us(1200); // waiting for Servo reply status
	_delay_us(1200); // waiting for Servo reply status
	_delay_us(1200); // waiting for Servo reply status
	_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;
	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)
	char lencmd = cmd[3];
	for(int i = 0; i < lencmd+4; i++)

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;

I was able to get it turning in Wheel mode
I set up my scope to show the ERROR code bits for each command.

Something must be wrong with my checksum calculation
for example

volatile char chk8 = ChecksumCalc(1+5+3+32+1+1);

Returns 212 and that checksum with the values 255,3 (0x3FF) works
char DynamixelMovingSpeed[] = {0xFF,0xFF,0x01,0x05,0x03,32,255,3,chk8}; // chk8 = 212 should be 214???

If i use the 255+3 ie. (ChecksumCalc(1+5+3+32+255+3):wink: I get a checksum of 214 that returns bit 3 ERROR code
volatile char chk8 = ChecksumCalc(1+5+3+32+255+3);

I must be doing something wrong in the checksum formula.

What is the proper way to set Moving Speed for wheel mode in the range
the datasheet suggests and calculating every checksum value.

  • Wheel Mode
    0 ~ 2,047(0x7FF) can be used, the unit is about 0.1%.
    If a value in the range of 0 ~ 1,023 is used, it is stopped by setting to 0 while rotating to CCW direction.
    If a value in the range of 1,024 ~ 2,047 is used, it is stopped by setting to 1,024 while rotating to CW direction.
    That is, the 10th bit becomes the direction bit to control the direction.
    In Wheel Mode, only the output control is possible, not speed.
    For example, if it is set to 512, it means the output is controlled by 50% of the maximum output.

Realized I had only an 8 bit char getting passed to function
Also i was adding the shifted High byte and only shifting by 7 instead of 8 but
i now realize the high byte just gets thrown away

Revised Checksum

char ChecksumCalc(uint16_t seed)
	volatile	char CheckSum = 0;
	volatile    uint8_t lowbyte=0;
	lowbyte = seed & 0xFF;
	CheckSum = ~(lowbyte);
	return CheckSum;

It’s only taken 4 days perhaps 6 hours a day to decipher this thing, There is not much to go on in the googlespheer .

Ill work on my library to make controlling these easier, I really miss the older forums wnd folks that used datasheets and registers to understand the bare metal coding necessary for these things, oh just pop in the Ardrino library and everything is good, you don’t really get the deep understanding of the register level and the simplicity of it once the correct information is understood.

It wasn’t till tonight i thought oh theres a wheel mode perhaps that would be easier to implement
If i would have had my new logic analyzer it would have been much easier to understand what i was doing was wrong, when an Ardrino library command fails to work people can’t do the deep dive to see why, using registers programming you get a lot more learning out of it.

A long time ago Robotis had this Embedded C library made for the AVR chip (CM-510)

Don’t know if you are aware of it?