A do-it-yourself approach for developing a magnetic field mapping setup using a 3D printer

The mapping of magnetic fields is an important task for characterizing permanent magnets, their systems, and the various devices that use magnets. However, commercial devices for this task are quite expensive and difficult to acquire. In this study, a design process for an automatized magnetic mapping setup utilizing a 3D printer was proposed via a do-it-yourself approach using common parts found in a laboratory. We used a 3D printer for two purposes: to create instrument parts to fix the Hall probe instead of the printer extruder, and to use the same 3D printer as the position controller of the magnetic probe. We describe the device assembly process, including hardware and software aspects. Several tests of the assembled setup were performed on samples with different magnetic texture dimensions from several centimeters (graduated permanent magnet) to tens of micrometers (flexible magnet with a planar Halbach structure and a 5¼ inch floppy disk). The spatial resolution was in the sub-millimeter range. The parameters of the mapping, such as the number of points and data acquisition time, were optimized for such samples.


Introduction
Magnetic materials and devices operating with magnetic fields are widely used in everyday life and in scientific laboratories * Authors to whom any correspondence should be addressed.
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. [1][2][3]. For example, the modern smartphone contains several tens of magnetic elements in the speaker, vibration mode motor, geolocation, camera autofocus mechanism, and others [4]. Inside and outside of the laboratory, we find magnetic materials to be indispensable elements in electrical generators, motors, drivers, and many biomedical devices. For researchers, many specific experiments require designed, confirmed, controlled, or measured magnetic fields, i.e. magnetic force and electron microscopy, and particle accelerators, among others. Some magnetic fields are generated explicitly for specific applications, while others are undesired parasitic signals. Independent of the signal type and value, magnetic fields must be measured in laboratories for magnetic-fieldaffected experiments.
There are several magnetic field sensors for measuring magnetic fields of different intensities, ranging from extremely low biomagnetic signals (∼pT) to around the geomagnetic field (∼µT), and the magnetic field generated by permanent magnets or superconductors (∼T) [5,6]. There is a wide range of different types of magnetic field sensors, which allow one to measure magnetic field induction in different field ranges; the most commonly used sensors for the high magnetic field range (from mT to T) are based on the Hall effect [7]. The advantages of Hall sensors are their low cost and the possibility to manufacture miniature sensors. While magnetic field sensors are widely available on the market, the systems for mapping the spatial distribution of the magnetic field are rare and quite expensive [8]. The cost of commercial systems for 3D mapping of the magnetic field is more than 25 000 euros [8][9][10].
A do-it-yourself (DIY) approach to creating a unique device/setup for experiments or automatizing the experimental process is essential and can be implemented in any laboratory. This method is used in physical, chemical, biological, and multidisciplinary laboratories to become a standard tool for creating new devices and sample holders or restoring broken equipment parts. Over the last decade, the DIY approach has been expanding due to the increasingly available additive manufacturing technologies like 3D printing [11,12]. Recently, a DIY approach was used to produce magnetic field mappers and map the magnetic fields of radiofrequency coils [13] and stray fields of magnetic resonance imaging devices [14]. For example, Erglis et al used common parts found in laboratories: a motorized microscope platform to move samples in the x,y plane, the z position was manually controlled by a micro screw, and a 3-axis Hall probe was used to measure the magnetic field [8].
This paper aims to demonstrate a cheap and simple DIY approach to realize a device for fully automatized magnetic field mapping in 3D, which uses the mechanical part of a commercially available 3D printer to position the Hall probe. This paper focuses on the strategy to assemble this device and to optimize the working conditions by collecting the magnetic field flux spatial distribution of different objects. This approach can have multipurpose use in laboratories and has a high potential to be scaled and improved, for example, by replacing or adding another type of sensor. Our group has applied this approach to map the magnetic field of assemblies of permanent magnet arrays for cell manipulation and molecule harvesting [15][16][17].

Equipment and software
A DIY kit of a 3D printer, Anet A8 (CTC A8 W5), with an A1284-base mainboard, was used as a base for position control. The kit was purchased from an online store, where different analog kits are available at about one hundred euros [18]. As declared by the manufacturer, the position accuracy is 0.012 mm for the x,y-axes and 0.004 mm for the z-axis. The working area is 220 mm × 220 mm × 240 mm.
For the magnetic induction (B) measurements, we used a Lake Shore gaussmeter model 475 DSP coupled with an axial Lake Shore 400 HSE Hall probe (Lake Shore Cryotronics Inc., USA). Thus, the instrument gives the measurement of the axial component (B z ) of the induction field B vector. The probe's sensitivity was lower than 5 milligauss (mG), while the magnetic induction range was up to 35 kG. As reported by the manufacturer, the nominal active area of the sensing element is about 1 mm in diameter. The stem for the Hall probe is made from fiberglass epoxy and has a diameter of 5 mm. It should be noted that the center of the active area of the Hall probe is inside the stem at a distance of 1.9 mm. Therefore, the position of the active area is at a distance of z active = z + 1.9 mm, where z is the position of the surface of the Hall probe stem. The stem was therefore fixed perpendicularly to the magnet plane. The LabView 8.2 (National Instruments, USA) development environment was used as an interface to control both the 3D printer and the gaussmeter.

Design and realization
The magnetic mapping setup consists of three components (figures 1(a) and (b)): (i) a personal computer (PC); (ii) a Hall probe connected to the gaussmeter; and (iii) a modified 3D printer (PC-controlled) to drive the probe movements. Serial commands achieve communication with the printer via USB. A Hall probe holder (figure 1(c)) fabricated with the 3D printer replaces the original extruder in which the probe is vertically inserted. Data obtained by the gaussmeter and, simultaneously, the spatial position of the probe, are collected and stored in the PC.
The software program for 3D printer movement control and data acquisition was operated using the LabView platform. The software solution provides a user interface consisting of several blocs (figure 2): (i) settings and checkout of the system; (ii) control of the position of the probe; (iii) the settings of the sequence of the measurement; and (iv) a real-time plot of the result.
The commands for position control are specified using the numerical control code (G-code) [19]. An example of the Gcode, setting the relative position of the probe, and moving the probe along the x-axis, is: G91; set to relative positioning G1 X1; move 1 mm along the x-axis Similarly, one can control the position for the y-and z-axes by replacing 'X1' with 'Y1' and 'Z1', respectively. The step size can be selected, and additional parameters, such as the speed, can be controlled by the command 'Fxxx' that sets it to xxx mm/time unit (the time unit may depend on the printer's firmware, mm/min for Marlin). The movement achievable by a standard commercial printer is about 3000 mm min −1 (usually, at speeds above, the printer starts to shake).
A 'VISA Instrument I/O' interface in LabView sends such commands to the device. The feedback signal is received from  a gaussmeter connected to a PC via an IEEE-488.2 GPIB interface for USB (National Instruments). The program solution was obtained using 'LabView Instrument Driver Export Wizard', after installing appropriated drivers provided by LakeShore [20].
Briefly, the software solution consisted of three stacked control statement structures ('for' loop). Each loop defines the position of the probe in one of the planes in the Cartesian coordinate system. Accordingly, the number of iterations and the increment allow one to control the scanning area. At each

Optimization of scanning parameters
We used an N35-grade test-magnet (HKCM Engineering e.K., Germany) with a block shape of 20 mm × 40 mm × 5 mm coated with Ni and well-known polarity to calibrate and test the system. The magnet was placed on the surface of the printing bed below the sensor ( figure 1(c)). Using both axial and transverse probes in two perpendicular orientations, the three components of magnetic flux density, B x , B y , and B z , were collected at 4 mm from the magnet surface. Ten measurements of the signal (N = 10) were collected every 100 ms; then, the signal was averaged, and the standard deviation σ was calculated at each point every 2 mm over a rectangular area of 40 mm × 50 mm. The first parameter to optimize was the delay time t d between measurements: this parameter was chosen to be equal to 0.1, 2, 5, and 10 s. All the measured B x, B y , and B z signals are reported in figure 4(a). All the obtained maps depict physically reasonable profiles expected for the axially magnetized magnet, with the maximum value of the B z component of the magnetic induction of about 1.4 kG under the magnet's edges. A more precise evaluation was achieved by comparison of standard deviation values ( figure 4(b)). According to our experiments, for t d ⩽ 5 s, σ increases to its maximum, reaching 3%, associated with residual vibrations after the mechanical movement of the probe and a significant time delay in the response of the probe. The next parameter of the experimental protocol, fixing t d = 5 s, is the step size for mapping (figure 5). At first glance, the smaller step size provides a better resolution; however, it dramatically increases the measurement time. For the testmagnet sample (figure 5), a single measurement took around 7, 40, and 170 min for a step size of 5, 2, and 1 mm, respectively. Therefore, this parameter and t d should be selected based on the task required and the size of the investigated object. The accuracy of the positioner setup (>0.012 mm for the x,y-axes) and the sensor's active-area size limit the lower spatial resolution. The sensor used in this study was 1 mm 2 in size, which provides sub-millimeter resolution. However, qualitative analysis with lower resolution is also possible. In this case, the magnetic flux at each point presents an average value over a region larger than the step size. In section 3.2, we show the mapping with a step size of 0.1 mm.
By considering a step size = 2 mm, t d = 5 s, and N = 10 s as optimal parameters, we measured the induction B of the HKCM test-magnet at different heights over the magnet  (z = 1.9, 5.9, and 9.9 mm). As reported in figures 6(a)-(c), vector B is composed by the three independently measured values of projections B x , B y , and B z utilizing the axial and transversal probes in two perpendicular orientations. In this case, the magnitude of B is proportional to the length of the arrows because the dimension of the axes is mm (length). The vectors start from the point of measurement in the space (x, y, z) and the coordinates of the ends of the arrows are (x + B x /k, y + B y /k, z + B z /k), where k is a scale factor (converting Gauss units into millimeters for visual rendering). Thus, the orientation of arrows shows the orientation of B, and their magnitude is proportional to the intensity of B.

Mapping of a complex magnetic field
To demonstrate this approach's applicability to mapping the magnetic field of different objects, we selected a smartphone, a flexible refrigerator (fridge) magnet, and a 5 1 /4 inch floppy disk  media. All the samples show a particular magnetic field texture with different magnetic fields and size ranges. We performed all scans at the minimal possible distance (<0.1 mm) above the objects' surface. The most intense component of the magnetic field for this configuration, B z , was measured with an axial Hall probe.
The magnetic field of the smartphone is mainly produced by the loudspeakers and vibration mode motor, placed on the upper central and downright part of the device. To overcome the significant difference in the magnitude of signals from different parts, the smartphone magnetic map is presented on a logarithmic scale ( figure 7). This example demonstrates the potential of the device for mapping sophisticated macroscopic objects. The maximal scanning area of our device is 220 mm × 220 mm × 240 mm. This area can be increased by extending the frame of the positioner setup (replacing guides with longer ones).
To define the device's spatial resolution, the magnetic field of a flexible fridge magnet was measured ( figure 8(a)). Typically, this material consists of magnetic ferrite particles embedded into resin [21,22]. The magnetic structure of the fridge magnet presents planar Halbach arrays that allow increasing magnetic flux from one side of this array [23][24][25]. Figure 8(a) shows a magnetic map of a 10 × 3 mm 2 part of the strong side of the Halbach planar array, performed with a step size of 0.1 mm along the x-axis. The upper part presents an average among all y-axis measurements of the field profile along the x-axis for one period of the structure. The signal has a sinusoidal shape with a period of 3.2 ± 0.1 mm and a magnitude of 204 ± 5 G. The corresponding width of one stripe ∼1.6 mm is in the range of 1-2 mm, known for standard flexible-sheet refrigerator magnets [21]. Measurement of this sample with a step size of 0.1 mm gives a reasonable result. The bottom part of figure 8(b) represents a domain structure of a single segment of a standard refrigerator magnet [22]. The magnetic induction vector gradually changes its local orientation along the x-axis [24,26]. The measured B z component was fitted with a sinusoidal function, which describes the behavior of the rotating vector of the magnetic induction well.
To demonstrate the possibility of further scaling of the system to measure at lower dimensions, a 10 mm × 10 mm area of the 5 1 /4 inch floppy was mapped with a resolution of 0.1 mm ( figure 9). The size of magnetic domains representing bits of information is of the order of tens of micrometers [27], which is lower than the sensor's resolution. However, the map shows distinguished areas with periodicity, probably resulting from several bits of information. Moreover, a clear stripe with a thickness around 0.4 mm was detected, presumably  corresponding to a sector on the disk. The amplitude of the magnetic field was about 0.3 G; that is, the order of magnitude of the ambient magnetic field, which was subtracted. To accurately measure magnetic fields below ∼1 G in the position controller, it is necessary to replace metallic parts made of magnetic materials (e.g. steel) with non-magnetic materials and insulate the environment's magnetic fields.

Conclusion and further perspectives
In this work, a method to automatize magnetic field mapping utilizing a 3D printer and a DIY approach to map the static magnetic field of a given 3D region with a sub-millimeter lateral resolution is presented. The printer was used in the first step to produce several parts of the device and transformed into the computer-controlled Hall probe positioner. The process was fully automatized using the LabView environment. As an alternative to commercial LabView, a free Python or other languages can be used, and simpler magnetic field sensors (with a cost of a few tens of euros) and an Arduino card can be implemented. Thus, the total cost of this device will be less than 200 euros.
The operational conditions of the created mapper were optimized and validated using a test-magnet of well-known magnetization. Then, the scaling was demonstrated by mapping samples generating more complex magnetic fields. The spatial resolution was found to be on the order of hundreds of micrometers and with sensitivity to a magnetic field magnitude of less than one Gauss. Lower resolution can be expected if sensors with a smaller active area are used. This setup has already been used to map assemblies of small permanent magnets for biomedical applications [15]. This approach may find applications in many other areas, for example, to study the micropatterned electromagnetic or micromagnetic structures for magnetophoretic technology [28,29]. Moreover, the Hall probe can be replaced by another sensor or additional sensors can be added for multiparametric spatial analysis.
We remark that the DIY approach to build up an instrumental system using a 3D printer can be exploited to teach physics or engineering in schools and colleges. Indeed, implementation of this project by students provides the following highly demanded traits in modern world knowledge and competitions: -A deep understanding of 3D printing technology, including hardware design of the 3D printer and software solutions (G-code) behind the printing process; -Training in computer-aided design (CAD) software for the creation of objects for further manufacturing with 3D printers; -Exploring the use of the LabView platform to control instruments; -Elaboration, curation, and presentation of complex data (3D vector fields).
The assembled device is a learning tool that allows students to investigate magnetic objects and magnetic fields. Everydaylive devices (smartphones, fridge magnets, hard drives of PCs, etc) can be used to analyze their structure and the rendered not visible by the naked eye magnetic field. Permanent magnets, assemblies, or electromagnets can be used to study the basic concepts of magnetism. The magnet's assemblies and coils can be manufactured using printed parts. In this case, students can deepen their understanding of CAD software.

Data availability statement
The data cannot be made publicly available upon publication because they are not available in a format that is sufficiently accessible or reusable by other researchers. The data that support the findings of this study are available upon reasonable request from the authors.