ADMT4000DRV-SRC ARDUINO User Guide (Rev.B)
ADMT4000DRV-SRC ARDUINO User Guide (Rev.B)
UG-2274
ADMT4000 Evaluation Board with Arduino Uno User Guide
HARDWARE REQUIRED Note that the ADMT4000 no-OS driver was tested using an Arduino
UNO board. Using a different Arduino board (for example, an Ardu-
► Arduino (microcontroller) ino MEGA) that was not tested and is not guaranteed compatible
► Arduino UNO with the ADMT4000DRV-SRC Software package.
► Arduino MEGA (optional alternative)
HARDWARE CONNECTIONS
► EVAL-ADMT4000SD1Z evaluation board
The EVAL-ADMT4000SD1Z acquires power and communicates
SOFTWARE REQUIRED with the microcontroller unit (MCU) through a link. The MCU allows
► ADMT4000DRV-SRC Software package communication between the PC and the EVAL-ADMT4000SD1Z by
providing the serial peripheral interface (SPI) required to control the
► Arduino IDE: https://www.arduino.cc/en/software
ADMT4000 and capture data directly via the host PC.
GENERAL DESCRIPTION The MCU can also be used independently to operate and process
This user guide provides a general guide for getting started with the data from the ADMT4000.
ADMT4000 no-OS drivers on an Arduino board using the Arduino It is important to complete the software setup before connecting
integrated development environment (IDE). the EVAL-ADMT4000SD1Z and Arduino board to the USB port of
the PC to ensure that the evaluation system is correctly recognized
SUPPORTED HARDWARE when it is connected to PC.
Because the Arduino IDE is used in building the software, technical-
ly, the ADMT4000 no-OS driver is usable with any Arduino board
that the IDE also supports.
REVISION HISTORY
05/2025—Rev. A to Rev. B
Changes to texts in Item 3............................................................................................................................... 5
02/2025—Rev. 0 to Rev. A
Replaced figures featuring code snippets with actual texts (Universal)...........................................................1
analog.com Rev. B | 2 of 14
User Guide ADMT4000 and Arduino Uno
PREBUILD CHECKLIST AND TO DOS
Figure 5. Arduino Sketch Project Folder with the ADMT4000 Drivers and
Examples
analog.com Rev. B | 3 of 14
User Guide ADMT4000 and Arduino Uno
PREBUILD CHECKLIST AND TO DOS
The ADMT4000 and arduino platform drivers alone will not work
Conversion of Print Mechanism because these drivers were built to adhere to a no-OS architecture.
Because the example codes were developed to work for a C To use no-OS drivers, users must install the following no-OS de-
environment, the default print mechanism based on printf used pendencies:
by these examples will not work when imported in the Arduino ► The following source files:
environment. util/no_os_alloc.c
►
Now that the files are in .cpp source file format, the Arduino.h ► drivers/api/no_os_spi.c
library can be added to the example files. ► util/no_os_util.c
► util/no_os_mutex.c
#include "no_os_delay.h"
► The following header files:
#include "no_os_print_log.h"
#include "admt4000.h" ► include/no_os_alloc.h
#include "admt4000_diag_example.h" ► include/no_os_delay.h
► include/no_os_error.h
#include <Arduino.h> ► include/no_os_mutex.h
► include/no_os_print_log.h
Replace pr_info instances in the example codes with combination
► include/no_os_spi.h
of Serial.print and Serial.println to output the same format as in a
C environment (see Figure 7). ► include/no_os_units.h
► util/no_os_util.h
// printf("ABSANGLE = %0.4f deg, ANGLE = %0.4f
deg, Turn Count: %d turns, fault = 0x%x \n", Aside from Sketch (.ino), these files are necessary to operate the
ADMT4000 drivers and are typically included in a project folder
// angle_f[0], angle_f[1], turns, temp); similar to what is shown in Figure 8.
analog.com Rev. B | 4 of 14
User Guide ADMT4000 and Arduino Uno
PREBUILD CHECKLIST AND TO DOS
#endif // _NO_OS_SPI_H_
#ifdef __cplusplus
extern "C" {
#endif
Addition of C++ Compatibility Figure 11. Adding of Preprocessor Directive for C++ Compatibility
Take the following steps to add C++ compatibility: 4. Add the following lines of code shown in Figure 12 after the end
of the header guard.
1. Using an editor (for example, Visual Studio Code), open one
of the header file dependencies listed in the No-OS for Import #ifdef __cplusplus
section. For this example, the no_os_spi.h can be used. }
2. Find header guard or the lines in the code that contains the #endif
#ifndef directive (see Figure 9 and Figure 10).
#ifndef _NO_OS_SPI_H
#define _NO_OS_SPI_H_
analog.com Rev. B | 5 of 14
User Guide ADMT4000 and Arduino Uno
PREBUILD CHECKLIST AND TO DOS
5. Repeat the same steps for all the header files inside the
project folder. These newly formatted files are now referred as
drivers. Do NOT include the example header files (for example,
admt4000_basic.h).
These steps are necessary because the no-OS build system is
mostly based on C. Applying these steps to the header files ena-
bles the Arduino IDE to compile and link the functions from a C
source file in a C++ environment (no name mangling).
For more information, refer to these programing tips (ethz.ch).
#define EBADMSG
Figure 13. Adding of EBADMSG Macro Due to Conflict with Arduino Errno
Library (admt4000.h)
Figure 14. Arduino ADMT4000 Project Folder (Updated)
INITIAL TEST BUILD
When the previous steps are followed, the project folder will contain At this point in the process, the Arduino Sketch is blank (see Figure
what is shown in Figure 14. 15).
analog.com Rev. B | 6 of 14
User Guide ADMT4000 and Arduino Uno
PREBUILD CHECKLIST AND TO DOS
// no OS related includes
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_error.h"
#include "no_os_mutex.h"
#include "no_os_print_log.h"
#include "no_os_spi.h"
#include "no_os_units.h"
#include "no_os_util.h"
// other includes
#include <SPI.h>
The code example above shows how to include the necessary Figure 16. no-OS Main File (Include Headers Depending on the Flag for
headers into the main Sketch. You can follow the same arrange- Certain Example Projects)
ment or groupings for better distinction or do your own grouping.
For you to do what was done in the no-OS build environment, you
Once included, you can try compiling the current Sketch and see must declare the corresponding flags for each example project and
if it generates any errors. You must verify that there are no errors employ the same mechanism for including certain headers.
before proceeding with the next steps.
#define ADMT4000_BASIC 1
#define ADMT4000_DIAG 0
#define ADMT4000_ECC 0
#define ADMT4000_TEST 0
#if (ADMT4000_BASIC)
#include "admt4000_basic.h"
#endif
#if (ADMT4000_DIAG)
#include "admt4000_diag_example.h"
#endif
#if (ADMT4000_ECC)
#include "admt4000_ecc.h"
#endif
#if (ADMT4000_TEST)
#include "admt4000_function_test.h"
#endif
analog.com Rev. B | 7 of 14
User Guide ADMT4000 and Arduino Uno
PREBUILD CHECKLIST AND TO DOS
analog.com Rev. B | 8 of 14
User Guide ADMT4000 and Arduino Uno
PREBUILD CHECKLIST AND TO DOS
Based on the code entered, it is now time to test the build output.
Note that you must verify the code by compiling and observing
any error that may arise. It is advisable to take this step before
uploading to the board.
analog.com Rev. B | 9 of 14
User Guide ADMT4000 and Arduino Uno
BUILDING THE PROJECT
#define ADMT4000_BASIC 1
#define ADMT4000_DIAG 0
#define ADMT4000_ECC 0
#define ADMT4000_TEST 0
analog.com Rev. B | 10 of 14
User Guide ADMT4000 and Arduino Uno
UART VERIFICATION
If the settings are correct, and the program uploaded is correct and
working, then there will be data being printed to the terminal.
The data being printed ton the terminal depends on the example
project enabled. Refer to the following sections for additional infor-
mation on UART verification
UART: BASIC EXAMPLE
Note that for one-shot measurement, Register 0x10 value must
be 0x1201 and the ECC register must be 0x94. For Continuous
measurement, Register 0x10 value must be 0x1200 and the ECC
register must be 0x17 (see Figure 21).
analog.com Rev. B | 11 of 14
User Guide ADMT4000 and Arduino Uno
UART VERIFICATION
Figure 24. ECC Test Example Terminal Output (No Errors Detected)
analog.com Rev. B | 12 of 14
User Guide ADMT4000 and Arduino Uno
TROUBLESHOOTING
For any errors, debug your project like you would with any other
Arduino project. Typical problems that may occur include, but not
limited to, the following:
► Blank serial display
► Compile error, most likely due to incompatibilities with C and C++
► Upload error
► Faulty cable
► Wrong serial port or board chosen
analog.com Rev. B | 13 of 14
User Guide ADMT4000 and Arduino Uno
FEEDBACK
For any issues not covered in this user guide, contact magnet-
[email protected] for further assistance. When doing so, specify the
following:
► The evaluation board number (for example, EVAL-
ADMT4000SD1Z)
► A picture of the setup
► The microcontroller used
► A summary of the issue
ESD Caution
ESD (electrostatic discharge) sensitive device. Charged devices and circuit boards can discharge without detection. Although this product features patented or proprietary
protection circuitry, damage may occur on devices subjected to high energy ESD. Therefore, proper ESD precautions should be taken to avoid performance degradation or loss of
functionality.
©2024-2025 Analog Devices, Inc. All rights reserved. Trademarks and Rev. B | 14 of 14
registered trademarks are the property of their respective owners.
One Analog Way, Wilmington, MA 01887-2356, U.S.A.