1. Device Overview
The Analog Devices ADIS16060 Digital Gyroscope Evaluation Board outputs digitized angular change data to a 4-wire SPI serial interface accessed through connector J1 on the board. The SPI signals needed for this example are SCLK, MSEL1 (CS), MSEL2, DOUT (MISO), and DIN (MOSI). For more information on the SPI bus, see Understanding the SPI Bus with NI LabVIEW.
Figure 1. J1 Connector for ADIS16060
Along with yaw, the ADIS16060 can also output the current temperature from an onboard sensor as well as two 12-bit ADC conversions. To select which data to read, a command must be sent to the device with MSEL2 active low. To read data, 20 bits must be sent to the device with MSEL1 active low.
2. Using NI RIO and LabVIEW FPGA with SPI Devices
This example uses a LabVIEW FPGA IP implementation of the SPI bus to communicate with the ADIS16060 evaluation board. There are two LabVIEW elements to this example. The first is a LabVIEW FPGA interface that performs the SPI communication. The second is a LabVIEW host API that interacts with the FPGA from a host PC or real-time controller. We have chosen a CompactRIO system with an NI 9401 module to provide connection to the device.
For more information on the LabVIEW FPGA SPI implementation and the host API, refer to Implementing SPI Communication Protocol in LabVIEW FPGA.
3. Implementing an SPI Example in LabVIEW FPGA
Using the host API created for interacting with the LabVIEW FPGA SPI engine, it is relatively simple to communicate with the ADIS16060. With the provided example, most of the configuration is provided and moving the program to a different FPGA target is fairly straight forward.
To run the program, open Example_cRIO_Host.vi from cRIO_adis16060_Example.lvproj. This is the host interface to the FPGA SPI core interacting with the gyroscope. The program begins by opening a reference to the top-level FPGA VI and waiting for notification from the FPGA that it is ready for data. Once the host VI receives notification, the SPI bus is configured for writing a command to the device. This is done by setting the clock mode to 1 (CPOL = 0, CPHA = 1) and asserting CS 1 which is connected to MSEL2. By default, the configuration command will be to read the angular rate of the gyroscope. This command is then written to the FPGA VI, which sends the command to the sensor.
Figure 2. Example_cRIO_Host.vi Block Diagram
After the command has been written, the device is reconfigured to use clock mode 0 (CPOL = 0, CPHA = 0) and CS 0 is asserted (MSEL1). Once this configuration has been completed, the host VI continuously sends the 20 bits needed for a sample to the device and reads back the data. This raw data is converted into an angular rate of change and plotted. When the program completes, the FPGA VI is reset and the reference is closed.
Figure 3. Example_cRIO_Host.vi Front Panel
To move the example to another target, create a new LabVIEW FPGA project and copy Example_cRIO_Host.vi, Example_cRIO_Top-Level FPGA.vi, and the two FIFOs from this example project. Once the FPGA is recompiled and the correct connections are made, no further configuration is required.
4. Other ADI Sensor Drivers
Find more sensor drivers for Analog Devices sensors here.
Using a LabVIEW FPGA implementation of the SPI communication protocol, we can communicate with many distributed embedded sensors. The ADIS16060 is one of many embedded sensors that use this common bus to return digitized data to a master for processing.
Originally Authored By: Greg Crouch, National Instruments