In this section, the hardware of the odor generation system is described, the algorithms used to control the valves are explained, the algorithms are analyzed and compared, and finally a short experimental validation is performed.
2.2.1. Odor Generation System: Hardware
The odor generation system schematic can be seen in
Figure 3. A cylinder of dry compressed air was the source of carrier gas and acted as zero gas. A mass flow controller (HoribaStec, SEC-400, Mark 3) regulated the flow rate at 200 mL/min. Then, the air flow reached a distributor that split the flow uniformly into 16 channels. The channels went to a rack of 16 vials of 10 mL, with half of the vials empty and the others containing 0.5 mL of an odorant liquid. Each vial was then connected to a three-way solenoid valve. The valves sent the flow that passed through the vial to either an outlet collector or an exhaust collector (we call these valve positions closed and open, respectively), and these paths are represented by dashed or solid lines, respectively, in
Figure 3. The collector chambers were placed in a circular arrangement to make every channel length equal (
Figure 4).
Each vial containing an odorant liquid was paired with an empty vial so that they alternated; when the flow of the channel with the vial containing the odorant liquid was directed to the exhaust, the flow of the paired channel with the empty vial was directed to the outlet, and vice versa. The flow was always passing through all paths in the system, so there were no flow rate or pressure changes. This arrangement can be seen in
Figure 3. The distribution of channels and vials was used to maintain an equal path for each channel so that the flow was always constant and equal in each channel. Further, the gas concentration of each odor in its path remained constant, due to the constant flow passing through the vial. In this arrangement, each channel sent either the flow from the odorant vial or the flow from the empty vial to the outlet. Fast alternating of valves in a single channel can be used to control the average of the odorant concentration going through the outlet. In this scenario, all flows from all channels are added together at the outlet.
The valves (Takasago, EXAK-3) were controlled by a field-programmable gate array (FPGA, Altera Cyclone 5 SE 5CSEMA5F31C6N) that communicated with a computer through a USB COM port (chip: FT234XD-FTDI) interfaced with a computer. The FPGA accepted a command with a number from 0 to 100 for each channel that represented the percentage of odor flow going to the outlet, with 100 meaning that all the flow from the vial with the odorant was directed to the sensor chamber, and that the flow passing through the empty vial was directed to the exhaust. The FPGA read the command every second, setting new values for all channels at once. A transistor array was used to drive the solenoid valves.
The odor generation system tubing volume after the valves acted as a low pass filter (LPF) that mixed the gases. If the solenoid valve switching frequency was slow, the cutoff frequency of this filter was too low and noise would be seen by the sensors. To combat this, an optional buffer volume of 5 mL was implemented by a small vial at the outlet. This bigger volume acted as a LPF with lower cutoff frequency that smoothed the concentration changes generated by the alternating solenoid valves.
2.2.2. Odor Generation System: Algorithms
In a preliminary test with a PWM algorithm, some noise was detected. The noise was caused by the abrupt change of the QCM conductance peak during the VNA frequency scan due to the on–off solenoid switching. Using a frequency counter, as in [
7,
9], the noise reduction can be automatically performed due to integration during the frequency counter gate time (in the previous works the peaks were counted over 1 s). However, VNAs are more sensitive to switching noise because they lack the proper integration mechanism, even when output space acts as a LPF.
To fix this problem, two different strategies were tested for the realization of the digital to analog converters (DAC) that transformed digital control signals into analog gas concentrations. The two strategies were different algorithms of the valve open/close commands—a simple pulse width modulation (PWM), and a delta-sigma modulator of first order [
13]. The PWM has a fixed period with a variable duty width. This generates noise peaks at certain frequencies that are generally hard to eliminate using analog filters. On the other hand, the delta-sigma DAC has a variable duty cycle and a variable frequency, pushing the noise toward higher frequencies and also spreading the noise power more evenly. These effects make it easier to remove the noise via analog filtering [
13].
The main constraint of the system was the switching speed of the valves, which was 15–20 ms when opening and 5–7 ms when closing. Valve control switching times that come close to these values will produce distortions in the desired final concentration percentages. Since the aim is to improve the accuracy of the system compared to former versions [
10], the minimum pulse width used in the tests was set to the difference between the valve opening time and closing time (i.e., 0.01 s instead of 0.002 s).
The minimum pulse will be related to the frequency of the PWM and the delta-sigma modulator. For the PWM, because we had a resolution of 1%, the minimum pulse corresponded to a period of 0.01 s. For the delta-sigma modulator, the minimum pulse corresponded to the period of the algorithm. In the rest of this paper, we report the minimum pulse when comparing both algorithms.
2.2.3. Odor Generation System: Analysis
To perform an exhaustive test on different configurations, a model of the odor generation system was made in Simulink. The model consisted of a single sensor coupled with the PWM or delta-sigma DAC, a model of the valves, and a model of a buffer volume that acted as an analog low pass filter (LPF).
Figure 5 shows a Simulink model of the delta-sigma modulator in which the blocks from left to right are: input control, sampling and holding (used to change the sample rate), a subtraction of the output from the signal, an accumulator, a threshold quantizer that outputs zero or one, and the output of the subsystem. The state of the solenoid valve could change according to minimum pulse or in multiples of that time.
One sensor and one channel of the odor system tubing were modeled together as a second-order transfer function with two poles and one zero (Equation (4)). A model of second order is common in QCM as one time constant represents the speed at which the absorptions occur at the surface, and the other time constant represents the diffusion into the sensing layer. A response to a step from 0% to 100% of hexanol concentration, resampled to 1 Hz, was used to model the odor generation system and sensor, as shown in
Figure 6. An adjustment made with the System Identification Toolbox of MATLAB yielded the following values:
a = −0.03342,
b = −0.0003197,
c = 0.1673, and
d = 0.001389.
The solenoid valves were manually modeled as a one-pole system (Equation (5)) with
e = 462 when closing and
e = 177 when opening, values that yielded 90% of the response at 17.5 and 6 ms, respectively. Also, because of these different switching times for the opening and closing valves, a compensation was implemented in the Simulink model by adding a delay to the valve closing, making the time intervals equal. That delay was also added to the FPGA control circuits.
An optional buffer volume of 5 mL (implemented by a small vial) at the outlet, which was acting as an LPF, was modeled as a first-order transfer function (also Equation (5)) where
e = 3 was given by the volume (V) and flow rate (F) as
a = V/F [
14].
The model was used to perform several tests, comparing the different strategies and optimizing the values of the control algorithms. Several frequencies for the PWM and delta-sigma modulation were tested, the maximum frequencies produced pulses widths of 0.01 s. of 0.01 s. The system was tested with target concentrations from 10% to 90%. The simulation time was 10 min and the last 60 s of simulation were used to calculate the noise. Two different signal-to-noise ratios (SNRs) were used to characterize the system. The first was the SNR
q corresponding to the quantization caused by the PWM or delta-sigma DAC, as given by Equation (6), where
S is the mean of the simulated signal and
σ is the standard deviation of the simulated signal. When the minimum pulse gets shorter, the sensors have less time to respond and to follow the ups and downs of the concentration. In this scenario, the sensor oscillation decreases its amplitude, and the SNR gets higher.
The second SNR, SNR
dis, corresponded to the distortion caused by the difference of the valve switching times. It was defined as the difference between the ideal response and the mean response obtained, and given by Equation (7), where
Sideal is calculated from the specified concentration ratio percentage multiplied by the response at 100% (where the control system keeps the valve totally open), and Δ
S is the difference between that ideal signal and the simulated signal. Also, the quantization noise will produce some oscillations in the signal, which will also contribute to the reconstruction noise. At some algorithm frequencies, this contribution to the noise will be greater than the contribution coming from the valves.
This
SNRdis is lower as we approach shorter minimum pulses, because the errors caused by the valve operation time difference become more important. The combined SNR, expressed in decibels, is given by Equation (8), in which
Sideal is the ideal response, and the noise is calculated as the root sum squared of σ and Δ
S errors [
15].
The results of the simulations, sampled at 1 ms, can be seen and compared in
Figure 7. Plots titled PWM show the SNR of the PWM algorithm, plots titled DSMod show the sigma-delta modulator SNR, and titles including “+5 mL” indicated that the buffer volume at the outlet is included. The orange line represents the
SNRdis that originated from the distortion, and we can see that it becomes worse as the minimum pulse decreases and the effects of the alternating valves start to have more weight in the signal. On the other hand, the SNR
q that originated from the quantization noise increases with the frequency (blue line), and at higher frequencies the sensor acted as an LPF that smoothed the signal, lessening the quantization noise. The oscillations of the
SNRdis in the PWM were produced by the oscillation noise, which occurs when the signal oscillates between the valve in on and off states. Depending on the time at which the average measurement is taken (just after the valve opened or after the valve closed), this error can vary. In
Figure 7, the combined SNR is drawn in yellow (sometimes overwriting the blue or orange lines), and the optimum value is represented by a black circle in the plot.
For the PWM and delta-sigma modulator, the addition of the buffer volume increased the SNR of the quantization errors. For the PWM control with buffer space, the optimal minimum pulse was 0.01 s, which corresponded to a PWM duty cycle of 1 Hz and had a SNR of 45.7 dB. For the delta-sigma DAC with buffer space, the minimum pulse was 0.1 s, which corresponded to a frequency of 10 Hz, and the SNR was 48.3 dB, which was better than the PWM. This was caused by a better balance between the reconstruction error and quantization error.
Another aspect to consider is the time that the system takes to reach the stationary state. We defined
t90 as the time the system takes to reach the 90% of the final response, and the same model was used to calculate this time for all the configurations of the control modes. The target concentration percentage was swiped between 10% and 90%, then the
t90 was averaged. The minimum pulse was swiped between 0.01 and 0.1 s. The averaged
t90 for both PWM and delta-sigma were very similar (with and without buffer volume at the outlet), taking the values of 32 s for a minimum pulse of 0.01 s, and 42 s for a minimum pulse of 0.1 s. However, there was a difference, as the PWM control produced a higher difference between the maximum
t90 and minimum
t90 than the delta-sigma modulation. This can be seen in
Figure 8, where the differences between maximum
t90 and minimum
t90 among the different concentration levels (10%–90%) versus the pulse width are drawn.
This lower difference of the delta-sigma modulator was caused by its more evenly distributed on times compared with the PWM. This means that the time to reach the steady state varied more with the frequency for the PWM control than for the delta-sigma modulation control.