## 4 Result
### Resurce Consumption of FPGA  
In the current FPGA implementation, the resource consumption is as shown in Table 2 in the case of the full detection process, EMD only without any reuse of logic resource, and EMD with Time Division Multiplexing. The comprehensive results from Vivado simulations indicate a power consumption of 1.44 W for all three cases above. The primary resource expenditure is concentrated in subsequent FFT processing, modulus calculation, energy normalization, and relative entropy computation. Therefore, we believe that relying on FPGA or CPLD in collaboration with a MCU to complete this detection process is feasible. After module reuse, the resource consumption for implementing the EMD algorithm and communication is sufficient to be executed on a small FPGA with 3 k LEs. With further optimization of some processes, it might even be possible to implement it on a 2 k LE FPGA. Offloading the subsequent computations to the MCU's DSP can reduce resource consumption [20]. Modern MCUs have computational speeds for 64-point FFTs and modulus operations that approach those of FPGAs, and their performance in energy normalization and relative entropy calculations is adequate to meet the real-time processing requirements at the proposed sampling rates. Therefore, we suggest that having the MCU and FPGA collaboratively handle this process, with targeted optimizations to save the FPGA's valuable hardware resources, is a more reasonable approach. Due to funding constraint in our lab, we lack a complete testing process for FPGA experimental verification. For the part that involves the standalone EMD algorithm + FFT + calculating relative Shannon entropy output, the output accuracy is no different from that of the ESP32. The hardware resource consumption cannot be directly compared between FPGA and ESP32. When using FPGA, the delay is 0.002 ms in the no-time-multiplexed pipeline scenario and 0.008 ms in the time-multiplexed pipeline scenario, while the delay for the ESP32 is 20. 60 ms. In the detection process, two different detection methods are designed for stones at the bottom and other positions. For example, a 12 kHz high-frequency spike triggered when a stone is placed at the bottom of the coffee beans will be detected by a filter and directly trigger an alarm. For other cases, the EMD algorithm is used for detection. In the experiment, the stones and coffee beans are thoroughly mixed before being placed, and the specific location of the stones is not experimentally tested. Additionally, due to the limitations of the coffee grinder structure and laboratory equipment, the descending speed of coffee beans at different distances from the axial center of the grinder could not be measured experimentally. Therefore, the impact of the physical position of the stone on the results also could not be quantified through simulation. It is certain that because the \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Logic Resource** & **Full Process** & **EMD Only w/o Reuse** & **EMD Only with Reuse** \\ \hline LUTs & 4700 & 2094 & 1239 \\ \hline Registers & 7267 & 3751 & 2283 \\ \hline CARRY8 & 219 & 122 & 22 \\ \hline F7 Muxes & 59 & 0 & 1 \\ \hline Block RAM Tiles & 18 & 14 & 4 \\ \hline DSPs & 33 & 14 & 2 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Abnormal recognition accuracy. EMD algorithm requires a sufficiently long time series to achieve stable decomposition of the corresponding modes, there is at least a 0.5 s dead time in the detection. If the stone does not appear at the bottom of the coffee beans and descends to the grinder blade during the dead time, the detection will fail. Under the designed fixture, the geometric distance between the microphone's front-end protective cover and the center of the coffee grinder blade is approximately 50 mm. During the fixture design, we found that the method's effectiveness does not seem to be sensitive to the geometric distance and directivity between the microphone and the grinder blade, unless the microphone casing directly contacts the coffee grinder casing.