Elektrotehniški vestnik 84(4): 189-194, 2017 Original scientific paper A Passive Load Identification System for the Switched-Mode Power Supply Jan Marjanovič1, Andrej Trost2 1CAEN ELS s.r.l, SS14, Km 163.5, Building Q1, 34149 Basovizza (TS), Italy 2Univerza v Ljubljani, Fakulteta za elektrotehniko, Tržaška 25, 1000 Ljubljana, Slovenija E-pošta: andrej.trost@fe.uni-lj.si Abstract: The paper presents a method to identify the load attached to a switched-mode power supply. The power supplies presented here are mostly used to power magnets in particle accelerators. The identified load parameters can be used for tuning the power supply PID controller. Our method allows obtaining model parameters from the voltage and current measurements during a normal power-supply operation without any perturbation on the load. Implementation of the load identification method using System-on-Chip composed of the FPGA and ARM microprocessor is described. The SoC implementation achieves a high performance and high flexibility. The experimental results show that only one variation of the signal on the load is required to adequately determine the load parameters. Keywords: Switched Mode Power Supply, Load Identification, System-on-ChipPovzetek Pasivna identifikacija bremena na stikalnem napajalniku Članek predstavlja metodo za identifikacijo bremena na stikalnem napajalniku, namenjenem predvsem za napajanje elektromagnetov v pospeševalnikih delcev. Pridobljeni parametri bremena se lahko uporabijo za optimizacijo PID krmilnika. Predstavljena metoda omogoča pridobivanje parametrov modela iz meritev toka in napetosti med normalnim obratovanjem napajalnika. S tem se izognemo potrebi po vzbujanju bremena s signali, drugačnimi od normalnih za določeno breme. Opisana je implementacija identifikacije bremena na sistemu na integriranem vezju, ki je sestavljena iz vezja FPGA in mikroprocesorja ARM. Implementacija na sistemu na integriranem vezju omogoča doseganje visokih zmogljivosti, hkrati pa daje načrtovalcem veliko svobode. Eksperimentalni rezultati kažejo, da lahko breme ustrezno karakteriziramo že iz ene same spremembe izhodnega signala. 1 Introduction Switched mode power supplies are the state-of-the-art electronic circuits composed of advanced sensors and powerful computational part executing highly sophisticated control algorithms. The application of the power supply defines requirements for the output voltage and current characteristics. Our applications are magnet power supplies in synchrotron light sources, free-electron lasers and other particle accelerators. The current in the electromagnetic coil produces a magnetic field which bends the beam of fast electrons. The output current must be precisely controlled in order to position the beam of electrons with a sub-micron precision. The output current ripple (e.g. at 50 Hz) should be as small as possible in order to prevent additional vibrations in the beam of electrons. The output current should be reasonably fast when the power supply is attached to corrector coils. All these requirements can be satisfied with a high-precision measurement system, fast and sophisticated control algorithm and precise output current actuator [1]. The output current of the power supply is controlled with a proportional-integral-derivative (PID) algorithm, which behavior depends on the load and PID parameters. The default parameters are set with a high-stability margin since the load is unknown, but they provide a suboptimal performance. By setting the right PID parameters, a faster controller response and better noise suppression are obtained. With the advent of digital PID controllers, changing the parameters has become a trivial task. This can be achieved by using a load-identification and auto-tuning procedure to obtain a better controller. Several authors have proposed their methods to identify the load. Most of them are based on injecting a signal on the load to obtain the load response. One of the first methods presented is the Relay Method [2] which uses a relay to create oscillations in the feedback loop. It requires a separate step of tuning before the controller can be used. This separate step is later implemented as a part of the soft-start procedure [3]. There are also approaches where the PRBS noise is induced in the observed system and the frequency response of the system is measured [4] [5] [6]. Received 6 September 2017 Accepted 21 September 2017 190 MARJANOVIC, TROST The environment where our power supplies are used forbids any additional active perturbation on the load. Instead, occasional changes in the output current set by the user are used to get the information about the system. The paper presents a passive load-identification algorithm for magnet power supplies which produces a mathematical model of the load. Once the load is identified, the results can be used to change the PID parameters with one of the numerous methods for PID tuning, for example the Ziegler-Nichols method. The presented method and implemented system are a generalization of the load-identification system using the model with no direct transmission term [7] and are able to characterize RL as well as the purely resistive loads. The paper is organized as follows. Section 2 presents the mathematical model for the loads and its transform in a discrete time. The method to obtain equations from the measurements and the method to solve them are also discussed. Section 3 is focused on aspects of implementating the algorithm on System-on-Chip. In section 4, the algorithm results are evaluated against a reference measurement. Section 5 presents our conclusions. 2 Load Identification Methods The power-supply load is generally considered as a system with a voltage input and current output. The output depends on the current value of the input and previous input values in case of elements that can store the energy. The stored energy can be modeled as an internal state of a dynamic system, which is not directly observable. We will first derive a model of the load using the gray-box approach [8]. A suitable presentation of the model in a discrete time will be given. Measurements of the voltage and current form a set of equations. The approach for solving such a set will be discussed. 2.1 Mathematical model of the load Since the magnets are conductive wires on a ferromagnetic material, the magnet can be approximated by the resistance and inductance in series. Model parameters R and L are determined by observing the system. Since the identification algorithm runs in a discrete time, presentation of the system in the z-domain is more suitable. The Euler backward method [9] is used to translate the system function from the Laplace domain to the z-domain: s ^ z—1 hz (2) where h is the sampling period. Combining 1 and 2, we get: Hd(z) = bo? z — a. or as a difference equation: i[n] = a1i[n — 1] + b0v[n] (3) (4) When there is a purely resistive load attached to the power supply, it can be modeled as: 1 i[n] =jv[n] + C (5) where C is the constant offset which matches the measurement system offset and thus allows R to be better fitted to the measured data. Equations (4) and (5) can now be easily superposed into a single model. i[n] = a1i[n — 1] + b0v[n] + C (6) By equalizing the continuous and discrete time response at a frequency zero, H(s = 0) = Hd(z = 1), the equations for R and L are: R = 1 — a-. Si = ■ a1 — 1 (7) ai — h L = -- R 2.2 Least-square approximation The presented system model is general enough to accommodate both the R and RL loads. The model parameters which fit best to the measured data can be found by using the least-square method [10]. Starting from a set of linear equations: Ax = b (8) Figure 1. Schematic presentation of the magnet model. The system in Fig. 1 can be described in the Laplace domain as: The solution that minimizes the squares of the error is given as: = (ATA)-1ATb (9) H (s) = I (s) 1 1 1/R V (s) Z (s) R + sL 1 + sL / R (1) Expecting that in some cases some of the parameters cannot be matched with a real world system, we shall also b 0 1 PASSIVE LOAD IDENTIFICATION SYSTEM FOR SWITCHED MODE POWER SUPPLY 191 determine the accuracy of our solution. The needed parameter is the covariance matrix of errors of vector x [11]. Suppose, there is an error (denoted by vector e) in our measurements: Ax = b + e (10) Let us assume that the mean value of the error is 0 and its covariance matrix is identity matrix I. This implies that the measurement noise is white with the variance value 1. E[x] = 0, E[xxT] = I (11) This is a considerable simplification, but we will show that we can determine which solutions are sufficiently matched using the assumptions. We are looking for the covariance matrix of errors of the result: I = E [(x — x)(x — x) ] From the derivation it follows: I, = (ATA)- (12) (13) 2.3 Solving the model equation with the square method least- i[n] = b0v[n] + axi[n — 1] + C (14) We therefore obtain a set of N-1 equations with three unknowns: bo, ai and C. We can use the least squares method (9) to solve this set of equations and (13) to determine how much a certain parameter of the model matches our measured data. In case of a purely resistive load, when the system responds immediately to the excitation and does not store the energy, the parameter a1 does not match the real world and is invalid. Fig. 2 presents the difference between the variance values for the case of the resistive and RL loada. A recursive least-square algorithm is used on this plot to give a better presentation on how the number of samples affects the parameters variances. On the first plot we can observe that with the increasing number of samples (more measurements) all three variances decrease. This implies that each of the three parameters sufficiently matches with load. On the second plot, the variance of parameter a1 remains almost unchanged, showing that for this load this parameter does not match the real world system. Eq. (13) is used to calculate the covariance matrix of the error in solution x. The diagonal elements in this matrix are variances for our matched parameters. By measuring voltage and current on the load concurrently in N measurements, sequences {v[0], v[1], v[2], ..., v[n - 1]} and {/[0], /[1], /[2], ..., i[n - 1]} are obtained. For each element in this sequence, Eq. (6) can be written: Figure 2. Difference in variances of the model parameters for the R and RL loads 3 Implementation Implementation of the described method on a switched-mode power supply requires the voltage and current sampling at relatively high frequencies (several kHz) to obtain a detailed information about the measured load. The measurement of the voltage and current should be synchronized not to induce a phase error. The ability to signal process in a real time is highly desirable and can improve the precision of the system identification algorithm by reducing the noise. The method is designed to measure large coils with ferrite cores with the time constant in the range of seconds. Therefore, it is important that the calculations are performed for several seconds of data sampling. This can be achieved recursively variating algorithm [7] or temporarily storing the data for a later elaboration. We chose to implement the second option. In the third part of the load-identification method, the calculation of the unknown parameters of the model using least-square approximation are calculated. A matrix inversion and several matrix multiplications are computed in this part of the method, hence the need for computational performance of the system. 3.1 System Architecture A solution which accommodates all our needs is a System-on-Chip (SoC), a combination of the Field Programmable Gate Array (FPGA) and microprocessor. There are two very similar solutions on the market, i.e. Xilinx Zynq and Altera Cyclone V SoC. The FPGA-microprocessor combination on the same integrated circuit allows engineers to divide the tasks between the hardware and software [12]. The tasks which require a low latency, high throughput and high determinism are better suited for the hardware implementation on the FPGA. Implementation of non- i 192 MARJANOVIC, TROST time-critical tasks is faster and easier on the microprocessor. Our system is composed of the Arrow SocKit development board with Altera Cyclone V SoC and the CAENels power supply module. The SoC contains a dual-core ARM Cortex-A9 processor, communication bridges and signal-processing chain in FPGA, as presented in Fig. 3. Figure 3. Load identification SoC connected to a switched-mode power supply. The power module transfers the measured voltage and current on the load to the control module. ADCs synchronously sample the voltage and current at 26 kHz with a 20-bit resolution. Our load-identification system is attached to the same bus to get the information about the load. The first module in FPGA (SPI->Avalon ST) captures the measured data from the SPI bus and produces the Avalon Streaming format [13], which is very suitable for a continuous stream of the measured data. The next module converts the integer ADC data to the IEEE754 format. This simplifies the algorithm implementation on the microprocessor, since the rounding error and possible overflows can be neglected. The gainOffset module applies the gain and offset to the measured data to perform the conversion from the raw value from ADC to the voltage in volts and the current in amperes. There are two sets of registers configuring this module, one for the voltage and other for the current. The last module (window averaging) in the signal-processing chain performs data averaging to reduce the noise and number of samples. Since the sampling frequency is several orders of the magnitude higher than the measured system frequency, reducing the number of samples lowers needed memory space while the precision remains the same. DMA engine [14] is used to transfer the data from the signal-processing chain into the DDR3 memory which is accessible from the processor. The control registers are also accessible from the processor and the driver in the Linux kernel runs the DMA transfer every time the read() function is called. Using the DMA engine significantly reduces the CPU load, since the thread which calles the read() function sleeps while waiting for the transfer to finish [15]. The gainOffset, window averaging and DMA engine module can be configured from the ARM processor using appropriate drivers. 3.2 Software The algorithm described in the previous chapter needs to perform several matrix multiplications and matrix inversions. While this can be performed in the FPGA part to achieve a high throughput, we decided to implement this part on the processor. This allowed us to develop the algorithm in a high-level language which resulted in a faster implementation and easier modification. The availability of the VFPv3 and NEON floating point engines in the ARM processor enables a satisfactory performance of the floating-point operations. The operating system of our choice was GNU/Linux due to its increasing popularity in embedded systems. We used Yocto Project [16] to create an executable kernel image together with user-space programs. The load-identification algorithm was implemented in the Python language with the Numpy library which provides a variety of numerical functions. Programming in Python enabled us to test the algorithm on PC first and later reuse the same code on the ARM processor. Figure 4. Experimental setup. 4 Results The system performance was evaluated by measuring the resistance and inductance of the adjustable load. The experimental setup is shown in Fig. 4. The load identification was performed on six different PASSIVE LOAD IDENTIFICATION SYSTEM FOR SWITCHED MODE POWER SUPPLY 193 configurations. The sampling frequency was set to 2.6 kHz and the buffer length was 32768 samples, resulting in 12 seconds of the data measuring for each calculation. The measurements are shown in Tables 1 and 2. The results of our identification algorithm were compared with the manufacturer specifications of an adjustable load and results obtained from the model with no direct transmission term [7]. Table 1: Resistance identification results Manufacturer specifications [mfl] Model [mn] Identification results [mn] 1 346 519.5 393.5 ± 0.02 2 673 846.2 713.5 ± 0.02 3 965 1122.0 981.9 ± 0.02 4 1247 1385.0 1277.7 ± 0.08 5 1547 1749.2 1607.2 ± 0.05 6 1805 1977.0 1832.7 ± 0.09 Table 2: Inductance identification results Manufacturer specifications [mH] Model [mH] Identification results [mH] 1 42.7 40.1 42.3 ± 0.01 2 139 135.9 138.3 ± 0.01 3 241 245.3 247.4 ± 0.01 4 380.6 387.4 389.4 ± 0.04 5 553.5 563.1 565.2 ± 0.02 6 686.8 699.8 701.7 ± 0.05 Manufacturer Model Identification specifications [n] results [H] [n] R1 6.0 ± 0.3 - 5.791 ± 0.0002 R2 12.0 ± 0.6 - 11.536 ± 0.0006 R3 18.0 ± 0.9 - 17.302 ± 0.0007 Figure 5. Distinction of the parameter ai variance between the R and RL loads. The minimum number of samples to obtain a valid result was also investigated. The signal on the load was saved in the memory and the identification algorithm was applied to different lengths of the signal, all starting from the same point. The starting length was 100 samples with an increment from 100 samples to 2000 samples. Results of the length variations are shown in Fig. 6. It is evident that, due to the high precision measurements, the algorithm needs only one variation of the signal to adequately determine the load parameters. The improved algorithm provides correct results even when the load has a purely resistive characteristic. This case was evaluated on 6 Q, 12 Q and 18 Q resistances. The results are shown in Table 3. The algorithm also correctly calculated the inductance of a purely resistive load which was in all cases less than 1 mH. Table 3: Improved resistance identification 500 1000 1500 Nr of samples for least squares Figure 6. Number of samples needed to identify the load. In Fig. 5 we can see a clear distinction between the R and RL loads. The purely resistive loads do not store any energy, therefore parameter ai from Eq. (6) cannot be matched to the measured signal. Since the various programs on the same processor compete for the processor time, the algorithm performance is also very important. The time needed to perform the least-square computations on a different number of samples is shown in Fig 7. 194 Algorithm performance with python numpy on ARM 0.05 - r : ; 2 •> 04 -............ .............-.............j...........................:.............:.............. v £ I 0 03 = : • : i> UJ 0.02 -......................... .............;...................................................... • 0.01 i, ' D000 5000 10000 15000 20000 25000 30000 35000 Nr samples Figure 7. Time needed to perform the least squares identification. 5 Conclusions We present a method to identify the load attached to the switched-mode power supply. By improving the method from [7], the purely restive load is also identified. The change in the transform from a continuous time to a discrete time produces a direct transition term that is matched perfectly in case of purely resistive loads. We also show implementation on a novel architecture, System-on-Chip. By using the integrated circuit with a combined FPGA and ARM processor, the computing task is distributed to achieve a high performance and high flexibility. The algorithm results match the factory measurement specifications in almost all cases by less than 5 % which allows the identification results to be used in the PID controller auto-tuning procedure. References [1] R. Visintini, M. Cautero and D. Molaro, "Magnet power supplies for FERMI@Elettra," in Proceedings of 2011 Particle Accelerator Conference, New York, NY, USA, 2011. [2] K. J. Astrom and T. Hagglund, PID Controllers: Theory, Design, and Tuning, 2nd Ed., Instrument Society of America, Research Triangle Park, NC, 1995. [3] W. Stefanutti, P. Mattavelli, S. Saggini and M. Ghioni, "Autotuning of Digitally Controlled Buck Converters Based on Relay Feedback," in Power Electronics Specialists Conference, 16 June 2005. [4] M. Shirazi, R. Zane and D. Maksimovic, "An Autotuning Digital Controller for DC-DC Power Converters Based on Online Frequency-Response Measurement," IEEE Transactions on Power Electronics, vol.24, no.11, pp.2578,2588,, Nov. 2009. [5] A. Congiu, M. Barbaro, A. Picciau, E. Bodano and D. Hammerschmidt, "Prototype of a novel steady-state load identification technique for digitally controlled DC-DC power supplies," in Design and Architectures for Signal and Image Processing (DASIP), 2013 Conference on, 2013. MARJANOVIC, TROST [6] S. Hashimoto, T. Sato, S. Naka, K. Motegi and W. Jiang, "Adaptive Identification and Control for Digital Control-Based Switching Power Supply System," in Power and Energy Engineering Conference (APPEEC), 2012 Asia-Pacific, vol., no., pp.1,4, 27-29, March 2012. [7] J. Marjanovic and A.Trost, "System on Chip for Load Identification on a Switching Power Supply," in Proceedings of MIDEM2014, Ljubljana, 2014. [8] L. Ljung, System Identification (2Nd Ed.): Theory for the User, Upper Saddle River, NJ, USA: Prentice Hall PTR, 1999. [9] F. Haugen, Discrete-time signals and systems, Available online at http://techteach.no/publications/discretetime_signals_systems/ discrete.pdf, February 17 2005. [10] O. Bretscher, Linear Algebra with Applications, Prentice Hall, 2001. [11] G. Strang, Computational Science and Engineering, Wellesley-Cambridge Press, 2007. [12] R. Sass and A. G. Schmidt, Embedded Systems Design with Platform FPGAs: Principles and Practices, San Francisco, CA, USA: Morgan Kaufmann Publishers Inc., 2010. [13] "Avalon Interface Specifications," [Online]. Available: http://www.altera.com/literature/manual/mnl_avalon_spec.pdf . [Accessed 21.12.2014]. [14] "Modular SGDMA," [Online]. Available: http://www.alterawiki.com/wiki/Modular_SGDMA. [Accessed 20.12.2014]. [15] J. Corbet, A. Rubini and G. Kroah-Hartman, Linux Device Drivers, 3rd Edition, O'Reilly Media, Inc., 2005. [16] C. Charreyre, "Using Yocto Project to build rich and reliable embedded Linux distributions," in Embedded Real Time Software and Systems 2014, 2014, Available online at http://www.erts2014.org/Site/0R4UXE94/Fichier/erts2014_3 A3.pdf. Andrej Trost received his Ph.D. degree in 2000 from the Faculty of Electrical Engineering, University of Ljubljana. Currently he works at the same faculty as an associate professor teaching high-level design techniques on several graduate and post-graduate study levels. His research interests include the FPGA technology and digital-system design for academic and industrial applications. Jan Marjanovic graduated in 2014 from the Faculty of Electrical Engineering, University of Ljubljana with a diploma entitled System on Chip for Load Identification on a Switching Power Supply. He works with CAEN ELS as a hardwaresoftware developer for measurement instruments and highperformance supply units.