Set the address of the OpenServo

By default the OpenServo comes with the device address 0x10. You will need to change this default behaviour if you want to use more than one OpenServo. You can change the default address of the servo using a couple of methods.

Method1 - reflash

You can change the address of the OpenServo by making a small change to the source code and recompiling. You will need to reflash the application code to the OpenServo once it is compiled. See the Software page to obtain latest source code.

In order to change the address in the source, you will need to load AVR Studio, and load the AVR_OpenServo application AT{your chip type}_OpenServo.aps

Open the file openservo.h which contains some defaults. (latest CVS Only)

Look for the lines below near the top of the file

// The default TWI address. Change this if you want to change the TWI address of the servo
#define REG_DEFAULT_TWI_ADDR            0x10

Change the last part (0x10) to the new servo address.

Compile the source using the menu "Build->Build" or press F7.

Now you need to flash the OpenServo with the new hex code. You can follow DocSoftwarePages for more information on flashing.

Method 2 - On the fly

The OpenServo's TWI/I2C address can be changed at run time. To change the address while the servo is powered up, you must be sure to not conflict address with any other OpenServo on the bus. This includes plugging in multiple default OpenServo boards at the same time. To ensure that there are no conflicts, you can remove all devices from the bus apart from the one you wish to change.

In order to change the address you can follow two steps; one to make the change temporary, and optionally save the new address in EEPROM.

It is important to note that the registers may be protected against writing, and as such must be enabled. You can enable the writing of registers by sending WRITE_ENABLE command.

WRITE_ENABLE = 0x84
[device WRITE_ENABLE]
send [0x10 0x84]

8 bit function

0x20

TWI_ADDRESS

Read/Write Protected

TWI address of servo

Using the TWI_ADDRESS value, send the string to the OpenServo as such:

Assuming default device address of 0x10.

The register address of TWI_ADDRESS translates to 0x20. So to send the new TWI address send:

TWI_ADDRESS = 0x20
[device TWI_ADDRESS {new_addr}]
send [0x10 0x20 {new_addr}]

Optionally you can save the new TWI address with the REGISTERS_SAVE command, which translates to 0x86.

REGISTERS_SAVE = 0x86
[device REGISTERS_SAVE]
send [0x10 0x86]

This will only persist until the registers are restored, or the servo has had significant software changes. WARNING These registers could be reset to default if a glitch is detected at run time.