HF-TMC9660 Driver
C++20 hardware-agnostic driver for Trinamic TMC9660 motor controller with FOC control, telemetry, and TMCL scripting
📚 Table of Contents
- Overview
- Features
- Quick Start
- Installation
- API Reference
- Examples
- Documentation
- Contributing
- License
📦 Overview
📖 📚🌐 Live Complete Documentation - Interactive guides, examples, and step-by-step tutorials
HF-TMC9660 is a portable C++20 driver for the Trinamic TMC9660 motor controller IC. The TMC9660 is a sophisticated motor driver supporting BLDC, stepper, and DC motors with advanced Field-Oriented Control (FOC), comprehensive telemetry, and TMCL scripting capabilities. The driver provides hardware-agnostic communication interfaces, allowing it to run on any platform (ESP32, STM32, etc.) with SPI or UART.
The driver exposes the full parameter mode interface, providing access to all 300+ TMC9660 parameters through an intuitive C++ API. It supports bootloader initialization, motor configuration, sensor integration (Hall sensors, encoders), FOC control loops, real-time telemetry, and protection systems.
✨ Features
- ✅ Multiple Motor Types: BLDC/PMSM, Stepper, and DC motor support
- ✅ FOC Control: Advanced Field-Oriented Control with torque, velocity, and position loops
- ✅ Sensor Integration: Hall sensors, incremental encoders, SPI encoders
- ✅ Comprehensive Telemetry: Real-time temperature, current, voltage, and position monitoring
- ✅ Protection Systems: Overcurrent, overtemperature, overvoltage protection
- ✅ TMCL Scripting: Execute custom scripts on device microcontroller
- ✅ Hardware Agnostic: SPI or UART interface for platform independence
- ✅ Modern C++20: Type-safe API with RAII principles
- ✅ Parameter Mode: Full access to 300+ TMC9660 parameters
🚀 Quick Start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "inc/tmc9660.hpp"
// 1. Implement the communication interface (see platform_integration.md)
class MySPI : public tmc9660::SpiCommInterface {
// ... implement required methods
};
// 2. Create driver instance
MySPI spi;
tmc9660::TMC9660 driver(spi);
// 3. CRITICAL: Initialize bootloader for Parameter Mode
tmc9660::BootloaderConfig cfg{};
cfg.boot.boot_mode = tmc9660::bootcfg::BootMode::Parameter;
cfg.boot.start_motor_control = true;
if (driver.bootloaderInit(&cfg) != tmc9660::TMC9660::BootloaderInitResult::Success) {
// Handle error
return;
}
// 4. Configure and start motor
driver.motorConfig.setType(tmc9660::tmcl::MotorType::BLDC_MOTOR, 7); // 7 pole pairs
driver.focControl.setTargetVelocity(1000);
For detailed setup, see Installation and Quick Start Guide.
🔧 Installation
- Clone or copy the driver files into your project
- Implement the communication interface for your platform (see Platform Integration)
- Include the header in your code:
1
#include "inc/tmc9660.hpp"
- Compile with a C++20 or newer compiler
For detailed installation instructions, see docs/installation.md.
📖 API Reference
| Method | Description |
|---|---|
bootloaderInit() |
Initialize bootloader for Parameter Mode (CRITICAL) |
motorConfig.setType() |
Set motor type and pole pairs |
focControl.setTargetVelocity() |
Set target velocity for FOC control |
telemetry.getTemperature() |
Read motor temperature |
telemetry.getCurrent() |
Read motor current |
For complete API documentation, see docs/api_reference.md.
📊 Examples
For ESP32 examples, see the examples/esp32 directory.
Detailed example walkthroughs are available in docs/examples.md.
📚 Documentation
For complete documentation, see the docs directory.
Special Features
- Bootloader Initialization - Critical bootloader setup guide
🤝 Contributing
Pull requests and suggestions are welcome! Please follow the existing code style and include tests for new features.
📄 License
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.