Configuration

This guide covers configuration options for the TMC9660 driver.

Bootloader Configuration

The bootloader must be configured for Parameter Mode operation. This is CRITICAL and must be done before any motor control.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
tmc9660::BootloaderConfig cfg{};

// CRITICAL: Set boot mode to Parameter
cfg.boot.boot_mode = tmc9660::bootcfg::BootMode::Parameter;

// Start motor control after configuration
cfg.boot.start_motor_control = true;

// SPI configuration
cfg.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 configuration
cfg.clock.use_external = tmc9660::bootcfg::ClockSource::Internal;

// Initialize bootloader
auto result = driver.bootloaderInit(&cfg);

Motor Configuration

Motor Type and Pole Pairs

1
2
3
4
5
6
7
8
// BLDC motor with 7 pole pairs
driver.motorConfig.setType(tmc9660::tmcl::MotorType::BLDC_MOTOR, 7);

// Stepper motor
driver.motorConfig.setType(tmc9660::tmcl::MotorType::STEPPER_MOTOR);

// DC motor
driver.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 scheme
driver.motorConfig.setPWMSwitchingScheme(
    tmc9660::tmcl::PwmSwitchingScheme::SVPWM);

Commutation Mode

1
2
3
4
5
6
7
8
9
10
11
// FOC with Hall sensors
driver.motorConfig.setCommutationMode(
    tmc9660::tmcl::CommutationMode::FOC_HALL);

// FOC with encoder
driver.motorConfig.setCommutationMode(
    tmc9660::tmcl::CommutationMode::FOC_ENCODER);

// Open-loop
driver.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 gains
driver.focControl.setVelocityLoopGains(100, 200);

// Set position loop gains
driver.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);

Protection Configuration

Undervoltage Protection

1
2
3
4
5
driver.protection.configureUndervoltageProtection(
    tmc9660::tmcl::UndervoltageLevel::Level_12V,
    tmc9660::tmcl::UndervoltageEnable::ENABLED,
    tmc9660::tmcl::UndervoltageEnable::ENABLED,
    tmc9660::tmcl::UndervoltageEnable::ENABLED);

Overcurrent Protection

1
2
3
4
driver.protection.configureOvercurrentProtection(
    tmc9660::tmcl::OvercurrentEnable::ENABLED,
    tmc9660::tmcl::OvercurrentEnable::ENABLED,
    tmc9660::tmcl::OvercurrentEnable::ENABLED);

Default Values

Most configuration methods have sensible defaults. Refer to the API Reference for specific default values.

Next Steps