Team:Bielefeld-CeBiTec/Model

Bielefeld-Cebitec-2020-Model

Model
In order to evaluate the hormone concentration detected with the help of the surface acoustic wave (SAW) technique, the phase shift between the signals at the exciting interdigital transducer (IDT) (c₁) and the IDT at the opposite end of the piezoelectric crystal (c₂) must be analyzed. Since our aim was to develop an easy-to-use, hendheld device, measuring the phase shift between the two signals using a laboratory oscilloscope was only considred as a reference method. Such devices capable of operating above 200 MHz are quite expensive and large scale. We therefore needed to find a way to preprocess the signals in hardware and decided to use modeling in the early stage of our hardware prototype development to evaluate which kind of circuit is best suited for our use case.

Figure 1: Schematic overview of the two modeled circuits. The two sine wave signals at the IDTs (c1 and c2) are routed to either one of two potential hardware circuits that preprocess the signals to process a single DC, analog signal correlating with the phase shift between c1 and c2. A: The mixer circuit consisting of the mixer and a subsequent low-pass filter. B: The XOR circuit with a comparator at each input of the XOR gate, followed by a low-pass filter.

We modeled the theoretical output behaviour of two different circuits that would potentially be suited for this purpose: The frequency multiplier or mixer and the XOR gate. The mixer circuit multiplies the two input sequences with each other. The XOR gate implements an exclusive or, that is, a high output results if one, and only one, of the inputs to the gate is high. In case of two inputs, if both are low or both are high, a false output results. In combination with a subsequent low-pass filter, both are in principle suitable for generating an analog, DC output signal correlating with the hormone concentration. This resulting analog signal can then be measured with any analog to digital converter (ADC), such as the ones included on the Arduino Uno, without the need of an oscilloscope. In the following, both methods are compared analytically and numerically to determine which is suited best for our measurement purposes.

Assumptions underlying the models

In the following, both methods will be performed analytically. Assuming signal noise is neglected and a perfect sine wave is generated by the direct digital synthesizer (DDS ) used to generate the excitation frequency c1, the two input signals are two simple wave functions, the wave from the measuring channel (c2) and from the reference channel (c1). c(t) = A cos(ωt+φ) = A (2πft+φ) Where f the frequency, ω is the angular frequency, A the amplitude and φ the phase shift of the wave function. The symbols belonging to signals c1 and c2 are labelled with a subindices 1 and 2, respectively. The surface acoustic wave (SAW) chip that we were planning to use in our hardware setup was designed with the SAW chip of Turbé et al. [1] as a reference and is identical with respect to materials and critical dimensions. Since they could not detect any change in frequency between the excitation signal (in our case: c1) and the output signal (c2) [1], we can savely assume that the same applies in our experimental setup. Therefore, we can take the simplifying assumption that f1 = f2 at all times. Therefore, the only remaining dimensions that can possibly differ between the two sine wave signals are the amplitude A and the phase shift φ. Both are independent of the frequency f. We therefore do not need to model the theoretical output behaviour of the two circuits at the operating frequency at approx. 250 MHz and chose f = 1Hz for the purpose of this modeling.

Analysis of the Mixer output:

The mixer circuit simply computes the product of the two inputs. This can be written as follows:

c₁(t) * c₂(t)
<=>(A₁ * cos(f₁*2πt+φ₁))*(aA₂*cos(f₂*2πt+φ₂))
f₁ and f₂ are assumed to be identical, f₁ = f₂ = 1Hz
<=> A₁*A₂*cos(1Hz*2πt+φ₁)*cos(1Hz*2πt+φ₂)

The mixer output therefore result depends on the amplitudes (aA₁ and aA₂), the time (t) and the phase shift (φ₁ and φ₂) in addition to the frequency f. The term above contains the product of two cosinus terms, which gives a superimposed wave function with twice the frequency of the input functions, in case f₁ = f₂.

Analysis of the XOR gate output:

The XOR gate is a logical function, operating on logical inputs that need to be either a logical 1 or a logical 0. Therefore, the XOR circuit needs an additional comparator infront of each input to the XOR gate. A comparator basically computes the sign function of its input: It outputs a logical 0 if the input is smaller than 0 V and a logical 1 if the input is larger or equal to 0 V. An XOR gate with two inputs outputs a logical 1 if and only if the sum of its inputs is equal to 1. The output behaviour is best understood by taking a look at the truth table of the XOR gate.
c₁c₂XOR = c₁ ⊻ c₂
000
011
101
110

Table 1: Truth table of an XOR gate with two inputs.


f₁ and f₂ are constant, set f₁ = f₂ = 1Hz
sgn(c1(t))⊻sgn(c2(t))
<=>sgn(A₁ * cos(1Hz*2πt+φ₁)) ⊻ sgn(A₂*cos(1Hz*2πt+φ₂))
<=> sgn(A₁ )* sgn(cos(1Hz*2πt+φ₁)) ⊻ sgn(A₂)*sgn(cos(1Hz*2πt+φ₂))
a₁,a₂>0 => sgn(a₁) = sgn(a₂) = 1
<=> sgn(cos(2πt+φ₁)) ⊻ sgn(cos(f2πt+φ₂))

Therefore, the output of the XOR gate depends on the time (t) and the phase shift (φ₁ and φ₂).

From the number of parameters alone, it can be seen that the theoretical output of the XOR gate is only influenced by phase shift and time whereas the mixer is additionaly influenced by the amplitudes. The smaller the number of parameters on which a method depends, the more precise the measurement results, since they are influenced by fewer parameters. The two additional comparators are not adding substancially to the costs or effort needed to develop and build the required circuitry.

Numeric analysis

In addition to the analytical analysis of the two different circuits, we also wrote a Python script that numerically determines and visualizes their output behaviour. It is written as an interactive Jupyter notebook that allows the user to adjust the parameters of both input sine waves in an interactive fashion to observe the changes to and differences between the outputs of the two circuits. The jupyter notebook is available for download on this gitlab repository: here
The following cell sets the time window for our model from 0 to 20 seconds, whereby simulated values are calculated for c1, c2 and the output for every 0.002 seconds within this window. It also defines the cosine wave function that is called by later function to compute the value of c(t) = cos (f2πt+φ).
The following section, an exemplary output of the interactive plots created with our python script. At first, the arrays containing the values for c1 and c2 for all samples in the time window is calculated, with respect to the user defined parameter values. Afterwards, the circuit output values for both the mixer circuit (variable m) and XOR gate (variable x) is calculated. These output values simulate the output of both circuits before passing the low-pass filter to reveal the diffrences between the two methods. At last, all values are plotted and displayed.

Figure 1: graphical representation of the mixer method
the figure shows the change in voltage (V) as a function of time (s)
the given variables have the values:
f_1 = 1.00, phi_1 = 3.14, a_1 = 1.00,
f_2 = 1.00. phi_2 = 4.40, a_2 = 1.30
the blue graph is c₁, the orange one is c₂ and the green graph is c₁*c₂

Figure 2: graphical representation of the XOR gate
the figure shows the change in voltage (volts) as a function of time (s)
the given variables have the values:
f_1 = 1.00, phi_1 = 3.14, a_1 = 1.00,
f_2 = 1.00. phi_2 = 4.40, a_2 = 1.30
the blue graph is c₁, the orange one is c₂ and the green graph is c₁ xor c₂

The next sections of the code is for vizualizing the dependency of the mean output of both circuits on the relative amplitude and the relative phase shift. Applying the mean on the simulated values within the time window approximates the effect of applying a low-pass filter.

Figure 3: Color gradient of the mixer method,showing the dependency of the measurement on amplitude and phase shift.

This part of the code shows the dependency of the measurement results of the XOR method on amplitude and phase shift. The first cosinus wave is taken as given, as is the sequence of the second wave. For the given phi value, the for loop goes through the values which the amplitude can assume. The change in the measured values as a function of the phase shift and the relative amplitude is shown. The color gradient within the graphic shows that the measured values depend on the phase shift. With the help of the two lines commented out, the mean, minimum and maximum of the measured values can be displayed for a given phase shift.

Figure 4: Color gradient of the XOR gate,showing the dependency of the measurement on amplitude and phase shift

Conclusion

Both the analytical as well as the numerical analysis of the two compared circuits reveal, that the XOR gate circuit is to be preferred for our use case. In contrast to the mixer circuit, it is independent of the relative amplitude of the two input signals. Therefore, the measurement is most likely more robust compared to a measurement performed using the mixer circuit. The two additional comparator circuits needed do not influence the development process substancially.

Based on our modeling, we therefore decided to use a XOR based phase detection on the phase detection PCB that we designed in cooperation with the CiTeC at Bielefeld University. This was a critical decision in the design process that was to be taken, and this eleborated modeling helped us to a lot in this respect. To read more about how the PCB including the XOR gate turned out in the end, read our hardware page.

Source

[1] V. Turbé et al., “Towards an ultra-rapid smartphone- connected test for infectious diseases,” Sci. Rep., 2017.