Implementation of DOA Estimation System Based on HackRF One

. In the practical direction of arrival (DOA) estimation applications, it is required that the multichannel signal acquisition equipment can synchronously collect the signals received by the array antenna. In addition, the signal phase relationships between channels are supposed to be stable. However, this kind of equipment is usually complex and expensive to manufacture. Since some SDR devices are reconfigurable and open source, this paper adopts HackRF Ones as the signal sampling devices to design the DOA estimation system. The clocks line is used to synchronize the clock frequencies between HackRF Ones. Besides, an external pulse is introduced to control the sampling devices to start sampling simultaneously. In this case, the stable phase difference between channels can be obtained. The experimental results show that the synchronization error between channels of the system is less than one sampling period. The system can be used to estimate the incident angles of single carrier signals or modulated signals. The RMS errors of the system when estimating one source and two sources are 1.94 ° and 2.85 ° , respectively.


Introduction
DOA estimation is an important part of array signal processing.Nowadays, it has been applied in many elds such as wireless communication, navigation, speech processing, sonar, radar, and radio astronomy [1].ere are many algorithms with high precision and low computational complexity, such as MUSIC (Multiple Signal Classi cation) [2], ESPRIT (Estimation of Signal Parameters via Rotational Invariable Techniques) [3], and PM (Propagator Method) [4].However, the RF channels of the signal receiving equipment used for DOA estimation should be time-synchronized and phase-coherent, and such equipment is expensive and complicated to manufacture.erefore, these algorithms are limited in the actual direction nding process.
e MUSIC algorithm has been implemented in FPGA [5], and the estimation error is less than 2 °in the range of −30 °to 30 °.In [6], a real-time direction of arrival estimator based on DSP is designed.
is estimator can e ectively estimate the direction of the underwater sound source, and the estimated error is about 4 °when the SNR is 4.4 dB.In [7], the received signals of two subarrays are synchronized.e synchronization process of signal acquisition is divided into two stages.Firstly, the time and frequency synchronization of the two subarrays is realized by using the joint maximum likelihood optimization (JML).en, the least mean square algorithm (LMS) and maximum likelihood algorithm (ML) are used to achieve phase consistency between the two subarrays.e average estimation error of this system is 4.1 °.
Software De ned Radio (SDR) takes hardware as the platform of wireless communication but uses software to change the frequency, bandwidth, and other parameters.In this way, the communication system can be made out of the constraints of hardware structure as much as possible [8].Using SDR not only makes it easy to debug and maintain but also can reduce the development cost and shorten the development period.SDR platform is well suitable to sample signals from antenna arrays synchronized in both time and frequency because its hardware and software are mostly open source and adjustable.At present, most direction nding equipment based on SDR is implemented by USRPs.
For example, two USRPs were used to estimate the direction of the signal source in [9][10][11].e angle estimation error in [9] is about 3 °.e system in [10] has an RMS error of 2.14 °and 2.49 °when estimating one source and two sources, respectively.In [11], experiments were carried out under three different environments, and the mean square error of angle estimation is less than 0.3 °.But the system can only correctly estimate angles greater than 30 °.In addition, there are two spectral peaks that are symmetry about 90 °, and one of them is a pseudospectral peak when estimating one source.erefore, some prior information is required for estimating.DOA estimation using USRP is costly, which is not conducive to the practical application of DOA estimation.
In order to solve the problems of high computation, high cost, and low acquisition accuracy of existing direction finding systems, this paper designs a DOA estimation system based on HackRF One, which is a low-cost SDR equipment.
e system uses the clock synchronization line to synchronize the clock frequencies between HackRF Ones, which achieves frequency synchronization.By modifying the code of the CPLD in HackRF One, multiple synchronization devices start sampling at the same time under the control of the time synchronization pulse signal, which realizes the synchronization of time.
e structure of the system is simple, the number of elements is small, and the cost is low.
e system has a wide application prospect.

Design of the DOA Estimation System
2.1.Fundamentals of DOA Estimation.DOA estimation refers to processing complex observation data received by an antenna array to estimate the direction of the signal [12].
Figure 1 shows a diagram of a DOA estimation system using the uniform linear array (ULA).In this figure, represents the angle between the incident direction and the normal, which is the angle to be estimated.If the distance between the receiving array and the radiation sources satisfies the far-field condition, the waves reaching the array can be considered plane waves.As shown in Figure 1, the number of array elements is M, the speed of light is c, the phase difference between array elements is φ, and the spacing of array elements is d.If there are N far-field narrow-band signals incident on the array, the delay between adjacent array elements is e delay of the ith signal received by the lth element is denoted by τ li τ li ; then, the received signal of the lth array element is as follows under ideal conditions.
where g li is the gain of the lth array element to the ith signal, and n l (t) is the noise of the lth array element at time t.S i (t) represents the incident signal.e signals received by M elements at a specific time form a column vector as In terms of the essence of DOA estimation, the delay of the signal arriving at adjacent array elements is caused by the wave path difference, as shown in (1).Furthermore, this wave path difference produces the phase difference shown in (4).e direction of the signal can be estimated based on the phase difference.erefore, when collecting the received signal, it is necessary to ensure that the signal phase difference between the array elements is accurate.
where λ and f are the wavelength and frequency of the signal, respectively.e matrix form of (2) is as follows: where A(θ) is the array manifold.
a i (ω) is the steering vector, and ω is the angular frequency.
e goal of DOA estimation is to use received P snapshots (x(1), . . ., x(P)) to estimate the incident directions of N signals (θ 1 , θ 2 , . . ., θ N ) through some algorithm.In addition, taking the sinusoidal signal as an example, the ith incident signal is shown in According to this formula, the instantaneous phase of the signal depends on time t, frequency f, and the initial phase ϕ 0 .erefore, in order to ensure the stability of phase difference, the frequency of the different receiving channels should be the same, and the start sampling moments of these channels are also supposed to be consistent.

Algorithm for DOA Estimation.
MUSIC algorithm is adopted by the system for DOA estimation.According to the basic principle of the MUSIC algorithm, the covariance matrix of the received data should be calculated first.In practical application, the maximum likelihood estimation of the covariance matrix R � E[XX H ] can be obtained by sampling data as follows: By eigendecomposition of R, the following formula can be obtained.
In the formula, U S is the subspace spanned by the eigenvectors corresponding to large eigenvalues, that is, the signal subspace.U N is the subspace spanned by the eigenvectors corresponding to small eigenvalues, that is, the noise subspace.According to the MUSIC algorithm, the spatial spectrum of ULA is as follows: e incident direction of the signal source θ can be obtained by searching the spectrum peak in the search range of the signal.

Synchronous Acquisition Scheme. In this paper, HackRF
One, a low-cost SDR device, is used as the array signal acquisition device.It can work in the frequency range of 1 MHz to 6 GHz and supports 8-bit sampling with a sampling rate of up to 20 Msps.It works in half-duplex mode [13].HackRF One has SMA clock input/output ports and a number of extension interfaces, which can facilitate the synchronous reception of signals.Its hardware architecture in receiving mode is shown in Figure 2.
e signal received by the antenna is amplified by LNA at the RF front end, and then the signal is downconverted to IF through the wideband mixer RFFC5072.Next, the IF signal is downconverted to baseband by MAX2837.e baseband signal is discretized by the ADC MAX5864 to generate the digital signal.After being processed by CPLD (Xilinx XC2C64), the signal is sent to the microcontroller NXP LP4330 through the parallel bus.Finally, the data is sent to the PC through the USB interface for display and postprocessing.
e signal synchronization scheme based on HackRF One mainly consists of two parts: frequency synchronization and time synchronization.Firstly, the clocks of different sampling channels are kept consistent by the same frequency source and kept stable during the sampling period.In addition, different channels start sampling under the control of the same trigger signal.As a result, the phase difference between channels can be stabilized.
e system block diagram of the synchronous acquisition system is shown in Figure 3.To synchronize the clock frequencies of the two HackRF One ( # 1 and # 2), we introduce another HackRF One ( # 0) and use its output clock signal as the input clock signal for the device # 1 and # 2 to be synchronized.In addition, we modify the source code of HackRF One # 1 so that the extended pin (SYNC_CMD) of its CPLD can output a pulse signal, which is connected to the SYNC_IN pins of HackRF One # 1 and # 2. It is used as a trigger signal to control the two devices to start sampling simultaneously [14].
Figure 4 shows a detailed hardware connection diagram.In the figure, HackRF One # 0 is the device that outputs the reference clock signal.e CLK_OUT port of this device will output a 10 MHz, 0V-3 V square wave signal after power-on.To achieve frequency synchronization, we use the clock synchronization lines to draw out the clock signal from this port and connect it to the CLK_IN of HackRF One # 1 and # 2.
e SYNC_CMD signal of HackRF One # 1 is used as the synchronization pulse, which is connected to the SYNC_IN of the two synchronization devices through the DuPont lines and the breadboard.Finally, the three devices are connected together for common ground.
In the receiving mode, as shown in Figure 5, CODEC_CLK is the clock signal.e ADC transmits the I channel of ADC_DATA to the CPLD on the rising edge of CODEC_CLK, and the Q channel of ADC_DATA on the falling edge.e CPLD begins to transmit data to the MCU when the CODEC_X2_CLK signal rises.When the MCU starts to record data, the HOST_DISABLE signal is set to "0" and the HOST_CAPTURE is "1." e specific synchronization process is as follows.At the rising edge of the SYNC_IN signal, the signal is stored in a latch to ensure that the signal remains at a high level throughout the data transmission.When the SYNC_IN's latch signal is "1" and the HOST_DISABLE signal is "0", the HOST_CAPTURE signal is set to "0" and the data is recorded.Part of the CPLD's VHDL code is shown in Figure 6.In this code, multiple devices can simultaneously start sampling by introducing the same external trigger pulse signal.
In addition to time synchronization, we also need to achieve frequency synchronization through a hardware connection so that several devices use the same external clock source.Before the synchronization mode is started, the "hackrf_debug -d series number--si5351 -n 0 -r" command is used to judge whether the CLK_IN port of HackRF One is connected to an external clock signal.If the output is 0 x 01, it means that the CLK_IN port is connected to an external International Journal of Antennas and Propagation clock signal.en, the "hackrf_transfer -H" command is used to start the synchronous mode of HackRF One; the collected synchronous data can be transmitted to the computer.

Antenna Arrays for DOA Estimation.
In this paper, a four-element ULA is used for DOA estimation, and the synchronous acquisition system needs to be extended to four devices.e hardware connection is modified on the basis of Figure 4. e same 10 MHz clock source is connected to the CLK_IN ports of the four devices, and then their SYNC_IN pins are connected to the same time pulse signal to realize the synchronous acquisition.
Figure 7 shows the photo of the array used in the experiment.e transmitting signal frequency is 2.5 GHz, so the signal wavelength λ � c/f � 0.12 m.In order to avoid ambiguity and reduce the influence of mutual coupling effects, the distance between the neighboring antennas is set to d � λ/2 � 6 cm.

Synchronization Error between Channels.
In order to verify the synchronization performance of the system, an oscilloscope is used to observe the clock signal that is input to the two synchronous devices at CLK_IN.As shown in Figure 8, the frequency signals input to the two devices have a good consistency; that is, the two devices operate at the same frequency.In addition, the SYNC_CMD of HackRF One is examined with an oscilloscope.At the moment of power-on, a 3.3 V step signal can be observed at this pin.It is under the control of the SYNC_CMD that the synchronous device starts sampling at the same time.
Next, the synchronization error between channels is tested in an open environment.
e experimental environment requires no obstruction within the receiver and the transmitter and no strong interference within the frequency band.
e configuration of the experimental devices is shown in Figure 9. e distance between the transmitter and receivers should meet the far-field condition; that is, L should be at least greater than 3∼4 wavelengths; let L � 5 m.
e length of the RF lines connected between two HackRF Ones and the antennas should be equal.e transmitting antenna is fixed on the centerline of BC.In this case, the lengths of AB and BC in Figure 9 are equal, so that the received signals of the two channels can be guaranteed to have the same delay relative to the transmitting signal.
e sampling rate of HackRF Ones is set to 2 MHz, 5 MHz, 10 MHz, and 20 MHz, respectively.e synchronization error is obtained by calculating the correlation function of the sampled signal between two channels and Lagrange interpolation near the peak point.1000 experiments were repeated for each sampling rate.We counted the synchronization errors of each group of experiments and calculated the probability distribution of the synchronization errors.en, the distribution of the probability density function (PDF) is obtained as shown in Figure 10.
As can be seen from this figure, when sampling rates are 2 MHz, 5 MHz, 10 MHz, and 20 MHz, respectively, the synchronization errors between channels are not more than International Journal of Antennas and Propagation 5 500 ns, 200 ns, 100 ns, and 50 ns, respectively.at is, the synchronization errors are all within one sampling period.is indicates that the frequency and sampling start times of different channels are consistent well.e phase noise of the device itself and multipath reflection of the environment leads to synchronization errors between channels.

Correction of the Phase Difference between Channels.
In theory, the stable phase difference can be obtained after time and frequency synchronization of the receiving channel is completed.e stable phase difference is composed of two parts, one of which is caused by the array spacing; In addition, local oscillators (LOs) in different HackRF Ones are independent of each other, and such independent LOs cause a fixed phase difference between different channels [15].Take the system shown in Figure 8 as an example.According to the IQ signals received by the 4 channels, the phase of signals can be calculated.Next, using channel 1 as a reference, the phase difference between other channels and channel 1 is calculated.e calculation results are shown in Figure 11.e standard deviation of the phase difference is about 7 °.e phase difference can be corrected as follows.Calculate the fixed phase difference from the multichannel collected signals with a known direction of arrival, and then eliminate the fixed phase difference of the collected signals to be measured.e fixed phase difference remains unchanged after power-on.erefore, the calculation and calibration of the fixed phase difference are performed once after each power-on, and the receiving devices are guaranteed to be uninterrupted during the subsequent DOA estimation.As shown in Figure 12, the transmitting device is placed at the position of incident angle 0 °.Although the distance meets the far-field condition, the positions of the receiving devices will still cause a small phase difference at this position.e distance between channel 1 and the transmitting equipment is equal to the distance between channel 4 and the transmitting equipment, so the phase difference between channel 1 and channel 4 should be 0 °in theory.As shown in the second column of Table 1, the phase difference between channel 2, channel 3, channel 4, and channel 1 is −2.3 °, −2.3 °, and 0 °, respectively.e fixed phase difference between channels can be obtained by subtracting the phase difference caused by array spacing from the total phase difference between the channels.e phase difference between channels after calibration is shown in Figure 13.Table 1 shows the phase difference between channel 1 and other channels before and after correction.

DOA Estimation.
After calibrating the phase difference between channels, the MUSIC algorithm can be used to estimate the direction of arrival.In this paper, three different DOA estimation experiments are carried out: one single carrier signal, one LoRa signal, and two LoRa signal sources.

DOA Estimation of a Single Carrier Signal.
e direction finding experiment was carried out in a relatively open environment with no obstruction within the line of sight and less interference near the tested frequency.According to the DOA estimation system designed in the previous section, four HackRF Ones are set as synchronous receiving mode, with frequency f � 2500 MHz and sampling rate f � 2 MHz. e distance between the receiving devices and the transmitting device shall meet the far-field condition (at least greater than 3∼4 wavelengths).
e distance   International Journal of Antennas and Propagation requirement can be met by setting r � 470 cm.Firstly, phase difference calibration is carried out at the position where the incident angle is 0 °.Next, the transmitting device is placed at four positions as shown in Figure 14, and four devices are set to synchronously sample transmitting signals.After phase difference calibration of the received signal, the spatial spectrum estimated by the MUSIC algorithm is shown in Figure 15.e spatial spectrum in this figure is estimated from 1000 snapshots, and the SNR of the four channels is between 15 dB and 28 dB.e solid and dotted lines in Figure 15 represent the experimental results and the simulation results of corresponding positions respectively.
Table 2 shows the actual incident angle calculated from the distance relationship in Figure 14. e third row of the table shows the average angles estimated by this system using the MUSIC algorithm (Table 2).
More experiments were performed at different positions.Figure 16(a) shows the relationship between the actual angle and the average DOA estimation angle.e average error of the angle estimation is 1.7 °, and the RMS error is 1.94 °. e change of MSE with the number of snapshots is shown in Figure 16(b).It can be seen from the figure that the estimated variance decreases with the increase of the number of snapshots and tends to be stable when the number of snapshots is greater than 400.

DOA Estimation of LoRa.
In order to verify whether the system is effective for modulated signals, we use LoRa signals to conduct DOA experiments.LoRa RF physical layer uses a modulation form based on chirp spread spectrum (CSS). is modulation method enables it to resist interference and multipath fading effectively [16].
e main operating frequency of the LoRa signal is 433 MHz.In our experiment, we used HackRF Ones to record LoRa signals.
To experiment with the antenna array in Figure 7, the signal frequency was upconverted to 2500 MHz as the transmitting source.We placed the signal source at the incident angle of 17.7 °, and the experimental operation was similar to the estimation of a single carrier signal.We set the receiving sampling rate to 2 MHz and used 500 snapshots for the calculation.18 represents the results (Table 3) of five groups of experiments, and the dotted red line represents the simulation results at the corresponding positions of each group of experiments.
In combination with Figure 18 and Table 3, it can be seen that when the interval angle between the two sources is large, two independent spectral peaks can be clearly seen in the spectrum peak diagram.As the incidence angle of the two    International Journal of Antennas and Propagation sources is gradually close to each other, the two spectral peaks are also gradually difficult to distinguish.When the incident angle difference is 16.1 °, the system has been completely unable to distinguish the two sources.Experimental results show that when the system estimates two sources simultaneously, the resolution is about 22.6 °and the RMS error is 2.85 °. is error is slightly larger than the error when estimating a single source.Compared with the simulation results, the resolution of the experimental results is poor. is may be the amplitude and phase error caused by the multipath effect and ambient noise in the experimental site.Although the experiment was carried out in an empty field as far as possible, this effect could not be completely avoided.In addition, inconsistencies in the receiving channel itself and manual construction will also produce amplitude and phase errors.e steering vector a i (ω) will change due to the amplitude and phase error, which will lead to the change in the array manifold A(θ) and covariance matrix R � E[XX H ]. Furthermore, the spectral peak of the MUSIC spatial spectrum will be reduced and broadened, which will affect the angular resolution of the system [17].
Compared with the experimental results in [10], in the case of using the same estimation algorithm and sampling rate, the RMS error of our system is smaller when testing one source.In addition, we used fewer snapshots in the calculation.In other words, for single source DOA estimation, the system has higher accuracy, faster calculation speed, and lower cost.However, the accuracy and resolution of our system are not as good as those of the system in [10] when testing two sources, which is what we need to improve in the next step.

Conclusion
is paper designs a DOA estimation system based on HackRF One.We use these devices to collect the signal received by the array antenna and achieve synchronization between channels.e experimental results show that (1) the synchronization error can be controlled within one sampling period, (2) the average angle error of a single source is 1.7 °when the sampling rate is 2 MHz, and (3) it can be effectively applied to the angle estimation of two LoRa signal sources.
e system has the advantages of low cost, high estimation accuracy, and low requirement on computer performance, which makes it widely applicable to DOA estimation in an indoor location, airborne direction finding, and other practical applications.

Figure 1 :
Figure 1: Diagram of the DOA estimation system.

igure 12 :
e I signals received by the four receiving devices are shown in Figure 17(b).e solid and dotted lines in Figure 17(a) represent the spatial spectrum of experiment and simulation, respectively.e peak value of the spatial spectrum appears at the position of incident angle 16.Diagram of phase difference correction experiment.

Figure 18 :
Figure 18: DOA estimation of two LoRa signal sources.

Table 1 :
Correction of phase difference.

Table 2 :
e results of DOA estimation.In order to verify the wide applicability of this system, we estimated the signal incidence angle of two LoRa signals at the same time.In order to reduce the coherence between two signals, we set the signal frequencies of the two transmitting sources as f 1 � 2500.023MHz and f 1 � 2500.023MHz, respectively.e receiving sampling rate was set to 2 MHz, and 500 snapshots were used for calculation.Using the experimental method similar to the above, we conducted DOA experiments of two sources at different locations.e solid blue line in Figure

Table 3 :
e results of DOA estimation.