## 2 Materials and Methods
### Cost-Effective Data Acquisition System
#### 2.3.3 Signal Processing Algorithms  
This section describes the strategy to achieve the desired acoustic power, as outlined in the theoretical method detailed in Section 2.2. Alongside scripts that enhance the Arduino's data acquisition frequency, this algorithm forms the basis of an immediate platform for measuring data from thermoacoustic devices. It is important to note that in this section, the approach adopted to address the unexpected time error behavior identified in preceding studies is detailed [15]; this involves adjusting the internal quantization reference of Arduino. Specifically, the ATMega2560 converter, which typically quantizes the continuous input signal using a default 5 V output reference, allocates the total resolution bits across a 0-5 V range. This default setting was modified through the acquisition code loaded onto the board by employing the analogReference function. In the operation of ADC converters, the input signal intended for quantification is successively compared with a reference voltage. When the input signal matches the reference voltage, both precision and resolution are optimized. However, if the input value is significantly lower than the reference voltage, a substantial portion of potential comparisons and value assignments is not utilized effectively. This underutilization leads to a consequent loss in resolution, as the system is unable to fully capitalize on its comparative range and resolution capacity. To address this limitation, the function analogReference (EXTERNAL) was employed to modulate the reference voltage. This adjustment allowed for the reference voltage to match the voltage input received at the AREF pin, which was controlled via a potentiometer. By varying the input voltage in this manner, an enhancement in resolution was achieved, enabling the ADC system to better utilize its full range of comparative and resolution capabilities for enhancing resolution. In the initial stage of the signal processing workflow, R software (R Release 4.1.2, R Foundation for Statistical Computing, Vienna, Austria) and its integrated development environment, RStudio (RStudio Release 4.1.2, Posit Software, PBC, Boston, MA, USA)  
Figure 10: Illustration of the wire connection diagram of the low-cost and Brüel & Kjaer (B&K) systems. (both open-source), were employed to manage raw data. The objective was to produce a refined dataset for further analysis. An automated system was set up to systematically read all files from their storage locations, organize them, and process them according to a pre-established template. This automated preprocessing significantly reduces the time required for post-processing by standardizing the input data. Following the preparation of data, some scripts were developed in Python (Python Release 3.10.2, Python Software Foundation, Beaverton, OR, USA) using numpy, scipy, pylab, pandas, matplotlib, tabulate, and mpld3 libraries to calculate the power output of the engine under different experimental conditions, based on the input data files. The operational approach remained consistent throughout, requiring the implementation of an algorithm that fits the data within each time window to a sinusoidal function, according to Equation (6), of a harmonic wave:  
\[y(t)=Asin(\omega t+\varphi)+c \tag{6}\]  
The fitting process was conducted using fast Fourier transform (FFT), enabling the extraction of the fundamental and characteristic parameters of the wave: amplitude (\(A\)), frequency (\(f=\frac{\omega}{2\pi}\)), phase (\(\varphi\)), and offset (\(c\)). The fitting of the input data arrays to a sine function was performed using the '\(fit\_sin(t,\ y)\)' function in Python. The algorithm includes several steps that clearly outline how the sinusoidal parameters are derived from the input data:  
Start  
Generate Arrays  
Generate one array from the time data column. Generate another array from the measurement records. Compute Sample Frequencies  
Use **fft.freq** function from the numpy library to obtain the sample frequencies of the discrete Fourier transform.