Critical implementation issues of excitation signals for embedded wearable bioimpedance spectroscopy systems with limited resources

Wideband excitation signals are essential in bioimpedance spectroscopy for measurements in a time ensuring a quasi-stable measurement condition. In particular, for wearable biomedical systems, due to limited system resources, several aspects regarding measurement time, crest factor, slew rate requirements, frequency distribution, amplitude spectrum, and energy efficiency need to be thoroughly investigated. In this paper, we present an investigation of excitation signals, which includes not only the theoretical aspects but also aspects of real implementation on microcontroller-based systems. At a fixed number of samples and sampling rate, we investigate the implementability of signal frequencies and the resulting spectral efficiency. We focus on sources of signal distortion due to timer and amplitude deviations. The results show that for 4096 samples and a sampling frequency of 1 MHz, wideband signals are 2.76 times faster than a stepped frequency sweep. The multisine signal provides a better energy efficiency and has a lower slew rate requirement on hardware (around 0.3 V µs−1), but has a relatively high crest factor, even after optimization. An exemplary investigation of the distortion of the time/frequency and amplitudes following implementation on a standard industrial advanced RISC machines microcontroller has shown that a sampling rate compensation is required to overcome timer inaccuracies. Furthermore, non-return-to-zero binary signals are more sensitive to distortion due to hardware-related issues and have a lower signal-to-distortion-and-noise (SINAD) ratio than 24 dB, which is lower than the multisine signal, having a SINAD of 31 dB.


Introduction
Bioimpedance spectroscopy is increasingly gaining importance as it provides information about biological tissues and organs as well as whole-body composition in a non-invasive way and without exposure to radiation [1]. In recent years, a pronounced trend toward the integration of bioimpedance spectroscopy in implants and wearable systems has been observed for several emerging medical applications, such as non-invasive clinical monitoring [2], cardiovascular monitoring [3], blood glucose monitoring [4], and urinary bladder filling rate and dysfunction [5].
Bioimpedance spectroscopy is typically done using an AC excitation signal [6], but can also be done using voltage signals [7,8]. The excitation signal needs to support the fulfillment of the requirements for impedance spectroscopy with respect to linearity, stability, and causality. In a wearable device, the stimulus signal is typically generated using an arbitrary waveform generator or a microcontroller, which could be interfaced to a voltage-controlled current source. To achieve a good measurement quality, despite limited resources, the excitation signal should meet a compromise between several requirements (see figure 1). The amplitude needs to be high and stable to achieve a high signal-to-noise-and-distortion (SINAD) ratio and ensure an accurate measurement while maintaining patient safety by adopting a secure current level below a given threshold. The signal should also have a low crest factor to ensure that when several frequencies are combined into one signal, it still remains below the amplitude threshold that satisfies the linearity condition but has a sufficient signal power at the excited frequencies [9]. Some signals require fast hardware with a high slew rate to avoid signal distortion. The signal duration needs to be short enough to avoid body state changes during the measurement process, but it must be long enough to provide a reliable measurement. According to Parseval's theorem, the signal energy in the time domain is equal to the signal energy in the frequency domain. This means that the energy carried by the signal in the time domain, which corresponds to the square value of the signal amplitude, is preserved after Fourier transform into the frequency domain. Energy losses due to harmonics and distortion therefore reduce the effective excitation energy and must be avoided by using signals with a high energy efficiency.
In fact, this leads to two main challenges. The first is to identify the appropriate signal fulfilling the requirements detailed above, and the second is to identify the appropriate signal parameters to ensure a sufficiently good implementation on systems with limited resources and processing performance. Several excitation signal surveys exist in the literature, yet they target expensive and/or bulky systems with resourceful peripherals and large storage capability, such as peripheral components interconnect extensions for instrumentation [6], field-programmable gate array systems [10], and applicationspecific integrated circuits [11,12], or implement a chirpready solution with limited adaptability [13].
In addition, microcontrollers have significantly low memory storage capability, limited sampling rate, and a slower processing speed. It can therefore be expected that the frequency resolution is limited as the clock frequency for the signal generation is not as fast and as accurate as reference systems. Although the D/A converter (DAC) resolution in microcontrollers is improving, a few quantization-related errors are expected. It is important to investigate further memory and processing aspects, such as the number of samples, frequency resolution, spectral amplitude, energy efficiency, crest factor, and slew rate hardware requirements. All of these aspects determine the quality of the excitation signal in the implementation and need to be carefully considered to enable a suitable choice of excitation signal.
In this paper, we study potential wideband excitation signals for bioimpedance spectroscopy for wearable portable devices based on cost-effective, resource-limited microcontrollers, to identify the most favored signal in embedded solutions. Afterward, we study the influence of the limitations of the embedded solutions on the signals themselves. The study is carried out on an industry-standard advanced RISC machines microcontroller, the STM32, with a maximum signal length of 4096, but could be generalized to other microcontrollers. In section 2, the potential signals for bioimpedance spectroscopy are described together with the implementation details. Section 3 contains a comparison of the signal on the basis of relevant key metrics in the time domain (signal duration, crest factor, and slew rate) and in the frequency domain (frequency distribution, count, amplitude value, and energy efficiency). Section 4 describes some possible distortions encountered following a signal implementation in STM32H743Zi. These distortions attack both the frequencies and the amplitude within the spectrum of the measurement.

Investigated signals
Excitation signals in impedance spectroscopy are divided into two main groups: the stepped frequency sweep and the wideband signals. The frequency sweep group includes single or limited frequency signals whose frequencies are swept stepwise as a function of time. The stepped sine frequency sweep [14] is considered to date as a reference in impedance spectroscopy. However, it suffers from a very long measurement time [6]. The calculation of the amplitude and phase of the signal is done before moving to the next frequency. This could be done typically using the lock-in amplifier or bridge method, and rarely discrete Fourier transform (DFT). The second category includes wideband signals, also called broadband and multifrequency signals. They are designed to contain multiple fundamental frequencies during one measurement cycle. Examples of this are chirp, multisine, pseudo-random binary sequences (PRBS), and ternary signals [15]. As microcontrollers can only generate either analog or binary signals, multisine, chirp, multifrequency non-return-to-zero (NRZ) binary, binary chirp, and maximum-length binary sequence (MLBS) are taken into consideration. The signal analysis is performed mainly at the end of the measurement, for all frequencies simultaneously, by means of time-frequency transformation. For this, DFT and its fast derivative, fast Fourier transform (FFT) are typically used. In this paper, we focus primarily on the comparison of wideband signals, in reference to the sine stepped frequency sweep. For a uniform comparison, all the signals are generated as normalized signals with a 1 V peak-to-peak amplitude, corresponding to −0.5 to 0.5 V voltage dynamic range, and have a common sampling frequency F s = 1 MHz. The frequencies are, if applicable, in the frequency range 1-100 kHz, ensuring at least 80 logarithmically distributed measurement points for a smooth impedance spectrum. As the implementation is intended for wearable embedded solutions, where the energy consumption is an important issue, the number of samples is set to 4096. In this section, all the signals are simulated using MATLAB to investigate the aforementioned parameters.

Chirp signals
Chirp signals consist of periodic signals whose frequency is continuously swept as a function of time f (t). Unlike the frequency sweep, where the frequency sweep is stepwise, the frequency function in chirp signals is continuous. This frequency function defines the type of chirp as linear, exponential, logarithmic, etc [16,17]. Among the aforementioned signals, only linear chirp signals keep the amplitude spectrum quasi-flat, and therefore two of its variants are studied: the linear sine chirp and the linear signum chirp.

Linear sine chirp.
The linear sine chirp uses a sinewave as the signal base, with a linear function frequency. Its mathematical expression x chirp (t) is shown in (1). In this equation, A and φ, respectively, describe the amplitude and phase of the base signal (sine), and are typically set as constants. t describes the time vector characterized by (k.∆T s ) k∈{0,...,N−1} and t max = (N − 1)∆T s , where ∆T s is the sampling period of the signal: where f (t) describes the frequency as it varies linearly as a function of time between a minimum frequency f min and a maximum frequency f max , for a duration of T stab : In figure 2, an excerpt of a 1 V peak-to-peak linear sine chirp is depicted. The frequency changes linearly until T stab = 2t max . Its spectrum is shown in figure 3. Due to the limited time-bandwidth product in the embedded systems, which is (t max .( f max − f min ) ≈ 405, Fresnel ripples are visible at the edges of the quasi-constant 10-100 kHz spectrum region. Here, the bandwidth is approximated to f max − f min . The quasiconstant region has a normalized single-sided Fourier amplitude spectrum of , where A is the amplitude of the chirp, N useful is the number of frequency bins in the useful region ( f min − f max ), and N is the total number of samples. In this case, the amplitude is set to A = 0.5 V and out of the 4096 frequency bins, only 404 frequency bins fall into the useful spectrum. The amplitude of the quasi-constant region is evaluated to |X N ( f )| = 0.0249 V.

Linear signum chirp.
The linear signum chirp uses a rectangular pulsewave signal as a signal base, with the same frequency function formula as the linear sine chirp f (t) defined in (2). The term 'signum' comes from a possible interpretation of this signal as a sign of the linear sine chirp [16]. The mathematical equation of this signal can be described as in (3): x bin chirp (t) = sign(x sin chirp (t)).
(3) This signal, as shown in figure 4 has the same periodicity as the linear sine chirp. The obtained spectrum in figure 5 looks distorted due to the proximity of the harmonics-tofundamental frequencies to each other. In fact, the NRZ binarization, i.e. through the sign function, of the signal leads to an amplitude gain factor of 4 / π at each fundamental frequency ( f fund ), in addition to the generation of a few harmonics defined by their frequencies f harmonics,n = (2n + 1).f fund , and their amplitudes of |X N ( f harmonics,n )| = 4 π.(2n+1) , which are decaying proportionally to the frequency. The Fourier approximation of the NRZ binarization of a sine with a fundamental frequency f fund is mathematically described in equation (4): ) .
The fundamental frequencies f fund in the case of the linear signum chirp are exactly the same as the frequencies of the peak values of the linear sine chirp, depicted in figure 3. Due to the limited samples, each fundamental frequency's harmonics overlay the other fundamental frequencies as well as the other harmonics from the other fundamental frequencies, causing a disturbance in the spectrum of the signum chirp signal. This effect becomes more visible proportionally to the frequencies, as the last frequencies tend to be affected by all the previous frequencies. In figure 5, the ideal signal (in green) is shown compared to the binarized signal (in red and blue). The main interest lies in the fundamental frequencies whose ideal non-overlapping single-sided amplitude spectrum has the value |X N ( f fund )| ≈ 4A √ N useful π , where A is the global amplitude of the signal and N useful is the number of frequency bins in the useful spectrum in the signal base, i.e. the linear sine chirp. This is evaluated to be 0.0316 V in this signal.

Multisine
A multisine is obtained by summing elementary sine signals as shown in equation (5). Each sinewave is indexed by k and characterized by its amplitude A k , a distinct frequency f k , and initial phase φ k . t is the time vector: In practice, summing multiple arbitrary sinewaves without any optimization leads to some problems. One problem is the high spectral leakage that can occur due to the spectral periodicity of the FFT when the frequencies are chosen arbitrarily. To avoid this, each elementary sinewave must complete an integer number of periods. The measurement time should therefore preferably be around the smallest common multiplier of all the periods, when the measurement time is flexible. When the measurement time is fixed, the frequencies of the elementary sinewave need to be aligned with the nearest frequency bin of the full signal, which is defined as f bin [k] = Fs N , where N is the total number of samples and F s is the sampling frequency. In this case, a sufficient condition is to choose a frequency res- , where n is the number of elementary sinewaves. When this frequency resolution condition is not satisfied due to limited number of samples, as in this case, two or more frequencies of the desired signals can be rounded into a single frequency bin during the spectrum analysis. To target ∼80 frequencies, 100 initial frequencies were used and were eventually rounded to 82 quasi-logarithmic distributions between 1 and 100 kHz. These frequencies are obtained with an error to the exact logarithmic distribution ranging between −7.32% and 2.34%, and the absolute value of relative error value averages 0.77% (standard deviation of 1.36%). The lost frequencies are in the first kHz range.
A further challenge is the high crest factor (see section 3.2) that results from the sum of several spectral shares. An optimization procedure can be adopted, aiming at minimizing   the crest factor by changing the phase of the elementary sinewaves. Several methods have been proposed, categorized as analytical methods, such as that of Schroeder [18], numerical methods, such as those of Van der Ouderaa (VDO) [19], Chebyschev polynomials [20], or a combination of these two methods, such as the Schroeder-VDO-logclip documented in [21,22]. By using the VDO algorithm and around 18k iterations, a crest factor of 1.77 is obtained, which is the lowest obtained crest factor among the previously mentioned methods, as shown in table 1. As a final step, the signal is normalized to the dynamic range −0.5/+0.5 V (see figure 6). The normalized single-sided amplitude of a multisine, revealed in figure 7, shows a relatively spectrally sparse constant amplitude spectrum [23]. The amplitude of the peaks is where A is the global amplitude of the signal and m is the normalization ratio, which is the ratio between the obtained crest factor CF obtained and the ideal crest factor of a non-distorted sinewave CF ideal , and is defined as m =

Multifrequency NRZ binary signal
The multifrequency NRZ binary signal [24] or discreteinterval binary sequences [6] describe the NRZ binary signals, whose spectrum can be used as an excitation signal. Typically, these signals are obtained via the binarization of a multisine signal, via Walsh functions [6,25], which are limited to 2 N frequencies, or more efficiently via the sign (signum) function [23,26]. However, other 1-bit modulation techniques could be interesting, such as sigma-delta (Σ∆) modulation [27]. Theoretically, the signum-based method provides a higher amplitude spectrum than the multisine's due to the binarization factor 4/π (see (4)). However, the spectrum becomes distorted due to the limited number of samples in the time domain and the limited bins in the frequency domain. Meanwhile, Σ∆ modulation tries to simulate the behavior of the sinewave through an NRZ binary sequence {−A,+A}. In this case, it is important to have a high oversampling rate corresponding to the ratio between the sampling rate and the maximum frequency. A major side effect of using this modulation is the artifacts at very high frequencies, in which a lot of signal energy is wasted. Aside from the high frequencies, the single-sided amplitude spectrum of the obtained signal resembles that of the multisine signal.
In figure 8, a comparison between the single-sided amplitude spectrum of sign-based and Σ∆-based multifrequency binary signals is shown. Due to the flatness and stability of the Σ∆ modulation technique, it was chosen over the sign-based multifrequency signal. A section of the Σ∆-based multifrequency NRZ binary signal in the time domain is depicted in figure 9. The useful amplitude spectrum of the single-sided power spectrum of the multifrequency binary signal is shown in figure 8 in orange, side-by-side with the waste spectrum in navy blue. Due to its imitation of the multisine signal, the amplitude spectrum is spectrally sparse and is the same as that of the multisine signal

Maximum-length binary sequence
The maximum-length binary sequence (MLS or MLBS) belongs to the class of PRBS [28]. It is composed of a sequence of {+A,−A} (see figure 10) whose spectrum is eventually flat and can be generated using a linear feedback shift register. A major constraint is the number of samples, which is restricted to a 2 N b − 1, where N b is the resolution of the linear feedback shift register. Since the selected number of samples is 4095, a 12-bit linear feedback shift register was used for signal generation, as shown in algorithm 1.
As previously mentioned, the spectrum is flat and is shown in figure 11. The amplitude of the spectrum is defined as where A is the signal amplitude and N is the length of the corresponding signal. |X N ( f )| is evaluated to be 0.0156 V in this case.

Comparative study of the digitalized excitation signals
In this section, the aim is to compare wideband signals to sine stepped frequency sweep as a reference signal, and to compare wideband signals to each other using relevant key metrics. The The generated signals will be implemented and proofed on a real microcontroller with limited resources in the next section.

Signal duration
The signal duration is directly related to the measurement time and should be minimized to fulfill the conditions of stability and causality. Signals utilizing stepped frequency sweep must finish at least an integer count N repeat of period(s) before data processing. The total measurement time is, therefore, defined as T meas,sweep = N repeat .
. The signal duration of wideband signals, on the other hand, is related to the frequency bins of interest. These signals are processed using DFT or its fast alternative FFT. The relationship between the signal duration/measurement time t max , number of samples N, and frequency resolution f res is defined in (6): For all wideband signals, this number N can be arbitrarily chosen, with MLBS imposing 2 n −1 measurement points (n ∈ N). The selected number of samples (4096) allows both sufficient measurement time for data acquisition for at least 82 logarithmically distributed frequencies, but also compatibility with the Radix-2 and Radix-4 FFT algorithms [29].
Comparing both signal families shows that for application in wearable bioimpedance devices, the frequency sweep signals require 11.33 ms to accomplish a full measurement cycle with one period according to (6). Wideband signals, on the other hand, require only 4.09 ms to get an equivalent signal, with 82 or more useful frequency bins. In table 2, the signal duration of the different signals is depicted.

Crest factor and slew rate
The crest factor defines the ratio between the peak of the signal and its root-mean-square (RMS) value, by the following equation The crest factor provides information on the signal compactness. Prior to signal generation in hardware, a normalization process to the voltage level of the system may be required. In this case, a compact signal will submit a lower normalization factor than a signal with a high crest factor. Second, for a compacter signal, the slew rate requirement for the hardware will be less demanding. Table 3 shows the crest factor of the selected signals. Theoretically, the crest factor of an NRZ binary signal is 1.0 (i.e. the maximum and RMS are the same), which is also affirmed by the simulation results. The crest factor of an undistorted sinewave is √ 2. Distorted sinewaves can be higher (e.g. triangulation of the signal) or lower (e.g. binarization of the signal) depending on the distortion factor. This is why the linear sine chirp and frequency-swept sinewave have a crest factor of around √ 2. The multisine is a special case, in which the crest factor should match the undistorted or distorted sinewaves depending on the parameters. Currently, no optimization algorithm is capable of returning a signal optimization with a reasonable number of iterations, and the issue remains to this day a challenge [22]. In this case, the crest factor of the multisine was optimized to 1.77.
For a lower distortion, the slew rate of the target hardware of both generation and measurement must match or be higher than the requirements shown in table 3. By definition, the maximum value of the differential of the voltage over the time dV/dt defines this slew rate. The NRZ binary signals require at least 2A/F s slew rate in all cases but are rather linked to the fall/rise time during signal generation. The other signals are related to the waveform of the signals and are determined numerically as shown in table 3.

Frequency distribution and frequency component count
Frequency-swept signals and multisine-based signals allow the customization of the frequency selection, range, and count. For multisine-based signals, this freedom is limited, as the choice of frequencies is linked to the measurement time, itself restricted by the frequency bins, as discussed in the previous section. Nonetheless, a logarithmic distribution of the frequencies within the frequency bins is possible, as described in section 2.2. The linear chirp and MLBS have a lower degree of freedom in the frequency selection. The linear chirp signals allow the parameterization of the frequency range, and the distribution is always linear regardless of the chosen frequencytime formula. On the other hand, the number of frequency bins in MLBS is restricted to 2 n −1, and it yields an equidistant flat spectrum. Table 4 shows a summary of the frequency distribution of the selected signals as well as the obtained frequency components within the frequency range of interest. Considering the prerequisites of this study, the single-sided spectrum analysis of the multisine and multifrequency NRZ binary signal results in 82 logarithmically distributed frequencies within the frequency range of interest. The MLBS and linear chirp operate on 447 linearly distributed frequency bins within the same range as the 447 frequencies; 404 are proven to be useful, as detailed in section 3.4.

Amplitude spectrum
The single-sided spectrum catalyzes the signal into a sum of elementary cosines. A spectrum with higher amplitudes indicates a better power distribution since the power spectrum density is estimated as follows: S xx ≈ |X N ( f )| 2 [30]. As discussed in section 2 and further mentioned in table 5, this amplitude is directly related to the total number of frequencies, and, more importantly, the useful frequency components within the frequency range of interest. Table 5 shows the average amplitude peak value within the amplitude spectrum and, if applicable, the standard deviation of these peaks, which is negligible if not mentioned. The sine stepped frequency sweep has a very high amplitude, as only one sinewave is generated at a time. The multisine and multifrequency binary signals share an amplitude of 0.04 V (−91.2% compared to the sinewave frequency sweep). Hence, they outperform all the other wideband signals due to their discrete concentrated energy within Finally, although the MLBS shows a flat spectrum, it suffers from very low amplitudes as its energy is dispersed throughout the spectrum with a spectrum amplitude of just 0.016 V.

Useful spectrum and energy efficiency
Although many frequency and amplitude components can be found in the spectrum, only a few can then be used for the impedance spectroscopy-based analysis. These components are defined using two main conditions: the frequency is in the frequency range of interest, and the amplitude is high, preferably matching the peak values in the amplitude spectrum defined in section 3.4, or at worst separable from the signal artifacts and noise. Mathematically, this amplitude can be defined within an inter-class variance maximization problem, where a threshold |X N,th | is used to separate the peaks from the artifacts within an amplitude spectrum. Combining the condition of the frequency and amplitude, a useful component within a spectrum for bioimpedance analysis should satisfy the equation defined in equation (7): The threshold value may be defined subjectively, or by using an algorithm to maximize the variance between the useful signal and signal artifacts, such as the Otsu threshold [31]. An Otsu-based threshold was applied to the (1-100 kHz) part of the normalized-to-1 spectrum, with a bias toward lower values for full compatibility with all the signals. In figure 12, the application of the threshold value to separate the useful spectrum from the waste on an example multifrequency NRZ signal is shown. The useful spectrum of all the signals is identified in orange (compared to the waste signal in blue) in the following figures 3, 5, 7, 8, and 11 using equation (7).
By setting the useful energy threshold and therein the useful spectrum, the energy efficiency can be calculated using equation (8) for a spectrum X(f ) of N samples: This equation cognates with the energy efficiency in [16] and power efficiency in [32], and is used as a metric to evaluate the energy of the waste signal during signal generation, compared to the signal energy to be used in impedance spectroscopy. In table 6, a comparison between the signals based on the energy efficiency for the full spectrum and the energy efficiency within the frequency range of interest (1-100 kHz) is depicted. The sine-based signals produce less waste energy than NRZ binary signals, as the latter suffer from energy loss due to the harmonics. The sine signals compared show that the sine frequency sweep and multisine are tailored signals and are therefore energy-efficient. The linear chirp is second to them, as Fresnel ripples and a slight energy loss of 1.15% in the total  spectrum and 0.67% in the frequencies of interest are noticeable. Following a comparison between the binary signals, it is shown that the linear signum chirp has a 14.53% energy loss across the spectrum but maintains 100% efficiency in the frequencies of interest. The multifrequency binary signals show a 31.79% energy efficiency due to the oversampling through Σ∆ modulation. These losses are minimal in the frequency range of interest, as the loss is only 3.85%. Finally, the MLBS has the lowest efficiency as most of the spectrum is outside the frequency range of interest, but there is no loss in the frequency range of interest. If the MLBS had been driven by a sampling frequency of 200 kHz or less, it would have suffered less loss.

Discussion
The compared wideband signals are 63% faster than stepped frequency sweep signals and have useful frequency components, crest factor, and energy efficiency that match the latter. Their amplitude spectrum is very small and is related to the number of useful frequency components N components , making them lower by a factor of 1/ √ N components compared to the frequency sweep. For 82 frequency components and multisine, being the best of the selected signals, this was evaluated to have an amplitude spectrum that is 92% smaller than that of the sine frequency sweep.
Among the wideband signals, signals with sparse spectra, such as multisine and multifrequency NRZ binary signals, have better amplitude spectra, making them potential alternatives for frequency sweep. For the other signals, while having more frequency components and a linear distribution, the energy is spread linearly, leaving less energy for the frequencies within the frequency range of interest, and especially among logarithmically distributed frequencies. In figure 13 we represent the realized spectrum for several types of excitation signal and different signal durations as a spectrum of colors in a 2D image, where the navy-blue color represents a low spectrum amplitude and the dark red color represents a high spectrum amplitude. For example, the square spc-2 ms in figure 13(a) corresponds to the realized spectrum for a signal with a duration of 2 ms in the time domain. The results for different signal types demonstrate the stability and discretization of the frequency components of the multisine and multifrequency NRZ binary in the function of time, in which the power is concentrated in these particular logarithmically distributed frequencies while being omnipresent throughout the whole signal duration. The main problem in the multifrequency NRZ binary is the excess of wasted energy signals, although a low crest factor is observable.
As a partial conclusion, spectrally sparse multifrequency signals have a better performance concerning temporal stability, energy concentration in logarithmic frequencies, and a relatively high amplitude spectrum compared to the other wideband signals. While the multifrequency NRZ binary signal is simpler to implement thanks to its binary nature, the major concern here is the energy efficiency of the signal due to the harmonics.

Comparative study by implementation on microcontroller
In order to evaluate the performance of the signals in practice, the signals have been implemented exemplarily on an STM32H743Zi. With this comparison, we go deep into the implementation aspects, comparing the realized signal performance with the theoretical results in section 3. The aim here is to evaluate the excitation signals, considering implementation in systems with limited resources. Each signal is generated using a look-up table, with an offset of 1.5 V to avoid negative voltages that cannot be generated by the microcontroller. The DAC is linked with a timer with a sampling clock F s,STM32 = 1 MHz. A direct memory access configuration is used to avoid CPU overheads during data transfer.
The data acquisition is performed using a Picoscope 2204A (PS) with a sampling rate of F s,PS = 1.5625 MHz. Due to the sampling rate mismatch, an STM32-driven trigger is used to synchronize the start and end of the data acquisition. In this case, the number of samples N PS collected must fulfill the condition that the frequency resolution is preserved, as shown in (9):

Sampling frequency and frequency uncertainty
Despite setting a constant sampling rate for the STM32 board during the configuration, the experimental sampling frequency of the STM32 kept changing over time. This uncertainty is not visible at low frequencies and intensifies in the MHz range. This could be linked to the clock jitter due to the internal RC oscillator imperfections of STM32. To monitor this behavior, a sinewave with a specific frequency (10 kHz) was used and monitored via an oscilloscope, which in turn was checked against possible mismatches using reference signal generators. While the temperature of the STM32's processing unit was not monitored, its ambient temperature rose from 22.9 • C (at 11:55 AM) to 23.2 • C (at 12:21 PM). In figure 14, it can be seen that the sampling frequency of the STM32 varied between 1.0008 and 1.0019 MHz during operation and matches the ambient temperature evolution. As the sampling rate changes, the frequencies and frequency bins change in the process, by a factor of F s,measured F s,theoretical . For the remainder of this paper, the sampling frequency of the measurement is estimated as an inverse problem, where a linear search algorithm, with optimization function RMS of the error between the spectrum of the measurement and the spectrum of the theoretical signal, is performed with a sweeping sampling frequency rate with an accuracy of 0.1 Hz.

Amplitude error: signal quantization and noise uncertainty
The amplitude of the implemented signal is subtle to many imperfections compared to the desired signal. These imperfections, also called distortions, could be due to hardware or system-related components, such as electronic noise and quantization errors. Others may stem from external environmental factors, colloquially referred to as 'external noise'. The analysis of the residuals in the timex(t) and frequency domain X residual ( f ) provides a general overview of the nature and value of the errors. When these distortions are combined and compared to the ideal signal, it can be seen that the NRZ binary signals are more affected by these artifacts than the analog sine-based signals. In table 7, the RMS of the residual as well as the estimated SINAD according to equation (10) is shown: where |X RMS,signal | is the RMS of the spectrum of the signal and |X RMS,residual | is the RMS of the noise, both in the frequency range of interest. Here, the residual X residual is calculated according to equation (11):  It is shown that the multifrequency binary has the highest error mean at 2 mV owing to the higher spectrum and binary nature. Altogether, the NRZ binary signals have a lower SINAD in the range of 20-24 dB within the frequency range of interest. The linear sine chirp has a higher SINAD of 27.41 dB and a lower residual RMS contribution of 1.06 mV to the ideal spectrum. Finally, multisine exhibits the highest SINAD of 31.45 dB and the lowest RMS error of 0.66 mV on average.
As mentioned earlier, these distortions are the result of many sources. Although the separation according to the distortion origin is complex and requires fine equipment, it is still possible to split them into systematic residuals, in which the distortion exhibits a specific pattern for a particular signal status or behavior, and non-systematic residuals, which include distortions uncorrelated to the signal. The application of the Savitzky-Golay filter [33] shows a pattern that resembles the spectrum of the signal in question for all the considered signals, presumably of the systematic error. This spectrum also overlaps with high-frequency oscillations for the NRZ binary sequences, as shown in figure 15.
For the NRZ binary signals, the main source of systematic distortion originates from the switching time errors. For example, the residual curve of the multifrequency NRZ binary residual in the time domain in figure 16 (left) shows recurring impulses that match the amplitude and frequency of the signal. Unlike the sine-based signals where the voltage changes at a rate of less than 0.3 V µs −1 , binary signals change at a constant rate much higher than 1 V µs −1 , and this sudden voltage change may not be tracked or timed correctly during the generation, as well as the measurement. This is also confirmed in figure 16 (right), where the residual histogram almost follows a normal distribution, except for small peaks related to quantization uncertainties with values between 0.5 V and −0.5 V. For this, the residual graph in the frequency domain is mainly affected by this timing mismatch, as can be seen in figure 15. Another major problem with NRZ binary-based signals is the overlapping highfrequency oscillations. These are due to the high quantization noise in the frequency domain. In figure 18, the spectrum of the expected quantization noise matches the overlap signal pattern of the residual spectrum of NRZ binary signals in figure 15.
For the sine-based signals, the comparison of the filtered spectrum of the residual in figure 15, together with the spectrum of sine-based signals (figures 3 and 7) and the spectrum of the quantization error in figure 18, shows that the final spectrum of the residual could be an equal contribution between quantization noise and time-mismatching error. For the multisine, for example, and in figure 17 (right), the graph shows that the quantization affects the histogram of the residual, which is otherwise normally distributed. However, in figure 17, just like the binary-based signals, the error shows up periodically but with a much lower amplitude and is shaped similarly to white noise. This is why the residual spectrum is not as affected by these impulses as the spectrum of the NRZ binary. This means, in practice, that it is crucial to measure the excitation signal to get feedback information about the generation and measurement-related distortions.

Conclusions
In this paper, we investigate potential excitation signals for bioimpedance spectroscopy in wearable devices. Several signals are compared with each other and with the sine stepped frequency sweep as a reference using several key metrics, including signal duration, crest factor, slew rate requirement, frequency distribution, amplitude spectrum, and energy efficiency. Thereby we go beyond the theoretical aspects to consider implementation aspects on systems with limited resources. The results show that wideband signals are 2.76 times faster than frequency sweep signals. Theoretically and by design, the NRZ binary signals show a very low crest factor but a high slew rate requirement compared to the sinewave. This translates to signal compactness during implementation, but the higher slew rate requirement demands that both the generation and the measurement hardware be capable of processing high signal changes. In the spectrum comparison, the multisine, being a spectrally sparse signal, concentrates the energy into fewer logarithmically distributed frequency components and therefore has the highest spectrum amplitude in wideband signals and is one of the most energy-efficient signals. Second to the multisine is the multifrequency NRZ binary signal, which should have matching properties but has an excess of waste energy due to oversampling.
The signal implementation in a cost-effective embedded system shows two main shortcomings, which are the time and frequency mismatch, and the amplitude imperfections. Experiments revealed a maximum error of 1.9% where the sampling frequency and the frequencies were deviated and accelerated by this rate. Therefore, it is important to retrieve the correct sampling rate before data processing or to compensate for this error before signal generation.
NRZ binary signals exhibit a very high distortion during implementation with a SINAD around 20-24 dB. These problems are related to the limited hardware capability, in terms of bandwidth, slew rate, and quantization, during signal generation and eventually measurement capability, causing recurring spikes. However, they remain easier to implement when compared to analog signals. Therefore, with a good signal processing system, they could replace the all-round multisine, which is otherwise the recommended solution. The question that remains open for the perspective work is the degree of generalization of the concrete results on the measurement deviation of impedance spectra. Whereas the methodology remains general, the concrete results and values are relative to STM32H743Zi. For other microcontrollers, a similar investigation needs to be carried out to deliver the corresponding values.

Data availability statement
All data that support the findings of this study are included within the article (and any supplementary files).