1 Introduction

Fig. 1
figure 1

Schematics for a general FFC NMR experiment

Fast-field cycling nuclear magnetic resonance (FFC-NMR) is a low field technique that allows to study the dependence of the spin-lattice relaxation rate \(R_1=1/T_1\) on the strength of the \(B_0\) magnetic field the sample is exposed to. The relation \(R_1(B_0)\) is called NMR dispersion (NMRD) profile, and allows to gather particular information about the molecular dynamics. An FFC experiment is based on a quick switch of the \(B_0\) field and allows to obtain the NMRD profile in a point-wise way. The experiment is carried out by cycling over three phases [1], as depicted in Fig. 1:

  • Polarization a high polarization field \(B_0=B_\mathrm{{pol}}\), is applied to pre-polarize the sample.

  • Relaxation the sample relaxes at a magnetic field \(B_0=B_\mathrm{{rel}}\), whose intensity is changed at every cycle to obtain relaxation at different field strengths.

  • Acquisition the field is set to the acquisition field \(B_0=B_\mathrm{{acq}}\), for signal acquisition at a better signal-to-noise ratio (SNR).

As in standard NMR experiments, stability of the magnetic field \(B_0\) during acquisition is a key point to obtain precise and repeatable results. Still, while in standard NMR the magnetic field can be generated by means of superconducting magnets to provide the required level of stability, in FFC NMR, \(B_0\) must be generated with very fast resistive magnets, that allow fast switchings of the field intensity. Control systems based on current feedback, typically implemented in the power supplies feeding FFC electromagnets, may not be enough to obtain the desired level of stability of the \(B_0\) magnetic field, since no direct feedback is present on the field itself. In addition, FFC NMR experiments require to obtain the desired stability as soon as possible, at the beginning of the acquisition phase. In fact, any delay in the measure would allow part of the relaxation process to occur at the acquisition field, thus obtaining a poorly reliable measure [1]. The field-frequency lock (FFL) is a well-known approach to avoid magnetic field oscillations. The idea is to exploit the dependence of the NMR signal on the field, and obtain an indirect but very fine grained measure of the magnetic field fluctuations from a parallel NMR experiment, called the “lock experiment”, which is carried out over a known nuclear specie (i.e. a known \(\gamma\)) [2,3,4,5,6,7,8]. Note that the two nuclear species must be different to avoid interference of the two experiments.

The classical implementation of the FFL relies on a phase-locked loop (PLL), where the NMR lock signal is compared to a reference one and an error signal proportional to the frequency deviation is generated. This error signal can be used to feed a P or PI regulation block [2,3,4]. Still, this implementation suffers from low SNR and is ineffective in rejecting the high-frequency current/field disturbances [7] that typically affect FFC electromagnets. A different approach is investigated in [7, 9], where the lock experiment is designed to obtain a continuous signal, which can be more effectively used as feedback in a control loop. However, this approach calls for a detailed model of the NMR lock experiment for a proper synthesis of the regulator. Just few works in literature exploit an NMR model for the design of the controller (e.g. [2, 7, 10]). In [9], the authors developed and tested in simulation a methodology based on dynamic models of the NMR sensor and on PID regulators that allow to obtain field stability within a prescribed time interval, as required by FFC NMR. The aim of this work is to give to the proposed methodology an experimental validation by performing closed-loop experiments. The performance of the control loop as FFL is also analyzed by performing the main experiment with and without loop closure, and comparing the results. The paper is organized as follows: the approach is first presented in Sect. 2 in a general framework, then a detailed description of the case studies is introduced along with the methodology applied to synthesize the regulators (Sects. 3.13.5). The results of closed-loop trials are reported and discussed in Sect. 3.6. Finally, Sect. 3.7 discusses the effect of the developed FFL on the main NMR experiment.

2 Methodology

This work faces the FFL problem with the methodology developed by the authors in [9]. This section describes the approach, which requires:

  • Building of the NMR lock sensor;

  • Modelling of the NMR lock sensor;

  • Designing of the closed-loop;

  • Synthesis of a PI/PID regulator according to the overall process transfer function.

Each of these steps is discussed in detail in the following sections.

2.1 Building of the NMR Lock Sensor

Fig. 2
figure 2

Static input/output relation of the NMR as a sensor. FWLR is the full width of the linear region, i.e. the width of the interval \([\varDelta B^\mathrm{{min}}; \, \varDelta B^\mathrm{{max}}]\). Here, the curve can be approximated as a straight line

Building the NMR lock sensor means setting up an NMR experiment so that the resulting signal can be effectively used as feedback in the control loop. In this phase, the typical features of a sensor, such as linearity, static gain and bandwidth, must be taken into account. All the aforementioned features depend on the choice of the sample used for the NMR lock experiment and on the way, it is stimulated by means of the radio-frequency (RF) pulse sequence. Both [7] and [9] suggest that a low-power, high-repetition rate pulse sequence allows to obtain a continuous NMR signal that is suitable to cope with fast magnetic field disturbances.

Let \(\theta\) be the angle the magnetization vector M moves away from the z-axis because of each pulse in the rotating reference frame. Let T be the inter-pulse period. The “lock sequence” is then composed of all identical RF pulses with \(\theta\) small (i.e. few degrees) and \(T<<T_2^{*}\).

The application of such a sequence to the sample makes the magnetization vector enter the steady-state free precession (SSFP) regime, described in [7, 11,12,13,14,15]. If the RF pulses are applied along the y-axis of the rotating frame, M reaches a steady state, oscillating in the \(x-z\) plane when the experiment is carried out on prefect resonance. This means that, if no field disturbance \(\varDelta B\) is present, the y component of the magnetization, \(M_{y}\), is zero. In general, \(M_{y}\) provides a measure of \(\varDelta B\) according to the curve depicted in Fig. 2. It is important to underline that the \(\varDelta B \text { to } M_{y}\) curve is bijective only if restricted to the interval \([\varDelta B^\mathrm{{min}};\varDelta B^\mathrm{{max}}]\); in this region, it is also approximately linear [7]. Let full width of the linear region (FWLR) be the width of the interval \([\varDelta B^\mathrm{{min}};\varDelta B^\mathrm{{max}}]\). A tentative expression relating the gain of the sensor (i.e. the slope of the linear part of the curve) to the parameters of the lock sample and sequence was reported in [7]. Still, whenever the main magnetic field \(B_{0}\) is non-homogeneous over the lock sample, i.e. \(T_2^{*} < T_2\), that expression loses significance, since the gain is mainly related to the homogeneity of the field. The more homogeneous the magnetic field, the higher the slope of the curve (and the narrower the FWLR). On the contrary, the less homogeneous the magnetic field, the lower the slope of the curve (and the wider the FWLR). The dynamics of the experiment is also strictly related to the parameters of the lock sample and sequence [11], and to field homogeneity in a complex way.

2.2 Modelling of the NMR Lock Sensor

To account for all the nonlinearities affecting gain, FWLR and dynamic response of the lock sensor, the authors implemented and validated in [9] a simulator for the experiment, based on the discrete-time bloch equations (DTBE) [7, 11, 14], and the isochromat decomposition of the NMR signal [11,12,13, 16, 17]. The overall model is referred to as Bloch-based isochromat model (BBIM). The simulator allows to collect data and to fit a linear model which can be used for control purposes. It is also useful as a design tool to test the response of the lock sensor according to the desired combination of sample and sequence parameters.

2.2.1 Transfer Function Model

BBIM carefully describes the dynamics of the lock experiment, but is not suitable for control purposes because of its complexity. A linear transfer function model describing the dynamic behavior of the lock sensor can be identified by means of input–output identification techniques, exploiting BBIM model to collect data from simulations. The identification phase is set-up as follows:

  • Simulation of a step response around\(\varDelta B=0\). The system is first brought in SSFP on perfect resonance. Then, once the steady-state condition is reached, a step variation of \(\varDelta B\) is applied. Let \(\varDelta B_\mathrm{{step}}\) be the amplitude of the step, which must be chosen so that \(|\varDelta B_\mathrm{{step}}|<<\varDelta B^\mathrm{{max}}\). The \(M_y(t)\) signal is collected at this point.

  • Filtering of output identification data The shape of the SSFP signal shows oscillations with fundamental harmonic at \(\frac{1}{T}\), and harmonic content at higher frequencies [11]. From the sensor point of view, these oscillations represent measurement noise and must not be described by the linear model. A low-pass filtering procedure allows to reduce the impact of SSFP oscillations on the \(M_y(t)\) signal.

  • Definition of the structure of the model The structure of the local model must be chosen according to the behavior of the step response \(M_y(t)\). A first-order transfer function with no zero is used in case of monoexponential response. A second-order transfer function with zero is used in case of more complex behaviors.

  • Identification of the parameters of the model via constrained least-square optimisation Constrained Least-Square (CLS) optimisation allows to exploit input–output data to optimize the values of model parameters, to provide the best fit between model prediction and identification data. In case of a second-order structure, it is possible to introduce constraints on the position of the zero according to the presence of an inverse response or an overshoot in the step response.

The CLS optimisation problem is expressed as follows [18]:

$$\begin{aligned} \hat{\mathbf{P }}^\mathrm{{CLS}}&= {} \mathrm{{min}}_\mathbf{P }(\mathbf Y -\hat{\mathbf{Y }}(\mathbf P ))'(\mathbf Y -\hat{\mathbf{Y }}(\mathbf P ))\\& \quad \phantom {min\;\;}\mathrm{{subject}}\;\mathrm{{to}}:\mathbf C {} \mathbf P \le \mathbf d \\ \end{aligned}$$
(1)

with \(\mathbf Y\) the vector containing the measured \(M_y(t)\) for each time instant t, \(\hat{\mathbf{Y }}\) the vector containing the predicted \(M_y(t)\) for each corresponding time instant t, \(\mathbf P\) the vector of unknown parameters, and \(\mathbf C\) and \(\mathbf d\), respectively, a matrix and a vector of proper size to introduce polytopic constraints on \(\mathbf P\).

The goodness of fit is evaluated with the following metric:

$$\begin{aligned} \mathrm{{FIT}}=100\left( 1-\frac{||\mathbf Y -\hat{\mathbf{Y }}||_2}{||\mathbf Y -\mathrm{{mean}}(\mathbf Y )||_2}\right) . \end{aligned}$$
(2)

In case of single exponential response of \(M_y\), the following first-order transfer function is adopted:

$$\begin{aligned} G_\mathrm{{nmr}}(s)=\frac{\mu _\mathrm{{nmr}}}{1+s\tau _\mathrm{{nmr}}} \end{aligned}$$
(3)

with the corresponding step response predictor \(\hat{M}_y(t)\):

$$\begin{aligned} \hat{M}_y(t)=\mu _\mathrm{{nmr}}\left( 1-e^{-t/\tau _\mathrm{{nmr}}} \right) . \end{aligned}$$
(4)

In the other cases, a second-order transfer function is adopted:

$$\begin{aligned} G_\mathrm{{nmr}}(s)=\frac{\mu _\mathrm{{nmr}}(1+sT_\mathrm{{nmr}})}{(1+s\tau _{\mathrm{nmr}_1})(1+s\tau _{\mathrm{nmr}_2})} \end{aligned}$$
(5)

with the convention \(\tau _{\mathrm{nmr}_2}<\tau _{\mathrm{nmr}_1}\) and the corresponding predictor:

$$\begin{aligned} \begin{array}{l} \hat{M}_y(t)= \mu _\mathrm{{nmr}}\left( 1-\frac{\tau _{\mathrm{nmr}_1}-T_\mathrm{{nmr}}}{\tau _{\mathrm{nmr}_1}-\tau _{\mathrm{nmr}_2}}e^{-t/\tau _{\mathrm{nmr}_1}}+\frac{\tau _{\mathrm{nmr}_2}-T_\mathrm{{nmr}}}{\tau _{\mathrm{nmr}_1}-\tau _{\mathrm{nmr}_2}}e^{-t/\tau _{\mathrm{nmr}_2}} \right) . \end{array} \end{aligned}$$
(6)

In particular, in the presence of an inverse response, the constraint \(T_\mathrm{{nmr}}<0\) is introduced. In case of overshoot, the constraint \(T_\mathrm{{nmr}}>\tau _{\mathrm{nmr}_1}\) is instead introduced. Stability constraints \(\tau _{\mathrm{nmr}_1}>0\;\tau _{\mathrm{nmr}_2}>0\) are always present.

2.3 Design of the Closed Loop

Fig. 3
figure 3

Block scheme with transfer function for the FFL. u(t) is the voltage control action, \(u_\mathrm{{sat}}(t)\) is the saturated voltage control action, and \(\varDelta I^{*}(t)\) is the current control action. \(\varDelta I(t)\) is the overall current deviation from the resonance condition; it is the sum of the current from the power supply, \(\varDelta I_\mathrm{{ps}}(t)\), and the current disturbance \(\varDelta I_{d}(t)\); \(\varDelta B(t)\) is the overall field deviation seen by the NMR sample; it is the sum of the field deviation from the magnet, \(\varDelta B_\mathrm{{mag}}(t)\), and the field disturbance \(\varDelta B_{d}(t)\); \(M_{y}(t)\) is the y component of the transverse magnetization in the rotating frame, \(\tilde{M}_{y}(t)\) is its low-pass filtered version; N(t) is measurement noise; \(M_{y}^\mathrm{{ref}}\) is the closed-loop reference, always set to zero; e(t) is the error signal feeding the regulator

The design of the closed-loop for the lock system should consider both the NMR lock sensor dynamics and the NMR hardware set-up required to run the lock experiment. The scheme in Fig. 3 shows the overall closed-loop setup for the FFL in terms of transfer functions. The regulator action u(t) is the voltage output from a DAC converter and is turned into a current by means of a known conductance C. The current output is limited; therefore, a saturation must be included. Note that it is modelled as the equivalent voltage saturation to ease an anti-windup implementation of the regulator. Let \(u_\mathrm{{sat}}(t)\) be the control action after the saturation block. The power supply features an internal control loop: the current control action is introduced by summing it to the overall current reference of the power supply. Let us, therefore, denote the current control action as \(\varDelta I^{*}\). The power supply unit is then modelled as a first-order transfer function relating \(\varDelta I_\mathrm{{ps}}\), i.e. the power supply current deviation from the resonance condition, to \({\varDelta I^{*}}\):

$$\begin{aligned} G_\mathrm{{ps}}(s)=\frac{\varDelta I_\mathrm{{ps}}\;[A]}{\varDelta I^{*}\;[A]}=\frac{\mu _\mathrm{{ps}}}{1+s\tau _\mathrm{{ps}}}. \end{aligned}$$
(7)

The magnet is instead modelled as a static gain:

$$\begin{aligned} \mu _\mathrm{{mag}}=\frac{\varDelta B_\mathrm{{mag}}\;[\mathrm{{Gauss}}]}{\varDelta I\;[A]} \end{aligned}$$
(8)

with \(\varDelta B_\mathrm{{mag}}\) the magnet field deviation from the resonance condition. The NMR receiver chain (the quadrature detector in particular) can be described by a low-pass filter, that should be considered in the design of the control loop as well. Note that, in this framework, the filter can be conceptually placed after the NMR lock sensor, as depicted in Fig. 3. It can, therefore, be modelled as

$$\begin{aligned} G_{qd}(s)=\frac{\tilde{M}_y\;[V]}{M_y\;[V]}=\frac{1}{1+s\tau _{qd}}, \end{aligned}$$
(9)

where \(\tilde{M}_{y}(t)\) is the low-pass filtered signal of \(M_{y}(t)\). The overall process transfer function is then given by

$$\begin{aligned} G(s)=G_{qd}(s)G_\mathrm{{nmr}}(s)\mu _\mathrm{{mag}}G_\mathrm{{ps}}(s)C. \end{aligned}$$
(10)

2.4 Synthesis of the Regulator

Once the process transfer function G(s) is known, it is possible to tune a parameterized regulator, which must cope with the following requirements:

  • stability of the closed-loop system;

  • settling time as short as possible;

  • rejection of current/field oscillations;

  • perfect rejection of step current/field disturbances (at steady state).

For sake of generality, the synthesis of a PID regulator is discussed in this section. However, in some cases, a simpler PI regulator may be enough to face the requirements. Note that the presence of an integral action in the regulator allows to guarantee perfect compensation of step process disturbances (no derivative action is present in the process). This would not be obtained by means of simpler proportional regulators. In addition, the closed-loop bandwidth \(b_{w}\) is required to be the largest possible to provide the shortest settling time and as much rejection of process disturbances as possible. Still, the presence of measurement noise N limits the closed-loop bandwidth. Recall that the oscillations of the SSFP signal represent a source of measurement noise (see Sect. 2.2). When \(b_{w}\) is expressed in [rad/s], it, therefore, holds:

$$\begin{aligned} b_{w}<\frac{2\pi }{T}. \end{aligned}$$
(11)

Equation (13) stresses the importance of T as design parameter. By reversing the inequality, it is possible to place a constraint on the choice of T according to the desired closed-loop bandwidth (i.e. according to the desired closed-loop settling time). Let us consider a PID controller in the realizable form:

$$\begin{aligned} R(s)=\frac{\mu _{r}(1+sT_{z1})(1+sT_{z2})}{s(1+s\tau _{f})}. \end{aligned}$$
(12)

It is possible to use the two zeros of the PID to cancel the two slowest poles of G(s), typically an NMR pole or the power supply one, while \(\tau _{dq}\) typically resides at high frequency. \(\tau _\mathrm{f}\) is placed out of the desired bandwidth and may be used to improve filtering of measurement noise N. A careful choice of \(\mu _{r}\) and \(\tau _\mathrm{f}\) allows to shape the loop function \(L(s)=G(s)R(s)\) to provide the required disturbance rejection and settling time. The stability of the closed-loop system can instead be assessed by means of the bode criterion [19].

Regulators are implemented in a discrete-time way, by exploiting the full computation capability of the hardware, which results in \(T_s=25\;\upmu s\). Discretisation of regulators is performed with Tustin method to guarantee that the stability is preserved (all asymptotically stable/stable continuous time poles are, respectively, mapped into asymptotically stable/stable discrete-time poles).

3 Experimental Trials

To validate the preliminary results obtained in [9], a series of experimental trials are performed in this work. This section is first devoted to the description of both the main NMR experiment and the lock set-up which are used to carry out experimental trials. Then, the methodology described in Sect. 2.2 is applied to synthesize a PI regulator. The results of closed-loop experiments are finally presented and discussed.

3.1 NMR Lock Set-up

Table 1 Parameters characterizing the lock samples: gyromagnetic ratio \(\gamma\), longitudinal relaxation time constant \(T_1\), transverse relaxation time constant \(T_2\), transverse relaxation time constant in non-homogeneous field \(T_2^*\), maximum available magnetisation \(M_0\)
Table 2 Details of the lock sequence: RF pulse repetition time T and tilt angle \(\theta\)

The main magnetic field \(B_0\) is generated by a Stelar s.r.l.-manufactured resistive magnet [20], driven by IECO MPS 400 VERIFY power supply [21] (prototypes for IDentIFY EU Project). According to the manufacturer, the power supply is characterized by a 25 kHz bandwidth, with an internal control loop guaranteeing perfect tracking of step references. The analysis of the noise spectrum of the amplifier highlights the presence of some harmonic content at 50 [Hz] and its multiples, up to 300 Hz. The main NMR experiment is carried out on a pure Galden sample, targeting the Fluorine \(F^{19}\) nucleus (\(\gamma =25{,}166.2\) rad/(s Gauss)). The lock experiment is instead carried out targeting the Proton \(H^{1}\) nucleus (\(\gamma =26{,}751.3\) rad/(s Gauss)). Two different samples are tested: a silicone one and a copper sulfate one. Note that the gyromagnetic ratios of \(H^{1}\) and \(F^{19}\) are not very distant in frequency (i.e. the two nuclei resonate at similar frequencies). To minimize the interference between the two experiments, two different probes are used for the main and lock experiment. These probes feature a magnetic shielding to protect the NMR samples from spurious RF pulses coming from the other experiment. The NMR parameters of interest of the two lock samples are reported in Table 1. Details of the lock sequences are reported in Table 2.

A PI controller is implemented on a Xilinx MicroBlaze microprocessor [22], embedded in the Xilinx Spartan FPGA board [22] hosting the firmware required for the NMR lock experiment. A minimum sampling time of \(T_\mathrm{s}=25\) μs can be achieved with this implementation. The control action (voltage) is generated by a 16-bit DAC and is turned into current by means of a \(5\;\varOmega\) resistance. For safety issues, the current output is limited to \(\pm 500\) mA. Due to the presence of this saturation, an anti-windup scheme is adopted for the PI implementation. As already stated in Sect. 2.3, the corresponding voltage saturation is considered (\(\pm 2.5\) V). The current control action is then summed to the current reference of IECO power supply. Step and sinusoidal current disturbances \(\varDelta I_\mathrm{d}(t)\) are artificially generated by an analog waveform generator and injected in the closed-loop by summing them to the reference of IECO power supply as well.

3.2 NMR Sensor Models

Transfer function models for the NMR sensor are now derived according to the methodology described in Sect. 2.2. Both silicone and copper sulfate cases are investigated. The NMR parameters of the two samples are reported in Table 1. An inversion-recovery (IR) experiment is used to estimate \(T_1\) [23], while a Carr–Purcell–Meiboom–Gill (CPMG) experiment allows to estimate \(T_2\) in the presence of a non-homogeneous \(B_0\) [23]. \(T_2^*\) and M0 are obtained by fitting a simple free induction decay (FID) signal [23]. Table 2 shows instead the lock sequence parameters. All these parameters are required by BBIM to perform simulations of the NMR lock experiment.

3.2.1 Silicone

Fig. 4
figure 4

Silicone sample. a Input–output data for CLS identification of the transfer function model. Top: \(M_y(t)\) step response data from BBIM model and filtered data. Bottom: magnetic field deviation \(\varDelta B(t)\). b Comparison of identification data \(M_y(t)\) and transfer function model prediction \(\hat{M}_y(t)\)

Fig. 5
figure 5

Silicone sample. Detail of input–output data for CLS identification of the transfer function model

The dynamic behavior of the silicone sample stimulated with the lock sequence is simulated with BBIM model (details are reported in Tables 1 and 2). In particular, a step response experiment is simulated. The amplitude of the applied field step is \(\varDelta B_\mathrm{{step}}=-0.048\) Gauss. The step is applied at time \(t=0\) s; Fig. 4a depicts the field step and the \(M_y(t)\) response, which are used as input–output data for CLS identification. Figure 4a also shows \(M_y(t)\) after low-pass filtering. A detail is depicted in Fig. 5: note how the oscillations of the SSFP signal are removed after filtering. The behavior of \(M_y(t)\) clearly shows an inverse response. A second-order system structure is then required, es defined in Eq. (7), with the predictor reported in Eq. (8). CLS identification allows to obtain the following values for the model parameters:

$$\begin{aligned} \begin{array}{l} \mu _\mathrm{{nmr}}=- \, 0.2127\;\mathrm{{V/Gauss}}\;\;\; T_\mathrm{{nmr}}=-0.044\;\mathrm{s}\\ \tau _{\mathrm{nmr}_1}=0.0966\;\mathrm{s}\quad \tau _{\mathrm{nmr}_1}=0.0001\;\mathrm{s}. \end{array} \end{aligned}$$
(13)

A comparison of the step response obtained from BBIM model and that predicted by \(G_\mathrm{{nmr}}(s)\) is reported in Fig. 4b. The goodness of fit results FIT \(=\) 89%.

3.2.2 Copper Sulfate

Fig. 6
figure 6

Copper sulfate sample. a Input–output data for CLS identification of the transfer function model. Top: \(M_y(t)\) step response data from BBIM model and filtered data. Bottom: magnetic field deviation \(\varDelta B(t)\). b Comparison of identification data \(M_y(t)\) and transfer function model prediction \(\hat{M}_y(t)\)

A step response simulation is performed based on BBIM model. A field step of amplitude \(\varDelta B_\mathrm{{step}}=- \, 0.113\) Gauss is applied at time \(t=0\) s to the copper sulfate sample, stimulated with the lock sequence (details are reported in Tables 1 and 2). The input–output data for CLS identification are reported in Fig. 6a. Again, \(M_y(t)\) shows an inverse response. The second-order system structure described in Eq. (7) is then required, with the predictor reported in Eq. (8). The parameters of the transfer function model obtained from CLS identification are then:

$$\begin{aligned} \begin{array}{l} \mu _\mathrm{{nmr}}=-\,0.2128\;\mathrm{{V/Gauss}}\;\; T_\mathrm{{nmr}}=-0.0015\;\mathrm{s}\\ \tau _{\mathrm{nmr}_1}=0.0015\;\mathrm{s}\qquad \;\; \tau _{\mathrm{nmr}_1}=0.0002\;\mathrm{s}. \end{array} \end{aligned}$$
(14)

Figure 6b shows a comparison of the step response obtained from BBIM model and that predicted by \(G_\mathrm{{nmr}}(s)\). The goodness of fit results \(\mathrm{FIT}=88.5\)\%.

3.3 Process Model

The whole process transfer function G(s) is now derived for both NMR lock samples. As stated in Sect. 3.1, the IECO power supply guarantees perfect tracking of step current references, with a bandwidth of \(25\;\mathrm{{kHz}}\) (157,082 rad/s). Hence, the parameters of Eq. (9) can be set as

$$\begin{aligned} \mu _\mathrm{{ps}}=1\; \tau _\mathrm{{mag}}=\frac{1}{157{,}082}\,\mathrm{s}. \end{aligned}$$
(15)

The quadrature detector low-pass filter is set to 40 kHz (251,327 rad/s) for the closed-loop experiments. Its transfer function time constant can then be set as

$$\begin{aligned} \tau _{qd}=\frac{1}{251,327}\,{s}. \end{aligned}$$
(16)

It is important to note that both NMR lock samples (silicone and copper sulfate) show an inverse response in the step response experiment. This places an upper bound to the closed-loop bandwidth \(b_\mathrm{w}\), which is not likely to be higher than the frequency of the non-minimum phase zero of \(G_\mathrm{{nmr} (s)}\). In particular, in case of silicone, the zero is placed at 22.72 rad/s, while in case of copper sulfate, it is placed at 674.3 rad/s. In view of this consideration, it is possible to neglect the dynamics of both \(G_\mathrm{{ps}}(s)\) and \(G_{qd}(s)\), since their poles are placed at higher frequencies with respect to the expected closed-loop bandwidth \(b_\mathrm{w}\). In addition, since \(\mu _\mathrm{{ps}}=\mu _{qd}=1\), it is possible to approximate:

$$\begin{aligned} G(s)\simeq G_\mathrm{{nmr}}(s)\mu _\mathrm{{mag}}C=\frac{\mu _g(1+sT_\mathrm{{nmr}})}{(1+s\tau _{\mathrm{nmr}_1})(1+s\tau _{\mathrm{nmr}_2})}. \end{aligned}$$
(17)

The NMR sensor dominates the overall dynamics of the system, while the gain is influenced by the magnet and the conductance. According to the manufacturer, the magnet is characterized by a gain \(\mu _\mathrm{{mag}}=47\;\) Gauss/A, while the conductance results \(C=0.2\) s. To sum up, the process transfer function in case of silicone can be expressed as

$$\begin{aligned} G(s)=\frac{-2(1-s0.044)}{(1+0.0966s)(1+0.0001s)}, \end{aligned}$$
(18)

while in case of copper sulfate it results in

$$\begin{aligned} G(s)=\frac{-2(1-s0.0015)}{(1+0.0015s)(1+0.0002s)}. \end{aligned}$$
(19)

3.4 Experimental Validation Trials

The process models identified in the previous section are obtained by means of simulations only. In this section, the process models are instead identified relying on real experimental data. Note that this would not be possible for the end-user of a lock system; therefore, the regulators will be tuned according to the models derived in Sect. 3.3, and the procedure here discussed is only intended as a validation one. The steps required for the experimental trials are the same adopted for the simulated ones: the sample is stimulated with the lock sequence and brought in SSFP regime. The voltage control action u(t) undergoes then a step variation. Both u(t) and \(M_y(t)\) are recorded as input–output data for identification, which is carried out by means of Matlab Identification Toolbox [24]. Data preprocessing is limited to the same low-pass filtering procedure also applied to the simulated data. The results are now presented for both NMR samples.

3.4.1 Silicone

Fig. 7
figure 7

Silicone sample. a Experimental Input–output data for identification of the process model. Top: \(M_y(t)\) step response data. Bottom: voltage control action u(t). b Comparison of experimental identification data \(M_y(t)\) and process model prediction \(\hat{M}_y(t)\)

The step response experiment performed with the silicone sample is depicted in Fig. 7a. As for the simulation, an inverse response is present in \(M_y(t)\). The same second-order structure is, therefore, adopted for the new identification based on experimental data. Both experimental and model predicted step response are reported in Fig. 7b. Let \(G_\mathrm{e}(s)\) be the resulting process transfer function:

$$\begin{aligned} G_\mathrm{e}(s)=\frac{-1.93(1-s0.0434)}{(1+0.11s)(1+0.0014s)}. \end{aligned}$$
(20)

A comparison to Eq. (20) highlights that the static gain, the non-minimum phase zero and the slow pole are closely identified, while the main difference is the fast pole.

3.4.2 Copper Sulfate

Fig. 8
figure 8

Copper sulfate sample. a Experimental input–output data for the identification of the process model. Top: \(M_y(t)\) step response data. Bottom: voltage control action u(t). b Comparison of experimental identification data \(M_y(t)\) and process model prediction \(\hat{M}_y(t)\)

Figure 8a shows the step response experiment input–output signals, u(t) and \(M_y(t)\), in case of copper sulfate sample. As in the previous case, the experimental data are in agreement with the simulated ones and both the responses are characterized by the inverse response. The process model identified from the experimental data is then:

$$\begin{aligned} G_\mathrm{e}(s)=\frac{-2.1(1-s0.0271)}{(1+0.0747s)(1+0.0017s)}, \end{aligned}$$
(21)

while the one identified from simulation is reported in Eq. (21). Figure 8b shows a comparison of the experimental step response and the one predicted by \(G_\mathrm{e}(s)\). Let us now compare Eqs. (21)–(23). In this case, the simulated response is faster than the real one: all the time constants of Eq. (21) are in fact shorter than those of Eq. (23). The static gain is instead close to 2 in both cases. Recall that the synthesis of the regulator is based on Eq. (21) only; therefore, some mismatch may exist between the closed-loop performances predicted by the linear approximation and those obtained with real experiments.

3.5 Synthesis of the Regulator

The synthesis of the regulator, based on the process model G(s) derived in Sect. 3.3, is now discussed for both lock samples. Note that, in both cases, the pole of G(s) associated with \(\tau _{\mathrm{nmr}_2}\), i.e. the one at higher frequency, is outside of the expected closed-loop bandwidth. It is, therefore, not necessary to compensate for its effect in the design of the loop function. This motivates the choice of implementing a PI regulator instead of a PID. The regulator transfer function can then be written as

$$\begin{aligned} R(s)=\frac{\mu _{r}(1+sT_{z1})}{s}. \end{aligned}$$
(22)

The synthesis is performed by setting:

$$\begin{aligned} \begin{array}{l} T_{z1}=\tau _{\mathrm{nmr}_1}\\ \mu _{r}=\frac{1}{\mu _g} b_{w} \end{array} \end{aligned}$$
(23)

with

$$\begin{aligned} b_{w}=-\frac{1}{2}\frac{1}{T_\mathrm{{nmr}}} \end{aligned}$$
(24)

to keep b3 lower than the frequency of the non-minimum phase zero of G(s).

3.5.1 Silicone

Fig. 9
figure 9

Loop functions L(s) in case of silicone sample (solid, blue line), and of copper sulfate sample (dashed, red line)

The process transfer function in case of silicone sample is reported in Eq. (20). By synthesizing the regulator according to the previous considerations, one has:

$$\begin{aligned} \mu _{r}=-5.68\;\;\;T_{z1}=0.0966. \end{aligned}$$
(25)

This allows to obtain a closed-loop bandwidth \(b_\mathrm{w}=13.1\) rad/s, with the dominant closed-loop poles placed at \(s_1=-22.83\) and \(s_2=-4572\). The expected closed-loop settling time is about 0.35 s. This stresses the fact that the choice of the NMR sample used for the lock experiment is crucial for the overall performances of the system. A careful design of the sample, without any inverse response—or with faster ones—may in fact allow to obtain better settling times and more rejection of process noise. With the lock sequence parameters adopted with the silicone sample (see Table 2), the measurement noise due to the SSFP signal is placed at 104,720 rad/s. The design of L(s) (see Fig. 9) allows rejection of \(-27\) dB of such measurement noise. The phase margin \(\phi _\mathrm{m}\) associated with the design results \(\phi _\mathrm{m}=60^{\circ }\), ensuring robust stability of the closed-loop (phase margin reduction due to discretisation is negligible).

3.5.2 Copper Sulfate

In case of copper sulfate lock sample, the process transfer function is reported in Eq. (21). The syntheses of the regulator result in:

$$\begin{aligned} \mu _{r}=-168.575\;\;\;T_{z1}=0.0015. \end{aligned}$$
(26)

The expected closed-loop bandwidth is \(b_\mathrm{w}=388\) rad/s, with an expected closed-loop settling time of about 0.0119 s. With the lock sequence parameters adopted with the copper sulfate sample (see Table 2), the measurement noise due to the SSFP signal is placed at 125,660 rad/s and the loop function (see Fig. 9) design allows \(-34\) dB of attenuation. The phase margin \(\phi _\mathrm{m}\) associated with the design results \(\phi _\mathrm{m}=55.5^{\circ }\), ensuring robust stability of the closed-loop (phase margin reduction due to discretisation is negligible). The dominant closed-loop poles are placed at \(s_1=-1213+405i\) and \(s_2=-1213-405i\).

3.6 Closed-Loop Trials

A set of closed-loop experiments is designed to assess the performances of the two-loop function design, with particular focus on the rejection of process disturbance, when dealing with the real process. Note that, with the current NMR hardware set-up, the measurement noise at low frequency is relevant when compared to the measure of the current disturbance of the IECO power supply (see Sect. 2.3). Waiting for a new NMR receiver chain with reduced measurement noise, to test the controller design, an artificial current disturbance of significant amplitude is injected in the system. The current disturbance is introduced by means of an analog current waveform generator, whose output is summed to the power supply current reference. In particular, two different kinds of experiments are performed: a step disturbance is injected to test the closed-loop settling time, while sinusoidal disturbance at different frequencies is useful to test the design of the loop function. Note that the amplitude of the current disturbances is chosen so that the corresponding field disturbance does not exceed the linear region of the NMR sensor.

3.6.1 Silicone

Fig. 10
figure 10

Silicone sample. Closed-loop response to a current step disturbance. Top: feedback signal \(M_y(t)\). Bottom: voltage control action u(t)

Fig. 11
figure 11

Silicone sample. Open-loop (a) and closed-loop (b) responses to a 1-Hz sinusoidal disturbance. Top: feedback signal \(M_y(t)\). Bottom: voltage control action u(t)

Fig. 12
figure 12

Silicone sample. Open-loop (a) and closed-loop (b) responses to a 10-Hz sinusoidal disturbance. Top: feedback signal \(M_y(t)\). Bottom: voltage control action u(t)

In case of NMR lock based on the silicone sample, according to the design described in Sect. 3.5, the expected closed-loop bandwidth is \(b_\mathrm{w}=13.1\) rad/s, corresponding to a settling time of about 0.35 s. Figure 10 shows the experimental response to a step current disturbance. The experimental evaluation results in about 0.1 s of settling time, which is faster than expected from the linear approximation. Figure 11a, b shows the open and closed loops to a 1 Hz sinusoidal disturbance, respectively. The effect on the feedback signal \(M_y(t)\) is reduced of about five times by the closed loop. This is slightly better than predicted by the loop function design, which has a magnitude of about 6 dB at 1 Hz (see Fig. 9). Figure 11a, b shows instead the open- and closed-loop responses to a 10 Hz sinusoidal disturbance. In this case, the effect on the feedback signal \(M_y(t)\) is not reduced by the closed loop. This is consistent with the loop function design. Note that a DC current offset is present in the current disturbance. This offset is correctly compensated by the integral action featured in the closed loop.

3.6.2 Copper Sulfate

Fig. 13
figure 13

Copper sulfate sample. Closed-loop response to a current step disturbance. Top: feedback signal \(M_y(t)\). Bottom: voltage control action u(t)

Fig. 14
figure 14

Copper sulfate sample. Open-loop (a) and closed-loop (b) responses to a 10-Hz sinusoidal disturbance. Top: feedback signal \(M_y(t)\). Bottom: voltage control action u(t)

Fig. 15
figure 15

Copper sulfate sample. Open-loop (a) and closed-loop (b) responses to a 50-Hz sinusoidal disturbance. Top: feedback signal \(M_y(t)\). Bottom: voltage control action u(t)

Fig. 16
figure 16

Copper sulfate sample. Open-loop (a) and closed-loop (b) responses to a 100-Hz sinusoidal disturbance. Top: feedback signal \(M_y(t)\). Bottom: voltage control action u(t)

The expected closed-loop bandwidth and settling time in case of copper sulfate sample are \(b_\mathrm{w}=388\) rad/s and 0.0119 s, respectively (Fig. 12). The experimental results obtained with the application of a current step disturbance are reported in Fig. 13. The closed-loop settling time can be experimentally valued as 0.015 s, that it slightly longer than expected. Figure 14a, b shows the open- and closed-loop responses to a 10-Hz sinusoidal disturbance. In this case, the effect on the feedback signal \(M_y(t)\) is reduced of a factor 3 by the closed loop. This is consistent with the loop function design, which should provide 14 dB of rejection at 10 Hz. Figure 15a, b shows the open- and closed-loop responses to a 50-Hz sinusoidal disturbance. The loop function has magnitude 1.8 dB at 50 Hz, providing a slight reduction of the effect of sinusoidal noise, as verified in the experiment (factor 1.3 of reduction). The open- and closed-loop responses to a 100-Hz current disturbance are instead depicted in Fig. 16a, b, with no appreciable rejection of noise, as expected from the loop function design.

3.7 Effect of Lock System on the Main NMR Experiment

Fig. 17
figure 17

Copper sulfate sample. Main NMR experiment without lock system (a) and with lock system (b), in the presence of a 10-Hz sinusoidal disturbance

Fig. 18
figure 18

Copper sulfate sample. Main NMR experiment without lock system (a) and with lock system (b), in the presence of a 50-Hz sinusoidal disturbance

The final aim of the NMR lock system is improving the results of the main NMR experiment which runs in parallel. For this purpose, a series of NMR experiments is performed without NMR lock first, then repeated with the lock system based on copper sulfate, in the presence of external current disturbances. The choice of copper sulfate is motivated by the better performances obtained in Sect. 3.6. The main NMR experiment is carried out on a pure Galden sample, targeting the Fluorine \(F^{19}\) nucleus (\(\gamma =25{,}166.2\;[\mathrm{{rad}}/({\rm {s}} \times \mathrm{{Gauss}})]\)) at a magnetic field \(B_0=1880\) Gauss, corresponding to a resonance frequency of about 8 MHz. Each experiment consists in a series of standard S1P sequences, generating a standard \(T_2^*\) decay of the recorded NMR signal [23]. A S1P experiment runs on resonance if the imaginary component of the quadrature-detected NMR signal is zero, and the real component shows an exponential decay. Figure 17a shows the main NMR signal in the presence of the 10-Hz sinusoidal current disturbance. According to the analysis carried out in Sect. 3.6, the lock system should appreciably improve the results by rejecting the current oscillations. The results of the NMR experiment with the same disturbance and the lock system are depicted in Fig. 17b. Note how the imaginary component of the NMR signal is closer to zero with respect to the open-loop case, and the exponential shape of the real component. The experiment is repeated with a 50-Hz sinusoidal current disturbance. Results are depicted in Fig. 18a, b. The presence of the lock system still improves the results, but some oscillations are still present in the NMR signal, since the current disturbance is just slightly rejected by the closed loop.

Table 3 Power of imaginary component of NMR signal with and without lock system, in the presence of external current disturbance

As stated before, the experiment runs on resonance if the imaginary signal is zero. Therefore, a possible way to quantitatively evaluate the effect of the lock system is to consider the power \(\mathbb {P}\) of that signal, with \(\mathbb {P}\) defined as follows:

$$\begin{aligned} \mathbb {P}[z]=\frac{1}{N+1}\sum _{n=0}^{N}|z(n)|^2, \end{aligned}$$
(27)

where z(n) is a generic discrete-time signal.

Table 3 reports a comparison of the power of the imaginary part of the NMR in the two trials discussed in this section. In both cases, the presence of the lock system allows to reduce the power with respect to the no-lock case. As expected from the loop function design and as already shown by the closed-loop trials, the lock is more effective with the 10-Hz sinusoidal disturbance.

4 Conclusion

This paper aims to verify with experimental trials the effectiveness of the FFL approach developed in [9]. Two lock sensors are designed and their linear models are obtained from simulated data. Experimental data are collected to evaluate the correctness of the procedure. The lock control loop is then designed, on the basis of the sensor model and on models of the hardware needed to perform the NMR lock experiment. Two PI regulators are tuned accordingly. Closed-loop trials confirm the correctness of the approach, providing results in agreement with the loop function design. Standard NMR experiments are also performed with and without the designed lock system, and highlight the benefit of its introduction. The next step of the research will consist in applying the proposed methodology to develop an external lock system for proton FFC NMR, with the lock experiment performed on fluorine. This will require the engineering of a proper fluorine sample allowing to efficaciously perform the lock experiment, and a dedicated receiver channel with high SNR.