Quantcast
Channel: Digital I/O topics
Viewing all articles
Browse latest Browse all 2147

How to Create a Serial Peripheral Interface Bus (SPI) Interface using Excel?

$
0
0

Excel can be used to create a user interface that controls a device under test (DUT) using a Serial Peripheral Interface Bus (SPI). The example interface uses the National Instruments USB 8451 SPI interface to control a digital to analog converter (DAC) or a digital step attenuator (DSA). For the DAC, the user opens up Excel and selects the parameters like clock frequency and clock polarity, for example, and inputs bytes of data. The user then commands the USB 8451 interface to send the serial data to the DAC. For the DSA, the user would select the attenuation state and command the USB 8451 to send the serial data to the step attenuator.

 

Excel was chosen because it provides a rich environment for data entry and post processing. Excel also supports real time debugging of Visual Basic code and serves as a basic graphical user interface (GUI). This prevents reinventing the wheel each time by tapping all of the resources that are already part of Excel.

 

The first challenge was the fact that National Instruments does not provide Visual Basic libraries for the USB 8451 hardware which prevented me from calling the functions directly. I first tried to make a wrapper that would take the C programming functions which were supported and call them from Visual Basic. I then got quickly humbled by the complexity and time it takes to understand how to call pointers from Visual Basic. Due to lack of time, I headed in a different direction to generate my interface.

 

Since C programming functions and C language examples were available for this device, I chose to compile custom executable files by adapting NI's C language examples. NI's examples were modified so that I could pass all the parameters and the data using command line arguments.

 

To complete the Excel interface, a GUI was created in Excel that allows the user to either select or input all of the command line arguments that are required. Excel then creates a custom DOS batch file with the arguments and executes the batch file. For the DAC interface, the user will select a voltage and excel will form all of the command line arguments automatically and send the DAC the data corresponding to the selected output voltage. For the DSA interface, the user will select an attenuation state and excel will handle formatting the command for the user.

 

The next step will be commanding a DUT that has both a DSA and a DAC that is connected to test equipment. Excel can command the DUT and command the test equipment over GPIB using a National Instruments USB to GPIB interface and 488.2 libraries to provide the complete automated test setup. National Instruments already has an example spreadsheet that contains all of the commands needed for the 488.2 interface. After the data is measured, excel can post process the data and spit out a graph of the results. Beautiful!


Viewing all articles
Browse latest Browse all 2147

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>