FPGA-Based Motor Controller Design

Motor control systems demand increasingly high standards for real-time performance, control precision, multi-axis coordination, and operational reliability.

While traditional MCU and DSP-based solutions offer advantages such as lower costs and shorter development cycles, they may encounter processing latency and resource contention when handling high-speed sampling, complex PWM timing, or multi-axis synchronous control.

FPGAs, through parallel logic, hardware state machines, and high-speed interfaces, enable deterministic real-time control.

An FPGA-based motor controller requires the integrated design of power drive circuitry, signal acquisition, control algorithms, protection logic, and communication interfaces—ensuring an optimal balance between control cycle timing, sampling precision, hardware resource utilization, and system safety.

FPGA-based Motor Controller Design

I. Overall System Architecture Design

1.1 Core Hardware Components

A typical FPGA-based motor controller consists of the following modules:

FPGA Main Control Module: Implements current, speed, and position loops, PWM generation, encoder interfacing, and fault management.

Power Drive Module: Includes gate drivers, MOSFET or IGBT power bridges, as well as necessary isolation and drive power supplies.

Signal Acquisition Module: Captures signals such as phase currents, DC-bus voltage, temperature, and position feedback.

Position Detection Module: Interfaces with incremental encoders, absolute encoders, resolvers, or Hall-effect sensors.

Communication Interface Module: Configured according to application requirements, supporting protocols such as CAN, CAN FD, Ethernet, RS-485, or EtherCAT.

Auxiliary Control Module: May utilize an MCU or a soft-core processor to handle parameter configuration, diagnostics, communication protocols, and non-real-time tasks.

For systems with strict control cycle requirements and high safety/protection demands, critical control paths and hardware protection logic should be implemented directly within the FPGA’s deterministic logic, rather than relying solely on an operating system or interrupt-based scheduling.

1.2 FPGA, MCU, and DSP Collaborative Architectures

In engineering practice, three primary architectural approaches are commonly used:

Pure FPGA Architecture: Control algorithms, sampling synchronization, PWM generation, and protection logic are all implemented within the FPGA. This approach is well-suited for equipment requiring high real-time performance and precise synchronization, though it demands strong expertise in fixed-point algorithm design and hardware verification.

FPGA + MCU Architecture: The FPGA handles high-speed closed-loop control and hardware-level protection, while the MCU manages parameters, communication with the host system, operating mode switching, and fault logging. This architecture strikes a balance between real-time performance and development efficiency.

FPGA + DSP Architecture: The FPGA manages high-speed interfaces, sampling synchronization, multi-axis PWM, and parallel pre-processing, while the DSP executes complex control algorithms.

This is well-suited for systems that require both sophisticated control algorithms and deterministic hardware timing.
For medium-to-high-performance servo drives, a collaborative FPGA-processor architecture typically makes it easier to achieve an optimal balance between development efficiency, system complexity, and control performance.

FPGA Motor Controller PCB Assembly

II. Motor Types and Control Strategy Selection

While the hardware structure of an FPGA offers high versatility, the specific control algorithm must be determined based on the motor type, load characteristics, and performance objectives.

2.1 Permanent Magnet Synchronous Motor (PMSM) Control

Permanent Magnet Synchronous Motors (PMSMs) are widely used in servo systems, robotic joints, and high-performance drive equipment. Common control methods include Field-Oriented Control (FOC) and Direct Torque Control (DTC).

FOC employs coordinate transformations to map three-phase currents into a rotating reference frame, allowing for the independent regulation of flux and torque components.

When using surface-mounted or interior-mounted PMSMs, the specific current control strategy must account for motor parameters, reluctance torque, and requirements for field-weakening operation.
In an FPGA, an FOC implementation typically includes:

Three-phase current sampling, along with zero-point and gain calibration.

Clarke and Park transformations.

PI regulation of d-axis and q-axis currents.

Inverse transformations and voltage vector calculation.

SVPWM modulation and PWM output updates.

These modules can be implemented using pipelining and parallel processing structures to reduce combinational delay along critical paths. However, parallelization does not negate the dependencies between control data; it is essential to clearly define the sampling instant and the PWM update cycle corresponding to each stage of the computation.

2.2 Brushless DC Motor (BLDC) Control

Brushless DC Motors (BLDCs) typically utilize six-step commutation, with commutation timing determined based on Hall-effect sensor signals or back-electromotive force (back-EMF) information. FPGAs can implement commutation control through hardware counters, edge detection, and state machines, while utilizing independent PWM channels to control the bridge arms for each phase.

Compared to software-based polling, a hardware state machine reduces uncertainty in commutation timing.
It should be noted that Hall sensor signals are subject to installation errors and edge jitter, while back-EMF detection can be affected by PWM switching noise. Therefore, filtering, commutation blanking times, and anomaly detection logic must be configured based on the motor’s operating speed range.

2.3 Induction Motor Control

Induction motors can be controlled using strategies such as V/f control or vector control. For applications requiring high dynamic performance, vector control typically necessitates more complex coordinate transformations, flux linkage estimation, and parameter compensation.

While an FPGA can accelerate coordinate transformations, multiply-accumulate operations, and observer calculations, control performance remains dependent on factors such as motor parameter identification, the accuracy of flux linkage estimation, and the quality of sampled data. It cannot be assumed that an FPGA’s parallel processing capability alone will automatically yield higher control precision.

III. Design of Core FPGA Logic Modules

3.1 PWM Generation and Dead-Time Control

The PWM module is a core hardware component of a motor controller, responsible for converting the voltage commands generated by the control algorithm into switching sequences for the power devices.
Key design considerations include:

Counting and Comparison Logic: Implementing center-aligned or edge-aligned counting schemes to generate PWM signals in accordance with the chosen modulation strategy.

Complementary Outputs: Generating complementary control signals for the high-side and low-side switches of a half-bridge.

Dead-Time Insertion: Preventing simultaneous conduction of the high-side and low-side power devices to mitigate the risk of a “shoot-through” (bridge-arm short circuit).

Synchronous Updating: Updating comparison values ​​simultaneously at predetermined count boundaries to prevent pulse anomalies that could arise from mid-cycle modifications.

Fault Shutdown: Disabling the relevant PWM outputs immediately in the event of an overcurrent condition or a drive-side fault.

Dead-time values ​​should not be based solely on generic empirical figures; rather, they must be determined by considering the switching delays of the power devices, the propagation delays of the gate drivers, turn-off characteristics, and empirical test results. An excessively short dead-time may lead to a shoot-through, while an excessively long dead-time can introduce voltage errors, current distortion at low speeds, and torque ripple.

3.2 Current and Voltage Sampling Interfaces

Motor current is typically acquired using shunt resistors, Hall-effect current sensors, or magnetically isolated sensors. The analog signals are amplified, filtered, and converted via an ADC before being fed into the FPGA for closed-loop control.

The design of the sampling system must address three key issues.
First is the sampling instant. Current sampling should be synchronized with the PWM cycle, avoiding switching transients and significant current spikes whenever possible. For single- or dual-resistor sampling schemes, the sampling window must also be validated based on the duration of the active voltage vectors.
Second is interface timing. When using an external ADC, the timing for conversion initiation, data validity, serial clocking, and data retrieval must be precisely defined to prevent data misalignment.

For ADCs with multiple synchronous sampling channels, it is essential to ensure that critical phase currents are captured simultaneously—or that appropriate time compensation is applied—before they enter the control algorithm.

Finally, there is data calibration. ADC quantization errors, analog front-end offsets, gain errors, and temperature drift can all affect the performance of the current loop. The system should perform zero-point calibration under safe operating conditions and include plausibility checks for anomalous sampled values.

3.3 Encoder and Position Feedback Module

Incremental encoders typically use A and B phase signals to determine direction and count, with the Z phase serving as a zero-position reference. The FPGA can utilize quadrature decoding logic and high-speed counters to calculate position, preventing high-frequency pulses from overwhelming software interrupts.
For absolute encoders, position data can be read via interfaces such as SPI, BiSS, or other supported protocols. The design must verify protocol timing, data frame integrity, checksums, and timeout handling.
The position feedback module should also account for input synchronization, glitch filtering, counter overflow, direction reversal, and detection of signal-line disconnections. Filtering parameters should not be set too high, as this could lead to pulse loss or position latency at high rotational speeds.

3.4 Hardware Implementation of Control Algorithms

Deploying control algorithms on an FPGA primarily involves transforming floating-point computations into hardware data paths with manageable resource usage and quantifiable error margins.

Common techniques include fixed-point arithmetic, pipelining, reuse of multiply-accumulate (MAC) units, and optimization via look-up tables (LUTs). Fixed-point implementation requires careful planning of the bit widths for integer parts, fractional parts, and intermediate results to prevent overflow and the accumulation of truncation errors.

For instance, a current PI controller must account for—beyond proportional and integral operations—integral saturation, output limiting, and the handling of the integral term during abnormal operating conditions. In coordinate transformation modules, it is essential to ensure that the angle data format, the precision of sine and cosine calculations, and the definition of phase are all mutually consistent.
In an FPGA-based system, the critical factor is not merely the correctness of the computational results, but also the ability to generate these results reliably within the specified control cycle.

FPGA Motor Controller PCB Assembly Factory in China

IV. FOC Control Workflow and Real-Time Scheduling

4.1 Control Cycle Design

A typical FOC system employs a hierarchical control structure consisting of a current loop, a speed loop, and a position loop.
The current loop directly regulates the currents associated with the motor’s electromagnetic torque and typically operates at the highest frequency. The speed loop generates torque or current commands based on speed error, while the position loop generates speed commands based on position error.
The update frequency for each loop should be determined by considering the motor’s electrical time constant, mechanical inertia, PWM frequency, and computational latency, rather than simply aiming for the highest possible frequency.

4.2 Hardware Data Path

The typical execution sequence is as follows:

The PWM counter enters a predetermined sampling window.

The ADC completes phase current sampling and outputs valid data.

The FPGA performs current offset correction and coordinate transformation.

The current regulator calculates the d-axis and q-axis voltage commands.

The modulation module calculates new PWM comparison values.

The new comparison values ​​are loaded at the designated update boundary.

The speed and position loops update their respective control commands according to their own cycles.

In practical design, sampling and computation can be partially parallelized; however, it is essential to clearly define data validity flags, computation completion signals, and PWM update boundaries. If a calculation result misses its update window, it may introduce an additional PWM-cycle delay, even if the algorithm itself is correct.

4.3 End-to-End Latency Analysis

Control latency arises not only from internal FPGA computations but also from sensor response, analog filtering, ADC conversion, data transmission, and the wait time for PWM updates to take effect.
Therefore, a comprehensive latency budget should be established, with the time overhead of each module measured or calculated individually. For high-speed servo systems and low-inductance motors, latency can directly affect the stability margin of the current loop and must be evaluated during the initial stages of controller design.
In multi-axis systems, it is also necessary to ensure a predictable phase relationship between the sampling, computation, and PWM updates of each axis to minimize inter-axis synchronization errors.

4.4 Fixed-Point Arithmetic and Numerical Precision

FPGA designs often utilize fixed-point arithmetic to reduce the consumption of DSP multipliers and logic resources. In engineering implementation, the signal range should be determined first, followed by the definition of the appropriate bit-width for data at each stage. Key areas requiring careful inspection include:

Overflow Protection: Implement appropriate limits for current commands, integrator states, and voltage outputs.

Rounding Strategy: Avoid cumulative control bias resulting from successive truncation.

Angular Accuracy: Ensure that the calculation of electrical angle is sufficiently precise to meet the requirements of high-speed operation.

Resource Utilization: Determine whether to use multiplexed multipliers or parallel computation based on timing constraints.

Fixed-point algorithms must be verified against a floating-point reference model, with a focus on operating conditions such as nominal operation, low-speed, high-current, rapid speed transitions, and voltage saturation.

V. Hardware Protection and Reliability Design

Beyond control precision, a motor controller must possess independent and reliable fault-handling capabilities.

5.1 Overcurrent and Short-Circuit Protection

Overcurrent protection should employ a combination of rapid hardware-based protection and digital control-based protection.
In the event of severe overcurrent or a potential bridge-arm short circuit, PWM hardware shutdown should be triggered directly—via current comparators, fault outputs from gate drivers, or dedicated protection circuitry—rather than waiting for the FPGA to complete sampling, logic evaluation, and state switching.
Simultaneously, the FPGA should record the source of the fault, latch the fault status, inhibit subsequent restarts, and execute a reset procedure based on predefined conditions. Protection thresholds and shutdown response times must be validated through actual hardware testing.

5.2 Overvoltage, Undervoltage, and Overtemperature Protection

Excessive DC-bus voltage can expose power devices to overvoltage stress; therefore, an overvoltage detection system and corresponding mitigation mechanisms must be implemented. Undervoltage can lead to erratic driver behavior or degraded control performance, necessitating a clear shutdown strategy.
Temperature protection should integrate data from power devices, heatsinks, and the motor itself to implement tiered power limiting, warnings, and system shutdowns.
Protection design should not rely solely on software-based threshold checks. For faults that could cause rapid hardware damage, a fast-shutdown path—independent of the main control flow—should be utilized whenever possible.

5.3 Fault State Machine

It is recommended to organize the controller’s operational states into categories such as Initialization, Self-Test, Standby, Enabled, Running, Deceleration/Shutdown, and Fault-Locked.
For each state, the entry conditions, permitted operations, and exit conditions must be clearly defined. For example, in the event of an encoder communication failure, the system must not continue to rely on invalid position feedback to maintain closed-loop control.

Furthermore, following a fault reset, power output should not be restored without first verifying that safe operating conditions are met.
For loads that generate regenerative energy, it is also necessary to evaluate risks associated with braking resistors, DC-bus voltage surges, and mechanical inertia to prevent new system issues that could arise from simply disabling the PWM signals.

VI. PCB Design and Electromagnetic Compatibility (EMC)

The performance of an FPGA-based motor controller is determined not only by its logic design but also by its PCB layout, power circuitry, and analog front-end.

6.1 Partitioning of Power and Control Circuits

The PCB should be logically partitioned into sections for power switching, analog sampling, FPGA digital logic, and communication interfaces. Within the power circuitry, the area of ​​high-frequency switching current loops must be minimized to reduce parasitic inductance and switching spikes.
Analog sampling traces should be kept away from high dv/dt switching nodes and high-current loops. Differential routing for current sensing, the connection methods for sense resistors, and the layout of analog reference grounds must all be optimized based on the specific circuit implementation.

6.2 Power and Signal Integrity

Because FPGA internal logic switches at high frequencies, multiple power rails—each with distinct voltage, ripple, and power-up sequencing requirements—are typically involved. Designs must adhere to device datasheets regarding power supply configuration, decoupling capacitors, and power-on reset circuitry.
For high-speed ADCs, encoders, and communication interfaces, careful attention must be paid to clock quality, trace impedance, signal return paths, and interface protection.

In industrial environments, factors such as motor cabling, grounding schemes, shield terminations, and common-mode interference can all affect system stability. EMC testing should be conducted based on actual cable lengths, drive power levels, and installation environments, rather than relying solely on the addition of filter components to the control board.

VII. FPGA Device Selection and Development Process

7.1 Key Considerations for Device Selection

When selecting an FPGA, one must comprehensively evaluate factors such as logic resources, the number of DSP multipliers, on-chip memory, I/O count, clock resources, transceiver capabilities, and industrial-grade temperature ratings.

For a single-axis BLDC controller, a small-to-medium-scale FPGA may suffice; however, for multi-axis PMSM servo systems, complex observers, or high-speed industrial communication systems, a more thorough evaluation of parallel computing resources and interface bandwidth is required.

Furthermore, factors such as the maturity of development tools, availability of IP cores, device lead times, power consumption, and cost must be considered. Selecting a device based solely on the number of logic units is insufficient.

7.2 Recommended Development Workflow

Phase 1: System Requirements Analysis. Define the motor type, rated power, DC-bus voltage, maximum rotational speed, control precision, sampling scheme, and protection requirements.
Phase 2: Algorithm Modeling. Use MATLAB/Simulink or other simulation tools to verify control strategies and establish a floating-point reference model.
Phase 3: RTL Development. Implement modules such as PWM, sampling interfaces, coordinate transformations, controllers, and fault management using Verilog or VHDL.
Phase 4: Simulation and Timing Verification. Verify boundary conditions, anomalous inputs, reset behavior, module handshaking, and timing constraints; assess critical paths and resource utilization.
Phase 5: Hardware Integration and Debugging. Begin with low-voltage, current-limited, and no-load conditions to incrementally verify sampling, PWM, rotation direction, closed-loop stability, and protection functions.
Phase 6: System Validation. Conduct tests including load steps, speed variations, temperature rise, long-duration operation, communication fault scenarios, and EMC testing; maintain traceable test records.

VIII. Key Challenges in Engineering Practice

In practical projects, the following issues warrant particular attention:
First, a lack of synchronization between sampling and PWM. This can introduce current measurement errors and compromise the stability of the current loop. A unified hardware time base should be employed to manage both sampling and modulation updates.

Second, discrepancies between fixed-point algorithms and the reference model. Through module-by-module comparison, boundary testing, and error analysis, identify issues such as overflows, truncation errors, and phase shifts.

Third, insufficient response speed of hardware protection. Critical faults should not rely solely on control algorithm cycles; an independent hardware-based shutdown path must be established.

Fourth, mismatches between actual motor parameters and the model. Variations in resistance, inductance, back-EMF constants, and mechanical inertia can all adversely affect control performance. Parameter identification and controller tuning should be performed when necessary.

Fifth, if the system remains unstable despite successful logic simulation, further investigation is required—covering factors such as sampling noise, grounding, drive latency, dead time, sensor installation errors, and mechanical resonance—rather than attempting to resolve the issue solely through FPGA code modifications.

IX. Conclusion

Designing an FPGA-based motor controller is, at its core, an exercise in collaborative engineering that integrates real-time control algorithms, digital hardware architecture, power electronics, electrical measurement, and system reliability.

The primary advantages of FPGAs—parallel processing, deterministic timing, high-speed interfacing, and flexible hardware customization—make them particularly well-suited for multi-axis synchronization, high-speed current control, and complex drive systems. However, an FPGA is no substitute for sound control theory, accurate current sampling, robust power-stage design, and rigorous safety verification.

For engineering R&D teams, the recommended approach is to first establish stable sampling and PWM timing, followed by the incremental implementation of current, velocity, and position loops. Concurrently, teams should refine fault protection mechanisms, conduct fixed-point precision analysis, and develop a comprehensive hardware testing framework.

Only by holistically addressing algorithmic performance, real-time requirements, hardware safety, and manufacturability can one successfully develop an FPGA-based controller suitable for industrial servo systems, robotics, and high-performance motor drive applications.

Share your love