{'fraction_non_alphanumeric': 0.034657772621809746, 'fraction_numerical': 0.0166038283062645, 'mean_word_length': 4.597808441558442, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Hardware in the Loop Real-time Simulation of Doubly Fed Off-grid Wind Power System

Hardware in the Loop (HIL) semi-physical real-time simulation can shorten the research period and complete the harsh working condition test, which is difficult to be carried out on the physical platform. Taking the off-grid Doubly Fed Induction Generator (DFIG) wind power system as the research object, this paper proposes the bottom modelling method of HIL real-time simulation. Using the Hardware Description Language VERILOG, the bottom real-time models of DFIG, converter and load are designed on Field Programmable Gate Array (FPGA), connected with the real controller, and the HIL real-time simulation platform is constructed. The experiments of conventional working conditions and unbalance load are carried out on the HIL platform and the physical platform. The operation speed of the HIL platform reaches 0.48μs. Compared with the physical platform, the error of HIL platform is between 1.17 ~ 3.29% under various working conditions.


Introduction
The off-grid wind power generation system using Doubly Fed Induction Generator (DFIG) can realize local energy consumption and storage [1] , which can be applied in the fields of distributed power generation, micro grid and energy storage system, and help to solve the power consumption problem in remote areas [2] . Due to direct load, it needs to face complex power load, and unbalanced condition is a common power quality problem in low voltage distribution.
Different from pure mathematical simulation, Hardware-in-the-Loop (HIL) real-time simulation retains part of the real object, which is composed of real controller and virtual-motor. The virtualmotor is a high speed circuit board, and the real-time model of motor and converter is embedded in the core chip to simulate the real motor to provide continuous feedback signal to the real controller. HIL real-time simulation can accelerate the research and development progress, and can also simulate fault conditions without risk in high power fields such as wind power generation [3] .
Since the 1950s, HIL was first used in aerospace and military industries, and gradually extended to automobile, power system and other occasions [4] . The real-time simulation speed is generally millisecond. At the beginning of this century, it has been applied to motor [5] and power converter [6] , and the model speed has reached tens or even a few microseconds.
At present, the HIL technology in wind power has the following characteristics: 1) it focuses on the test of algorithm and controller hardware, 2) under abnormal working conditions, it mostly focuses on the control compensation method of Low Voltage Ride Through (LVRT), 3) the bottom motor modeling does not touch much, and tends to adopt the packaging model in mature real-time simulation tools. In [7], it proposes a control method within the framework of direct model prediction, which is used to deal with the LVRT of permanent magnet wind turbine system with back-to-back power converter. The effectiveness of the scheme is verified on the HIL platform based on Field Programmable Gate Array (FPGA). The HIL platform of DFIG wind power system constructed includes power grid, fan, motor and converter to verify the LVRT control method [8] . In [9], it established the dynamic model of wind farm based on RT-LAB, and simulated the grid connection and disconnection by using MPPT to control the power generation or according to the dispatching instruction. A rotor position estimation method is proposed in [10], and the effectiveness of the algorithm is verified on the real-time simulation platform composed of OPAL-RT and STM32F407 microcontroller. For the direct drive permanent magnet wind power generation system, in [11], it proposes a grid connected power system simulation architecture, which combines the additional control devices in RTDS and Lab-VIEW, and realizes the HIL real-time simulation of the control method.
For off-grid wind power system, this paper proposes the method of programming and constructing the bottom real-time model on FPGA, including DFIG, rotor side converter and resistive load. Compared with the physical platform, the accuracy and speed of HIL platform are tested. On this basis, the unbalance load experiments are also carried out.

Overall principles
The DFIG, rotor side converter and load real time model are designed in FPGA with VERILOG (Fig1). The HIL semi-physical real-time platform is composed of FPGA board and real controller. "Semiphysical" means that the controller is real and the DFIG, converter and load are virtual. In the physical platform, the final signals transmitted from the motor to the controller are signals, so as long as the virtual-machine transmits the same signal to the controller, the virtual-machine is equivalent to the real motor for the controller.

Figure1. HIL real time module for DFIG off-grid wind power
The key of HIL technology lies in the operation speed and accuracy of real-time module, which are a pair of contradictions under the premise of limited FPGA resources. Therefore, two measures are taken: 1) using fixed-point-number to save chip resources and improve operation speed; 2) FPGA is selected as the core chip, which has the advantage of parallel computing. All modules operate at the synchronous clock with frequency of 50MHz, and the operation speed is not affected by the scale of the model [12] . The selected FPGA is EP3C120F780, which possess the most abundant resources in cyclone III series of ALTERA Company.

Discrete mathematical per-unit model
The mathematical discrete model is a necessary condition for fixed-point-number operation. The perunit equation of DFIG and converter will bring three benefits: (1) The model is universal and can be used for motors with various rated-power, (2) It is easier to compromise the contradiction between accuracy and operation speed; (3) It is convenient for fixed-point-number calibration. Three quantities are selected as the basic base values: dc link voltage, maximum current and rated rotation speed, and other per-unit values are derived from these three basic base values. The voltage base value is 500V, the current base value is 100A, and the speed base value is 1500rpm.
The Forward Euler method is used to discrete the DFIG mathematical model based on stator voltage orientation. The per-unit discrete iterative equation of flux linkage is: In eq.1, T is real-time simulation period (1μs), c 1 = −c 6 =T, c 2 =−TR s , c 3 = −c 4 =ω 1 T, c 5 =−TR r , ψ sd and ψ sq are stator flux linkage，ψ rd and ψ rq are rotor flux linkage；ω 1 is synchronous angular velocity，ω r is rotor angular velocity；R s and R r are resistance of stator and rotor.
The per-unit discrete iteration equation of stator and rotor current is: In eq.3, c 10 =T/2π.

Real-time module of DFIG
The top-down design scheme is selected and DFIG module is divided into different parts firstly, then the bottom design is carried out for each part. The parts included in the DFIG module are: coordinate transformation and its inverse transformation, current calculation, angle calculation, position calculation and flux calculation .  Figure 2. Packaging circuit for DFIG The frequency of synchronous clock is 50MHz, which is provided by Phase Locked Loop. The Hardware Description Language VERILOG is used for programming using QUARTUSII IDE software, combined with the IP-core to generate VERILOG code of each part, and finally encapsulated uniformly (Fig 2). Input signals include synchronous clock, stator voltages u sa 、 u sb 、 u sc , rotor voltages u ra 、u rb and u rc , synchronous rotation angular speed ω 1 , rotor rotation angular speed ω r and reset signal. Output signals include stator currents i sa 、i sb 、i sc and rotor current i ra 、i rb 、i rc , which are used for subsequent calculation of motion equations.

Real-time module of rotor side converter
The reference voltage ground is the negative pole of the dc link voltage. The positive direction of rotor current i ra 、i rb and i rc flows into the motor. According to the PWM signals input by the real controller, the star midpoint voltage are calculated firstly, then calculate the bridge-arm midpoint voltages u rao 、 u rbo 、u rco and three phase voltages u ra 、u rb 、u rc , finally transmit the phase voltage results to the DFIG model.
Each bridge arm of converter model contains four states: 1)10 (upper IGBT turn-on and lower IGBT turn-off), 2)01 (upper IGBT turn-off and lower IGBT turn-on), 3)00 (upper and lower IGBT turn-off), 4)11 (upper and lower IGBT turn-on). IGBT on-state voltage drop u ce shall be deducted during its conduction. The input rotor current comes from the DFIG model. When both IGBT of the bridge arm are turned-off, it enters the freewheeling state. Firstly, the current direction is estimated to obtain the output voltage, in which the freewheeling diode conduction voltage drop u d is considered. The encapsulation generated by VERILOG code is shown in Figure 3.

Real-time module of load
The load is three star connected resistors, and the resistance value is given by the external real controller. The input stator currents i sa 、i sb and i sc come from the DFIG model and are multiplied by the fixed-point resistance value to output the stator three phase voltages u sa 、u sb and u sc (Fig 4).

Timing analysis
The simulation step, maximum time for all models to run once, is 1μs. The PWM cycle is 100μs. Through timing analysis by MODELSIM, the simulation speed, that means all HIL models run once, needs 24 clock cycles, a total of 0.48μs. The DFIG model is the most time consuming, with a total of 0.36μs. The time consuming ratio of converter and load model is 16.67% and 8.33% respectively.

Experiments
Comparative experiments are carried out on HIL platform and physical platform respectively. The physical platform includes (Fig 5a): DFIG with 5kW rated power, a 4kw DC motor for wind simulation, DSP chip 56F84763 of NXP Company and four 1kW power resistance loads, two of which are connected in parallel as one phase and form three phase unbalance load with the other two resistors.
(a) Physical platform (b) HIL platform Figure 5. Experimental device HIL platform includes (Fig 5b): 1) FPGA board, which embeds the real-time model of DFIG, rotor side converter and load, 2) Real controller, 3) The D/A board converts the real-time model digital results into analog quantities for oscilloscope observation.
The experiment is divided into balance load and unbalance load. The control method is vector control based on stator voltage orientation.

Three phase balance load
In order to prevent the real resistance from burning, the dc link voltage is 60V, the phase current does not exceed 5A, the PWM frequency is 10 kHz, and the dead time is 3μs. Four steady-state experiments are carried out at 600, 900, 1200 and synchronous speed 1500 rpm. The results show that the rotor current frequency changes with the speed, the variable speed constant frequency can be realized, the generator outputs 50Hz three phase symmetrical sine wave voltage (Fig 6). Compared with the experimental results of the physical platform, the proximity error of HIL platform is analyzed. The rotor phase current i ra , stator phase current i sa , stator line voltage u sab , rotor phase current frequency f r and stator phase voltage frequency f s at four speeds are compared, with an error range of 1.17 ~ 3.29%.

Unbalance load 1
A notch filter is added into the control method to filter the negative sequence secondary AC flow in the positive dq coordinate system of stator voltage, realize the compensation of voltage amplitude, and the stator line voltage tends to be symmetrical (Fig 7). Compared with the experimental results of the physical platform, the average approach error of HIL platform is 1.95% and 1.99%, ranging from 1.19 to 2.52%.

Unbalance load 2
If the unbalance load test with high voltage and high current is carried out on the physical platform, the risk is great. HIL platform does not have this concern, which is also an important value of realtime simulation: it can carry out destructive experiments without any risk.
The dc link voltage is 500V, the three phase load resistance R a =80Ω, R b =R C =50Ω, and the stator voltage changes obviously before and after introducing the notch filter (Fig 8a). The steady-state errors of three phase voltage are 6.27%, 7.21% and 0.3% respectively, the voltage imbalance is 0.97%, and the time delay for the voltage to enter the steady state is 0.149 milliseconds.  Figure 8. Phase voltage with introducing notch filter in control method The load resistance R a is 80Ω, and the resistance of phase B and C are 50Ω. After entering the steady state, increase the R a to 130Ω instantly, and the resistance value of other two phases remains unchanged. At this moment, the stator phase voltage has a large impact and an obvious peak-up to 399.5V (Fig 8b). When the R a suddenly decreases from 130Ω to the original value of 80Ω, the peak of stator phase voltage reaches 420.9V (Fig 8c).

Conclusions
For the off-grid DFIG wind power system, the design method of HIL semi-physical real-time model is proposed, including three real-time models of DFIG, rotor side converter and resistance load. Comparative experiments are carried out on the physical platform and HIL semi-physical real-time simulation platform, including balance load and unbalance load. The update speed of HIL real-time model is 0.48μs. Compared with the physical platform, the error range of HIL platform is 1.17 ~ 3.29%. HIL platform can realize the rapid test of conventional algorithms. For the fault condition such as unbalance load, it can test the performance of control methods without risk.