tmc9660::BootloaderConfigcfg{};// CRITICAL: Set boot mode to Parametercfg.boot.boot_mode=tmc9660::bootcfg::BootMode::Parameter;// Start motor control after configurationcfg.boot.start_motor_control=true;// SPI configurationcfg.spiComm.boot_spi_iface=tmc9660::bootcfg::SPIInterface::IFACE0;// UART configuration (if using UART)cfg.uart.baud_rate=tmc9660::bootcfg::BaudRate::BR115200;cfg.uart.tx_pin=tmc9660::bootcfg::UartTxPin::GPIO6;cfg.uart.rx_pin=tmc9660::bootcfg::UartRxPin::GPIO7;// Clock configurationcfg.clock.use_external=tmc9660::bootcfg::ClockSource::Internal;// Initialize bootloaderautoresult=driver.bootloaderInit(&cfg);
Motor Configuration
Motor Type and Pole Pairs
1
2
3
4
5
6
7
8
// BLDC motor with 7 pole pairsdriver.motorConfig.setType(tmc9660::tmcl::MotorType::BLDC_MOTOR,7);// Stepper motordriver.motorConfig.setType(tmc9660::tmcl::MotorType::STEPPER_MOTOR);// DC motordriver.motorConfig.setType(tmc9660::tmcl::MotorType::DC_MOTOR);
Current Limits
1
2
3
4
5
// Set maximum torque current (2A)driver.motorConfig.setMaxTorqueCurrent(2000);// Set maximum flux current (1A)driver.motorConfig.setMaxFluxCurrent(1000);
PWM Configuration
1
2
3
4
5
6
// Set PWM frequency (20 kHz)driver.motorConfig.setPWMFrequency(20000);// Set PWM switching schemedriver.motorConfig.setPWMSwitchingScheme(tmc9660::tmcl::PwmSwitchingScheme::SVPWM);
Commutation Mode
1
2
3
4
5
6
7
8
9
10
11
// FOC with Hall sensorsdriver.motorConfig.setCommutationMode(tmc9660::tmcl::CommutationMode::FOC_HALL);// FOC with encoderdriver.motorConfig.setCommutationMode(tmc9660::tmcl::CommutationMode::FOC_ENCODER);// Open-loopdriver.motorConfig.setCommutationMode(tmc9660::tmcl::CommutationMode::OPEN_LOOP);
FOC Control Configuration
Control Loop Gains
1
2
3
4
5
6
7
8
// Set current loop gains (Kp, Ki)driver.focControl.setCurrentLoopGains(50,100);// Set velocity loop gainsdriver.focControl.setVelocityLoopGains(100,200);// Set position loop gainsdriver.focControl.setPositionLoopGains(10,20);
Sensor Configuration
Hall Sensors
1
driver.feedbackSense.configureHall();
ABN Encoder
1
2
// Configure incremental encoder (2048 counts per revolution)driver.feedbackSense.configureABNEncoder(2048);