1. Introduction
CH
4, the primary component of natural gas, is a vital energy carrier in modern industrial processes but also poses significant challenges for process safety and environmental monitoring [
1,
2]. Owing to its flammability, reliable CH
4 monitoring is required in industrial plants, energy infrastructure, and residential environments [
3,
4]. Beyond safety hazards, CH
4 is also a potent greenhouse gas—second only to carbon dioxide in terms of global warming potential [
5,
6,
7,
8]. In many practical process streams, CH
4 coexists with other light alkanes such as ethane and propane, which exhibit very similar physicochemical properties and, critically, strongly overlapping infrared absorption spectra [
9,
10]. This spectral congestion makes it difficult for conventional gas analyzers to selectively identify CH
4 in real time, yet accurate composition information is essential for process optimization, safety management, and emission control.
Beyond detecting single target gases, there is a growing need to discriminate the dominant component in complex alkane mixtures [
11]. Such capability is important for monitoring reaction pathways, optimizing natural gas processing, and diagnosing early faults in oil-immersed power transformers via dissolved gas analysis [
12,
13,
14]. While intelligent sensing and machine-learning-assisted process control have advanced rapidly in recent years [
15], most gas sensing studies still focus on improving the detection accuracy of individual gases under relatively simple conditions. The selective identification of CH
4 as the principal component in multicomponent alkane environments remains comparatively underexplored.
Among available techniques for industrial gas monitoring, nondispersive infrared (NDIR) spectroscopy is particularly attractive because of its wide dynamic range, long-term stability, and independence from ambient oxygen, which distinguish it from electrochemical or semiconductor-based sensors [
16]. However, the selectivity of traditional NDIR sensors relies on the spectral separation of absorption bands and the use of narrowband optical filters based on the Beer–Lambert law [
17]. When target gases have closely spaced or overlapping absorption features—as in the case of CH
4 and other light alkanes—single-wavelength NDIR configurations suffer from severe cross-interference and often require expensive, application-specific interference filters. These constraints limit both the performance and scalability of conventional NDIR systems for component discrimination in complex industrial gas mixtures.
To address this limitation, we propose in this work a software-defined algorithmic filter for CH4 discrimination in alkane mixtures. Instead of relying on fixed narrowband optical filters, a four-source, single-detector NDIR architecture is employed to generate a rich composite absorption signal. Three measurement wavelengths probe different parts of the alkane absorption band, while a fourth reference wavelength with minimal gas absorption provides a baseline for compensating non-selective effects. The resulting multi-wavelength time-domain signals are transformed into compact feature vectors using Fast Fourier Transform (FFT) and reference-channel normalization. These features are then processed by a hybrid Convolutional Neural Network–Support Vector Machine (CNN–SVM) model, where the CNN automatically learns high-level representations and the SVM performs robust classification of the dominant component.
Using CH4–ethane mixtures as a representative and challenging case, we demonstrate that the proposed system can reliably discriminate whether CH4 is the principal component of the mixture, achieving an overall identification accuracy of 89%. This study thus shifts the burden of selectivity from costly optical hardware to flexible computational algorithms and illustrates a generalizable approach for algorithmic selectivity in spectrally congested gas sensing problems. The main contributions of this work can be summarized as follows:
1. A custom hardware architecture was developed, employing a four-source, single-detector configuration. This multi-wavelength strategy produces a rich, composite absorption signal without the need for optical filters.
2. A hybrid intelligent model was proposed, combining a Convolutional Neural Network (CNN) for automated spectral feature extraction with a Support Vector Machine (SVM) for robust classification. This model demonstrated superior performance compared to conventional machine learning approaches.
3. Fast Fourier Transform (FFT) was applied to raw sensor outputs to extract discriminative amplitude-domain features, providing a robust representation for downstream classification tasks.
4. A comprehensive dataset of mixed alkane gases was collected, and experiments confirmed that the proposed system achieves a CH4 identification accuracy of 89%, thereby validating its effectiveness for real-world sensing applications.
2. Proposed Detection System
Conventional single-wavelength NDIR sensors perform well when the absorption bands of the target and background gases are well separated, but they suffer from severe cross-interference in alkane mixtures such as methane–ethane, where the infrared spectra are strongly overlapping. As a result, commercial analyzers are generally not able to identify the principal component of an unknown alkane mixture without prior compositional information.
To address this limitation, we propose a multi-wavelength differential NDIR scheme combined with a software-defined algorithmic filter. The core of the system is a four-source, single-detector configuration. Three infrared LEDs are selected to probe different regions of the alkane absorption band, whereas a fourth reference LED operates at a wavelength with negligible gas absorption. The three measurement channels provide complementary sensitivity to variations in mixture composition, while the reference channel supplies a baseline for correcting non-selective effects such as source drift or particulate scattering. Instead of aiming at direct spectral interpretation, the system is designed to encode the gas composition into a rich composite signal that can be decoded by machine-learning algorithms.
The optical components share a common-path configuration, i.e., all four beams pass through the same gas chamber and are detected by the same photodetector. This arrangement minimizes systematic errors due to hardware mismatches among channels and ensures that the recorded signals are highly correlated and thus well suited for differential analysis. The overall concept of the proposed NDIR platform is illustrated in
Figure 1.
In operation, the four infrared LEDs are sequentially driven by a microcontroller at a fixed modulation frequency. For each active source, the transmitted radiation passes through the mixed-gas chamber and is converted into an electrical signal by the photodetector. The signal is then conditioned by an analog front-end circuit (amplification and anti-alias filtering) and digitized by the on-board ADC. The digitized samples are finally transferred to a host computer, where signal processing and feature extraction are performed, and the resulting feature vectors are fed into the CNN–SVM classifier described in
Section 5.
This architecture is intentionally kept hardware-minimal: it uses inexpensive broadband LEDs, a single detector, and simple electronics, while shifting the burden of selectivity from narrowband optical filters to the software-defined algorithmic filter implemented in the data-processing and classification pipeline. The system architecture is shown in
Figure 2.
3. Hardware System
The hardware was designed with a singular goal: to reliably produce a high-fidelity, multi-wavelength absorption signal optimized for subsequent analysis by our neural network model. Every design choice serves to enhance the quality and discriminatory power of the data fed into the algorithm.
3.1. Optical Subsystem
The selection of the detection elements is primarily determined by the infrared absorption characteristics of the target gas. CH
4 exhibits a strong absorption band near 3.4 µm, which partially overlaps with the absorption bands of other alkane gases (e.g., ethane, propane) that often coexist with CH
4 [
18,
19]. Consequently, the optical design must ensure high sensitivity within this spectral region, which directly informs the choice of both the infrared (IR) light source and the detector.
Light Source and Detector Selection: To capture the nuances of this spectral region, we selected an LED array integrating four distinct chips (Lms34LED, Lms35LED, Lms36LED, and Lms37LED) and a corresponding photodiode (Lms36PD-05) with a sensitivity cutoff around 3.6 µm. This specific combination ensures that our system is highly sensitive to the characteristic absorption features of CH4 while also gathering spectral information from adjacent bands. This multi-point spectral sampling is precisely what provides the rich input required for the CNN to extract subtle discriminatory features that a single-wavelength system would miss.
Four-Source, Single-Detector Design: A key design choice was the “four-source, single-detector” common-path configuration. This approach is instrumental for the algorithm’s success because it ensures all four wavelength signals travel through the identical optical path and are processed by the same electronics. This inherently minimizes inter-channel inconsistencies and cancels out systematic errors, guaranteeing that the subtle differences in the signal are due to gas absorption, not hardware variability. This provides a clean, consistent, and reliable dataset for the algorithm.
Gas Chamber: The effective absorption path length, determined by the gas chamber, directly impacts the signal-to-noise ratio. Through experimental optimization, a chamber length of 80 mm was found to provide a sufficient absorption signal for robust detection without significant attenuation. The chamber was fabricated using 3D-printed resin for its chemical inertness and ease of prototyping.
3.2. Circuit Subsystem
The circuit subsystem was engineered to precisely control the light sources and to amplify and filter the weak photodetector signal with maximum fidelity, ensuring the signal fed to the ADC is a clean representation of the optical absorption.
System Control: A microcontroller (MCU) (STM32F407ZET6) serves as the control core, orchestrating the timing of the LEDs and the acquisition of the detector signal.
Light Source Drive and Signal Modulation: To enable subsequent lock-in amplification—a crucial technique for extracting weak signals from noise—the MCU generates a 10 Hz Pulse Width Modulation (PWM) signal. This signal, via a simple driver circuit, sequentially drives the four infrared LEDs. The 10 Hz modulation frequency was deliberately chosen as an optimal trade-off: it is low enough to allow for effective sampling and to avoid high-frequency harmonic distortions, yet high enough to be well above the typical low-frequency (1/f) noise floor of the electronics. This modulation strategy is a fundamental prerequisite for achieving the high signal-to-noise ratio needed by the subsequent analytical algorithm.
Signal Conditioning: The raw output from the photodetector is a minuscule current signal (on the order of µA or nA) that must be carefully processed. The signal conditioning chain was designed with several key functions in mind:
Current-to-Voltage Conversion: A transimpedance amplifier (TIA) performs the initial conversion of the weak photocurrent into a usable voltage signal.
Gain Adjustment: To accommodate a wide dynamic range of gas concentrations, a multi-stage amplifier with a digitally controlled potentiometer provides adjustable gain. This ensures the signal properly fills the input range of the ADC without clipping.
Noise Filtering: To maximize the signal-to-noise ratio, a bandpass filter centered at the 10 Hz modulation frequency was implemented. This filter is critical as it selectively passes the desired signal frequency while rejecting broadband noise, effectively isolating the absorption information from unwanted interference.
The final conditioned analog signal is then sampled by the MCU’s integrated ADC for digital processing. The efficacy of this entire signal chain, particularly the filtering, was validated through AC analysis. This multi-step conditioning process ensures that the final digital data is a clean and accurate representation of the gas absorption, ready for feature extraction and classification.
4. Signal Processing and Feature Vector Construction
4.1. Raw Signal Pre-Processing and Denoising
The digitized output of the NDIR system is a periodic waveform whose fundamental frequency corresponds to the modulation frequency of the infrared LEDs. In addition to the useful signal component, the waveform contains broadband electronic noise and low-frequency drift originating from environmental and hardware variations. Direct time-domain analysis is therefore sub-optimal for robust pattern recognition.
To enhance the signal-to-noise ratio and isolate the gas-related information, we adopt a frequency-domain approach based on the Fast Fourier Transform (FFT) [
20,
21]. For each channel, an FFT is applied to the sampled time series, and the amplitude at the modulation frequency is extracted as the primary feature. This operation effectively suppresses aperiodic noise and DC drift, providing a more stable and discriminative input for the subsequent classifier.
4.2. Feature Vector Construction
For each gas sample, the control system sequentially excites the three measurement LEDs and the reference LED, yielding four time-domain signals that are processed as described above. After FFT, the amplitudes at the modulation frequency from the four channels form a raw four-dimensional feature vector. To compensate for common-mode variations such as changes in overall source intensity, detector aging, or losses in the optical path, the amplitudes of the three measurement channels are normalized by the amplitude of the reference channel. This step results in a final three-dimensional feature vector that is more robust against non-selective disturbances and more sensitive to changes in the relative composition of the gas mixture.
These normalized feature vectors constitute the input to the CNN–SVM model introduced in
Section 5.
5. CNN-SVM Model
To effectively discriminate the principal component in mixed alkane gases from the processed spectral data, a hybrid intelligent model that synergistically combines a Convolutional Neural Network (CNN) and a Support Vector Machine (SVM) was developed. This section details the theoretical underpinnings of each component and the architecture of the integrated CNN-SVM model.
5.1. Convolutional Neural Network
Convolutional Neural Networks (CNNs) are a class of deep neural networks particularly renowned for their ability to automatically and adaptively learn spatial hierarchies of features from data [
22,
23,
24,
25]. While traditionally applied to image processing, their architecture is highly effective for extracting discriminative patterns from sequential or multi-channel data, such as the feature vectors generated by our NDIR system.
A typical CNN architecture consists of an input layer, one or more convolutional layers, pooling layers, and an output layer [
26]. The key innovation of CNNs lies in the convolutional layers, which employ local connectivity and shared weights. Neurons in a convolutional layer are connected only to a local region of the input, allowing the network to learn localized patterns. By sharing weights across the entire input field, the network significantly reduces the number of trainable parameters (w, b), which accelerates training and mitigates the risk of overfitting. The structure of a fundamental CNN model is illustrated in
Figure 3.
5.2. Support Vector Machine
To benchmark and complement the neural network’s performance, the Support Vector Machine (SVM), a powerful and widely used supervised learning algorithm, was employed. SVM is particularly effective for classification tasks, demonstrating high accuracy, robust performance with small-to-medium sized datasets, and excellent generalization capabilities by being less prone to overfitting than other models like decision trees.
The core principle of SVM is to find an optimal hyperplane that maximally separates data points of different classes in a high-dimensional feature space. This hyperplane is determined by identifying the support vectors—the data points closest to the decision boundary. The objective of the SVM algorithm is to maximize the margin, which is the distance between the hyperplane and the nearest support vector from either class. A schematic of SVM classification is shown in
Figure 4.
For a linearly separable dataset, the distance from the nearest point to the decision boundary is given by:
Simplifying the distance from the point to the line yields:
The optimization objective is therefore to maximize the margin, which is equivalent to minimizing:
The constraint is obtained by performing the deflation transformation, and from the above equation, it is only necessary to consider , and choose the appropriate values of and so that reaches the maximum. In order to facilitate the objective function operation, the problem of finding the maximum of is transformed into the problem of finding the minimum of , which eventually evolves into the value of . In order to solve the situation that the existence of noise points in the data leads to the poor effect of classification line, the parameter relaxation factor is introduced to make , called soft interval optimization, and the new objective function is converted to , when tends to infinity, it means that the classification is stricter and cannot have errors, and conversely when tends to infinity, it means that it can have greater error tolerance. To solve the problem of linear indivisibility, the kernel function is introduced for dimensional transformation, and the categories that are indivisible in one-dimensional space are transformed to two-dimensional space for segmentation.
5.3. CNN-SVM
To capitalize on the distinct strengths of both models, this study proposes a hybrid CNN-SVM architecture. This approach leverages the CNN’s superior capability for automated feature learning and the SVM’s robustness in performing classification, particularly in high-dimensional feature spaces. It has been demonstrated that replacing the standard fully connected and softmax layers of a CNN with an SVM classifier can improve generalization and overall classification performance [
27].
The architecture of our proposed hybrid model is depicted in
Figure 5. In this configuration, the CNN component functions as a sophisticated feature extractor. The input feature vectors, derived from the NDIR sensor signals, are processed through a series of convolutional and ReLU activation layers. Instead of proceeding to a fully connected layer for classification, the output from the final convolutional or pooling layer is flattened into a one-dimensional vector. This vector, which represents a rich set of high-level features learned by the CNN, is then fed directly as input to an SVM model, which performs the final classification task.
The workflow of the hybrid model is outlined in
Figure 6. The process involves two main stages:
Feature Extraction: A CNN is first trained on the dataset. Through this training, the network’s convolutional layers learn to identify and extract the most salient features that distinguish between the different gas mixture compositions.
Classification: The feature maps generated by the trained CNN are then used as the input dataset to train the SVM classifier. The SVM then learns the optimal decision boundary within this learned feature space to perform the final classification.
6. Results and Analysis
This chapter presents the experimental validation of the proposed NDIR system and the synergistic CNN-SVM model. The section begins by detailing the composition of the dataset used for training and evaluation. Subsequently, it provides a comparative performance analysis of several machine learning models, starting with benchmark algorithms and culminating with the proposed hybrid model. The analysis confirms the superior discriminatory capability of the CNN-SVM architecture for identifying the principal component in mixed alkane gases.
6.1. Experimental Dataset and Pre-Processing
To validate the proposed system, a dataset was generated using mixtures of CH4 and ethane. These were selected as representative alkanes due to their significant spectral overlap and industrial relevance, which pose a challenging discrimination problem.
The dataset encompasses six distinct mixture scenarios designed to thoroughly evaluate the model’s discriminatory capabilities. Pure gas samples include 80 measurements of 100% CH
4 (±0.5% uncertainty) and 80 measurements of 100% ethane (±0.5% uncertainty), establishing baseline performance benchmarks. For CH
4-dominant mixtures with large margins, we prepared 80 samples containing 80% CH
4 and 20% ethane (±1% uncertainty), while ethane-dominant mixtures with large margins consisted of 80 samples with 20% CH
4 and 80% ethane. To test the system’s sensitivity near decision boundaries, we included challenging near-parity mixtures: 90 samples of CH
4-dominant small margin mixtures (60% CH
4, 40% ethane) and 90 samples of ethane-dominant small margin mixtures (40% CH
4, 60% ethane). The absorption information of the four light sources under several different gas samples is shown in
Figure 7.
Our experimental dataset consists of 500 measurements, carefully balanced with 250 CH4-dominant samples and 250 ethane-dominant samples to prevent classification bias. The dataset was partitioned using an 80/20 split. The classification task was defined as a binary problem: to identify whether CH4 (labeled as Class 1) or ethane (labeled as Class 2) was the principal component in the gas sample.
6.2. Performance of Benchmark Classification Models
To establish a performance baseline, the dataset was first used to train and evaluate several established machine learning algorithms.
6.2.1. Backpropagation Neural Network (BPNN)
A conventional Backpropagation Neural Network (BPNN) was implemented as an initial benchmark. Through empirical testing, the optimal network architecture was determined to comprise three hidden layers with 6, 3, and 3 neurons, respectively. The model was trained to classify whether CH4 was the principal component.
The performance of the trained BPNN is summarized by the confusion matrices in
Figure 8. The overall classification accuracy on the test set was 77.3%. The Receiver Operating Characteristic (ROC) curve analysis, shown in
Figure 9, yields an Area Under the Curve (AUC) value significantly above 0.5, indicating that the classifier’s performance is substantially better than random chance and provides a valid benchmark.
6.2.2. Standalone CNN and SVM Models
Further benchmarking was conducted using standalone Convolutional Neural Network (CNN) and Support Vector Machine (SVM) models.
The CNN model, leveraging its inherent capability for automated feature extraction from structured data, demonstrated a notable improvement over the BPNN. As shown in the confusion matrix in
Figure 10, the CNN achieved a classification accuracy of 87% on the test set. This result highlights the advantage of convolutional layers in identifying salient patterns within the multi-channel sensor data.
Similarly, an SVM classifier was trained on the same feature vectors. The SVM, a powerful algorithm known for its robust performance in high-dimensional spaces, yielded a competitive test accuracy of 86% (
Figure 11). This underscores the effectiveness of kernel-based methods for this classification task and confirms the feature vectors contain sufficient discriminatory information.
6.3. Performance of the Proposed CNN-SVM Hybrid Model
The proposed hybrid CNN-SVM model, designed to synergistically combine the feature extraction prowess of a CNN with the robust classification of an SVM, was then evaluated. In this architecture, the trained convolutional layers serve as an adaptive feature extractor, and the resulting high-level feature maps are classified by the SVM.
As detailed in the confusion matrix in
Figure 12, this hybrid model achieved a superior test accuracy of 89%. This result validates the central hypothesis of this study: decoupling the feature learning and classification stages into specialized components enhances overall discriminatory power.
6.4. Comparison with Other Methods
A comparative analysis against other traditional machine learning algorithms, including Logistic Regression, Bayesian classifiers, Decision Trees, and K-Nearest Neighbors (KNN), further solidified the superiority of the proposed model. As summarized in
Table 1, the CNN-SVM model consistently outperformed all other tested algorithms, establishing its efficacy for this challenging gas discrimination task.
The above results show that CNN-SVM model achieves near-perfect identification for pure gases and for mixtures with a clearly dominant component. However, the rate of misclassification increases when the concentrations of CH4 and ethane approach parity. This observation suggests that while the learned features are highly discriminative for imbalanced mixtures, the subtle spectral differences in near-equal compositions represent the primary frontier of the classification challenge. Nonetheless, the 89% accuracy achieved represents a significant advancement in using NDIR systems for complex alkane mixture analysis.
7. Summary
In order to address the issue that it is challenging to distinguish the primary components of mixed alkane gases, this paper chooses the non-split infrared gas detection method, designs a reference detection method based on the infrared gas absorption principle with four light sources and single sensors, and reasonably designs the optical part and circuit part of the detection system. It uses CH4 and ethane as the object of study, and obtains the classification accuracy. The CNN and SVM algorithms are combined to create a neural network model with a high rate of correct CH4 discrimination, and the classification accuracy reaches 89%, which is a good reference value.
It is important to note that the method proposed in this article is intended as a supplemental monitoring tool or a first-stage screening device in a multi-layered safety system, not a standalone safety tool. In high-risk industrial environments, such as underground mining operations, petrochemical facilities, or confined spaces where CH4 accumulation poses a risk of explosion, higher accuracy is required given the potentially catastrophic consequences.
To address the gaps in practical deployment in safety-critical scenarios, the following optimization strategies will be considered in the future. a. Enhanced Training Strategy: Implementing data augmentation techniques and collecting larger and more diverse datasets encompassing extreme environmental conditions (temperature variations, humidity, and pressure changes) will improve model robustness. b. Ensemble Approach: Developing a voting system that combines multiple machine learning models with different architectures to reduce classification uncertainty and provide a confidence metric for each prediction. c. Hybrid Redundancy: Combining algorithmic approaches with selective hardware redundancy.
The value of this manuscript lies in demonstrating the feasibility of replacing expensive optical filters with intelligent algorithms. This represents a significant advancement, making NDIR technology more accessible to a wide range of industrial monitoring applications where cost-effectiveness is important and moderate accuracy is acceptable. Future work will extend the dataset to include additional alkane species such as propane and butane, as well as more complex multi-component mixtures, to further validate the scalability and robustness of the proposed algorithmic filter approach across a broader range of industrial gas analysis scenarios.