ASN consultancy could answer the question with an ultrasonic bistatic sensor. However, our developers needed first to design an analog front-end (AFE) hardware PCB (printed circuit board) for transmitting and receiving the ultrasonic signals.
The AFE was then coupled to a DAQ (data acquisition module) for sampling. A sampling rate of 250kHz was chosen to capture the reflected 40kHz ultrasonic pulses.
Data analysis and algorithms
Loading the captured datasets into the ASN filter designer’s signal analyser, designing an FIR Hilbert filter and filtering the data, we were able obtain a time domain envelope of the received signal. The envelope was passed through the tool’s Advanced time domain analysis block, and positions of the peaks (pertaining to the top and bottom of the mug) localised via Savitzky-Golay data analysis for robust differentiation.
Our developers found that by looking the 3rd derivative we could accurately determine where the edge (top) and bottom of the mug was. The plot shown below illustrates the concepts, whereby the first peak pertains to the top of the mug and second (much larger) pertains to the bottom. The time domain envelope from the FIR Hilbert filter is shown in red.
Captured data: ultrasounic echo data and envelope (red)
Real-time tracking during filling
Armed with the top and bottom location information, we were able to begin tracking the coffee during the filling process. The basic idea was to track the largest peak of time domain envelope as it moved from right, i.e. from the bottom of the mug to left (the top of mug). Inconsistencies in peak location readings due to ripples and vibrations in the liquid were filtered out via a median filter.
The result for the client
A working prototype for around 10 EUR, that was able to accurately fill various type of coffee mug and tea cups. The system also worked well in the presence of milk foam (from cappuccinos, latte etc).