<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">CS</journal-id><journal-title-group><journal-title>Circuits and Systems</journal-title></journal-title-group><issn pub-type="epub">2153-1285</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/cs.2018.910016</article-id><article-id pub-id-type="publisher-id">CS-88235</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Computer Science&amp;Communications</subject><subject> Engineering</subject><subject> Physics&amp;Mathematics</subject></subj-group></article-categories><title-group><article-title>
 
 
  Peak Detection Implementation for Real-Time Signal Analysis Based on FPGA
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Alperen</surname><given-names>Mustafa Colak</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Taito</surname><given-names>Manabe</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Yuichiro</surname><given-names>Shibata</given-names></name><xref ref-type="aff" rid="aff1"><sup>1</sup></xref></contrib><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Fujio</surname><given-names>Kurokawa</given-names></name><xref ref-type="aff" rid="aff2"><sup>2</sup></xref></contrib></contrib-group><aff id="aff1"><addr-line>Graduate School of Engineering, Nagasaki University, Nagasaki, Japan</addr-line></aff><aff id="aff2"><addr-line>Nagasaki Institute of Applied Science, Nagasaki, Japan</addr-line></aff><pub-date pub-type="epub"><day>31</day><month>10</month><year>2018</year></pub-date><volume>09</volume><issue>10</issue><fpage>148</fpage><lpage>167</lpage><history><date date-type="received"><day>3,</day>	<month>October</month>	<year>2018</year></date><date date-type="rev-recd"><day>27,</day>	<month>October</month>	<year>2018</year>	</date><date date-type="accepted"><day>31,</day>	<month>October</month>	<year>2018</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  In this paper a real-time peak detection method based on modified Automatic Multiscale Field Detection (AMPD) algorithm and Field Programmable Gate Arrays (FPGA) technologies of a time series data is studied, and optimum scaling is highlighted after testing several scales. To validate the results obtained from modified algorithm, they are compared with the results of original AMPD method. As data of this study, three-phase voltage values of a power station are used. A detail detective sensitivity analysis of phase-to-phase voltage values is tried at different scales. Moreover, the original algorithm is tested regarding the off-line mode to obtain optimum scaling for real-time peak point detection. It is concluded that the peak detection of minimum and maximum points of data series achieved by modified algorithm is very close to the results of original AMPD algorithm.
 
</p></abstract><kwd-group><kwd>AMPD Algorithm</kwd><kwd> Off-Line Method</kwd><kwd> FPGA</kwd><kwd> Peak Detection</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>Peak detection of any time series data is always a hot topic in many engineering fields including chemistry, biology, biomedical, optics, astrophysics and energy systems. So these fields often require real-time peak detection. As the environment noises can affect the signals somehow, a robust peak detection, in this case, is a challenging topic. To obtain a successful peak detection method, several methods have been proposed, including automatic multiscale-based peak detection [<xref ref-type="bibr" rid="scirp.88235-ref1">1</xref>] , window-threshold techniques [<xref ref-type="bibr" rid="scirp.88235-ref2">2</xref>] [<xref ref-type="bibr" rid="scirp.88235-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.88235-ref4">4</xref>] , wavelet transform [<xref ref-type="bibr" rid="scirp.88235-ref5">5</xref>] - [<xref ref-type="bibr" rid="scirp.88235-ref11">11</xref>] , techniques using entropy [<xref ref-type="bibr" rid="scirp.88235-ref12">12</xref>] , and artificial neural networks [<xref ref-type="bibr" rid="scirp.88235-ref13">13</xref>] [<xref ref-type="bibr" rid="scirp.88235-ref14">14</xref>] . Particularly, each method was investigated in terms of the detection method employed and the detection performance achieved. Drawbacks of the peak detection algorithms available in the literature are that many free parameters such as the window length of a threshold value have to be used in order to apply the algorithm to the signal, and to make the algorithm applicable. Generally, the algorithms with fewer parameters are restricted for use in specific applications like the detection of R-peaks in electroencephalography (ECG) signals and to obtain an adaptive and time-efficient R-peak detection algorithm for ECG processing as well as reduce the size and noise of ECG signals [<xref ref-type="bibr" rid="scirp.88235-ref15">15</xref>] - [<xref ref-type="bibr" rid="scirp.88235-ref20">20</xref>] . In addition, noise in analyzed signal is a challenge for many peak detection algorithms.</p><p>On the other hand, periodic and quasi-periodic signals are the most difficult ones to detect the peak points. However, AMPD method is suitable for all types of peak point detecting. Thus, the automatic multiscale-based peak detection (AMPD) method [<xref ref-type="bibr" rid="scirp.88235-ref1">1</xref>] has been introduced as an effective method. In this research, we used the off-line and online terms to show the scale. Off-line algorithm means to fix the scale, then analysis all input data with using stable scale for each clock. On the other hand, online algorithm means to vary the scale for each clock. However, these software methods are not suited for real-time processing but emphasized off-line sophisticated data analysis.</p><p>The use of FPGAs provides a promising approach to real-time peak analysis [<xref ref-type="bibr" rid="scirp.88235-ref21">21</xref>] [<xref ref-type="bibr" rid="scirp.88235-ref22">22</xref>] . FPGAs do not run a program stored in the program memory because they are reprogrammable chips and include a lot of logic gates, which are internally connected to form a complex digital circuitry. FPGAs are not processors and are entirely different from CPUs, GPUs, and DSP. However, they offer various opportunities for efficient real-time signal processing by making the best use of pipelined structure in computing. Furthermore, in previous work, we applied AMPD method on an FPGA as off-line by changing its bite size and scales and then analyzed it in terms of speed, cost and memory [<xref ref-type="bibr" rid="scirp.88235-ref23">23</xref>] . Eventually, we realized that changes in bit size did not affect the peak detection.</p><p>This paper introduces a novel approach for robust and real-time peak detection by using the AMPD algorithm and the FPGA technology. It highlights the modification of the original AMPD algorithm to be an off-line method, and how it can be implemented on an FPGA so that a pipelined structure in computing is extracted on hardware. Thus, the optimum scaling for the off-line peak detection is obtained, and results compared with the original AMPD method are found very promising.</p></sec><sec id="s2"><title>2. Overview of Algorithm</title><sec id="s2_1"><title>2.1. AMPD Method</title><p>The AMPD method [<xref ref-type="bibr" rid="scirp.88235-ref1">1</xref>] is a technique especially to find the peak points of periodic and quasi-periodic noisy signals on-line. It calculates all input data by using matrix equation to find the peak points. Also, AMPD determines the local maxima points in different time periods, each of which is named scale and is the number of compared data at a time. AMPD is divided into 4 different stages: Local Maxima Scalogram (LMS) calculation, Row-Wise summation of the LMS, LMS rescaling, and peak detection. <xref ref-type="fig" rid="fig1">Figure 1</xref> shows the flowchart about the original algorithm. However, to enable off-line processing on an FPGA, Row-Wise summations of the LMS and LMS rescaling are skipped to obtain optimal scale decision and LMS rescaling, which is possible to perform in advance in a calibration phase. Number of combinations to create scale pattern like 33, 65, 129, 257, 513 and 1025 for make a simple and efficient pipeline to implement on FPGA. Fixed scales are then chosen and, based on them, the sensitivities of the peak points are analyzed.</p><sec id="s2_1_1"><title>2.1.1. LMS Calculation</title><p>Essentially, LMS calculation means analysis of all input values ( x = x 1 , x 2 , x 3 , x 4 , ⋯ , x n ) by using the moving window approach to fill in the Z matrix given in Equation (1) below that also indicates the size of the Z matrix. In Z matrix, k denotes the number of rows while i denotes the columns. The relation between n and L can be defined as shown in Equation (1):</p><p>Z = [ z 1 , 1 z 1 , 2 z 1 , 3 ⋯ z 1 , n z 2 , 1 z 2 , 2 z 2 , 3 ⋯ z 2 , n ⋮ ⋮ ⋮ ⋱ ⋮ z L , 1 z L , 2 z L , 3 ⋯ z L , n ] = ( z k , i ) (1)</p><p>When all numbers denoted by x<sub>i</sub> are analyzed, the previous value should be (X<sub>i-</sub><sub>1</sub>) and the next value (X<sub>i+</sub><sub>1</sub>) is checked and compared using the window approach, which is called distance between all the points. Furthermore, the window approach scale depends on the L.</p><p>where;</p><p>n denotes total column number</p><p>L denotes total row number</p><p>L = ( n / 2 ) − 1 (2)</p><p>At the same time k is changed from 1 to L in <xref ref-type="fig" rid="fig2">Figure 2</xref>, which shows the comparison mechanism of input values.</p><p>Elements of Z matrix can be calculated by Equation (3).</p><p>z k , i = { 0 ,       if   ( x i − 1 &gt; x i − k − 1 ) ∧ ( x i − 1 &gt; x i + k − 1 ) r ,                           otherwise (3)</p><p>where</p><p>r denotes random number between 1 and 2.</p><p>If this condition point ( x i ) is provided,</p><p>x i &gt; x i − 1 and x i &gt; x i + 1 ,</p><p>Then, new diagonal element z<sub>L,n</sub> value assigned to z k , i is zero in the Z matrix, or else, a random number (r) assigned to z k , i is generated at every time by a random generator. The range of random numbers is between 1 &lt; r &lt; 2. In this way, the whole Z matrix is obtained by analyzing each element of it.</p></sec><sec id="s2_1_2"><title>2.1.2. Positive Edge and Negative Edge Peak Points Detection</title><p>The target of this study is to detect peak points by applying the variance formula. After completing the formation of the Z matrix, the zero points are detected by applying the variance formula to each column. In some cases this value may not be zero due to noises; however, detection is done when the value is smaller than a minimal threshold value. Thus, if sigma (σ), in Equation (4) is found to be zero, then this point is interpreted to correspond to the peak value. If sigma is different from zero, this point does not correspond to the peak value,</p><p>σ i = 1 λ − 1 ∑ k = 1 λ [ ( z k , i − 1 λ ∑ k = 1 λ z k , i ) 2 ] 1 2 (4)</p><p>where, for i ∈ { 1 , 2 , 3 , ⋯ , n } then, lambda in Equation (4) should be denoted as L so that all zero points of Z matrix given in Equation (4) are detected.</p></sec></sec></sec><sec id="s3"><title>3. Implementation</title><sec id="s3_1"><title>3.1. Overview of the System</title><p>In the original AMPD algorithm, the best scale is automatically found by using four calculation steps Local Maxima Scalogram (LMS) calculation, Row-Wise summation of the LMS, LMS rescaling, and peak detection. On the other hand, it is necessary to reduce the amount of memory used in this AMPD algorithm while applying it to the FPGA in order to make a simple and effective pipeline design. The reason is that using more steps in application will increase memory usage and low latency. Original and modified algorithm flowcharts were given in <xref ref-type="fig" rid="fig1">Figure 1</xref> and <xref ref-type="fig" rid="fig4">Figure 4</xref> respectively. It was also mentioned that original algorithm flowchart in <xref ref-type="fig" rid="fig1">Figure 1</xref> is more complex and has more steps than modified algorithm flowchart in <xref ref-type="fig" rid="fig4">Figure 4</xref>. In modified algorithm, step size is reduced and therefore the memory size is also reduced. If the time complexity (O) of algorithm is analyzed in terms of the flowchart given in <xref ref-type="fig" rid="fig3">Figure 3</xref>, total time complexity is found as O ( 2 n 2 ) .</p><p>Since the main target of this study is to apply AMPD algorithm to FPGA, a new algorithm has been proposed where the number of steps of AMD algorithm have been reduced. <xref ref-type="fig" rid="fig4">Figure 4</xref> shows the flowchart about the off-line algorithm. Therefore, there are only two steps in the proposed algorithms: Local Maxima Scalogram and peak detection for the best off-line calculations of peak points. The proposed system cannot straightforwardly calculate the peak points automatically with the low memory of FPGA. When the AMPD algorithm is applied on an FPGA, it can be reprogrammed for desired applications so that a logical gate is needed to make a process. Nevertheless, applying the deviation formula generates the LMS matrix and then all values are kept in registers. <xref ref-type="fig" rid="fig5">Figure 5</xref> shows the hardware design of the overview of implementation where k is the window scale.</p><p>In this design, a different element of the matrix in every clock cycle is compared and generated. Matrix generators with input X and output Z are serially connected to take advantage of the pipelining. After completion of generating all values, a basic peak flag is used to determine if a value corresponds to a zero point, that is, if a peak point is detected. Matrix generators are used to shift data sequentially, with the data for each matrix generator being compared with newly sampled data. In this manner, matrix elements of each scale are generated. In</p><p>one clock cycle, an element of the matrix will be generated, and as a result the summation and square summation are calculated sequentially. Finally, a division is performed to obtain an average and a squared average.</p><p>In the original AMPD algorithm, the standard deviation formula is utilized for detecting peak points. This involves rather complex arithmetic such as square root. To improve performance and efficiency of the FPGA implementation, the process is modified to use variance instead of standard deviation. The formula used in this design is in Equation (5), which shows the matrix designed by applying the variance formula to each column. Although both Equation (4) and Equation (5) are suitable for applying the variance, Equation (5) is used in this study due to its easy representation in hardware design.</p><p>σ i = 1 L [ ( ∑ k = 1 L z k , i 2 ) − ( 1 L ∑ k = 1 L z k , i ) 2 ] (5)</p></sec><sec id="s3_2"><title>3.2. Matrix Generator and Decision Mechanism</title><p><xref ref-type="fig" rid="fig6">Figure 6</xref> depicts a Matrix Generator block diagram that is a decision mechanism to generate a matrix by using LMS calculation. It is also a critical part of the LMS calculation. The Matrix Generator requires a decision part for comparing values, which constitutes the major design of the matrix generator module. This module generates a matrix of one scale. The data generated by matrix generator for comparison reason is reduced to store and fed into the shift. The length of the shift register depends on the shift register’s scale.</p><p>The input data is stored into the register and the data it is to be compared with will be inputted into the comparator in every clock cycle. <xref ref-type="fig" rid="fig7">Figure 7</xref> is the expanded detailed hardware of the selector section of <xref ref-type="fig" rid="fig6">Figure 6</xref> and it is the decision giving section on the achievement of positive and negative peak detections.</p></sec></sec><sec id="s4"><title>4. Results and Discussion</title><p>In this section, the original AMPD algorithm and the modified algorithm are evaluated in detail by comparing their detections of peak points of the same data</p><p>series. First of all, simulation results of both algorithms are given and then compared with each other. Later on, both original and modified algorithms are evaluated at different scales. After that, the sensitivity equation below is applied to each design to find their peak sensitivities.</p><p>Sensitivity = TP ( TP + FN ) (6)</p><p>where;</p><p>TP = True Positive.</p><p>FN = False Negative.</p><sec id="s4_1"><title>4.1. Simulation of the Original AMPD Algorithm</title><p>In this section, the peak points obtained from the original AMPD method as on-line have been introduced. A simulation has been performed with input data of the phase-to-phase effective voltage values of a medium-voltage transformer located in the Organized Industrial Zone used for the period from October 1 to October 31, 2015. The corresponding dataset contains 4470 data points recorded at 10-min intervals for each L3-L2, L2-L1 and L1-L3 phase-to-phase effective voltages. L1, L2 and L3 denote the power line in order in a 3-phase power system. The daily maximum and minimum peak points detected by the original AMPD method are shown in Figures 8(a)-(c) for L3-L2 (V<sub>L</sub><sub>3-L2</sub>), L2-L1 (V<sub>L</sub><sub>2-L1</sub>) and L1-L3 (V<sub>L</sub><sub>1-L3</sub>) line voltage values, respectively. When these figures are compared in detail, the original AMPD method detects the daily maximum peak points with the sensitivities of 93.75% for V<sub>L</sub><sub>3-L2</sub>, 96.96% for V<sub>L</sub><sub>2-L1</sub> and 90.90% for V<sub>L</sub><sub>1-L3</sub>. Thus, high numbers of the daily maximum peak points are observed at the time of 06:20, 06:30, 06:50, 07:00, 07:10 and 07:50. Moreover, it detects the daily minimum peak points with the sensitivities of 93.75% for V<sub>L</sub><sub>3-L2</sub>, 96.77% for V<sub>L</sub><sub>2-L1</sub> and 93.75% for V<sub>L</sub><sub>1-L3</sub>. In addition, identification of most of the daily minimum peak points are done at the time of 10:40, 11:00, 11:10, 17:30 and 19:00. Nevertheless, it should be noted that the original AMPD method introduced in this section has been designed in C Programming Language and it has been run as on-line. Max-Peak Sensitivities and Min-Peak Sensitivities concerning the line voltages are shown in <xref ref-type="table" rid="table1">Table 1</xref>.</p></sec><sec id="s4_2"><title>4.2. Simulation of the Modified Off-Line Algorithm</title><p>In this section, a similar simulation as in 4.1 has been repeated for the designed Verilog algorithm using the same data. Hardware Description Language (HDL) simulations were performed with a Cadence NC-Verilog simulator. Figures 9(a)-(c) and Figures 10(a)-(c) illustrate the real data in red color with plus sign and modified Verilog algorithm data in green color with a star sign. However, in this case simulation results are obtained from the Verilog design algorithm as off-line.</p><p>The daily maximum and minimum peak points detected by the modified AMPD method are depicted in Figures 9(a)-(c) for scale 33 for L3-L2 (V<sub>L</sub><sub>3-L2</sub>), L2-L1 (V<sub>L</sub><sub>2-L1</sub>) and L1-L3 (V<sub>L</sub><sub>1-L3</sub>) line voltage values, respectively.</p><p>The daily maximum and minimum peak points detected by the modified AMPD method are depicted in Figures 10(a)-(c) for scale 1025 for L3-L2 (V<sub>L</sub><sub>3-L2</sub>), L2-L1 (V<sub>L</sub><sub>2-L1</sub>) and L1-L3 (V<sub>L</sub><sub>1-L3</sub>) line voltage values, respectively.</p><p><xref ref-type="table" rid="table2">Table 2</xref> represents the positive edge sensitivities at different scales. When the scale was increased, the sensitivities of L3-L2 line voltage were reduced gradually, but positive edge sensitivity of 87.87% was obtained at scales 33, 65 and 129 for L2-L1 line voltage values. Furthermore, the sensitivities of L2-L1 line voltage</p><table-wrap id="table1" ><label><xref ref-type="table" rid="table1">Table 1</xref></label><caption><title> Max-peak sensitivities and min-peak sensitivities concerning the line voltages</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Phase-to-Phase Effective Voltages</th><th align="center" valign="middle" >Max-Peak Sensitivities</th><th align="center" valign="middle" >Min-Peak Sensitivities</th></tr></thead><tr><td align="center" valign="middle" >L3-L2 line voltage values</td><td align="center" valign="middle" >93.75%</td><td align="center" valign="middle" >93.75%</td></tr><tr><td align="center" valign="middle" >L2-L1 line voltage values</td><td align="center" valign="middle" >96.96%</td><td align="center" valign="middle" >96.77%</td></tr><tr><td align="center" valign="middle" >L1-L3 line voltage values</td><td align="center" valign="middle" >90.90%</td><td align="center" valign="middle" >93.75%</td></tr></tbody></table></table-wrap><table-wrap id="table2" ><label><xref ref-type="table" rid="table2">Table 2</xref></label><caption><title> Positive edge sensitivities for different scales and line voltages</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Sensitivities (Positive edge)</th><th align="center" valign="middle" >L3-L2 Line Voltage Values</th><th align="center" valign="middle" >L2-L1 Line Voltage Values</th><th align="center" valign="middle" >L1-L3 Line Voltage Values</th></tr></thead><tr><td align="center" valign="middle" >Scale 33</td><td align="center" valign="middle" >84.37%</td><td align="center" valign="middle" >87.87%</td><td align="center" valign="middle" >81.81%</td></tr><tr><td align="center" valign="middle" >Scale 65</td><td align="center" valign="middle" >81.25%</td><td align="center" valign="middle" >87.87%</td><td align="center" valign="middle" >81.81%</td></tr><tr><td align="center" valign="middle" >Scale 129</td><td align="center" valign="middle" >78.125%</td><td align="center" valign="middle" >87.87%</td><td align="center" valign="middle" >81.81%</td></tr><tr><td align="center" valign="middle" >Scale 257</td><td align="center" valign="middle" >78.125%</td><td align="center" valign="middle" >75.75%</td><td align="center" valign="middle" >75.75%</td></tr><tr><td align="center" valign="middle" >Scale 513</td><td align="center" valign="middle" >12.5%</td><td align="center" valign="middle" >21.21%</td><td align="center" valign="middle" >21.21%</td></tr><tr><td align="center" valign="middle" >Scale 1025</td><td align="center" valign="middle" >6.25%</td><td align="center" valign="middle" >9.09%</td><td align="center" valign="middle" >9.09%</td></tr></tbody></table></table-wrap><p>and L1-L3 line voltage remain constant for scales 33, 65 and 129. Nevertheless, they are also reduced at scales 257, 513 and 1025 because of the low frequencies of compared data at these scales. Finally, it is seen that maximum sensitivities are obtained at scales 33 and 65 for all line voltage values. They give almost the same results as the original algorithm.</p><p><xref ref-type="table" rid="table3">Table 3</xref> shows the negative edge sensitivities at different scales. As the scale is increased from 33 to 1025, the big changes in sensitivities have been observed for L1-L3 line voltage values. On the other hand, it was seen that maximum sensitivities of 93.54% were obtained at scales 33 and 65 for L2-L1 line voltage values that were almost the same as the original algorithm results. The sensitivities of L2-L1 line voltage values remain constant for scales 33 and 65. However, they are also reduced for the scales 129, 257, 513 and 1025 due to the low frequencies of compared data at these scales. Nevertheless, the sensitivities of L3-L2 line voltage values are constant for the scales 33, 65, 129 and 257, but they are also reduced for the scales 513 and 1025. Lastly, it is seen that negative edge sensitivities are obtained at scales 33 and 65 for all line voltage values. Almost the same results were obtained at scales 33 and 65 as the original algorithm.</p><p>Finally, sensitivities of all line voltages of L3-L2, L2-L1 and L1-L3 at higher scales were found very low due to very high sampling periods so that it caused missing the detection of peaks. This can also be explained simply by looking at Equation (1) and <xref ref-type="fig" rid="fig2">Figure 2</xref>, where it was seen that, when the scale is increased, the number of detected points are reduced due to an increased number of L in Z matrix. In another case, the sensitivity is also decreased at higher scales due to availability of noises in the signal.</p></sec><sec id="s4_3"><title>4.3. Evaluation Environments and Method</title><p>In this section, the aforementioned hardware designed in Verilog HDL is explained and then device utilization and performance of the modified algorithm on the Kintex-7 XC7K325T [<xref ref-type="bibr" rid="scirp.88235-ref24">24</xref>] FPGAs are evaluated. As a mapping tool, a Vivado 2016.3 tool was used. Furthermore, the analog-to-digital converters (ADCs) transform analog electrical signals, generally the voltage amplitude, into a sequence of discrete values for data processing purposes. In this study, it was preferred to use a DC919af ADC with 100 MHz maximum system frequency</p><table-wrap id="table3" ><label><xref ref-type="table" rid="table3">Table 3</xref></label><caption><title> Negative edge sensitivities for different scales and line voltages</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Sensitivities (Negative edge)</th><th align="center" valign="middle" >L3-L2 Line Voltage Values</th><th align="center" valign="middle" >L2-L1 Line Voltage Values</th><th align="center" valign="middle" >L1-L3 Line Voltage Values</th></tr></thead><tr><td align="center" valign="middle" >Scale 33</td><td align="center" valign="middle" >75%</td><td align="center" valign="middle" >93.54%</td><td align="center" valign="middle" >87.5%</td></tr><tr><td align="center" valign="middle" >Scale 65</td><td align="center" valign="middle" >75%</td><td align="center" valign="middle" >93.54%</td><td align="center" valign="middle" >84.37%</td></tr><tr><td align="center" valign="middle" >Scale 129</td><td align="center" valign="middle" >75%</td><td align="center" valign="middle" >90.32%</td><td align="center" valign="middle" >78.125%</td></tr><tr><td align="center" valign="middle" >Scale 257</td><td align="center" valign="middle" >75%</td><td align="center" valign="middle" >67.74%</td><td align="center" valign="middle" >43.75%</td></tr><tr><td align="center" valign="middle" >Scale 513</td><td align="center" valign="middle" >21.87%</td><td align="center" valign="middle" >22.58%</td><td align="center" valign="middle" >25%</td></tr><tr><td align="center" valign="middle" >Scale 1025</td><td align="center" valign="middle" >12.5%</td><td align="center" valign="middle" >9.6%</td><td align="center" valign="middle" >12.5%</td></tr></tbody></table></table-wrap><p>(sampling rate) and it was implemented on the FPGA board. The main target in this study was to increase the scale to observe and analyze the latency, memory usage and performance of the FPGA board. Therefore, different window lengths at various scales were designed to implement and analyze them on the FPGA board. Firstly, the bit size factor was fixed at 12 because there are many ADC compatible with 12 bits. Then the scale of input data was varied such as 33, 65, 129, 257, 513 and 1025 scales for comparison of resource usage, the result of which is shown in <xref ref-type="table" rid="table4">Table 4</xref>.</p><p>As seen in <xref ref-type="table" rid="table4">Table 4</xref>, when the scale is increased, an increase is detected directly from some slice logic utilization such as the number of slice LUTs, BRAMs, FFs, and DSP48E1 blocks, as well as the latency. In addition, design algorithm uses on-chip memory blocks (BRAMs) since the entire process is mapped on a pipelined structure based on shift registers. In terms of performance, the latency of peak detection was 23 clock cycles for the scale of 33. When each input data element has 12 bits, the maximum clock frequency is 144.927 MHz in <xref ref-type="table" rid="table4">Table 4</xref>. Furthermore, the maximum frequency was adjusted to 126.438 MHz in <xref ref-type="table" rid="table4">Table 4</xref> by using scale 1025 input sources.</p></sec><sec id="s4_4"><title>4.4. Evaluation of the AMPD Method with an FPGA Board</title><p>An evaluation of the AMPD method with an FPGA board is done in this section. <xref ref-type="table" rid="table5">Table 5</xref> gives information on the performance of latency at 100 MHz timing constraint for two different scales. To state the purpose of detecting the peak points efficiently, the approach in this study achieves the real-time peak detection based on AMPD algorithm on an FPGA. When implementing AMPD algorithm on the FPGA board, bit size was chosen as 12, which was compatible with the ADC and 100 MHz maximum system frequencies.</p><p><xref ref-type="fig" rid="fig1">Figure 1</xref>1 shows the overview of the experiment system. First, FPGA sends the starting signal to the ADC. Then ADC sends 12 bits input data and 100 MHz system clock signal to the FPGA. Finally, the designed algorithms successfully detect all peak points as illustrated in <xref ref-type="fig" rid="fig1">Figure 1</xref>4 and <xref ref-type="fig" rid="fig1">Figure 1</xref>5. In particular, two different AMPD algorithms were designed with scales 65 and 33 due to having best sensitivities. Although the system can successfully detect peak points at both scales, the latency is taken into account for the performance. When scale</p><table-wrap id="table4" ><label><xref ref-type="table" rid="table4">Table 4</xref></label><caption><title> Resource usage with different scales</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Scale</th><th align="center" valign="middle" >Number of Slice LUTs</th><th align="center" valign="middle" >Number of BRAMs</th><th align="center" valign="middle" >Number of Flip-Flop</th><th align="center" valign="middle" >Number of DSP48E1</th><th align="center" valign="middle" >Max Frequency (MHz)</th><th align="center" valign="middle" >Latency (clock cycle)</th></tr></thead><tr><td align="center" valign="middle" >33</td><td align="center" valign="middle" >2151</td><td align="center" valign="middle" >52</td><td align="center" valign="middle" >2910</td><td align="center" valign="middle" >22</td><td align="center" valign="middle" >144.927</td><td align="center" valign="middle" >23</td></tr><tr><td align="center" valign="middle" >65</td><td align="center" valign="middle" >3148</td><td align="center" valign="middle" >52</td><td align="center" valign="middle" >4370</td><td align="center" valign="middle" >32</td><td align="center" valign="middle" >145.50</td><td align="center" valign="middle" >40</td></tr><tr><td align="center" valign="middle" >129</td><td align="center" valign="middle" >5143</td><td align="center" valign="middle" >52</td><td align="center" valign="middle" >7306</td><td align="center" valign="middle" >64</td><td align="center" valign="middle" >156.66</td><td align="center" valign="middle" >73</td></tr><tr><td align="center" valign="middle" >257</td><td align="center" valign="middle" >9141</td><td align="center" valign="middle" >52</td><td align="center" valign="middle" >13,182</td><td align="center" valign="middle" >128</td><td align="center" valign="middle" >147.57</td><td align="center" valign="middle" >138</td></tr><tr><td align="center" valign="middle" >513</td><td align="center" valign="middle" >15,625</td><td align="center" valign="middle" >52</td><td align="center" valign="middle" >24,938</td><td align="center" valign="middle" >256</td><td align="center" valign="middle" >125.54</td><td align="center" valign="middle" >267</td></tr><tr><td align="center" valign="middle" >1025</td><td align="center" valign="middle" >31,467</td><td align="center" valign="middle" >52</td><td align="center" valign="middle" >48,454</td><td align="center" valign="middle" >512</td><td align="center" valign="middle" >126.438</td><td align="center" valign="middle" >524</td></tr><tr><td align="center" valign="middle" >Available</td><td align="center" valign="middle" >203,800</td><td align="center" valign="middle" >445</td><td align="center" valign="middle" >407,600</td><td align="center" valign="middle" >840</td><td align="center" valign="middle" >-</td><td align="center" valign="middle" >-</td></tr></tbody></table></table-wrap><table-wrap id="table5" ><label><xref ref-type="table" rid="table5">Table 5</xref></label><caption><title> Performance of different scales</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Scale</th><th align="center" valign="middle" >Bit Size</th><th align="center" valign="middle" >Upper Limit Frequency</th><th align="center" valign="middle" >System Clock Frequency</th><th align="center" valign="middle" >Latency Measure from <xref ref-type="fig" rid="fig9">Figure 9</xref> and <xref ref-type="fig" rid="fig1">Figure 1</xref>0</th></tr></thead><tr><td align="center" valign="middle" >33</td><td align="center" valign="middle" >12</td><td align="center" valign="middle" >6 MHz</td><td align="center" valign="middle" >100 MHz</td><td align="center" valign="middle" >320 ns</td></tr><tr><td align="center" valign="middle" >65</td><td align="center" valign="middle" >12</td><td align="center" valign="middle" >3 MHz</td><td align="center" valign="middle" >100 MHz</td><td align="center" valign="middle" >502 ns</td></tr></tbody></table></table-wrap><p>33 is selected, the latency is around 320 ns. This latency is a combination of ADC latency and algorithm calculation latency. When scale 65 is selected, total latency becomes around 502 ns because the window scale increases. Accordingly, the more the scale increases, the less the upper limit frequency becomes. The upper limit frequency is obtained by increasing the frequency from signal generator up to losing output signal.</p><p><xref ref-type="table" rid="table5">Table 5</xref> provides information on latency and maximum upper limit frequency for different scales with a fixed bit size and system clock frequency. This table shows the evaluation result of the two different scales of 33 and 65. Furthermore, upper limit frequencies indicated the maximum time step of execution of the algorithm.</p><p>While the system is operating, the delay time is composed of two critical parts as algorithm calculation and converter as well as transmitting wire. For instance, when we implemented scale 65, we detected 502 ns total latency time from the oscilloscope screen depicted in <xref ref-type="fig" rid="fig1">Figure 1</xref>4. To calculate its component for the calculation of algorithm, latency clock cycle at scale 65 in <xref ref-type="table" rid="table4">Table 4</xref> is divided by constraint system clock frequency (100 MHz) first so that algorithm calculation time is found as 40/100 = 0.4 [μs] = 400 [ns]. Then, it was subtracted from the total latency time, 502 ns, read from the oscilloscope in <xref ref-type="fig" rid="fig1">Figure 1</xref>4, in order to calculate the converter and transmitting wire part as 502 [ns] - 400 [ns] = 102 [ns]. <xref ref-type="fig" rid="fig1">Figure 1</xref>2 shows detail about latency for scale 65.</p><p>This calculation is repeated for the scale 33 to make the distribution of latency time clearer and understandable. At scale 33, total latency time is measured as 320 ns from the oscilloscope screen in <xref ref-type="fig" rid="fig1">Figure 1</xref>5. From <xref ref-type="table" rid="table4">Table 4</xref>, algorithm calculation time is found by dividing the latency clock cycle by constraint system clock frequency (100 MHz). So it is calculated as 23/100 = 0.23 [μs] = 230 [ns]. After that, when this time is subtracted from total latency measure, converter and transmitting wire part can be calculated as 320 [ns] - 230 [ns] = 90 [ns]. <xref ref-type="fig" rid="fig1">Figure 1</xref>3 shows detail about latency for scale 33.</p><p><xref ref-type="fig" rid="fig1">Figure 1</xref>4 and <xref ref-type="fig" rid="fig1">Figure 1</xref>5 are snapshots of experimental results with different scales on FPGA by using an oscilloscope. These results prove that a designed</p><p>algorithm can effectively detect all peak points on the positive edge. <xref ref-type="fig" rid="fig1">Figure 1</xref>4 illustrates that designed algorithm can fully detect all peak points on the positive edge. This algorithm produces the peak points with synchronized 3.00 MHz sinusoidal signals. This implementation result shows scale 65, 12 bit size and around 502 ns total latency time and a maximum frequency of around 3 MHz. <xref ref-type="fig" rid="fig1">Figure 1</xref>5 shows all of the peak points on positive edge with synchronizing 6.148 MHz sinusoidal signal. This implementation result shows scale 33, 12 bit size, around the 320 ns latency time and a maximum frequency of around 6 MHz.</p></sec></sec><sec id="s5"><title>5. Conclusions</title><p>In this paper, a novel modified AMPD method was implemented on an FPGA. It was highlighted that the modified AMPD mechanism could be implemented as a pipelined hardware on an FPGA, and that fast detection latencies (320 ns and 502 ns for scales 33 and 65) could be achieved with a reasonable amount of hardware resources by slightly modifying the original on-line algorithm to fit the off-line processing. It was also demonstrated that the modified AMPD mechanism detects peak points from noisy time series data of the phase-to-phase effective voltage values of a medium-voltage transformer located in the Organized Industrial Zone.</p><p>Thus, modified AMPD algorithm has been proposed and evaluated by using different scales on an FPGA board. The proposed approach has achieved real-time peak detection based on AMPD algorithm on an FPGA. The latency was also presented at different scales from 33 to 1025. The codes written in real time were implemented and results were compared with simulation results to achieve the main target of this study. Although both scales can effectively detect the peak points, the latency was taken into account for the performance on the ADC and algorithm calculating time. So peak sensitivities obtained from on-line original AMPD were compared with the sensitivities obtained from off-line modified algorithm using the same data. It was observed that scales 33, 65, 129 and 257 produced more or less successful results. In terms of the peak sensitivities, scales 33 and 65 produced similar results as the original AMPD that was proposed in this study. That means the proposed novel mechanism can be used as an off-line robust and real-time peak detection algorithm by combining the AMPD algorithm and the FPGA technology.</p></sec><sec id="s6"><title>Conflicts of Interest</title><p>The authors declare no conflicts of interest regarding the publication of this paper.</p></sec><sec id="s7"><title>Cite this paper</title><p>Colak, A.M., Manabe, T., Shibata, Y. and Kurokawa, F. (2018) Peak Detection Implementation for Real-Time Signal Analysis Based on FPGA. Circuits and Systems, 9, 148-167. https://doi.org/10.4236/cs.2018.910016</p></sec></body><back><ref-list><title>References</title><ref id="scirp.88235-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Scholkmann, F., Boss, J. and Wolf, M. (2012) An Efficient Algorithm for Automatic Peak Detection in Noisy periodic and Quasi-Periodic Signals. Algorithms 2012, 5, 588-603. https://doi.org/10.3390/a5040588</mixed-citation></ref><ref id="scirp.88235-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Jacobson, M. (2001) Auto-Threshold Peak Detection in Physiological Signals. Technical Report, DTIC Document.</mixed-citation></ref><ref id="scirp.88235-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Ding, F., Booth, C.D. and Roscoe, A.J. (2016) Peak-Ratio Analysis Method for Enhancement of LOM Protection Using M-Class PMUs. IEEE Transactions on Smart Grid, 7, 291-299. https://doi.org/10.1109/TSG.2015.2439512</mixed-citation></ref><ref id="scirp.88235-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Belkaid, A., Gaubert, J.P. and Gherbi, A. (2017) Design and Implementation of a High-Performance Technique for Tracking PV Peak Power. IET Renewable Power Generation, 11, 92-99. https://doi.org/10.1049/iet-rpg.2016.0023</mixed-citation></ref><ref id="scirp.88235-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Du, P., Kibbe, W.A. and Lin, S. (2006) Improved Peak Detection in Mass Spectrum by Incorporating Continuous Wavelet Transform-Based Pattern Matching. Bioinformatics, 22, 2059-2065. https://doi.org/10.1093/bioinformatics/btl355</mixed-citation></ref><ref id="scirp.88235-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Nenadic, Z. and Burdick, J.W. (2005) Spike Detection Using the Continuous Wavelet Transform. IEEE Transactions on Biomedical Engineering, 52, 74-87.  
https://doi.org/10.1109/TBME.2004.839800</mixed-citation></ref><ref id="scirp.88235-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Goodfellow, J., Escalona, O.J., Kodoth, V., Manoharan, G. and Bosnjak, A. (2016) Denoising and Automated R-Peak Detection in the ECG Using Discrete Wavelet Transform. Computing in Cardiology Conference (CinC), Vancouver, 1045-1048.</mixed-citation></ref><ref id="scirp.88235-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Das, S., Mukherjee, S., Chatterjee, S. and Chatterjee, H.K. (2016) Noise Elimination and ECG R Peak Detection Using Wavelet Transform. Ubiquitous Computing, Electronics &amp; Mobile Communication Conference (UEMCON), IEEE Annual, New York, 1-5. https://doi.org/10.1109/UEMCON.2016.7777876</mixed-citation></ref><ref id="scirp.88235-ref9"><label>9</label><mixed-citation publication-type="other" xlink:type="simple">Thiamchoo, N. and Phukpattaranont, P. (2016) Application of Wavelet Transform and Shannon Energy on R Peak Detection Algorithm. 13th International Conference on Computer, Telecommunications and Information Technology (ECTI-CON), Chiang Mai, 1-5. https://doi.org/10.1109/ECTICon.2016.7561280</mixed-citation></ref><ref id="scirp.88235-ref10"><label>10</label><mixed-citation publication-type="other" xlink:type="simple">Li, Q., Zhang, W., Li, M., Niu, J. and Wu, Q.M.J. (2017) Automatic Detection of Ship Targets Based on Wavelet Transform for HF Surface Wavelet Radar. IEEE Geoscience and Remote Sensing Letters, 14, 714-718.  
https://doi.org/10.1109/LGRS.2017.2673806</mixed-citation></ref><ref id="scirp.88235-ref11"><label>11</label><mixed-citation publication-type="other" xlink:type="simple">Khan, G.K. and Sawant, A.G. (2016) Spartan 6 FPGA Implementation of 2D-Discrete Wavelet Transform in Verilog HDL. 2016 IEEE International Conference on Advances in Electronics, Communication and Computer Technology (ICAECCT), Pune, 139-143. https://doi.org/10.1109/ICAECCT.2016.7942570</mixed-citation></ref><ref id="scirp.88235-ref12"><label>12</label><mixed-citation publication-type="other" xlink:type="simple">Palshikar, G. (2009) Simple Algorithms for Peak Detection in Time Series. Proc. 1st Int. Conf. Advanced Data Analysis, Business Analytics and Intelligence, Ahmedabad.</mixed-citation></ref><ref id="scirp.88235-ref13"><label>13</label><mixed-citation publication-type="other" xlink:type="simple">Khatri, K.L. and Tamil, L. (2017) Early Detection of Peak Demand Days of Chronic Respiratory Diseases Emergency Department Visits Using Artificial Neural Networks. IEEE Journal of Biomedical and Health Informatics, 22, 285-290.   
https://doi.org/10.1109/JBHI.2017.2698418</mixed-citation></ref><ref id="scirp.88235-ref14"><label>14</label><mixed-citation publication-type="other" xlink:type="simple">Sumukha, B.N., Kumar, R.C., Bharadwai, S.S. and George, K. (2016) A Novel Approach to Peak Detection Using Sequential Learning Algorithm. 2nd International Conference on Contemporary Computing and Informatics (IC3I), IEEE, Noida, 1-6.</mixed-citation></ref><ref id="scirp.88235-ref15"><label>15</label><mixed-citation publication-type="other" xlink:type="simple">Crema, C., Depari, A., Flammini, A. and Vezzoli, A. (2016) Efficient R-Peak Detection Algorithm for Real-Time Analysis of ECG in Portable Devices. Sensors Applications Symposium (SAS), IEEE, Catania, 1-6.</mixed-citation></ref><ref id="scirp.88235-ref16"><label>16</label><mixed-citation publication-type="other" xlink:type="simple">Dora, C. and Biswal, P.K. (2016) Robust ECG Artifact Removal from EEG Using Continuous Wavelet Transformation and Linear Regression. 2016 International Conference on Signal Processing and Communications (SPCOM), IEEE, Bangalore, 1-5. https://doi.org/10.1109/SPCOM.2016.7746620</mixed-citation></ref><ref id="scirp.88235-ref17"><label>17</label><mixed-citation publication-type="other" xlink:type="simple">Annam, J.R. and Surampudi, B.R. (2016) Inter-Patient Heart-Beat Classification Using Complete ECG Beat Time Series by Alignment of R-Peaks Using SVM and Decision Rule. International Conference on Signal and Information Processing (IConSIP), IEEE, Vishnupuri, 1-5. https://doi.org/10.1109/ICONSIP.2016.7857480</mixed-citation></ref><ref id="scirp.88235-ref18"><label>18</label><mixed-citation publication-type="other" xlink:type="simple">Aqil, M., Jbari, A. and Bourouhou, A. (2016) Adaptive ECG Wavelet Analysis for R-Peaks Detection. 2016 International Conference on Electrical and Information Technologies (ICEIT), IEEE, Tangiers, 164-167.  
https://doi.org/10.1109/EITech.2016.7519582</mixed-citation></ref><ref id="scirp.88235-ref19"><label>19</label><mixed-citation publication-type="other" xlink:type="simple">Park, J.S., Lee, S.W. and Park, U. (2017) R Peak Detection Method Using Wavelet Transform and Modified Shannon Energy Envelope. Journal of Healthcare Engineering, 2017, 1-14. https://doi.org/10.1155/2017/4901017</mixed-citation></ref><ref id="scirp.88235-ref20"><label>20</label><mixed-citation publication-type="other" xlink:type="simple">Qin, Q., Li, J., Yue, Y. and Liu, C. (2017) An Adaptive and Time-Efficient ECG R-Peak Detection Algorithm. Journal of Healthcare Engineering, 2017, 1-14.  
https://doi.org/10.1155/2017/5980541</mixed-citation></ref><ref id="scirp.88235-ref21"><label>21</label><mixed-citation publication-type="other" xlink:type="simple">Singh, A., Dubey, S. and Bhatia, M. (2013) Design and Simulation of FPGA Based Digital System For Peak Detection and Counting. IJARCSSE, 3, 804-807.</mixed-citation></ref><ref id="scirp.88235-ref22"><label>22</label><mixed-citation publication-type="other" xlink:type="simple">Ma, M. (2005) Developing and Implementing Phase Normalization and Peak Detection for Real-Time Image Registration. Ph.D. Thesis, Master’s Thesis, Delft University of Technology.</mixed-citation></ref><ref id="scirp.88235-ref23"><label>23</label><mixed-citation publication-type="other" xlink:type="simple">Colak, A.M., Shibata, Y. and Kurokawa, F. (2016) FPGA Implementation of the Automatic Multiscale Based Peak Detection for Real-Time Signal Analysis on Renewable Energy Systems. 5th International Conference on Renewable Energy Research and Applications (ICRERA), Birmingham, 379-384.</mixed-citation></ref><ref id="scirp.88235-ref24"><label>24</label><mixed-citation publication-type="other" xlink:type="simple">Kintex-7 XC7K325T Evaluation Kit.  
https://www.xilinx.com/products/boards-and-kits.html</mixed-citation></ref></ref-list></back></article>