Skip to content

Controlling multiple devices

Zaber devices can connect to each other in series (also referred to as daisy-chaining). This arrangement allows control of multiple devices through one serial port using a single @class Connection class instance.

The example below demonstrates how to home all axes of all devices on a port.

# connection is previously opened Connection
device_list = connection.detect_devices()

print("Found {} devices".format(len(device_list)))

for device in device_list:
    print("Homing all axes of device with address {}.".format(device.device_address))
    device.all_axes.home()
// connection is previously opened Connection
var deviceList = connection.DetectDevices();

Console.WriteLine($"Found {deviceList.Length} devices.");

foreach (var device in deviceList)
{
    Console.WriteLine($"Homing all axes of device with address {device.DeviceAddress}.");
    device.AllAxes.Home();
}
// connection is previously opened Connection
const deviceList = await connection.detectDevices();

console.log(`Found ${deviceList.length} devices.`);

for (const device of deviceList) {
    console.log(`Homing all axes of device with address ${device.deviceAddress}.`);
    await device.allAxes.home();
}
// connection is previously opened Connection
Device[] deviceList = connection.detectDevices();

System.out.println(String.format("Found %d devices.", deviceList.length));

for (Device device : deviceList) {
    System.out.println(String.format("Homing all axes of device with address %d.", device.getDeviceAddress()));
    device.getAllAxes().home();
}
% connection is previously opened Connection
deviceList = connection.detectDevices();

fprintf('Found %d devices.\n', deviceList.length);

for i = 1:length(deviceList)
    device = deviceList(i);
    fprintf('Homing all axes of device with address %d.\n', device.getDeviceAddress());
    device.getAllAxes().home();
end
// connection is previously opened Connection
std::vector<Device> deviceList = connection.detectDevices();

std::cout << "Found " << deviceList.size() << " devices" std::endl;

for (auto& device: deviceList) {
    std::cout << "Homing all axes of device with address " << device.getDeviceAddress() << "." << std::endl;
    device.getAllAxes().home();
}

The @method DetectDevices method returns devices ordered by their assigned address. Check or change the addresses assigned to your devices in the Zaber Console application.

Device address conflict

If you connect multiple devices in series for the first time, you may encounter a @class DeviceAddressConflictException exception when running this program. This exception is thrown when multiple devices have the same address. Use the Zaber Console application to assign distinct addresses to your devices.