A multi-level collaborative SAW exhaled breath detection system and method based on a large language model
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-19
- Publication Date
- 2026-08-11
AI Technical Summary
[0005]本发明的目的是提供一种基于大语言模型的多层级协同SAW呼出气检测系统及方法,以解决现有SAW呼出气检测装置射频参数配置门槛高、自然语言控制难以安全落到DDS寄存器、普通AIoT控制不能适配精密扫频检测、底层固件扩展成本高的问题
1)构建了自然语言语音指令到DDS频率合成器频率调谐字寄存器的端到端装置级映射通道,使非专业用户可通过语音直接驱动精密射频参数配置。
Smart Images

Figure CN122551834A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of SAW detection technology, and in particular to a multi-level collaborative SAW exhaled breath detection system and method based on a large language model. Background Technology
[0002] Surface acoustic wave (SAW) gas detection technology is a highly sensitive gas sensing method used to detect volatile gas markers such as NH3, H2S, and acetone in exhaled breath. Exhaled breath detection devices typically require point-frequency or sweep-frequency excitation near a specific center frequency, converting the device response into telemetry data such as frequency offset, amplitude, or phase. For portable SAW devices using DDS frequency synthesizers such as the AD9910, parameters such as center frequency, sweep range, frequency step, and dwell time directly affect detection stability and device safety. Currently, the mainstream technical solutions can be mainly divided into the following three categories: The first type is a benchtop laboratory testing system consisting of a SAW resonator, an independent RF source, and host computer software. This type of system connects the SAW device to the RF output of a signal generator. The host computer software sends frequency setting commands to the signal generator via a general-purpose interface bus and collects and analyzes the response data of the SAW device. The RF parameter configuration must be manually completed by the operator using the host computer software. The system lacks a device-level data channel for end-to-end mapping of natural language voice commands to signal generator register configurations, resulting in a high operational barrier for basic user scenarios. Furthermore, no hardware-level parameter pre-verification mechanism is implemented during the RF parameter initialization phase. Illegal parameters can be directly written into the register path and drive the SAW resonator, posing a structural risk of the RF output path being compromised by illegal parameters.
[0003] The second category consists of IoT environmental monitoring systems based on single-core or dual-core shared-memory microcontrollers. These systems revolve around a single microcontroller handling three tasks: sensor data acquisition, network protocol stack, and peripheral data processing. These tasks share code and data via the same internal static random access memory (SRAM). When this system is required to perform both high-throughput tasks—network communication and audio acquisition—simultaneously, the network communication task of the single microcontroller and the audio acquisition task will block each other at the CPU time-slice level and interfere with each other at the shared-memory level, leading to audio data frame loss or network communication interruptions.
[0004] The third category comprises intelligent assistant systems that apply large language models to the control of consumer-grade IoT devices. These systems deploy large language model inference services within a cloud server. User speech is converted to text by a speech recognition service and input into the large language model. The output, after simple string parsing, drives actuators that control on / off or integer quantities, such as light switches, air conditioning temperature settings, and music playback. However, the cloud server in these systems lacks a submodule to map the return values of large language model tool calls into command strings with leading characters, separator characters, command type fields, and command parameter fields. Therefore, the return values of large language model tool calls cannot directly drive the frequency tuning word register of a precision RF synthesizer. Consequently, the controlled objects of these systems are limited to consumer-grade peripherals with parameter precision of on / off or integer degrees, and cannot support the Hertz-level precision RF parameter configuration required for SAW gas detection. Summary of the Invention
[0005] The purpose of this invention is to provide a multi-level collaborative SAW exhaled breath detection system and method based on a large language model, in order to solve the problems of high threshold for RF parameter configuration in existing SAW exhaled breath detection devices, difficulty in safely implementing natural language control into DDS registers, inability of ordinary AIoT control to adapt to precise frequency sweep detection, and high cost of underlying firmware expansion.
[0006] To achieve the above objectives, this invention provides a multi-level collaborative SAW exhaled breath detection system based on a large language model, comprising a precision RF excitation control layer, an IoT gateway layer, and a cloud AI analysis layer arranged from bottom to top, with data interaction between the three layers achieved through a heterogeneous communication protocol stack; The precision RF excitation control layer includes a microcontroller, a DDS frequency synthesizer, a SAW exhaled breath detection front-end, and a signal acquisition circuit. The microcontroller has a built-in pre-verification module. The microcontroller is connected to the register write port of the DDS frequency synthesizer through a serial peripheral interface. The RF output of the DDS frequency synthesizer is connected to the RF input of the SAW exhaled breath detection front-end. The RF output of the SAW exhaled breath detection front-end is connected to the analog-to-digital conversion channel of the microcontroller through a detection circuit. The IoT gateway layer includes a dual-core processor, a wireless communication module, a UART interface, and an I / O interface. 2 The dual-core processor employs a heterogeneous architecture with physical isolation between cores for memory and tasks; it communicates with the microcontroller of the precision RF excitation control layer via a UART interface and with the cloud-based AI analysis layer via the wireless communication module; the I... 2 The S-audio interface is used to capture user voice; The cloud-based AI analysis layer is deployed on a cloud server and includes a speech recognition service, a large language model inference service, a utility function definition library submodule, a command string generation submodule, an MQTT message listening submodule, a data persistence submodule, and an MQTT downlink publishing submodule. The speech recognition service communicates with the wireless communication module of the IoT gateway layer via the HTTP protocol, and the MQTT message listening submodule and the MQTT downlink publishing submodule communicate with the IoT gateway layer via the MQTT protocol. The large language model inference service is connected to the speech recognition service, the utility function definition library submodule, the data persistence submodule, and the command string generation submodule via signal connections. The system constructs an end-to-end device-level mapping channel from natural language voice commands and SAW exhaled breath detection data to the frequency tuning word register configuration of the DDS frequency synthesizer: user voice commands are transmitted via I... 2 After the audio is acquired via the S-channel interface, it is uploaded to the speech recognition service of the cloud AI analysis layer via HTTP protocol and converted into recognized text. The large language model inference service retrieves historical telemetry data stored in the data persistence submodule as context, and performs tool call inference in combination with the predefined tool functions in the tool function definition library submodule, outputting the tool function name and input parameters. The command string generation submodule encodes the tool function name and input parameters into a command string. The command string is transmitted to the microcontroller of the precision RF excitation control layer via the downlink topic of the MQTT downlink publishing submodule, the wireless communication module, and the UART interface. After parsing, the microcontroller writes the corresponding configuration parameters into the DDS frequency synthesizer through the serial peripheral interface, so that the SAW exhalation detection front end performs point frequency or sweep frequency detection according to the configuration parameters, and uploads the generated telemetry data back to the cloud AI analysis layer, completing the end-to-end mapping from voice commands to RF hardware configuration.
[0007] Preferably, the dual-core processor of the IoT gateway layer includes a first core and a second core, forming a dual-core heterogeneous task isolation structure; the first core is coupled to an internal static random access memory (SRAM) and is used to carry the LwIP network protocol stack, MQTT client tasks, and UART pass-through tasks; the second core is coupled to an external pseudo-static random access memory (PSRAM) and is used to carry I... 2 S-voice acquisition task; the first core and the second core do not share peripheral resources physically, but only exchange metadata through the real-time operating system queue, so that network communication, telemetry reporting, command issuance and voice acquisition can run in parallel.
[0008] Preferably, the second core continuously monitors I 2The S audio interface detects valid voice and starts recording. The acquired PCM audio stream is stored in the audio buffer of an external pseudo-static random access memory. After recording, it is uploaded to the speech recognition service of the cloud AI analysis layer via HTTP POST through the wireless communication module. The first core subscribes to the downlink command topic and publishes the uplink telemetry data topic of the cloud AI analysis layer through the MQTT client to realize the bidirectional transparent transmission of command strings and telemetry data.
[0009] Preferably, the startup pre-verification module is configured to sequentially verify the preset frequency range, preset step size range, and preset dwell time range during the system power-on initialization process; if any verification fails, the microcontroller enters a blocking state and drives the alarm indicator device, while prohibiting the serial peripheral interface from writing any register value to the DDS frequency synthesizer, so as to form a hardware-level parameter security locking structure; after the verification passes, the microcontroller completes hardware initialization and enters the main loop working state.
[0010] Preferably, the microcontroller's main loop has a built-in UART receive interrupt driven circular buffer, and the receive interrupt service routine only performs byte enqueue operations; the main loop performs segmented parsing of the data stream in the circular buffer according to a preset preamble character, and calls the corresponding register write function to complete the parameter configuration of the DDS frequency synthesizer according to the command type field obtained from the parsing. After each register write is completed, the microcontroller outputs an update pulse to make the configuration parameters effective.
[0011] Preferably, the command string begins with a preset leading character and includes a command type field and a command parameter field; the command type field includes at least one of point frequency setting, working mode setting, sweep center setting, sweep start and end frequency setting, frequency step setting, dwell time setting, and status query; the preset leading character is "CMD:", the command string generation submodule selects the corresponding command encoding template according to the tool function name, and encodes the center frequency, sweep bandwidth, sweep start and end frequency, step size, and dwell time in the tool function input parameters into the command parameter field; the microcontroller calls one of the write functions in the Profile register and the digital ramp generator register in the DDS frequency synthesizer according to the command string to configure the point frequency output, sweep center, sweep range, frequency step, and dwell time, and outputs an update pulse through the input / output update pin to make the configuration parameters effective.
[0012] Preferably, the heterogeneous communication protocol stack includes three types of communication protocols: the first type is the UART serial port protocol, used for bidirectional transmission of command strings and telemetry data between the precision RF excitation control layer and the IoT gateway layer; the second type is the MQTT message queue protocol, used for uplink transmission of telemetry data and downlink transmission of command strings between the IoT gateway layer and the cloud AI analysis layer; and the third type is the HTTP protocol, used for unidirectional transmission of audio acquisition data from the IoT gateway layer to the cloud AI analysis layer.
[0013] Preferably, the telemetry data output by the SAW exhaled breath detection front-end is reported in JSON format. The telemetry data includes at least one of the following: operating mode, point frequency, sweep center, sweep bandwidth, amplitude voltage, phase voltage, amplitude decibels, phase angle, frequency offset, sampling status, and timestamp. The SAW exhaled breath detection front-end is used to detect volatile gas markers, including NH3, H2S, and acetone, in exhaled breath. The SAW exhaled breath detection front-end uses a single-channel SAW resonator or a multi-channel SAW resonator array. When a multi-channel SAW resonator array is used, each channel is time-division selected by an RF switch, and the amplitude and phase components are obtained by an amplitude and phase detector.
[0014] Preferably, the tool function definition library submodule stores parameter configuration tool functions, data query tool functions, and analysis prompt tool functions. Each tool function entry point describes its input parameter structure in JSON Schema format. The large language model inference service calls the data query tool function to obtain the current telemetry data within a single dialogue cycle, and calls the parameter configuration tool function to output the tool function name and input parameters required for the next point frequency or sweep frequency detection.
[0015] This invention also provides a multi-level collaborative SAW exhaled breath detection method based on a large language model, comprising the following steps: S1. Voice Acquisition and Upload: The IoT gateway layer transmits data via I... 2 The audio interface collects the user's natural language voice commands and uploads them to the cloud AI analysis layer via HTTP protocol through the wireless communication module. S2, Speech Recognition and Large Language Model Inference: The speech recognition service of the cloud AI analysis layer converts speech commands into recognized text, and the large language model inference service retrieves historical telemetry data as context, combines predefined tool functions to execute tool call inference, and outputs the tool function name and input parameters; S3, Command Encoding and Distribution: The command string generation submodule encodes the tool function name and input parameters into a command string, which is then distributed to the microcontroller of the precision RF excitation control layer via the MQTT downlink topic, the wireless communication module of the IoT gateway layer, and the UART interface. S4. Microcontroller parses structured commands: The microcontroller writes the corresponding configuration parameters into the Profile register or Digital Ramp Generator register of the DDS frequency synthesizer through the serial peripheral interface, and outputs an update pulse to make the RF parameters effective. S5. RF Parameter Configuration and Gas Detection: The DDS frequency synthesizer outputs an RF signal to drive the SAW exhaled breath detection front-end. The microcontroller collects the detection signal and generates telemetry data, which is then uploaded to the cloud AI analysis layer via the UART interface, IoT gateway layer, and MQTT uplink topic. The cloud AI analysis layer continues to perform data query, analysis prompts, and the next round of RF parameter configuration based on the telemetry data.
[0016] Therefore, the present invention employs the above-mentioned multi-level collaborative SAW exhaled breath detection system and method based on a large language model, which has the following beneficial effects: 1) An end-to-end device-level mapping channel was constructed from natural language voice commands to the frequency tuning word register of the DDS frequency synthesizer, enabling non-professional users to directly drive the configuration of precise radio frequency parameters via voice.
[0017] 2) The IoT gateway layer adopts a dual-core heterogeneous task isolation structure, where network communication and audio acquisition run in parallel in physical terms, without blocking or interfering with each other.
[0018] 3) The pre-verification module of the precision RF excitation control layer constitutes a parameter security locking structure at the hardware level, cutting off the propagation of illegal parameters at the very front of the RF output path.
[0019] 4) The large language model inference service constructs a closed-loop control link of detection data perception-inference-RF parameter execution within a single dialogue cycle. The system functions can be structurally extended through cloud-based tool function definition libraries without modifying the underlying hardware or firmware.
[0020] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0021] Figure 1 This is a block diagram of the overall architecture of the three-layer collaborative SAW exhaled breath detection system of the present invention; Figure 2 This is a schematic diagram of the end-to-end data flow from voice commands to the DDS register in this invention; Figure 3 This is a flowchart of the main loop and UART command processing of the MSP430 precision RF excitation control layer of the present invention; Figure 4 This is a flowchart of the decision-making process for calling the large language model tool in the cloud AI analysis layer of this invention; Figure 5This is a schematic diagram of an optional implementation structure of the SAW exhaled breath detection front-end and amplitude-phase telemetry acquisition of the present invention. Detailed Implementation
[0022] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0023] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0024] Example 1 This embodiment discloses a multi-level collaborative SAW exhaled breath detection system based on a large language model. The overall system architecture is as follows: Figure 1 As shown, Figure 1 It also offers some hardware options, including a bottom-up structure of a precision RF excitation control layer, an IoT gateway layer, and a cloud-based AI analysis layer. These three layers interact via a heterogeneous communication protocol stack, creating an end-to-end device-level mapping channel from natural language speech commands to the DDS frequency synthesizer's frequency tuning word register configuration. The heterogeneous communication protocol stack includes three types of communication protocols: the first is the UART serial port protocol, used for bidirectional transmission of command strings and telemetry data between the precision RF excitation control layer and the IoT gateway layer; the second is the MQTT message queue protocol, used for uplink transmission of telemetry data and downlink transmission of command strings between the IoT gateway layer and the cloud-based AI analysis layer, with the uplink topic being SAW / data and the downlink topic being SAW / cmd; the third is the HTTP protocol, used for unidirectional transmission of audio acquisition data from the IoT gateway layer to the cloud-based AI analysis layer.
[0025] I. Precision RF Excitation Control Layer.
[0026] The precision RF excitation control layer serves as the system's RF excitation and gas detection execution end. Its core components include a microcontroller, a DDS frequency synthesizer, a SAW exhaled breath detection front-end, and a signal acquisition circuit, along with peripheral circuits such as a detection circuit and an alarm indicator. This embodiment provides optional hardware models, such as the MSP430F5529 as the microcontroller and the AD9910 as the DDS frequency synthesizer. The physical connections are as follows: The microcontroller's serial peripheral interface is connected to the DDS frequency synthesizer's register write port. One general-purpose input / output port of the microcontroller is connected to the DDS frequency synthesizer's input / output update pulse pin. Multiple general-purpose input / output ports of the microcontroller are connected to the DDS frequency synthesizer's Profile selection pin. The microcontroller is connected to the dual-core processor of the second-layer IoT gateway layer via the UART interface's transmit and receive pins. The DDS frequency synthesizer's RF output is connected to the SAW exhaled breath detection front-end's RF input via an RF coupling capacitor. The SAW exhaled breath detection front-end's RF output is down-converted by the detection circuit and then connected to the microcontroller's built-in analog-to-digital converter channel. The microcontroller’s two general-purpose input / output ports drive two alarm indicator lights respectively.
[0027] The microcontroller has a built-in pre-verification module, configured to sequentially verify the preset frequency range, preset step size range, and preset dwell time range during system power-on initialization. If any verification fails, the microcontroller enters a blocked state and drives two alarm indicator lights to flash alternately at a preset cycle for alarm indication. Simultaneously, it prohibits the serial peripheral interface from writing any register values to the DDS frequency synthesizer, thus forming a hardware-level parameter safety lockout structure to cut off the propagation of illegal parameters at the very beginning of the RF output path. If all three verifications pass, the microcontroller performs hardware initialization of the serial peripheral interface, UART interface, and relevant general-purpose input / output ports, and then enters the main loop operating state.
[0028] The microcontroller's main loop has a built-in UART receive interrupt-driven circular buffer. The receive interrupt service routine only performs byte enqueue operations and does not perform time-consuming command parsing. The main loop performs segmented parsing of the data stream in the circular buffer according to a preset preamble character. In this embodiment, the preset preamble character is "CMD:". The main loop reads data byte by byte from the circular buffer. When a continuous sequence of characters "CMD:" is detected, the start of a new command is determined. Subsequently, the command type field and command parameter field are read until a complete command string is encountered. Based on the parsed command type field, the main loop calls the corresponding register write function to complete the parameter configuration of the DDS frequency synthesizer. Specifically, when the command type is in fixed-frequency operating mode, the DDS frequency synthesizer's Profile register write function is called to write the frequency tuning word in the command parameter field to the corresponding register; when the command type is in sweep frequency operating mode, the DDS frequency synthesizer's internal ramp generator register write function is called to write the start and end frequencies, step size, and step time to the corresponding registers. After each register write, the microcontroller outputs an update pulse via the IO_UPDATE pin to activate the configuration parameters. The DDS frequency synthesizer then outputs the corresponding RF signal based on the written register value. The main loop acquires the DC voltage output from the SAW exhaled breath detection front-end detector circuit at preset intervals, calculates the frequency offset, generates telemetry data in JSON format, and reports it to the IoT gateway layer via the hardware UART interface.
[0029] The telemetry data output by the SAW exhaled breath detection front-end is reported in JSON format. The telemetry data includes at least one of the following: operating mode, point frequency, sweep center, sweep bandwidth, amplitude voltage, phase voltage, amplitude in decibels, phase angle, frequency offset, sampling status, and timestamp. The SAW exhaled breath detection front-end is used to detect volatile gas markers such as NH3, H2S, and acetone in exhaled breath. The SAW exhaled breath detection front-end uses a single-channel SAW resonator or a multi-channel SAW resonator array; when using a multi-channel SAW resonator array, each channel is time-division selected by an RF switch, and the amplitude and phase components are acquired by an amplitude and phase detector.
[0030] II. IoT Gateway Layer.
[0031] The IoT gateway layer serves as the edge data processing and communication relay for the system. Its core components include a dual-core processor, a wireless communication module, a UART interface, and an I / O interface. 2 The S-audio interface provides the system with voice acquisition, network communication, and bidirectional data transmission functions. It adopts a dual-core heterogeneous architecture with physical isolation between core storage and physical isolation between core tasks, which structurally eliminates the problems of task blocking and mutual interference between network communication and audio acquisition.
[0032] The two cores of the dual-core processor are each bound to an independent real-time operating system task, forming a dual-core heterogeneous task isolation structure; the second core (Core1) is coupled with dedicated storage resources and dedicated to I / O. 2 The S-level voice acquisition task uses a dedicated core (Core0) coupled with dedicated storage resources to handle the network protocol stack, MQTT client tasks, and UART pass-through tasks. The two cores do not physically share peripheral resources or memory space; they only exchange a small amount of metadata through a real-time operating system queue. This ensures that task blocking on one core does not propagate to the other, enabling the physical parallel execution of two high-throughput tasks. The dual-core processor communicates with the microcontroller of the precision RF excitation control layer via a UART interface, enabling bidirectional transmission of commands and detection data. It also establishes network communication with the cloud-based AI analysis layer through a wireless communication module, enabling remote transmission of audio data, telemetry data, and control commands. 2 The S-Audio interface connects to the audio acquisition device for high-fidelity acquisition of user natural language voice commands.
[0033] During operation, the second core continuously monitors I. 2 Upon detecting valid voice data via the S-audio interface, recording begins. The acquired PCM audio stream is stored in the audio buffer of an external pseudo-static random access memory. After recording, it is uploaded to the / asr endpoint of the cloud AI analysis layer via HTTP POST through the wireless communication module. The MQTT client of the first core subscribes to the downlink command topic SAW / cmd of the cloud AI analysis layer and publishes uplink telemetry data topic SAW / data. After receiving JSON telemetry data reported by the microcontroller from the UART interface, the first core publishes it to the cloud AI analysis layer via the MQTT uplink topic SAW / data. After receiving the command string from the MQTT downlink topic SAW / cmd, the first core forwards it to the microcontroller of the precision RF excitation control layer via the UART interface. The first and second cores do not physically share peripheral resources. Even if the network protocol stack tasks of the first core are blocked due to network congestion, it will not affect the I / O operations of the second core. 2 S-voice acquisition continuity and DMA transfer.
[0034] III. Cloud-based AI analysis layer.
[0035] The cloud-based AI analytics layer is deployed on a cloud server. It comprises seven sub-modules: a speech recognition service, a large language model inference service, a utility function definition library sub-module, a command string generation sub-module, an MQTT message listening sub-module, a data persistence sub-module, and an MQTT downlink publishing sub-module. The speech recognition service communicates with the wireless communication module of the IoT gateway layer via the HTTP protocol. The MQTT message listening and MQTT downlink publishing sub-modules communicate with the wireless communication module via the MQTT protocol. The large language model inference service is connected to the speech recognition service, the utility function definition library sub-module, the data persistence sub-module, and the command string generation sub-module via signal connections.
[0036] The functions of each submodule are as follows: The MQTT message listening submodule subscribes to the uplink topic SAW / data as an MQTT client and writes the received JSON telemetry data to the data persistence submodule. The data persistence submodule stores all historical telemetry data in a database format, indexed by timestamps, providing contextual data support for the large language model inference. The speech recognition service receives audio data uploaded from the IoT gateway layer via the HTTP endpoint / asr, completes the speech-to-text conversion, and pushes the recognized text content to the large language model inference service. The utility function definition library submodule stores parameter configuration utility functions, data query utility functions, and analysis prompt utility functions. Each utility function entry point describes its input parameter structure in JSON Schema format, providing a standardized interface definition for large language model tool calls. The large language model inference service receives the recognized text via the HTTP endpoint / chat, configures the large language model's tool call interface according to the utility function entry point descriptions provided by the utility function definition library submodule, reads the historical telemetry data stored in the data persistence submodule as context, and calls the large language model to return the name and parameters of the selected utility function. The command string generation submodule selects the corresponding command encoding template based on the tool function name, encoding the center frequency, sweep bandwidth, sweep start and end frequency, step size, and dwell time from the tool function input parameters into command parameter fields. The command string begins with a preset leading character, specifically "CMD:", followed by the command type field and command parameter fields. The command type field includes at least one of the following: frequency setting, operating mode setting, sweep center setting, sweep start and end frequency setting, frequency step setting, dwell time setting, and status query. The MQTT downlink publishing submodule publishes the command string to the IoT gateway layer via the downlink topic SAW / cmd.
[0037] Based on the above system, a complete end-to-end device-level mapping channel from natural language speech commands to the DDS frequency synthesizer frequency tuning word register configuration was constructed. The complete link is as follows: Figure 2 As shown, specifically: user voice commands are transmitted via I2 After audio is acquired via the S-channel interface, it is uploaded to the speech recognition service of the cloud AI analysis layer via HTTP and converted into recognized text. The large language model inference service retrieves historical telemetry data stored in the data persistence submodule as context, and performs tool call inference in conjunction with predefined tool functions from the tool function definition library submodule, outputting the tool function name and input parameters. The command string generation submodule encodes the tool function name and input parameters into a command string. The command string is transmitted to the microcontroller of the precision RF excitation control layer via the downlink topic SAW / cmd of the MQTT downlink publishing submodule, the wireless communication module, and the UART interface. After parsing, the microcontroller writes the corresponding configuration parameters into the frequency tuning word register of the DDS frequency synthesizer through the serial peripheral interface, completing the end-to-end mapping from voice commands to RF hardware configuration.
[0038] Within a single dialogue cycle, the large language model inference service simultaneously invokes data query utility functions to obtain current detection telemetry data and parameter configuration utility functions to adjust the RF parameters of the DDS frequency synthesizer, constructing a closed-loop control chain of detection data perception, large language model inference, and RF parameter execution. Furthermore, without modifying the firmware of the precision RF excitation control layer and the IoT gateway layer, the system's control dimensions and data analysis capabilities can be expanded by adding utility function entry points and corresponding command string encoding templates to the utility function definition library submodule. This expansion process at the device structure level only involves updating the submodule configuration of the cloud AI analysis layer, without affecting any hardware or firmware of the precision RF excitation control layer and the IoT gateway layer.
[0039] Example 2 like Figure 3 and Figure 4 As shown, taking the user saying "scan the vicinity of a certain frequency" to the MEMS microphone as an example, the SAW exhaled breath detection method based on the above system includes the following steps: S1. Voice Acquisition and Upload: The user issues a Chinese voice command, and the MEMS microphone transmits it via I... 2 The S-channel audio interface sends the PCM audio stream to the second core of the dual-core processor via DMA transfer. The second core stores the PCM audio stream in an external pseudo-static random access memory audio buffer. After recording, the stream is uploaded to the / asr endpoint of the cloud AI analysis layer via HTTP POST through the wireless communication module.
[0040] S2. Speech Recognition and Large Language Model Inference: The speech recognition service in the cloud-based AI analysis layer receives audio data and returns the recognized text. The large language model inference service reads historical telemetry data stored in the data persistence submodule as context, constructs prompts according to the tool function entry descriptions provided by the tool function definition library submodule, executes inference through the tool call interface, and outputs the tool function name and input parameters matching the user's voice command. The large language model inference service returns tool function calls, such as calling the set_mode tool function to set the working mode to frequency sweep mode, and calling the set_frequency tool function to set the center frequency and bandwidth parameters. During this process, the large language model inference service also calls query_recent_data to query the current telemetry data, forming a closed loop of perception and inference.
[0041] S3. Command Encoding and Distribution: The command string generation submodule receives the tool function name and input parameters returned by the large language model and encodes them into command strings according to a preset text protocol, such as "CMD:MODE:SWEEP" and "CMD:SWEEP:center frequency:bandwidth". The MQTT downlink publishing submodule publishes the command string via the downlink topic SAW / cmd. The first core of the dual-core processor receives the command string via the MQTT client and forwards it to the microcontroller of the precision RF excitation control layer via the UART interface.
[0042] S4. Microcontroller Parses Structured Commands: The microcontroller's hardware UART interface receive interrupt enqueues bytes into a circular buffer. The main loop parses the data in the circular buffer segment by the "CMD:" leading character, calls the corresponding DDS register write function according to the command type field, and writes the parameters into the DDS frequency synthesizer register; after each register write is completed, the microcontroller outputs an update pulse to make the configuration effective.
[0043] S5. RF Parameter Configuration and Gas Detection: The DDS frequency synthesizer outputs an RF signal to the RF input of the SAW exhaled breath detection front-end. The RF output of the SAW exhaled breath detection front-end is down-converted by the detection circuit to the analog-to-digital converter channel of the microcontroller. The microcontroller collects voltage data at a preset cycle, calculates the frequency offset, and reports it in JSON format to the first core of the dual-core processor via the UART interface. The first core publishes the JSON telemetry data to the cloud AI analysis layer via the MQTT uplink topic SAW / data. The large language model inference service of the cloud AI analysis layer is triggered again, calling the data query and analysis utility functions in the utility function definition library submodule to generate trend analysis and health advice text, completing the complete closed loop from RF parameter execution to detection data re-sensing.
[0044] Example 3 like Figure 2 and Figure 4 As shown, after a user issues natural language voice commands such as "scan around 260 MHz", "switch to frequency scanning mode", or "view recent detection data", the IoT gateway layer collects the audio and uploads it to the cloud AI analysis layer. The speech recognition service returns the recognized text, and the large language model inference service reads the most recent SAW exhaled breath detection telemetry data and combines it with the tool function definition library submodule to execute tool call inference.
[0045] When a user requests to change detection parameters, the large language model inference service can output utility function names and input parameters such as `set_mode`, `set_frequency`, `set_sweep_center`, or `set_sweep_param`. The command string generation submodule encodes it as "CMD:MODE:SWEEP", "CMD:FREQ:260000000", "CMD:SWEEP_CENTER:260000000", or equivalent formats. The ESP32-S3 receives the command via MQTT and forwards it to the MSP430F5529, which then writes it to the corresponding register in the AD9910 according to the command type.
[0046] When a user requests to view the results or the system automatically enters the next analysis cycle, the large language model inference service can call `query_recent_data` to read the most recent telemetry data and call `analyze_trend`, `generate_health_advice`, or `generate_report` to generate trend analysis, status prompts, or detection reports. If further adjustment of RF detection parameters is needed, the large language model inference service calls parameter configuration utility functions within the same dialogue cycle, forming a closed loop of detection data perception, large language model inference, RF parameter execution, and telemetry re-sensing.
[0047] Example 4 like Figure 5 As shown, Figure 5 This is a schematic diagram of an optional implementation structure for the SAW exhaled breath detection front-end and amplitude-phase telemetry acquisition of the present invention. This embodiment is used to illustrate the specific implementation methods of radio frequency excitation, SAW exhaled breath detection, amplitude-phase acquisition, and telemetry reporting in the precision RF excitation control layer.
[0048] The DDS frequency synthesizer, controlled by an MSP430F5529 microcontroller, outputs spot or sweep frequency radio frequency signals. These signals are selected by an RF switch and input to the SAW exhaled breath detection front-end. The SAW exhaled breath detection front-end is equipped with an exhaled breath sample inlet and may include multiple detection channels, such as SAW channel 1, SAW channel 2 to SAW channel N. Different SAW channels can be configured with different sensitive structures according to the target substance, for the detection of volatile exhaled breath markers such as NH3, H2S, and acetone.
[0049] The detection signal output from the SAW exhaled breath detection front end is input to the amplitude and phase detector. As an optional method, the amplitude and phase detector uses an AD8302 to output the amplitude voltage Vmag and phase voltage Vphs. These voltage signals are acquired by the ADC and then sent to the MSP430F5529 microcontroller, which calculates or converts the amplitude, phase, and frequency offset detection parameters.
[0050] After receiving the command string transmitted from the ESP32-S3 via the UART interface, the MSP430F5529 microcontroller parses the command and completes the register configuration of the AD9910 DDS frequency synthesizer through the SPI interface and the IO_UPDATE signal. At the same time, the microcontroller can also output a channel selection control signal to control the RF switch to select the corresponding SAW channel.
[0051] After the detection is completed, the MSP430F5529 microcontroller encapsulates data such as mode, freq, sweep_center, Vmag, Vphs, mag_dB, phase_deg, and Δf into JSON telemetry data, which is then reported to the cloud AI analysis layer via MQTT through the ESP32-S3 for storage by the data persistence submodule and for use by the large language model inference service in subsequent dialogue cycles.
[0052] Therefore, this invention employs the aforementioned multi-level collaborative SAW exhaled breath detection system and method based on a large language model. By constructing an end-to-end device-level mapping channel from natural language speech commands to the frequency tuning word register of the DDS frequency synthesizer, non-professional users can directly drive precise RF parameter configuration via voice. The IoT gateway layer adopts a dual-core heterogeneous task isolation structure, enabling network communication and audio acquisition to run in physical parallel without blocking or interfering with each other. The pre-verification module built into the precise RF excitation control layer constitutes a parameter safety locking structure at the hardware level, cutting off the propagation of illegal parameters at the very front of the RF output path to prevent illegal parameters from impacting the SAW transducer. Simultaneously, the large language model inference service constructs a closed-loop control link of detection data perception-inference-RF parameter execution within a single dialogue cycle. Furthermore, the system functions can be structurally extended through a cloud-based tool function definition library. Within the coverage of existing command types and reserved command templates, no modification to the underlying hardware or firmware is required, improving the system's usability, security, and scalability.
[0053] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.
Claims
1. A multi-level collaborative SAW exhaled breath detection system based on a large language model, characterized in that, It includes a precision RF excitation control layer, an IoT gateway layer, and a cloud AI analysis layer arranged from bottom to top, with data interaction between the three layers achieved through a heterogeneous communication protocol stack; The precision RF excitation control layer includes a microcontroller, a DDS frequency synthesizer and a SAW exhaled breath detection front-end, and a signal acquisition circuit. The microcontroller has a built-in pre-verification module. The microcontroller is connected to the register write port of the DDS frequency synthesizer through a serial peripheral interface. The RF output of the DDS frequency synthesizer is connected to the RF input of the SAW exhaled breath detection front end. The RF output of the SAW exhaled breath detection front end is connected to the analog-to-digital conversion channel of the microcontroller through a detector circuit. The IoT gateway layer includes a dual-core processor, a wireless communication module, a UART interface, and an I / O interface. 2 The S-audio interface, the dual-core processor adopts a dual-core heterogeneous architecture with physical isolation between core storage and physical isolation between core tasks; The dual-core processor communicates with the microcontroller of the precision RF excitation control layer via a UART interface, and communicates with the cloud-based AI analysis layer via the wireless communication module; the I 2 The S-audio interface is used to capture user voice; The cloud-based AI analysis layer is deployed on a cloud server and includes a speech recognition service, a large language model inference service, a utility function definition library submodule, a command string generation submodule, an MQTT message listening submodule, a data persistence submodule, and an MQTT downlink publishing submodule. The speech recognition service communicates with the wireless communication module of the IoT gateway layer via the HTTP protocol, and the MQTT message listening submodule and the MQTT downlink publishing submodule communicate with the IoT gateway layer via the MQTT protocol. The large language model inference service is connected to the speech recognition service, the utility function definition library submodule, the data persistence submodule, and the command string generation submodule via signal connections. The system constructs an end-to-end device-level mapping channel from natural language voice commands and SAW exhaled breath detection data to the frequency tuning word register configuration of the DDS frequency synthesizer: user voice commands are transmitted via I... 2 After the audio is collected by the S-interface, it is uploaded to the speech recognition service of the cloud AI analysis layer via HTTP protocol and converted into recognized text; the large language model inference service calls the historical telemetry data stored in the data persistence submodule as the context, and combines the predefined tool functions of the tool function definition library submodule to execute tool call inference, and outputs the tool function name and input parameters; The command string generation submodule encodes the tool function name and input parameters into a command string. The command string is transmitted to the microcontroller of the precision RF excitation control layer via the downlink topic of the MQTT downlink publishing submodule, the wireless communication module, and the UART interface. After parsing, the microcontroller writes the corresponding configuration parameters into the DDS frequency synthesizer through the serial peripheral interface, so that the SAW exhaled breath detection front end performs point frequency or sweep frequency detection according to the configuration parameters, and uploads the generated telemetry data back to the cloud AI analysis layer, completing the end-to-end mapping from voice commands to RF hardware configuration.
2. The multi-level collaborative SAW exhaled breath detection system based on a large language model according to claim 1, characterized in that, The dual-core processor of the IoT gateway layer includes a first core and a second core, forming a dual-core heterogeneous task isolation structure; the first core is coupled to the internal static random access memory and is used to carry the LwIP network protocol stack, MQTT client tasks and UART pass-through tasks. The second core is coupled to an external pseudo-static random access memory (PSRAM) and is used to carry I... 2 S-voice acquisition task; The first core and the second core do not share peripheral resources physically, but only exchange metadata through a real-time operating system queue, so that network communication, telemetry reporting, command issuance and voice acquisition can run in parallel.
3. The multi-level collaborative SAW exhaled breath detection system based on a large language model according to claim 2, characterized in that, Second core continuous monitoring I 2 The S audio interface detects valid voice and starts recording. The acquired PCM audio stream is stored in the audio buffer of an external pseudo-static random access memory. After recording, it is uploaded to the speech recognition service of the cloud AI analysis layer via HTTP POST through the wireless communication module. The first core subscribes to the downlink command topic and publishes the uplink telemetry data topic of the cloud AI analysis layer through the MQTT client to realize the bidirectional transparent transmission of command strings and telemetry data.
4. The multi-level collaborative SAW exhaled breath detection system based on a large language model according to claim 1, characterized in that, The startup pre-verification module is configured to perform sequential verification of the preset frequency range, preset step size range, and preset dwell time range during the system power-on initialization process. If any check fails, the microcontroller enters a blocking state and drives the alarm indicator device, while simultaneously prohibiting the serial peripheral interface from writing any register value to the DDS frequency synthesizer, thus forming a hardware-level parameter security lockout structure. After the verification is successful, the microcontroller completes hardware initialization and enters the main loop working state.
5. The multi-level collaborative SAW exhaled breath detection system based on a large language model according to claim 4, characterized in that, The microcontroller's main loop has a built-in UART receive interrupt-driven circular buffer. The receive interrupt service routine only performs byte enqueue operations. The main loop performs segmented parsing of the data stream in the circular buffer according to a preset preamble character. Based on the command type field obtained from the parsing, it calls the corresponding register write function to complete the parameter configuration of the DDS frequency synthesizer. After each register write is completed, the microcontroller outputs an update pulse to make the configuration parameters effective.
6. The multi-level collaborative SAW exhaled breath detection system based on a large language model according to claim 5, characterized in that, The command string begins with a preset leading character and includes a command type field and a command parameter field. The command type field includes at least one of the following: frequency setting, working mode setting, sweep center setting, sweep start and end frequency setting, frequency step setting, dwell time setting, and status query. The preset leading character is "CMD:". The command string generation submodule selects the corresponding command encoding template according to the tool function name and encodes the center frequency, sweep bandwidth, sweep start and end frequency, step size, and dwell time in the tool function input parameters into the command parameter field. The microcontroller calls one of the write functions in the Profile register and the digital ramp generator register in the DDS frequency synthesizer according to the command string to configure the frequency output, sweep center, sweep range, frequency step, and dwell time, and outputs an update pulse through the input / output update pin to make the configuration parameters effective.
7. The multi-level collaborative SAW exhaled breath detection system based on a large language model according to claim 1, characterized in that, The heterogeneous communication protocol stack includes three types of communication protocols: the first type is the UART serial port protocol, used for bidirectional transmission of command strings and telemetry data between the precision RF excitation control layer and the IoT gateway layer; the second type is the MQTT message queue protocol, used for uplink transmission of telemetry data and downlink transmission of command strings between the IoT gateway layer and the cloud AI analysis layer; and the third type is the HTTP protocol, used for unidirectional transmission of audio acquisition data from the IoT gateway layer to the cloud AI analysis layer.
8. The multi-level collaborative SAW exhaled breath detection system based on a large language model according to claim 1, characterized in that, The telemetry data output by the SAW exhaled breath detection front-end is reported in JSON format. The telemetry data includes at least one of the following: operating mode, point frequency, sweep center, sweep bandwidth, amplitude voltage, phase voltage, amplitude in decibels, phase angle, frequency offset, sampling status, and timestamp. The SAW exhaled breath detection front-end is used to detect volatile gas markers, including NH3, H2S, and acetone, in exhaled breath. The SAW exhaled breath detection front-end uses a single-channel SAW resonator or a multi-channel SAW resonator array. When a multi-channel SAW resonator array is used, each channel is time-division selected by an RF switch, and the amplitude and phase components are obtained by an amplitude and phase detector.
9. The multi-level collaborative SAW exhaled breath detection system based on a large language model according to claim 1, characterized in that, The utility function definition library submodule stores parameter configuration utility functions, data query utility functions, and analysis prompt utility functions. Each utility function entry point describes its input parameter structure in JSON Schema format. The large language model inference service calls the data query utility function to obtain the current telemetry data within a single dialogue cycle, and calls the parameter configuration utility function to output the name and input parameters of the utility function required for the next point frequency or sweep frequency detection.
10. A multi-level collaborative SAW exhaled breath detection method based on a large language model, characterized in that, The SAW exhaled breath detection system according to any one of claims 1-9 comprises the following steps: S1. Voice Acquisition and Upload: The IoT gateway layer transmits data via I... 2 The audio interface collects the user's natural language voice commands and uploads them to the cloud AI analysis layer via HTTP protocol through the wireless communication module. S2, Speech Recognition and Large Language Model Inference: The speech recognition service of the cloud AI analysis layer converts speech commands into recognized text, and the large language model inference service retrieves historical telemetry data as context, combines predefined tool functions to execute tool call inference, and outputs the tool function name and input parameters; S3, Command Encoding and Distribution: The command string generation submodule encodes the tool function name and input parameters into a command string, which is then distributed to the microcontroller of the precision RF excitation control layer via the MQTT downlink topic, the wireless communication module of the IoT gateway layer, and the UART interface. S4. Microcontroller parses structured commands: The microcontroller writes the corresponding configuration parameters into the Profile register or Digital Ramp Generator register of the DDS frequency synthesizer through the serial peripheral interface, and outputs an update pulse to make the RF parameters effective. S5. RF Parameter Configuration and Gas Detection: The DDS frequency synthesizer outputs an RF signal to drive the SAW exhaled breath detection front-end. The microcontroller collects the detection signal and generates telemetry data, which is then uploaded to the cloud AI analysis layer via the UART interface, IoT gateway layer, and MQTT uplink topic. The cloud AI analysis layer continues to perform data query, analysis prompts, and the next round of RF parameter configuration based on the telemetry data.