mc_interface) that works across all of them. You select the motor type and control mode through the configuration, and issue commands through the same set of functions regardless of the underlying algorithm.
Motor types
FOC
Field Oriented Control. Sinusoidal current control with smooth torque and high efficiency. Supports sensorless, Hall sensor, encoder, and HFI feedback.
BLDC
Trapezoidal commutation for brushless DC motors. Lower computational overhead than FOC. Supports sensorless, sensored, and hybrid modes.
DC
Brushed DC motor support. Uses a fixed switching frequency defined by
MCCONF_M_DC_F_SW (default: 25000 Hz).mc_motor_type enum defined in datatypes.h:
MOTOR_TYPE_FOC (MCCONF_DEFAULT_MOTOR_TYPE).
Motor state
At any point the motor controller is in one of four states, reported bymc_interface_get_state():
Control modes
The active control mode is reported bymc_interface_get_control_mode() and set implicitly by the command you issue:
Sensor modes
For BLDC mode, the sensor mode is set viamc_sensor_mode:
- Sensorless (
SENSOR_MODE_SENSORLESS) — BEMF zero-crossing detection. No position sensor required. Default mode. - Sensored (
SENSOR_MODE_SENSORED) — Hall sensors provide commutation timing at all speeds. - Hybrid (
SENSOR_MODE_HYBRID) — Hall sensors are used at low speeds; sensorless commutation takes over aboveMCCONF_HALL_ERPM(default: 2000 ERPM).
mc_foc_sensor_mode. See FOC for details.
The mc_interface API
All motor control commands go throughmc_interface. This layer handles safety limits, fault detection, and dispatches to the underlying BLDC or FOC implementation.
Configuration
Motor commands
Telemetry
Fault handling
When a fault occurs, the controller ignores new commands for
MCCONF_M_FAULT_STOP_TIME milliseconds (default: 500 ms) before resuming normal operation.Statistics
Multi-motor support
VESC hardware with dual motor support usesmc_interface_select_motor_thread() to select which motor the current thread controls:
Next steps
FOC
Sensor modes, HFI, field weakening, and FOC-specific configuration.
BLDC
PWM modes, commutation modes, and BLDC-specific parameters.
Configuration
Full reference of current, voltage, temperature, and speed limits.
