ESP32-C6 TMC9660 Comprehensive Test Suite

This directory contains comprehensive test suites for the TMC9660 motor driver using the ESP32-C6 DevKit-M-1. The tests support both the TMC9660-3PH-EVKIT (BLDC motor board) and TMC9660-STP-EVKIT (Stepper motor board).

πŸ“‹ Table of Contents


πŸ”Œ Hardware Overview

ESP32-C6 DevKit-M-1

The ESP32-C6 DevKit-M-1 serves as the host controller for communicating with the TMC9660 motor driver via SPI or UART.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚        ESP32-C6 DevKit-M-1                      β”‚
β”‚                                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚        ESP32-C6 Microcontroller          β”‚   β”‚
β”‚  β”‚                                          β”‚   β”‚
β”‚  β”‚  GPIO Pins:                              β”‚   β”‚
β”‚  β”‚  β€’ SPI: MOSI, MISO, SCLK, CS             β”‚   β”‚
β”‚  β”‚  β€’ UART: TX, RX                          β”‚   β”‚
β”‚  β”‚  β€’ Control: RST, DRV_EN, FAULTN, WAKE    β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                 β”‚
β”‚  USB-C Connector                                β”‚
β”‚  (Power + Serial Communication)                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

TMC9660-3PH-EVKIT (BLDC Motor Board)

Evaluation kit for 3-phase BLDC motor control with Hall sensors and ABN encoders.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      TMC9660-3PH-EVKIT                          β”‚
β”‚                                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚        TMC9660 IC                        β”‚   β”‚
β”‚  β”‚                                          β”‚   β”‚
β”‚  β”‚  Features:                               β”‚   β”‚
β”‚  β”‚  β€’ 3-phase BLDC motor driver             β”‚   β”‚
β”‚  β”‚  β€’ Hall sensor inputs (U, V, W)          β”‚   β”‚
β”‚  β”‚  β€’ Dual ABN encoder inputs               β”‚   β”‚
β”‚  β”‚  β€’ SPI Flash memory                      β”‚   β”‚
β”‚  β”‚  β€’ Brake chopper & mechanical brake      β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                 β”‚
β”‚  Motor Connectors:                              β”‚
β”‚  β€’ U, V, W (3-phase motor)                      β”‚
β”‚  β€’ Hall sensors (GPIO2, 3, 4)                   β”‚
β”‚  β€’ ABN encoder 1 (GPIO8, 13, 14)                β”‚
β”‚  β€’ ABN encoder 2 (GPIO15, 16)                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

TMC9660-STP-EVKIT (Stepper Motor Board)

Evaluation kit for stepper motor control with reference switches and ABN encoders.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      TMC9660-STP-EVKIT                          β”‚
β”‚                                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚        TMC9660 IC                        β”‚   β”‚
β”‚  β”‚                                          β”‚   β”‚
β”‚  β”‚  Features:                               β”‚   β”‚
β”‚  β”‚  β€’ Stepper motor driver                  β”‚   β”‚
β”‚  β”‚  β€’ Reference switches (Left, Right, Home)β”‚   β”‚
β”‚  β”‚  β€’ Dual ABN encoder inputs               β”‚   β”‚
β”‚  β”‚  β€’ SPI Flash memory                      β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                 β”‚
β”‚  Motor Connectors:                              β”‚
β”‚  β€’ Step/Direction interface                     β”‚
β”‚  β€’ Reference switches (GPIO2, 3, 4)             β”‚
β”‚  β€’ ABN encoder 1 (GPIO8, 13, 14)                β”‚
β”‚  β€’ ABN encoder 2 (GPIO15, 16)                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”— Pin Connections

SPI Communication Interface

1
2
3
4
5
6
7
8
9
10
11
12
13
ESP32-C6 DevKit-M-1          TMC9660-3PH-EVKIT / STP-EVKIT
──────────────────          ───────────────────────────────
GPIO7  (MOSI)      ───────> SPI MOSI
GPIO2  (MISO)      <─────── SPI MISO
GPIO6  (SCLK)      ───────> SPI SCLK
GPIO18 (CS)        ───────> SPI CS

Control Pins:
──────────────────          ───────────────────────────────
GPIO22 (RST)       ───────> RST     (Active HIGH)
GPIO20 (DRV_EN)    ───────> DRV_EN  (Active HIGH)
GPIO19 (FAULTN)    <─────── FAULTN  (Active LOW, open-drain)
GPIO21 (WAKE)      ───────> WAKE    (Active LOW)

UART Communication Interface (Alternative)

1
2
3
4
ESP32-C6 DevKit-M-1          TMC9660-3PH-EVKIT / STP-EVKIT
──────────────────          ───────────────────────────────
GPIO5  (TX)        ───────> UART RX (GPIO6 on TMC9660)
GPIO4  (RX)        <─────── UART TX (GPIO7 on TMC9660)

Power and Common

1
2
3
4
ESP32-C6 DevKit-M-1          TMC9660-3PH-EVKIT / STP-EVKIT
──────────────────          ───────────────────────────────
GND                ───────> GND (Common ground)
3.3V / 5V          ───────> VCC (if needed for level shifting)

πŸ› οΈ Hardware Setup

BLDC Motor Board Setup (TMC9660-3PH-EVKIT)

Connection Diagram

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  ESP32-C6 DevKit    β”‚         β”‚ TMC9660-3PH-EVKIT   β”‚
β”‚                     β”‚         β”‚                     β”‚
β”‚  GPIO7 (MOSI)  ─────┼─────────┼─> SPI MOSI          β”‚
β”‚  GPIO2 (MISO)  <────┼─────────┼─< SPI MISO          β”‚
β”‚  GPIO6 (SCLK)  ─────┼─────────┼─> SPI SCLK          β”‚
β”‚  GPIO18(CS)    ─────┼─────────┼─> SPI CS            β”‚
β”‚                     β”‚         β”‚                     β”‚
β”‚  GPIO22(RST)   ─────┼─────────┼─> RST               β”‚
β”‚  GPIO20(DRV_EN) ────┼─────────┼─> DRV_EN            β”‚
β”‚  GPIO19(FAULTN)<────┼─────────┼─< FAULTN            β”‚
β”‚  GPIO21(WAKE)  ─────┼─────────┼─> WAKE              β”‚
β”‚                     β”‚         β”‚                     β”‚
β”‚  GND           ─────┼─────────┼─> GND               β”‚
β”‚                     β”‚         β”‚                     β”‚
β”‚                     β”‚         β”‚  Motor Connections: β”‚
β”‚                     β”‚         β”‚  β€’ U, V, W (3-phase)β”‚
β”‚                     β”‚         β”‚  β€’ Hall (2,3,4)     β”‚
β”‚                     β”‚         β”‚  β€’ Encoder1(8,13,14)β”‚
β”‚                     β”‚         β”‚  β€’ Encoder2 (15,16) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Setup Steps

  1. Power Off: Ensure both boards are powered off before making connections.

  2. Connect SPI Interface:
    • Connect ESP32 GPIO7 β†’ TMC9660 SPI MOSI
    • Connect ESP32 GPIO2 β†’ TMC9660 SPI MISO
    • Connect ESP32 GPIO6 β†’ TMC9660 SPI SCLK
    • Connect ESP32 GPIO18 β†’ TMC9660 SPI CS
  3. Connect Control Pins:
    • Connect ESP32 GPIO22 β†’ TMC9660 RST
    • Connect ESP32 GPIO20 β†’ TMC9660 DRV_EN
    • Connect ESP32 GPIO19 β†’ TMC9660 FAULTN
    • Connect ESP32 GPIO21 β†’ TMC9660 WAKE
  4. Connect Ground: Connect GND between ESP32 and TMC9660 boards.

  5. Connect Motor (if testing with actual motor):
    • Connect 3-phase BLDC motor to U, V, W terminals
    • Connect Hall sensors to Hall connector (if using Hall feedback)
    • Connect ABN encoder to Encoder connector (if using encoder feedback)
  6. Power On:
    • Power ESP32 via USB-C
    • Power TMC9660 board via its power supply (typically 12V-48V)

Stepper Motor Board Setup (TMC9660-STP-EVKIT)

Connection Diagram

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  ESP32-C6 DevKit    β”‚         β”‚ TMC9660-STP-EVKIT   β”‚
β”‚                     β”‚         β”‚                     β”‚
β”‚  GPIO7 (MOSI)  ─────┼─────────┼─> SPI MOSI          β”‚
β”‚  GPIO2 (MISO)  <────┼─────────┼─< SPI MISO          β”‚
β”‚  GPIO6 (SCLK)  ─────┼─────────┼─> SPI SCLK          β”‚
β”‚  GPIO18(CS)    ─────┼─────────┼─> SPI CS            β”‚
β”‚                     β”‚         β”‚                     β”‚
β”‚  GPIO22(RST)   ─────┼─────────┼─> RST               β”‚
β”‚  GPIO20(DRV_EN) ────┼─────────┼─> DRV_EN            β”‚
β”‚  GPIO19(FAULTN)<────┼─────────┼─< FAULTN            β”‚
β”‚  GPIO21(WAKE)  ─────┼─────────┼─> WAKE              β”‚
β”‚                     β”‚         β”‚                     β”‚
β”‚  GND           ─────┼─────────┼─> GND               β”‚
β”‚                     β”‚         β”‚                     β”‚
β”‚                     β”‚         β”‚  Motor Connections: β”‚
β”‚                     β”‚         β”‚  β€’ Step/Dir         β”‚
β”‚                     β”‚         β”‚  β€’ Ref Switches     β”‚
β”‚                     β”‚         β”‚    (Left,Right,Home)β”‚
β”‚                     β”‚         β”‚  β€’ Encoder1 (8,13,14)β”‚
β”‚                     β”‚         β”‚  β€’ Encoder2 (15,16) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Setup Steps

  1. Power Off: Ensure both boards are powered off before making connections.

  2. Connect SPI Interface: (Same as BLDC board)
    • Connect ESP32 GPIO7 β†’ TMC9660 SPI MOSI
    • Connect ESP32 GPIO2 β†’ TMC9660 SPI MISO
    • Connect ESP32 GPIO6 β†’ TMC9660 SPI SCLK
    • Connect ESP32 GPIO18 β†’ TMC9660 SPI CS
  3. Connect Control Pins: (Same as BLDC board)
    • Connect ESP32 GPIO22 β†’ TMC9660 RST
    • Connect ESP32 GPIO20 β†’ TMC9660 DRV_EN
    • Connect ESP32 GPIO19 β†’ TMC9660 FAULTN
    • Connect ESP32 GPIO21 β†’ TMC9660 WAKE
  4. Connect Ground: Connect GND between ESP32 and TMC9660 boards.

  5. Connect Motor (if testing with actual motor):
    • Connect stepper motor to motor connector
    • Connect reference switches to REF SWITCHES connector (Left=GPIO2, Right=GPIO3, Home=GPIO4)
    • Connect ABN encoder to Encoder connector (if using encoder feedback)
  6. Power On:
    • Power ESP32 via USB-C
    • Power TMC9660 board via its power supply

πŸ—οΈ Building the Tests

Prerequisites

  • ESP-IDF: Version 5.5 (release/v5.5) or later
  • Python: Version 3.8 or later (for ESP-IDF tools)
  • CMake: Version 3.16 or later
  • Git: For cloning the repository
  • Bash: For running the build scripts (Linux/macOS/Git Bash on Windows)

Installation Steps

  1. Install ESP-IDF (if not already installed):

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    # Clone ESP-IDF
    git clone --recursive https://github.com/espressif/esp-idf.git
    cd esp-idf
       
    # Checkout release version 5.5
    git checkout release/v5.5
    git submodule update --init --recursive
       
    # Install ESP-IDF (Linux/macOS)
    ./install.sh esp32c6
       
    # Set up environment (add to ~/.bashrc or ~/.zshrc for persistence)
    . ./export.sh
    
  2. Clone the Repository:

    1
    2
    
    git clone <repository-url>
    cd hf-tmc9660-driver
    
  3. Navigate to ESP32 Examples:

    1
    
    cd examples/esp32
    
  4. Setup Repository (First time only):

    1
    2
    3
    
    # Make scripts executable and setup the build environment
    chmod +x scripts/*.sh
    ./scripts/setup_repo.sh
    

Available Test Applications

The test suites use a centralized build system with scripts. Available applications:

Application Name Description Board
bldc_comprehensive_test Comprehensive BLDC motor testing with Hall sensors, ABN encoders, and velocity control TMC9660-3PH-EVKIT
stepper_comprehensive_test Comprehensive Stepper motor testing with FOC and step/dir control TMC9660-STP-EVKIT
dc_comprehensive_test Comprehensive DC motor testing with current and velocity control TMC9660-3PH-EVKIT
telemetry_comprehensive_test Comprehensive telemetry monitoring for temperature, current, voltage, and status TMC9660-3PH-EVKIT
bootloader_comprehensive_test Comprehensive bootloader testing for initialization and configuration TMC9660-3PH-EVKIT

List Available Applications

1
2
# List all available applications
./scripts/build_app.sh list

Output:

1
2
3
4
5
6
Available Applications:
  β€’ bldc_comprehensive_test         - Comprehensive BLDC motor testing suite
  β€’ stepper_comprehensive_test      - Comprehensive Stepper motor testing suite
  β€’ dc_comprehensive_test           - Comprehensive DC motor testing suite
  β€’ telemetry_comprehensive_test    - Comprehensive telemetry monitoring test suite
  β€’ bootloader_comprehensive_test   - Comprehensive bootloader testing suite

Building Applications

Build Syntax

1
./scripts/build_app.sh <app_type> <build_type>

Parameters:

  • <app_type>: Application name (e.g., bldc_comprehensive_test)
  • <build_type>: Build configuration - Debug or Release

Build Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Build BLDC comprehensive test (Release build)
./scripts/build_app.sh bldc_comprehensive_test Release

# Build Stepper comprehensive test (Debug build)
./scripts/build_app.sh stepper_comprehensive_test Debug

# Build DC motor comprehensive test (Release build)
./scripts/build_app.sh dc_comprehensive_test Release

# Build Telemetry comprehensive test (Debug build)
./scripts/build_app.sh telemetry_comprehensive_test Debug

# Build Bootloader comprehensive test (Release build)
./scripts/build_app.sh bootloader_comprehensive_test Release

Build Output

Build artifacts are located in:

1
build-app-<app_type>-type-<build_type>-target-esp32c6-idf-<idf_version>/

Example:

1
build-app-bldc_comprehensive_test-type-Release-target-esp32c6-idf-release_v5.5/

Build Types

Build Type Optimization Debug Info Use Case
Debug -O0 (no optimization) Full (-g3) Development, debugging
Release -O2 (optimized) Minimal (-g0) Production, performance testing

πŸš€ Running the Tests

Flashing and Monitoring

The build scripts provide convenient commands for flashing and monitoring your ESP32-C6.

Flash and Monitor (Auto-detect Port)

1
./scripts/flash_app.sh <app_type> <build_type>

This command will:

  1. Auto-detect the ESP32 serial port
  2. Flash the firmware
  3. Start monitoring serial output

Flash and Monitor (Specify Port)

1
2
3
./scripts/flash_app.sh <app_type> <build_type> /dev/ttyUSB0    # Linux
./scripts/flash_app.sh <app_type> <build_type> /dev/cu.usbserial-*  # macOS
./scripts/flash_app.sh <app_type> <build_type> COM3            # Windows

Flash Only (No Monitor)

1
./scripts/flash_app.sh <app_type> <build_type> --no-monitor

Monitor Only (Reconnect)

1
2
./scripts/monitor_app.sh
./scripts/monitor_app.sh /dev/ttyUSB0    # Linux (specify port)

Complete Workflow Example

1
2
3
4
5
6
7
8
9
10
11
# 1. Build the application
./scripts/build_app.sh bldc_comprehensive_test Release

# 2. Flash and monitor
./scripts/flash_app.sh bldc_comprehensive_test Release

# Output will show:
# βœ… Building app: bldc_comprehensive_test
# βœ… Build type: Release
# βœ… Flashing firmware...
# βœ… Starting monitor...

Expected Output

After flashing and running, you should see output like:

1
2
3
4
5
6
7
8
9
10
11
12
13
╔══════════════════════════════════════════════════════════════════════════════╗
β•‘                    ESP32-C6 BLDC COMPREHENSIVE TEST SUITE                    β•‘
β•‘                         HardFOC TMC9660 Driver Tests                         β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
Debug logging enabled for TMCL communication traces

╔══════════════════════════════════════════════════════════════════════════════╗
β•‘                 BLDC TEST SECTION CONFIGURATION                                β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

I (1234) BLDC_Test: Running core BLDC functionality tests...
I (5678) BLDC_Test: βœ… SPI bootloader initialization successful with EVKIT config
...

Test Progression Indicator

The test suite uses GPIO14 as a visual test progression indicator:

  • LOW β†’ HIGH β†’ LOW: Each transition indicates a completed test
  • Monitor GPIO14 with an oscilloscope or logic analyzer for visual feedback

Available Scripts

Script Purpose Usage
build_app.sh Build specific application ./scripts/build_app.sh <app> <build_type>
flash_app.sh Flash and monitor application ./scripts/flash_app.sh <app> <build_type> [port]
monitor_app.sh Monitor serial output ./scripts/monitor_app.sh [port]
setup_repo.sh Initial repository setup ./scripts/setup_repo.sh
clean_app.sh Clean build artifacts ./scripts/clean_app.sh <app> <build_type>

Advanced Build Options

For advanced configuration, you can use ESP-IDF’s menuconfig:

1
2
# Configure build options
./scripts/config_app.sh <app_type> <build_type>

This opens the ESP-IDF menuconfig where you can customize:

  • Component config β†’ TMC9660 Driver: Driver configuration options
  • Serial flasher config: Serial port and flash settings
  • Compiler options: Optimization and debug settings

πŸ“Š Test Suites

BLDC Comprehensive Test (BLDCComprehensiveTest.cpp)

Tests for 3-phase BLDC motor control:

  • βœ… Bootloader initialization and configuration
  • βœ… Motor type configuration (BLDC with various pole pairs)
  • βœ… Hall sensor configuration and testing
  • βœ… ABN encoder configuration and testing
  • βœ… FOC control loop configuration
  • βœ… Velocity and current control
  • βœ… Commutation modes (FOC_HALL, FOC_ABN, FOC_OPENLOOP)
  • βœ… Telemetry monitoring
  • βœ… Performance benchmarking
  • βœ… Error handling and edge cases

Board: TMC9660-3PH-EVKIT

Stepper Comprehensive Test (StepperComprehensiveTest.cpp)

Tests for stepper motor control:

  • βœ… Bootloader initialization and configuration
  • βœ… Motor type configuration (Stepper)
  • βœ… Reference switch configuration (Left, Right, Home)
  • βœ… ABN encoder configuration
  • βœ… FOC position control
  • βœ… Step/Direction control
  • βœ… Microstepping configuration
  • βœ… Position and velocity control
  • βœ… Stall detection
  • βœ… Telemetry monitoring

Board: TMC9660-STP-EVKIT

DC Motor Comprehensive Test (DCComprehensiveTest.cpp)

Tests for DC motor control:

  • βœ… Bootloader initialization and configuration
  • βœ… Motor type configuration (DC motor)
  • βœ… Current control and torque limiting
  • βœ… Velocity control with encoder feedback
  • βœ… Open-loop current mode
  • βœ… H-bridge control
  • βœ… Protection features
  • βœ… Telemetry monitoring

Board: TMC9660-3PH-EVKIT (same board as BLDC)

Telemetry Comprehensive Test (TelemetryComprehensiveTest.cpp)

Tests for telemetry and monitoring:

  • βœ… Temperature monitoring
  • βœ… Current monitoring
  • βœ… Voltage monitoring
  • βœ… Position and velocity feedback
  • βœ… System status reporting
  • βœ… Performance benchmarking
  • βœ… Multi-device monitoring

Board: TMC9660-3PH-EVKIT

Bootloader Comprehensive Test (BootloaderComprehensiveTest.cpp)

Tests for bootloader functionality:

  • βœ… Bootloader initialization
  • βœ… Mode detection (bootloader vs parameter)
  • βœ… Configuration reading and writing
  • βœ… Flash memory operations
  • βœ… Reset and recovery procedures

Board: TMC9660-3PH-EVKIT or TMC9660-STP-EVKIT


βš™οΈ Test Configuration

Each test suite supports enabling/disabling specific test categories via compile-time flags at the top of each test file:

1
2
3
4
5
// Enable/disable specific test categories
static constexpr bool ENABLE_CORE_TESTS = true;
static constexpr bool ENABLE_HALL_SENSOR_TESTS = true;
static constexpr bool ENABLE_ABN_ENCODER_TESTS = true;
// ... etc

Edit these flags to customize which tests run.


πŸ”§ Troubleshooting

Common Issues

1. Communication Timeout

Symptoms: Tests fail with communication timeout errors

Solutions:

  • Verify all SPI/UART connections are secure
  • Check that GPIO pins match the configuration
  • Ensure proper ground connection between boards
  • Check power supply voltage (TMC9660 may need 12V-48V)

2. Bootloader Not Detected

Symptoms: Tests fail at bootloader initialization

Solutions:

  • Verify RST pin is properly connected (GPIO22)
  • Check that FAULTN pin is connected (GPIO19)
  • Try power cycling both boards
  • Verify SPI communication with a logic analyzer

3. Motor Not Starting

Symptoms: Motor configuration succeeds but motor doesn’t run

Solutions:

  • Verify DRV_EN pin is set (GPIO20)
  • Check motor connections (U, V, W for BLDC)
  • Verify current limits are set appropriately
  • Check that PWM frequency is configured before setting current limits
  • Ensure motor feedback (Hall/encoder) is properly connected if using closed-loop control

4. FAULTN Asserted

Symptoms: FAULTN pin is low (fault condition)

Solutions:

  • Check TMC9660 datasheet for fault conditions
  • Verify power supply voltage is within range
  • Check for overcurrent conditions
  • Verify motor connections are correct
  • Check temperature (overtemperature protection)

5. Build Errors

Symptoms: ./scripts/build_app.sh fails

Solutions:

  • Verify ESP-IDF is properly installed and sourced: . $IDF_PATH/export.sh
  • Check that all submodules are initialized: git submodule update --init --recursive
  • Verify script is executable: chmod +x scripts/build_app.sh
  • Clean build: ./scripts/clean_app.sh <app_type> <build_type> then rebuild
  • Verify CMake and Python versions meet requirements
  • Check that app name is valid: ./scripts/build_app.sh list

6. Script Not Found

Symptoms: ./scripts/build_app.sh: No such file or directory

Solutions:

  • Ensure you’re in the examples/esp32 directory
  • Verify scripts exist: ls scripts/
  • Make scripts executable: chmod +x scripts/*.sh
  • Run setup script: ./scripts/setup_repo.sh

Debugging Tips

  1. Enable Debug Logging: The test suites enable DEBUG logging by default. Monitor serial output for detailed communication traces.

  2. Use GPIO14 Indicator: Monitor GPIO14 with an oscilloscope to see test progression visually.

  3. Logic Analyzer: Use a logic analyzer to monitor SPI/UART communication for detailed protocol analysis.

  4. Oscilloscope: Monitor control pins (RST, DRV_EN, FAULTN, WAKE) to verify timing and states.


πŸ“Έ Hardware Setup Photos

Add photos of your actual hardware setup here:

  • ESP32-C6 DevKit connected to TMC9660-3PH-EVKIT
  • ESP32-C6 DevKit connected to TMC9660-STP-EVKIT
  • Motor connections
  • Overall test setup

πŸ“š Additional Resources


πŸ“ License

Copyright (c) 2025 HardFOC. All rights reserved.


πŸ‘₯ Contributing

Contributions are welcome! Please see the main repository’s CONTRIBUTING.md for guidelines.


Happy Testing! πŸš€