## 2 Materials and Method
If this array contains less than two locations, the number of samples is increased until meeting this condition; if instead the number is larger or equal to 2, then \(N\) is simply set at twice the period between the first two index locations; this new value is to be used for the next loop of data acquisition. This operation occurs within the synchronization sub-VI that also calculates a shift, taken as the difference between the first index and 1/4 the total number of samples. The data acquisition sequence starts with \(1/4\cdot N-1\) samples, continues with \(1/2\cdot N\) samples, during which the DO channel stays in the true/false state (depending on the odd/even value stored as the shift register), and ends with \(1/4\cdot N\) samples, during which the DO is switched to the false/true state, respectively. These samples constitute the waveform (built with the Append waveform function) that is analyzed for transferring the synchronization data required for the next loop. Additional samples (a minimum of 1 point) are acquired (but not recorded) for compensating for the shift calculated as previously described. Besides the synchronization part, the data analysis sub-VI also outputs the duration of the two spark events it identifies each loop. Depending on the method used for TDC ID, these two durations are used directly or accumulated in an array, by replacing two out of the 200 values contained in the array. Three different operating modes were defined for the spark duration method: median, odd/even, and distribution evaluation. The first is basically the same as the previous study [37], but applied as an online evaluation; it simply compares the single spark duration with the median value of 200 events and classifies the first spark (of the two recorded during the loop) as below or above the median. The second mode compares the two spark events and assigns the shorter one as the firing TDC marker (thus the odd/even denomination). The third instead continuously evaluates the array that contains 200 spark durations and divides the odd and even events as below or above the median to impose the sequence of true/false or false/true to be written within the DO task. Figure 2: Schematic representation of the LabVIEW code. Figure 3 illustrates average traces obtained with the third mode of operation that continuously evaluates the odd/even condition but requires 200 spark events to function correctly (and therefore does not feature true cycle-to-cycle capabilities). One immediate observation is that the spark ID trace is not a true square waveform signal. This is due to the fact that the graphs contain traces averaged over 200 consecutive cycles; even if cycle-by-cycle, the DO is a series of sharp rising and falling edges, the average clearly shows a jitter caused by the software. One reason for the jitter is the mode in which synchronization was achieved (i.e., by changing the number of acquired samples rather than true synchronous acquisition by using an external clock), and therefore, a certain shift is to be expected. Another reason is that as previously iterated, the PCI6143 card allows only on demand DO write actions, and therefore, depends directly on the actual CPU runtime. Nonetheless, the signal generated in this way was considered as more than sufficient for the purpose of the current work, i.e., to evaluate online firing TDC ID capabilities. To render the correlation between spark ID and in-cylinder pressure even more reliable, the integration window was limited to the \(-270.-90\) deg aTDC crank angle range during the intake-compression strokes and to \(0.180\) deg aTDC interval during expansion-exhaust. The data shown in Figure 3 for the two load points clearly illustrates that when correctly identified, the low side of the TDC ID signal is correlated with low in-cylinder pressure (below 1 bar), while its high side to increased pressure (between 1 and 5 bar for the idling condition and in the range of 2.30 bar at full load).