|
| | TMC51x0MultiNode (CommType &comm, uint8_t num_onboard_devices, uint32_t f_clk=ClockFreq::DEFAULT_F_CLK) noexcept |
| | Construct a multi-node manager.
|
| |
| uint8_t | GetNumOnboardDevices () const noexcept |
| | Get the number of onboard devices (fixed at construction)
|
| |
| uint8_t | GetNumActiveDevices () const noexcept |
| | Get the total number of active devices (onboard + extra)
|
| |
| constexpr size_t | GetMaxCapacity () const noexcept |
| | Get the maximum capacity (onboard + extra devices)
|
| |
| bool | IsDeviceActive (uint8_t index) const noexcept |
| | Check if a device slot is active (has a device instance)
|
| |
| Result< void > | ProgramSequentially (uint8_t send_delay=2) noexcept |
| | Program all active devices sequentially using NAI/NAO addressing.
|
| |
| Result< void > | ProgramDevice (uint8_t index, uint8_t send_delay=2) noexcept |
| | Program a single device at the specified logical index.
|
| |
| Result< void > | AddDevice (uint8_t index) noexcept |
| | Add an extra device at the specified logical index.
|
| |
| Result< void > | RemoveDevice (uint8_t index) noexcept |
| | Remove an extra device at the specified logical index.
|
| |
| TMC51x0< CommType > & | operator[] (uint8_t index) noexcept |
| | Access individual TMC5160 driver by logical index.
|
| |
| const TMC51x0< CommType > & | operator[] (uint8_t index) const noexcept |
| | Const access to individual TMC5160 driver by logical index.
|
| |
| Result< void > | InitializeAll (const DriverConfig &config=DriverConfig()) noexcept |
| | Initialize all active devices with the same configuration.
|
| |
template<typename CommType, size_t MaxDevices = 8>
class tmc51x0::TMC51x0MultiNode< CommType, MaxDevices >
High-level manager for multiple TMC51x0 drivers in a UART multi-node configuration.
This class manages multiple TMC51x0 drivers on a single UART bus using sequential addressing with NAI/NAO pins. 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
- Sequential Programming: Handles NAI/NAO pin control for sequential addressing
- Individual Access: Access individual drivers via operator[] using logical indices
Architecture
- One UartCommInterface: Shared by all TMC51x0 instances on the UART bus
- Multiple TMC51x0 Instances: One per device, each with its own programmed node address
- Sequential Addressing: Uses NAI/NAO pins for sequential programming per datasheet
Important: Sequential Addressing (Per Datasheet)
In UART multi-node mode, devices are programmed sequentially using NAI/NAO pins:
Initial State at Power-Up:
- First chip: NAI tied to GND (hardware) → responds to address 0
- All other chips: NAI=HIGH (from previous chip's NAO) → respond to address 1
Programming Sequence (Per Datasheet Figure 5.1):
- Program first chip (accessible at address 0) to address 254, NAO goes LOW
- Next chip becomes accessible at address 0 (because previous chip's NAO is LOW)
- Program second chip (accessible at address 0) to address 253, NAO goes LOW
- Continue: program chip i to address (254 - i)
Logical vs Physical Addressing:
- Devices are accessed via operator[] using logical indices (0, 1, 2, ...)
- Physical addresses programmed into chips are (254, 253, 252, ...)
- This follows the datasheet procedure for addressing up to 255 nodes
Users can create their own aliases/names in their code for better readability:
tmc5160::TMC51x0MultiNode<MyUART, 5> nodes(uartComm, 3, 12'000'000);
nodes.ProgramSequentially();
auto& x_axis = nodes[0];
auto& y_axis = nodes[1];
auto& z_axis = nodes[2];
x_axis.rampControl.SetTargetPosition(1000);
y_axis.rampControl.SetMaxSpeed(500.0f);
z_axis.motorControl.Enable();
Usage Example
class MyUART : public tmc5160::UartCommInterface<MyUART> { ... };
MyUART uartComm;
uartComm.Initialize();
tmc5160::TMC51x0MultiNode<MyUART, 5> nodes(uartComm, 3, 12'000'000);
if (!nodes.ProgramSequentially()) {
}
cfg.motor.irun = 20;
cfg.motor.ihold = 10;
nodes.InitializeAll(cfg);
if (nodes.AddDevice(3)) {
nodes[3].Initialize(cfg);
}
auto& motor_a = nodes[0];
auto& motor_b = nodes[1];
auto& motor_c = nodes[2];
auto& motor_d = nodes[3];
motor_a.rampControl.SetTargetPosition(1000);
motor_b.rampControl.SetMaxSpeed(500.0f);
nodes.RemoveDevice(3);
Driver initialization configuration structure.
Definition tmc51x0_types.hpp:2870
- Template Parameters
-
| CommType | The communication interface type (must be UartCommInterface<CommType>) |
| MaxDevices | Maximum total capacity (onboard + extra devices, default: 8) |
template<typename CommType , size_t MaxDevices = 8>
Program all active devices sequentially using NAI/NAO addressing.
- Parameters
-
| send_delay | SENDDELAY value for NODECONF (default: 2, minimum for multi-node) |
- Returns
- Result<void> indicating success or error
This method programs all active devices sequentially using the datasheet procedure:
Initial state at power-up:
- First chip: NAI=GND (hardware) → responds to address 0
- All other chips: NAI=HIGH (from previous chip's NAO) → respond to address 1
Programming sequence (per datasheet Figure 5.1):
- Program first chip (accessible at address 0) to address (254 - 0) = 254 After programming, chip's NAO goes LOW → next chip becomes accessible at address 0
- Program second chip (accessible at address 0) to address (254 - 1) = 253 After programming, chip's NAO goes LOW → next chip becomes accessible at address 0
- Continue for all devices: program chip i to address (254 - i)
The devices are stored with their logical indices (0, 1, 2, ...) but programmed with addresses (254, 253, 252, ...) as per datasheet specification.
- Note
- This must be called after construction and before using the devices.
-
For multi-node systems, SENDDELAY should be set to minimum 2 for all nodes.
-
The programmed addresses (254, 253, 252...) are stored internally but the logical device indices (0, 1, 2...) are used for access via operator[].