template<typename CommType, size_t MaxDevices = 8>
class tmc51x0::TMC51x0DaisyChain< CommType, MaxDevices >
High-level manager for multiple TMC51x0 drivers in a daisy-chain configuration.
This class manages multiple TMC51x0 drivers on a single SPI bus using daisy-chaining. It supports a fixed number of onboard devices (known at construction) and allows dynamic addition/removal of extra devices up to a maximum capacity.
Key Features
- Onboard Devices: Fixed number of devices created at construction time
- Dynamic Devices: Support for adding/removing extra devices at runtime
- Proper Chain Length: Automatically configures SpiCommInterface with total chain length
- Individual Access: Access individual drivers via operator[]
Architecture
- One SpiCommInterface: Shared by all TMC51x0 instances in the chain
- Multiple TMC51x0 Instances: One per device, each with its own position (0, 1, 2, ...)
- Total Chain Length: Automatically updated when devices are added/removed
Important: Sequential Positioning
In a daisy chain, devices are physically connected in sequence (MISO of one device connects to MOSI of the next). Therefore, positions MUST be sequential (0, 1, 2, 3...). The position corresponds to the physical order in the chain, not arbitrary numbering.
- Onboard devices are always created at positions 0, 1, 2, ..., (num_onboard-1)
- Extra devices must be added sequentially starting from position num_onboard
- You cannot skip positions (e.g., cannot add device at position 5 if position 4 is empty)
Users can create their own aliases/names in their code for better readability:
auto& x_axis = chain[0];
auto& y_axis = chain[1];
auto& z_axis = chain[2];
x_axis.rampControl.SetTargetPosition(1000);
y_axis.rampControl.SetMaxSpeed(500.0f);
z_axis.motorControl.Enable();
High-level manager for multiple TMC51x0 drivers in a daisy-chain configuration.
Definition tmc51x0_daisy_chain.hpp:115
Usage Example
MySPI spi_comm;
spi_comm.Initialize();
cfg.motor.irun = 20;
cfg.motor.ihold = 10;
chain.InitializeAll(cfg);
position) if (chain.AddDevice(3)) {
chain[3].Initialize(cfg);
}
auto& motor_a = chain[0];
auto& motor_b = chain[1];
auto& motor_c = chain[2];
auto& motor_d = chain[3];
motor_a.rampControl.SetTargetPosition(1000);
motor_b.rampControl.SetMaxSpeed(500.0f);
chain.RemoveDevice(3);
CRTP-based SPI implementation of TMC5160CommInterface.
Definition tmc51x0_comm_interface.hpp:1660
Driver initialization configuration structure.
Definition tmc51x0_types.hpp:2870
- Template Parameters
-
| CommType | The communication interface type (must be SpiCommInterface<CommType>) |
| MaxDevices | Maximum total capacity (onboard + extra devices, default: 8) |