Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Troubleshooting I2C Interface

I2C, or Inter-Integrated Circuit, is a chip-to-chip interface supporting two-wire communication. Instrument Control Toolbox™ I2C support lets you open connections with individual chips and to read and write over the connections to individual chips.

The Instrument Control Toolbox I2C interface lets you do chip-to-chip communication using an Aardvark or NI-845x host adaptor. Some applications of this interface include communication with SPD EEPROM and NVRAM chips, communication with SMBus devices, controlling accelerometers, accessing low-speed DACs and ADCs, changing settings on color monitors using the display data channel, changing sound volume in intelligent speakers, reading hardware monitors and diagnostic sensors, visualizing data sent from an I2C sensor, and turning on or off the power supply of system components.

Supported Platforms

You need to have either a Total Phase Aardvark host adaptor or an NI-845x adaptor board installed to use the I2C interface.

The I2C interface is supported on these platforms when used with the Aardvark host adaptor:

  • Linux® – The software works with Red Hat Enterprise Linux 4 and 5 with kernel 2.6. It may also be successful with SuSE and Ubuntu distributions.

  • macOS 64-bit – The software is supported on Intel versions of macOS 10.5 Leopard and 10.6 Snow Leopard.

  • Microsoft® Windows® 64-bit

The I2C interface is supported on these platforms when used with the NI-845x host adaptor:

  • Microsoft Windows 64-bit

For updates to the list of currently supported platforms for MATLAB®, see http://www.mathworks.com/support/sysreq/current_release/.

Adaptor Requirements

You need to have either a Total Phase Aardvark host adaptor or an NI-845x adaptor board installed to use the I2C interface. The following sections describe requirements for each option.

Aardvark-specific Requirements

To use the I2C interface with the Aardvark adaptor, download the Hardware Support Package to obtain the latest driver, if you do not already have the driver installed. If you already have the latest driver installed, you do not need to download this Support Package.

If you do not have the Aardvark driver installed, see Install the Total Phase Aardvark I2C/SPI Interface Support Package to install it.

Install the Aardvark Software API and Shared Library appropriate for your operating system.

The aardvark.dll file that comes with the Total Phase Aardvark adaptor board must be available in one of these locations for use on Windows platforms:

  • Location where MATLAB was started from (bin folder)

  • MATLAB current folder (PWD)

  • Windows folder C:\winnt or C:\windows

  • Folders listed in the path environment variable

For use on Linux platforms, the aardvark.so file that comes with the Total Phase Aardvark adaptor board must be in your MATLAB path.

NI-845x-specific Requirements

To use the I2C interface with the NI-845x adaptor, download the hardware support package to obtain the latest driver, if you do not already have the driver installed. If you already have the latest driver installed, you do not need to download this support package.

If you do not have the NI-845x driver installed, see Install the NI-845x I2C/SPI Interface Support Package to install it.

Configuration and Connection

  1. Make sure that you have the correct instrument driver installed for your device. Refer to your device’s documentation and the vendor’s web site.

  2. Make sure your device is supported in Instrument Control Toolbox. See Is My Hardware Supported?.

  3. You must have a Total Phase Aardvark host adaptor or an NI-845x adaptor board installed to use the i2c interface. Install the appropriate support package if you have not already. See Adaptor Requirements.

    Make sure that your I2C adaptor board is plugged into the computer running MATLAB. You can verify that you have one of the adaptors installed by using the instrhwinfo function with the i2c interface name.

    If you do not see either aardvark or ni845x listed, you need to install one of the support packages or install the driver directly from the vendor.

  4. Make sure that Instrument Control Toolbox recognizes your device, by using the instrhwinfo function with the i2c interface name, and your adaptor name, either aardvark or ni845x. For example:

    instrhwinfo('i2c', 'Aardvark')
    ans = 
    
              AdaptorDllName: [1x127 char]
           AdaptorDllVersion: 'Version 3.0.0'
                 AdaptorName: 'aardvark'
           InstalledBoardIds: 0
       ObjectConstructorName: 'i2c('aardvark', BoardIndex, RemoteAddress);'
               VendorDllName: 'aardvark.dll'
     VendorDriverDescription: 'Total Phase I2C Driver'
    

    You will need the information displayed to create the i2c object. If your device is not displayed, check the previous steps.

  5. Make sure you can create the i2c object. You must provide three arguments to create the object. BoardIndex is usually 0, and Vendor is either aardvark or ni845x. The RemoteAddress is specific to your device. Read the documentation of the chip in order to know what the remote address is. For example, in this case we create an object to communicate with an eeprom chip at remote address 50h:

    % Vendor = aardvark
    % BoardIndex = 0
    % RemoteAddress = 50
    
    eeprom = i2c('aardvark', 0, '50h');

    Tip

    You can also see what the remote address of the chip is by scanning for instruments in the Test & Measurement Tool. In the tool, right-click the I2C node and select Scan for I2C adaptors. Any chips found by the scan are listed in the hardware tree. The listing includes the remote address of the chip.

  6. If you do not get an error, the object was created successfully. To verify, you can look at the object properties, using the name you assigned to the object, eeprom in this case.

  7. Make sure you can connect to the device, using the fopen function with the object name.

    fopen(eeprom);

    If you do not get an error, the connection was made successfully. If you do get an error, follow the steps in the error message and/or check the previous steps listed here.

  8. When you have connected, you can communicate with your device. See Transmitting Data Over the I2C Interface for an example of reading and writing to a chip.

Was this topic helpful?