###### Abstract  
In ultracold-atom and ion experiments, flexible control of the direction and amplitude of a uniform magnetic field is necessary. It is achieved almost exclusively by controlling the current flowing through coils surrounding the experimental chamber. Here, we present the design and characterization of a modular, analog electronic circuit that enables three-dimensional control of a magnetic field via the amplitude and direction of a current flowing through three perpendicular pairs of coils. Each pair is controlled by one module, and we are able to continuously change the current flowing thorough the coils in the \(\pm 4\) A range using analog waveforms such that smooth crossing through zero as the current's direction changes is possible. With the electrical current stability at the \(10^{-5}\) level, the designed circuit enables state-of-the-art ultracold experiments. As a benchmark, we use the circuit to compensate stray magnetic fields that hinder efficient sub-Doppler cooling of alkali atoms in gray molasses. We demonstrate how such compensation can be achieved without actually measuring the stray fields present, thus speeding up the process of optimization of various laser cooling stages. stray magnetic fields; compensation coils; sub-Doppler cooling; bipolar current source; bidirectional current source +
Footnote †: journal: Applied Sciences  
has a low noise at the \(10^{-5}\) level, sufficient for many modern experiments. The circuit operates with single-sided supplies, which makes the overall setup more compact and cost effective than designs powered with symmetric supplies. Of the two frequently used approaches, digital and analog, we choose the latter one. Digital circuits, although offering better independence of nonlinearities, thermal drifts, and repeatability [16], often rely on expensive, complex, high-resolution digital-to analog (DAC) and analog-to-digital (ADC) converters [12; 13]. Moreover, switching of digital signals is a well known noise source for the analog part of the circuit. Analog devices, on the other hand, need careful compensation of quiescent currents and parasitic impedances, but they allow construction of more compact devices without the need for separation of analog and digital parts. They are also easier to make and more intuitive to debug by an inexperienced user, a feature quite useful in particular in an academic environment, where new students join research groups often without too much hands-on experience in electronics. The analog circuit presented here allows for the control of current within its full range with a bandwidth up to 1 kHz and can be used for most applications common in ultracold atomic physics, such as canceling stray magnetic fields, defining a quantization axis, or splitting Zeeman sub-levels for state transfer with Raman beams or microwaves. As an element of validation of the quality of the designed current source, we propose and demonstrate a fast and robust method of compensating stray magnetic fields using sub-Doppler cooling in gray molasses, which has been shown to work the best when the magnetic field at the location of atoms is near 0 G [17; 18; 19; 20; 21]. We postulate that the circuit is sufficiently good for many demanding cold-atom experiments if it enables repeatable and efficient sub-Doppler cooling, defined by the lowest temperatures that can be reached in a given experiment. For the demonstration of our stray field compensation method, we use D1-line gray molasses cooling of \({}^{39}\)K, but the technique can be applied to any species where cooling relies on coherences between hyperfine levels of the ground state. The key advantage of our approach is its speed. The actual value of the stray magnetic fields present in the experimental chamber is impossible to measure without putting a sensor at the location of atoms, but any method requires an initial estimation of this value to obtain a signal to optimize.