Communication across SPI uses a system known as data exchange. Whenever a bit is written to an SPI device across the MOSI line, the SPI device concurrently returns a bit on the MISO line. Because data is transferred in both directions, it is up to the receiving device to know whether the received bit is meaningful or not. For example, to receive data from an EEPROM, the master must configure the EEPROM to send n bytes of data and then must send n bytes to be exchanged for valid data. Depending on the device, these bytes can usually be any value, i.e., dummy data, and writing them serves only to clock the data out of the receiving device. In other cases, an instruction may be written to the MOSI line that directs the SPI slave device to output specific data. For example, many ADCs require the user to write an 8-bit instruction that specifies a register to read. After that instruction is written, a delay is required, followed by dummy data that is written to the slave device (MOSI) to clock out the specified data. In the NI-845x API, you can implement such communication schemes by means of the SPI Advanced palette, with which you can create custom SPI scripts for implementing variations of SPI and other serial protocols.
The ADS1224EVM contains three header blocks for connecting the analog input signal, power supply, and serial output. In addition, a series of switches and jumpers are available to configure settings such as the ADC voltage reference, the input select, and the digital power select. Before making any connections to the evaluation module or writing any code, we must examine the data sheet for the ADS1224 and the ADS1224EVM to determine the proper jumper and switch settings to place the ADS1224EVM in a mode compatible with the USB-8451.Upon close examination of the ADS1224 user manual, pages 13-16, it becomes clear that the serial output is not pure SPI, but a slightly different serial protocol implemented as 2-wire serial. The USB-8451 offers advanced functionality that allows for flexibility and ultimately, the ability to support different flavors of serial protocols, not just pure SPI or I2C. As we continue to examine the ADS1224 data sheet, we see that the serial output connector contains two terminals relevant to the serial data transfer: SCLK (input) and DOUT/DRDY (output). The SCLK line, also known as the serial clock, is an input to the ADC that clocks data bits out of the ADC onto the DOUT/DRDY line. Each SCLK clock cycle input into the ADC produces one output bit, representing the conversion produced from the ADC. Because the ADS1224 is a 24-bit ADC, we need to clock out 24-bits to obtain each ADC conversion result.The DOUT/DRDY line is a multifunction line serving to transfer the serial data and to alert the device that a new conversion result is ready to be transferred to the USB-8451. When the normally high DOUT/DRDY line transitions to a low state, a conversion is ready to be output from the ADS1224. After this low signal is received, 24-bits of data are ready to be clocked out.There are four other inputs to the ADS1224 that define its behavior. The first two are digital input lines MUX0 and MUX1. These inputs define the analog input channel which will be read. In our case, setting MUX0 and MUX1 low specifies that the ADS1224 will read channel 0. Another input, TEMPSEN, when enabled, bypasses the external analog inputs and outputs a voltage from an on-board temperature sensor to the ADC. The last input, BUFEN, enables a built-in buffer circuit. The buffer circuit would be useful in applications where a high impedance signal source is used, but in this example, a low impedance source is used so BUFEN is disabled.
Now that we understand the basics of how the ADS1224 works, we are ready to connect it to the USB-8451. To begin, we examine the analog input connector; the input to the ADC. For simplicity we configure channel 0 of the ADC for a differential measurement by connecting AN0+ and AN0- to our signal source. The power connector, J3, requires four connections: +5 V analog and digital supply, and analog and digital grounds. Because the USB-8451 contains a +5 V supply, we can power the evaluation module directly from the USB-8451. Before making the connection to the USB-8451, make sure +5VD (pin 9) is shorted to DVDD (pin 10) on the ADS1224EVM jumper block. This configures the ADS1224 to use a +5 V input. Alternatively, we could use a 1.8 or 3.3 V digital supply. Next, we connect both +5 V analog and digital supplies to the USB-8451 +5 V terminal and the analog and digital grounds to the 8451 ground connector. Now that we have connected the analog input signal and the power to the ADS1224EVM, we need to connect the serial output to the USB-8451.The following settings and connections were used for the evaluation of the Texas Instruments 1224EVM:
Power Connector – J3
Serial Output Connector – J2
Slide SwitchesThe slide switches on the ADS1224EVM configure what kind of signal is input to the ADC, whether we want to measure an onboard reference to test the accuracy of the ADC, or we want to configure the ADS1224 to perform a single-ended or differential measurement. The following switch settings were used in this evaluation.
The LabVIEW API provided for the USB-8451 provides two different APIs for programming I2C and SPI devices. The first method, known as the Basic API, involves using a minimum number of LabVIEW functions and is best suited for simple communication schemes that comply with the timing characteristics of the USB-8451. Figure 7, shown below, is an example of the LabVIEW API for basic SPI communication. The program can be broken into three distinct pieces. The first piece configures the 845x device by specifying the desired behavior of the digital lines. The second piece configures the SPI specific features such as the SCLK rate, the clock phase, the clock polarity, and the chip select line to use. This simple methodology will work for many devices, but the TI ADS1224 requires more advanced control over the specific timing of its serial communications. Specifically, the simple method of communication performs serial operations at a speed that is too fast for the ADS1224 to keep up. This results in corrupted data and inconsistent results. To solve this problem, we can use the Advanced API for the USB-8451that provide scripting functionality to effectively create custom transactions of the serial operations you wish to perform.Figure 8. Simple SPI Example Using the LabVIEW Basic SPI VIs
When designing our program, we can break it into three pieces. The first piece is configuration. Here we configure the digital lines used to determine which analog input channel we are going to read, whether or not we are enabling the on-board buffer circuit, and whether we are going to read the on-board temperature sensor. In addition, we configure the properties of the serial clock such as the clock rate, polarity, and phase.The second piece of the program is the script that will define how the serial protocol will function. For our program, we will set digital lines, wait for a period of time, and then clock out 24-bits of data (one conversion result). Finally, we execute the script we created on the USB-8451, transfer the data obtained, and perform the appropriate conversion on the data. In the case of the ADS1224, the data transferred is in the form of binary twos-complement. A custom VI was created, twos complement to voltage.vi, that converts the output data from the ADS1224 to voltage.Figure 9. Programming Architecture for Example Program
The example program, attached below, is an implementation of the concepts and ideas discussed in the previous sections. The VI will communicate through the USB-8451 to the TI ADS1224 each time the “Press to take a Reading” button is pushed. Each reading will then be stored in a waveform chart.
Figure 10. Screenshot of Example VI Measuring a 1 VDC Source
To view and download this example program, visit the Developer Zone Example: Using a NI USB-8451 I2C/SPI Device to Evaluate a Texas Instruments Analog-to-Digital Converter - Example Program.
The NI USB-8451 I2C and SPI device provides an excellent platform for evaluating electronic components such as analog-to-digital converters. Using the API included, you can integrate SPI, I2C, as well as other flavors of serial protocols via the built-in scripting functionality.For more further information and ordering details for the NI USB-8451, please visit the Web page for the USB-8451.
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.