by stevo3d » Wed May 24, 2006 8:34 am
by stevo3d
Wed May 24, 2006 8:34 am
Glad to hear you got your wheel to rotate continuously Inaki!
inaki wrote:On the other hand, have you been able to write to EEPROM registers using Robot Terminal ? It seems it only works under Behavior Control prog. Am I right ?
Ok, with a bit of experimentation I think I have it all figured out.
Let's start with something we're all familiar with from the user manual. Using Manage mode and Robot Terminal, you can turn on the LED by setting RAM register 25 to a value of 1:
[CID:021(0X15)] write 25 1
->[Dynamixel]:255 255 021 004 003 025 001 201 LEN:008(0X08)
The AX-12 responds with:
<-[Dynamixel]:255 255 021 002 000 232 LEN:006(0X06)
Note the last byte value returned, 232. That's the AX-12's way of saying, "command completed with no error". You get the same status code when you set the LED to 0 for off.
Review the table on page 18 of the AX-12 manual. It shows all the registers and the valid range of values each register can hold. The entry for register 25, LED, says the min value is 0 and the max value is 1. Let's try to set an invalid value for the LED register:
[CID:021(0X15)] write 25 2
->[Dynamixel]:255 255 021 004 003 025 002 200 LEN:008(0X08)
<-[Dynamixel]:255 255 021 002 008 224 LEN:006(0X06)
Interesting. The status byte is 224, not 232! The AX-12 is smart enough to complain about setting any register outside that register's valid range. A status byte of 224 is an "invalid data" error. This is corroborated by the Range paragraph on page 18 of the AX-12 manual: "Each data has a valid minimum and maximum values. Write instructions made outside of these valid ranges will return an error." Let's see if the register was changed anyway:
[CID:021(0X15)] dump
...
[RAM AREA]
TORQUE_ENABLE (R/W)[024(0X18)]:000(0X00)
LED (R/W)[025(0X19)]:001(0X01)
...
The value of register 25 is still 1, unchanged from before. Ok great. So now we know we can set a RAM register and see when an error (code 224) or success (code 232) occurs.
How about the EEPROM registers? Let's try setting a simple one. EEPROM register 11, Limit Temperature will do. According to the table it's 1 byte, min value 0 and max value 150. What's it currently set to?
[CID:021(0X15)] dump
...
[EEPROM AREA]
...
LIMIT_TEMPERATURE (R/W)[011(0X0B)]:070(0X46)
Let's set the temperature limit to 72 degrees C:
[CID:021(0X15)] write 11 72
->[Dynamixel]:255 255 021 004 003 011 072 117 LEN:008(0X08)
<-[Dynamixel]:255 255 021 002 000 232 LEN:006(0X06)
232! Success! Let's make sure.
[CID:021(0X15)] dump
...
[EEPROM AREA]
...
LIMIT_TEMPERATURE (R/W)[011(0X0B)]:072(0X48)
Ok, in my own long winded way hopefully I've proven that you
can set EEPROM registers with Manage mode. Let's try setting register 8, the CCW Angle Limit. It's a 2 byte register with min value of 0 and max of 1023. What happens when we try to set it to 0:
[CID:021(0X15)] write 8 0
->[Dynamixel]:255 255 021 004 003 008 000 219 LEN:008(0X08)
<-[Dynamixel]:255 255 021 002 008 224 LEN:006(0X06)
Didn't work. Error code 224 rears its ugly head yet again. If the AX-12 is smart enough to recognize out of range errors, maybe it is also smart enough to recognize other errors. According to the table, register 8 has to be treated as a 2-byte register. Hmm. What if we set it using two bytes:
[CID:021(0X15)] write 8 0 0
->[Dynamixel]:255 255 021 005 003 008 000 000 218 LEN:009(0X09)
<-[Dynamixel]:255 255 021 002 000 232 LEN:006(0X06)
Woo hoo! Success!
![Very Happy :D](images/smilies/icon_biggrin.gif)
Let's make sure:
[CID:021(0X15)] dump
...
CCW_ANGLE_LIMIT_L (R/W)[008(0X08)]:000(0X00)
CCW_ANGLE_LIMIT_H (R/W)[009(0X09)]:000(0X00)
Register 8 and so-called register 9 are both set to 0. You have to set both bytes at the same time with 2-byte registers. This also explains why, when setting angle limits, you only have to set registers 6 and 8 in the Behavior Control Programmer, and don't have to worry about 7 and 9. You can't set 6 without setting 7 and you can't set 8 without also setting 9. The Behavior Control Programmer apparently knows this and sets 7 and 9 automatically.
Another tricky thing: to set any 2-byte register with Manage mode you have to convert the value you want to set into hex, break it into two bytes, and then convert each byte back into decimal. For example, if you want to set register 8 back to the default of 1023, you'd convert 1023 to hex (3FF), break the hex value into two bytes (high byte 03 and low byte FF), and convert the hex back into decimal (high byte 3 and low byte 255). Those are the values you'll need to enter into the write command. But one last tricky thing is you have to swap the order of the bytes because the AX-12 expects the low byte first (255) and the high byte last (3). So finally we use this command to set register 8 to a value of 1023:
[CID:021(0X15)] write 8 255 3
->[Dynamixel]:255 255 021 005 003 008 255 003 216 LEN:009(0X09)
<-[Dynamixel]:255 255 021 002 000 232 LEN:006(0X06)
Command completed successfully. Let's check the value with a dump command:
[CID:021(0X15)] dump
...
CCW_ANGLE_LIMIT_L (R/W)[008(0X08)]:255(0XFF)
CCW_ANGLE_LIMIT_H (R/W)[009(0X09)]:003(0X03)
Finally, if you print the value of register 8 using the Behavior Control Programmer, you'll see that it contains the value 1023:
LOAD CM5 Print DX:Custom ID: 21:8
Hope you found this helpful and not too tedious. I wanted to make this as general-purpose as possible for everyone.
Glad to hear you got your wheel to rotate continuously Inaki!
inaki wrote:On the other hand, have you been able to write to EEPROM registers using Robot Terminal ? It seems it only works under Behavior Control prog. Am I right ?
Ok, with a bit of experimentation I think I have it all figured out.
Let's start with something we're all familiar with from the user manual. Using Manage mode and Robot Terminal, you can turn on the LED by setting RAM register 25 to a value of 1:
[CID:021(0X15)] write 25 1
->[Dynamixel]:255 255 021 004 003 025 001 201 LEN:008(0X08)
The AX-12 responds with:
<-[Dynamixel]:255 255 021 002 000 232 LEN:006(0X06)
Note the last byte value returned, 232. That's the AX-12's way of saying, "command completed with no error". You get the same status code when you set the LED to 0 for off.
Review the table on page 18 of the AX-12 manual. It shows all the registers and the valid range of values each register can hold. The entry for register 25, LED, says the min value is 0 and the max value is 1. Let's try to set an invalid value for the LED register:
[CID:021(0X15)] write 25 2
->[Dynamixel]:255 255 021 004 003 025 002 200 LEN:008(0X08)
<-[Dynamixel]:255 255 021 002 008 224 LEN:006(0X06)
Interesting. The status byte is 224, not 232! The AX-12 is smart enough to complain about setting any register outside that register's valid range. A status byte of 224 is an "invalid data" error. This is corroborated by the Range paragraph on page 18 of the AX-12 manual: "Each data has a valid minimum and maximum values. Write instructions made outside of these valid ranges will return an error." Let's see if the register was changed anyway:
[CID:021(0X15)] dump
...
[RAM AREA]
TORQUE_ENABLE (R/W)[024(0X18)]:000(0X00)
LED (R/W)[025(0X19)]:001(0X01)
...
The value of register 25 is still 1, unchanged from before. Ok great. So now we know we can set a RAM register and see when an error (code 224) or success (code 232) occurs.
How about the EEPROM registers? Let's try setting a simple one. EEPROM register 11, Limit Temperature will do. According to the table it's 1 byte, min value 0 and max value 150. What's it currently set to?
[CID:021(0X15)] dump
...
[EEPROM AREA]
...
LIMIT_TEMPERATURE (R/W)[011(0X0B)]:070(0X46)
Let's set the temperature limit to 72 degrees C:
[CID:021(0X15)] write 11 72
->[Dynamixel]:255 255 021 004 003 011 072 117 LEN:008(0X08)
<-[Dynamixel]:255 255 021 002 000 232 LEN:006(0X06)
232! Success! Let's make sure.
[CID:021(0X15)] dump
...
[EEPROM AREA]
...
LIMIT_TEMPERATURE (R/W)[011(0X0B)]:072(0X48)
Ok, in my own long winded way hopefully I've proven that you
can set EEPROM registers with Manage mode. Let's try setting register 8, the CCW Angle Limit. It's a 2 byte register with min value of 0 and max of 1023. What happens when we try to set it to 0:
[CID:021(0X15)] write 8 0
->[Dynamixel]:255 255 021 004 003 008 000 219 LEN:008(0X08)
<-[Dynamixel]:255 255 021 002 008 224 LEN:006(0X06)
Didn't work. Error code 224 rears its ugly head yet again. If the AX-12 is smart enough to recognize out of range errors, maybe it is also smart enough to recognize other errors. According to the table, register 8 has to be treated as a 2-byte register. Hmm. What if we set it using two bytes:
[CID:021(0X15)] write 8 0 0
->[Dynamixel]:255 255 021 005 003 008 000 000 218 LEN:009(0X09)
<-[Dynamixel]:255 255 021 002 000 232 LEN:006(0X06)
Woo hoo! Success!
![Very Happy :D](images/smilies/icon_biggrin.gif)
Let's make sure:
[CID:021(0X15)] dump
...
CCW_ANGLE_LIMIT_L (R/W)[008(0X08)]:000(0X00)
CCW_ANGLE_LIMIT_H (R/W)[009(0X09)]:000(0X00)
Register 8 and so-called register 9 are both set to 0. You have to set both bytes at the same time with 2-byte registers. This also explains why, when setting angle limits, you only have to set registers 6 and 8 in the Behavior Control Programmer, and don't have to worry about 7 and 9. You can't set 6 without setting 7 and you can't set 8 without also setting 9. The Behavior Control Programmer apparently knows this and sets 7 and 9 automatically.
Another tricky thing: to set any 2-byte register with Manage mode you have to convert the value you want to set into hex, break it into two bytes, and then convert each byte back into decimal. For example, if you want to set register 8 back to the default of 1023, you'd convert 1023 to hex (3FF), break the hex value into two bytes (high byte 03 and low byte FF), and convert the hex back into decimal (high byte 3 and low byte 255). Those are the values you'll need to enter into the write command. But one last tricky thing is you have to swap the order of the bytes because the AX-12 expects the low byte first (255) and the high byte last (3). So finally we use this command to set register 8 to a value of 1023:
[CID:021(0X15)] write 8 255 3
->[Dynamixel]:255 255 021 005 003 008 255 003 216 LEN:009(0X09)
<-[Dynamixel]:255 255 021 002 000 232 LEN:006(0X06)
Command completed successfully. Let's check the value with a dump command:
[CID:021(0X15)] dump
...
CCW_ANGLE_LIMIT_L (R/W)[008(0X08)]:255(0XFF)
CCW_ANGLE_LIMIT_H (R/W)[009(0X09)]:003(0X03)
Finally, if you print the value of register 8 using the Behavior Control Programmer, you'll see that it contains the value 1023:
LOAD CM5 Print DX:Custom ID: 21:8
Hope you found this helpful and not too tedious. I wanted to make this as general-purpose as possible for everyone.
Last edited by stevo3d on Wed May 24, 2006 7:40 pm, edited 1 time in total.
Steve Munk