Visible to Intel only — GUID: hco1423076597844
Ixiasoft
Visible to Intel only — GUID: hco1423076597844
Ixiasoft
6.6.1. Position, Speed, and Current Control for AC Motors
The model file is psc_ctrl.mdl. Also, an equivalent fixed-point design, psc_ctrl_fixed.mdl, exists. To change the precision this design uses, refer to the setup_position_speed_current_controller_fixed.m script.
Functional Description
An encoder measures the rotor position in the motor, which the FPGA then reads. An analog-to-digital converter (ADC) measures current feedback, which the FPGA then reads.
Each of the FOC, speed, and position feedback loops use a simple PI controller to reduce the steady state error to zero. In a real-world PI controller, you may also need to consider integrator windup and tune the PI gains appropriately. The feedback loops for the integral portion of the PI controllers are internal to the design.
The example assumes you sample the inputs at a rate of 100 kHz and the FPGA clock rate is 100 MHz (suitable for Cyclone IV devices). ALU folding reduces the resource usage by sharing operators such as adders, multipliers, cosine. The folding factor is set to 100 to allow each operator to be timeshared up 100 times, which gives an input sample rate of 1 Msps, but as the real input sample rate is 100 ksps, only one out of every ten input timeslots are used. DSP Builder identifies the used timeslots when valid_in is 1. Use valid_in to enable the latcher in the PI controller, which stores data for use in the next valid timeslot. The valid_out signal indicates when the ChannelOut block has valid output data. You can calculate nine additional channels on the samedesign without incurring extra latency (or extra FPGA resources).
You should adjust the folding factor to see the effect it has on hardware resources and latency. To adjust, change the Sample rate (MHz) parameter in the ChannelIn and ChannelOut blocks of the design either directly or change the FoldingFactor parameter in the setup script. For example, a clock frequency of 100 MHz and sample rate of 10 MHz gives a folding factor of 10. Disabling folding, or setting the factor to 1, results in no resource sharing and minimal latency. Generally, you should not set the folding factor greater than the number of shareable operators, that is, for 24 adders and 50 multipliers, use a maximum folding factor 50.
The control algorithm, with the FOC, position, speed, control loops, vary the desired position across time. The three control loops are parameterized with minimum and maximum limits, and Pl values. These values are not optimized and are for demonstrations only.
Resource Usage
Folding Factor | Add and Sub Blocks | Mult Blocks | Cos Blocks | Latency |
---|---|---|---|---|
No folding | 22 | 22 | 4 | 170 |
>22 | 1 | 1 | 1 | 279 |
The example uses floating-point arithmetic that automatically avoids arithmetic overflow, but you can implement it in a fixed-point design and tune individual accuracies while manually avoiding overflows.