The Impinj Monza® X chip is a UHF Gen 2 RFID chip that is also accessible via I²C. I²C is a two-wire interface that is supported by many embedded systems, computers and other electronics devices. This application note will show you how to connect a Monza X chip to a host computer for development and testing. Here are the components you'll need:
- An Impinj Monza X-2K Dura or Monza X-8K Dura development board
- A Total Phase Aardvark I²C /SPI Host Adapter (Part #TP240141)
- A computer running Windows or Linux
- The GNU C Compiler (gcc)
- The Monza X API for C
- A Speedway® Revolution RFID reader
- A UHF RFID antenna
- Microsoft Visual Studio 2008 or later
- Monza X RFID Example for C#
The Monza X API for C
The Monza X API is a platform-independent programming interface written in C. Most of the source code is portable across a range of processors and operating systems. However, there are a few functions that must be defined for your particular setup. These platform-specific functions are contained in monzax_api_platform.c and monzax_api_platform.h. In these files, you'll find three functions that define the basic I²C read, write and initialization routines for a particular platform. Since the Monza X sample application uses an Aardvark I²C host adapter, these functions are populated with the code needed to control the Aardvark. You should replace these functions with the logic needed for your particular device:
This function is called once when the API is initialized. If you need to configure or start your I²C controller, it should be done in this function.
int i2c_write(int i2c_device_id, int address, char *data, int data_len)
Performs a basic I²C write operation. Arguments include the I²C device ID (i2c_device_id), the address in memory to start writing from (address), the data to write (data) and the number of bytes to write (data_len). This function returns the number of bytes written.
int i2c_read(int i2c_device_id, int address, char *data, int data_len)
Performs a basic I²C read operation. Arguments include the I²C device ID (i2c_device_id), the address in memory to start reading from (address), the data to read (data) and the number of bytes to read (data_len). This function returns the number of bytes read.
This function is called once when the API is shut down. If you need to shut down or stop your I²C controller, it should be done in this function.
Building the API and Sample Application
First, install the Aardvark USB drivers for your particular operating system. They can be downloaded from here:
Once the drivers are installed, you need setup a GNU-compatible build system. If you're running Linux, you may already have one installed. If not, you can usually install one using the package manager for your distribution. For example, on Ubuntu, you can install the GNU build system using APT like this:
sudo apt-get install build-essential
If you're running Windows, you should install MinGW:
When installing MinGW, you should select the "C Compiler" and "MSYS Basic System" options. The installer will create a shortcut on the Start menu, under MinGW, called "MiniGW Shell". Clicking on this shortcut will open a Linux-style command window from which you can build and run the sample application.
Once you have the build system setup, download the Monza X API source code:
Download Monza X API
Unzip the file, navigate to the API source code directory and enter the command 'make' at a command prompt. The compiler will run and produce an executable in the same directory called 'hello_monzax' (Linux) or 'hello_monzax.exe' (Windows).
Connecting the Hardware
The ribbon cable on the Aardvark I²C host adapter follows the standard convention. The red line indicates the position of pin 1. When looking at your Aardvark adapter in the upright position (figure 1), pin 1 is in the top left corner and pin 10 is in the bottom right corner.
Figure 1: The Aardvark I²C Host Adapter in the upright position.
Figure 2: The Aardvark I2C Host Adapter in the upside down position.
Only four of the Aardvark pins are used by the Monza X development board:
- SCL (I2C clock)
- SDA (I2C data)
For additional technical details on the Aardvark I²C Host Adapter, please consult the datasheet from Total Phase Inc.:
Figure 3: The Monza X Dura Development Board
The Aardvark I²C Host Adapter should be connected to the Monza X Dura development board by plugging the ribbon cable into the 10-pin connector labeled "Aardvark". This connector is keyed, so it can only be inserted in the correct orientation. The Aardvark provides power to the Monza X, so the battery or battery jumper on the development board should be removed when the Aardvark is plugged in.
Running the Sample Application
The Monza X API contains a sample application showing how to access the most popular features of the chip. The source code for this application is contained in main.c and is compiled as 'hello_monzax' (Linux) or 'hello_monzax.exe' (Windows). When you run the application, you will be presented with a menu of functions that allow you to exercise the various features of the chip.
You can verify basic connectivity by reading the chip's model number. To do this, select the menu option labeled "Read model number". The program should display 0x0140 (Monza X-2K) or 0x0150 (Monza X-8K). Next, try zeroing and then dumping the user memory. Each byte of the user memory should contain 0x00. Now try filling and dumping the user memory. Each byte of the user memory should contain 0xFF.
If you get the error message, "No Aardvark devices found !", please verify that Aardvark drivers are installed correctly and that you have rebooted. Also, try disconnecting the Aardvark from the USB port and then reconnecting it. On Windows, the Aardvark should appear in Device Manager under "Universal Serial Bus controllers".
Accessing Monza X via the RFID Interface (Optional)
Now that we've covered accessing Monza X over the I²C bus, we'll discuss how to access the chip using the RFID interface. You will need a UHF Gen 2 RFID reader to do this. The example software provided in this article called monzax_rfid_example.zip contains a sample application written in C#.
Download Monza X RFID Example
This application shows how to access the chip using an Impinj Speedway Revolution® reader. To use it, open up the project file in Visual Studio® 2008 or later. At the top of Program.cs are several constants that you will need to define for your particular setup:
This string should be set to the IP address or hostname of the Speedway Revolution® reader.
The size of User memory, in 16-bit words. Monza X-2K has 136 words of User memory. Monza X-8K has 512 words of User memory.
Once you have defined these constants, place the Monza X Dura development board near the RFID antenna and run the application. The program will fill the memory with random values. Press enter and the user memory will be read and displayed. See screenshot as example:
Article is closed for comments.