Low-cost bidirectional coil driver with microamp precision

We describe a compact constant current power supply with µ A precision designed to drive coils. The unit generates currents from − 125 mA to 125 mA with a load up to 10 Ω using a precision 16-bit digital to analogue converter, driven from a microcontroller (e.g. Raspberry Pi Pico). All power for the unit is derived from the 5 V of the microcontroller. As a demonstration of the capability of the power supply, it was applied to spin manipulation in a helium spin echo system.


Introduction
Precise control of static magnetic fields is a requirement for many experimental situations, see for example, [1][2][3].Generating the field from a winding, either air cored, or with a yoke, necessitates an accurate and stable current source [4][5][6].The device described here was designed for various applications in the manipulation of quantum spin in a helium spin echo (HeSE) apparatus [7]; however, we believe it has application in other areas, such as magnetic resonance, spintronics, magneto-optic traps, etc.In HeSE experiments, a trimming field is required to change the spin alignment between the input and output beam-lines [7] as well as in determining the exact phase for the condition of zero precession [8].The latter process is achieved using a small air-cored solenoid aligned coaxially with the helium beam and it can also be used to modulate the spin-precession allowing for the beam energy to be determined [2].An important aspect of the latter application Original Content from this work may be used under the terms of the Creative Commons Attribution 4.0 licence.Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI. is to have a bi-directional current supply so that the field direction can be reversed.
These considerations along with the availability of specific, low-cost devices and PCB assembly [9] led us to a specification of a maximum current of ±125 mA, with 16-bit accuracy and stability and with the current to be derived from a standard +5 V supply, which also drives the microcontroller.Thus, one least-significant-bit (lsb) corresponds to change in current of ∼4 µA and, below, we demonstrate that level of overall precision.The device is self-contained on a small (57 × 26 mm) PCB, as shown in figure 1(c) and the unit cost is typically $60, where the main costs are precision resistors and resistor networks together with the voltage reference and digital to analogue converter (DAC).Full details of device, including a detailed schematic, PCB assembly files and bill of materials are available [10].

Description
The device consists of a DAC and analogue driver on a small printed-circuit board, which is discussed in detail below.In addition a micro-controller is used to communicate with the rest of the experiment and to monitor faults.For the microcontroller, we use a Raspberry Pi Pico [11], which has ample performance and low cost.We limit the discussion here to the analogue driver board as the microcontroller aspects are relatively routine and do not depend on the precise implementation.Communication between the analogue board and the microcontroller is through a standard SPI interface and communication between the microcontroller and the rest of the experiment make use of an RS232 interface.
Figure 1 shows a simplified schematic of the current source.It is divided into two principal parts: figure 1(a) shows the analogue section with high-current amplifiers and precision current sensing, while (b) is the voltage reference and DAC.In the analogue section, figure 1(a), the current amplifiers, (U6.1 and U6.2, AD8532) operate in a push-pull configuration to drive the floating load coil, which is in series with a precision, 10 Ω, sensing resistor (Vishay: VPR221).The Kelvin connections on the sense resistor are fed to a unity-gain differential amplifier comprising a precision op-amp, U5.1, (AD8607) and a precision, 10 kΩ resistor network, RNa-d, (Vishay: VTF286UF).Resistor ratios are matched to 0.02% giving the required linearity and precision in the differential amplifier.Notice that the input impedance of the differential amplifier appears in parallel with the sense resistor.There is no effect on the linearity; however, there is a small change (∼0.1%) in the absolute scaling.
The output of the differential amplifier is measured with respect to the mid range of the DAC, DACmid (figure 1(a)), so that a mid-range input voltage corresponds to zero output current.The signal from the differential amplifier is fed back to a second precision op-amp, U5.2 (AD8607), which compares the sensed current with the output from the DAC.Feedback stability is ensured using the simple pole generated by R f and C f .The loop is completed by connecting the output of U5.2 to the two high-current amplifiers, U6.1/2, which are configured respectively in an inverting and a non-inverting unity gain configuration.The resulting push-pull effect allows the output current to swing both positively and negatively generating the required bipolar operation from a single supply.Note that the output common-mode voltage, V ocm , is set by the positive input of U6.1, and is chosen to be 2.1 V, midway between +ve and −ve supplies of U6, which is 4.2 V, see below.
The output voltage of the AD8532 swings to roughly 1 V of either supply rail at the maximum current, ±125 mA, and there is a voltage drop of 1.25 V across the sense resistor leaving approximately 1 V head-room for the load coil.Thus the maximum coil resistance for the full-scale current is ∼10 Ω.The worst case power dissipation in the AD8532 is 375 mW, which will generate a 60 • C temperature rise in the SOIC package.
Static errors are controlled by the inherent precision of the AD8607 amplifiers (typically V os = 10 µV) and the temperature coefficients of the critical components (typical values: AD8607, 1 µV/ The dynamical response of the circuit gives settling of a current step within <20 µs for a purely resistive load.Most coils are likely to present a load with some inductance and the PCB includes an on-board snubber, R 1 = 50 µΩ, C 1 = 1 µF, which will be appropriate for many practical situations (see section 3).
Figure 1(b) shows a schematic of the other principal components.Power for the whole circuit at 4.2 V, is generated from the 5 V microcontroller supply using a low-noise, lowdropout regulator (ADP7104).A MAX6071 voltage reference provides a precise and stable 2.5 V output, which defines the range of the DAC and provides the output common-mode voltage, V ocm , through a resistive divider.The 16-bit DAC (LTC2642) guarantees monotonicity and has <1 lsb integral and differential nonlinearity.In addition the LTC2642 includes precision resistors (matched to ± 0.02%), which we use as a voltage divider to define the mid-point of the output range, V mid .The output voltage of DAC, V out , and the midrange voltage, INV, are buffered by further precision amplifiers, U4.1,2, (AD8607) to provide the voltages DAC and DACmid respectively.
In addition to the standard SPI interface, the device includes a precision window-comparator, which indicates a fault if the + and − inputs of U5.2 are not equal to within a few tens of µV (see full schematic [10]).The window-comparator, together with a fault indicator for the 4.2 V supply, allows the microcontroller to confirm that the device is working correctly.

Results
In order to calibrate the current source, we measured the output current, using a Keithley 2000 multimeter [12], as a function of the digital input from the microcontroller.A series of 2048 numbers, in an arithmetic progression from 0 to 2 16 − 1 with a common difference of 32 were sent to the DAC (the order of the numbers was randomised).
Figure 2(a) shows the measured current (blue dots) as a function of the number sent to the DAC, denoted N. The inset, which is a greatly magnified portion of the data, illustrates the linear model, shown as a red line and given by the equation with p 1 = 3.815921(6) µA and p 2 = −125.0910(2)mA.These values are consistent with the theoretical estimates.The residual differences between the measured current and the ideal current (given by equation ( 1)) are shown in figure 2(b), which represents the total non-linearity of the complete device and shows that the deviation from predicted  performance is, with very few exceptions, <1 lsb.The residuals correspond closely to those generated by the LTC2642 DAC as can be seen from the integral nonlinearity plot in the product data sheet [14].Figure 2(b), therefore, demonstrates the fidelity with which the DAC output is converted into a current.A histogram of the residuals is presented in figure 2(c).The distribution is close to Gaussian (red line) and has a standard deviation of 1.4 µA, corresponding to 0.3 lsb.The results confirm that the inherent precision of the DAC is maintained by the additional analogue circuitry.
The precision evident in figure 2 is supported by current measurements, under standard laboratory conditions, and over a long time period.Figure 3(a) shows the Allan deviation [15] derived from the resulting time-series as blue circles.The smooth red curve indicates that the behaviour conforms approximately to expectation in that the the deviation is dominated by white noise on short time scales (σ 2 (τ ) ∼ τ −1 , τ < 10 2 sec) and there is evidence of drift at long times scales (σ 2 (τ ) ∼ τ , τ > 10 4 sec).Differences between the smooth curve and the measured data may indicate slight sensitivity to environmental factors; however, such effects are negligible on the scale of the quantisation of the DAC.Under all measurement conditions, the Allan deviation is less than 1 lsb.
We have simulated the response for an inductive load using Simscape [13].Figure 3(b) compares a highly inductive load, 50 µH with no snubber (grey lne).The resulting overshoot is much improved by the snubber circuit (blue line) giving settling in <100 µs.

Application
The current source was used to drive the newly-designed 'phase coil' of the HeSE instrument [8,16].Figure 4(a) provides an illustration of the experimental set-up.A beam of 3 He atoms is produced from the 3 He source.Then a spin polariser selects the atoms with nuclear spin polarised along the x direction (the spin state is . The spin polarised beam subsequently goes through the phase coil (100 turns).When there is a current I in the coil, the nuclear spin state of a 3 He atom undergoes Larmor precession and becomes |ψ⟩ = (e −iϕ/2 , e iϕ/2 ) † / √ 2, where Here γ is the gyromagnetic ratio, B is the magnetic field generated by the current, and v is the speed of the 3 He atom.After going through the phase coil, the beam scatters from a surface (not shown in figure 4(a)) and enters a spin analyser.The spin analyser performs a measurement of the nuclear spin of the atoms.Only atoms with nuclear spin polarised along the positive x direction can get into the 3 He detector, which measures the number of atoms.The signal in the 3 He detector is proportional to Figure 4(b) presents a measurement of detector signal as a function of I, which clearly shows such a relationship.The fact that the minimum is non zero arises from small imperfections in the spin analyser, while the fact that the maximum signal is not at I = 0 is due to stray fields in the instrument [8].Correcting the stray fields is one function for the phase coil driver.Overall, these results demonstrate the ability of the current source for precision spin manipulation.

Summary
We have described a low-cost current source designed to control magnetic fields with high precision.The device has a fullscale range of ±125 mA, better than ±1 lsb accuracy and linearity, together with 16-bits of resolution.Our measurements reveal an overall ±1σ precision of 1.4 µA.The device is simple to apply and involves the minimum of external components.For example, power is derived from the associated microcontroller.Many experimental situations could make use of such a device.

Figure 1 .
Figure 1.Schematic diagram of the coil-driver.Component values and further design information is available from [10].Asterisks indicate additional components included in simulations discussed in the main text.(a) The main analogue circuit, which generates a constant current through the floating load coil and sense resistor.The current is proportional to voltage difference between the DAC output (DAC) and the mid range voltage (DACmid).(b) The power supply and DAC components.Power for the whole system is generated from the +5 V signal of the attached micro-processor using a low-noise, low-dropout (LDO) regulator (ADP7104).The LDO output (4.2 V) powers the precision voltage reference (MAX6071) together with the analogue circuitry.The voltage reference is also used to define the average output voltage, Vocm.Note that the mid-range voltage (DACmid) is generated from the voltage reference using internal precision resistors in the DAC (LTC2642), see text.(c) The complete printed circuit board (57 × 26 mm).Construction details and bill of materials are provided on GitHub [10].

Figure 2 .
Figure 2. Calibration of the current source.(a) Measurements of current, blue points, as a function of the number, N sent to the DAC.Note that the data points for N < 100 are not included because of additional nonlinearity when the DAC output is close to 0 V.A red line showing the linear model from equation (1) is superimposed on the data and can be observed in the magnified region shown by the inset.Even on this magnified view the difference between the measured current and the model is negligible.(b) The residual current error, which is the difference between the measured values and the linear model in panel (a), shown as a function of N. (c) Histogram of the current residuals shown in panel (b).The probability gives the frequency of occurrences in the dataset, with bins of width 0.4 µA.The red line shows a normal distribution with a standard deviation of 1.4 µA, 0.3 lsb, which provides a good description of the distribution of errors.

Figure 3 .
Figure 3. (a) Allan deviation for the output current over a period from 0. s to 2 × 10 4 s.Measurements correspond to the blue circles and the red curve is a model to illustrate the expected behaviour: at short times the noise is approximately white and, at long times, there is evidence for slow drift.However, the deviation throughout is less than 1 lsb.A model shown as the red line, σ 2 (τ ) = aτ −0.8 + b + cτ , is used to describe the data, with a = 1.4 × 10 −13 , b = 4 × 10 −15 , and c = 3 × 10 −19 , for τ in seconds and σ in A. (b) Simulated response, to a unit step, of the analogue section (as shown in figure 1(a)).Significant overshoot occurs with a 50 µH inductive load, grey line.The overshoot is reduced significantly by the on-board snubber, R 1 = 50 µΩ, C 1 = 1 µF, blue line.The simulations were performed in the MATLAB/Simulink/Simscape environment [13] using the linearisation app about the notional operating point.For a resistive load the response settles within approximately 20 µs.

Figure 4 .
Figure 4. (a) A simplified schematic of the HeSE instrument (bottom) and the nuclear spin states of 3 He in various sections (top).A beam of nuclear spin-polarised 3 He atoms is produced from the 3 He source and spin polariser.The phase coil (drawn in red), powered by the current source proposed in this work, provides a phase change of ϕ to the nuclear spin defined by equation (2).The spin analyser performs a spin measurement and selects atoms with the |+⟩x state to be measured in the 3 He detector, whereas |−⟩x is not measured.(b) Signal of the 3 He detector as a function of the current in the phase coil, which should follow the relationship in equation (3).The mean kinetic energy of the 3 He atoms is 8 meV.