Theta (Sawtooth) generator
This file calculates a theta-angle-signal based on the given frequency-information:
This file calculates a theta-angle-signal based on the given frequency-information:
FPGAs are very useful when calculating plus or minus or dealing with large logic-vectors. Even multiplication is fine. But when it comes to dividing signals, FPGAs need support. Lothar Miller has a nice implemenation of a Radix-2-procedure to calculate the division of two fixed-point-numbers:
To convert a 6-phase signal into a 90° system, the following logic can be helpful:
I had a special BLDC motor with 6 phases. To control the motor with a field-orientet control (FOC) I had to implement a 6-phase conversion from a 90° alpha/beta system into a 6-phase system. This is the logic for this:
To convert a 90° system (alpha/beta) into a dq-system, the Park-Transformation is performed. The following logic can be used for Q15.16 fixed-point-signals:
For both microcontrollers and FPGAs its quite challenging to calculate sine- and cosine-values with good enough precision to calculate different things with higher accuracy. Mitu Raj and Roshan Raju implemented a nice Mini-Cordic-IP-Core that does exactly this: calculate sin/cos as fixed-point values that can be used within an FPGA.
The following logic performs an inverse park transformation and converts dq-components into alpha-beta-components. It uses the cordic implementation of Mitu Raj that supports angles between -360° and 360°. The implementation can be found in another snippet on this website.
The following logic contains a standard PI-controller
This logic allows to inject a deadtime to an input-signal. The deadtime can be set in clocks, so the absolute deadtime is depending on the used clock:
Disturbances in measured signals for voltage or current are a bit annoying. This file contains a Second Order Generalized Integrator to filter a sine-wave at the input to a disturbance-free output. As replacement for the regular integrator it uses a special third order integrator implementation suggested by Theodorescu et. al. It reduces the ripple on…