## 7 Experiments
### Results and Discussions  
Figure 8 shows the comparison between the implemented solution with RF switch compensation (a) and the one without it (b). Both were implemented in MATLAB. The implemented solution without the RF switch compensation is totally inaccurate, whereas the one with it attains much better accuracy as the SNR increases which demonstrates the effectiveness of such compensation. As previously explained, this experiment was the only one carried out totally in a simulation environment. For the next experiments, the implemented solution was run in an nRF52840 SoC. Accuracy is the most important performance criterion of a DOA method. Some companies [53; 54] reported an average accuracy of about 5 degrees with an average position accuracy of around 1 m. Thus, it would be desirable for the implemented solution to achieve such a value. Figure 9 shows the RMSE of the accuracy for each SNR run in an nrf52840 SoC, which have almost the same values as one in MATLAB. We clearly see that as the noise decreases the accuracy improves. However, low accuracy is observed between SNR 5-10 dB. However, it should not be a concern since the minimum SNR value for Bluetooth to operate reliably is between 10-15 dB. With less than 10 dB, it is most likely that the receiver fails to decode and the cyclic redundancy check fails as well [55]. With SNR slightly higher than 10 dB, the RMSE values attain less than 5 degrees, reaching our desired result. Nevertheless, the experiments did not consider non-idealities of the antenna array and RF front-end; in fact, the antennas have an ideal isotropic characteristic. As mentioned previously, the implemented solution considers an ideal array response. Since those imperfections deteriorate the accuracy, one should compute a real array response and use it in the implemented solution. The real array response should attenuate the problem, but not completely solve it. Figure 8: The implemented solution with RF switch compensation (a) and without it (b) run in a simulation (MATLAB). Table 3 shows each main operation of the implemented solution with its respective stack memory consumption and relative execution time. All operations have a stack memory consumption of a few hundred bytes; thus, setting maximum stack memory to be 512 kB in the microcontroller is enough since none of the stack memory surpasses that value. The fifth operation concerns the finding-root method, which took up an incredible 83.17% of the method's execution time. It is not difficult to verify that no other operation demands so much computation as the fifth one, since finding polynomial roots composed of complex roots and coefficients is a difficult numerical computing task. Notably, Algorithm 3 tackles this problem by applying the Shifted QR Algorithm, a complicated method that requires two pre-processing methods to speed up its convergence and accuracy. On the other side of the spectrum, computing the companion matrix (four operations) is the least demanding task. It computes the polynomial coefficients defined in Equation (25), and afterward, it constructs the real companion matrix, which is \(\textbf{P}_{R}\) defined in Equation (50). Moreover, the second operation is the second most time-consuming operation. It involves computing Equation (39) and the conversion of a complex-valued into a real-valued covariance as explained in step 2 Section 4. Notably, even though the implemented solution applies the optimization (Equation 39), which reduces the computation by half and stack memory by 600 B, that operation comes in second, which shows the importance of that optimization in reducing both the execution time and stack memory. Furthermore, the third operation constitutes the Power Method (Algorithm 2), and Equations (45) and (46). As explained in Section 6, the optimization avoids the execution of an EVD method, which could be as computationally demanding as the fifth operation. Finally, the first operation is composed of Algorithm 1 and Equations (44) and (30), which are computationally inexpensive.