Issue with mexNI845x Not Finding Resource Names Properly

조회 수: 5 (최근 30일)
James Maroney
James Maroney 2018년 5월 1일
댓글: Han Du 2018년 5월 4일
I am attempting to utilize a NI-8452 to be a SPI master that will communicate with a test board. Matlab code eventually makes use of NI845xSPILib.m
Tracing through the issue, I found that the problem lies with mexNI845x('findDevices') not returning the proper resource name. On my system it simply returns 'ni845x'. On my coworkers system, it returns USB0::0x3923::0x7514::01BE1159::RAW. Code that exists in the Utility.m file, attempt to parse this resource name and split it based on '::' however, the string being based to it does not contain any '::' and therefore it causes failures.
On my coworkers system, everything runs as expected with no problems he is using (Matlab 2017b) On my system, running a command like instrhwinfo('spi') causes it to hit the line of code mentioned earlier and crash. (I am using Matlab 2018a)

답변 (1개)

Han Du
Han Du 2018년 5월 4일
Make sure the support package is installed. The NI-USB-8452 is supported via a support package, per: https://www.mathworks.com/hardware-support/spi-interface.html
See at the bottom of the page for the support package link.
Here's an example of using the support package:
Unfortunately it doesn't look like the device can be simulated in NI MAX so I cannot try to reproduce the issue in R2018a. I wouldn't expecting running instrhwinfo('spi') to check for devices. It only returns the supported vendors and installed vendors:
>> i2cInfo = instrhwinfo ('spi')
i2cInfo =
HardwareInfo with properties:
SupportedVendors: {'aardvark' 'ni845x'}
InstalledVendors: {'ni845x'}
I would expect instrhwinfo('spi', 'ni845x') to check for devices:
>> i2cInfo = instrhwinfo ('spi', 'ni845x')
i2cInfo =
HardwareInfo with properties:
VendorName: 'ni845x'
VendorDescription: 'National Instruments'
VendorLibraryName: 'Ni845x.dll'
InstalledBoardIds: {1×0 cell}
BoardSerialNumbers: {1×0 cell}
ObjectConstructors: {1×0 cell}
  댓글 수: 2
James Maroney
James Maroney 2018년 5월 4일
I have already performed and reviewed the two links that you included but my issue wasn't resolved. When the device is not connected, I can reach the first I2C block you mentioned above:
HardwareInfo with properties:
SupportedVendors: {'aardvark' 'ni845x'}
InstalledVendors: {'ni845x'}
Again with the device NOT connected, I run instrhwinfo('spi','ni845x') and get the same printout you showed above.
When the device is connected, the code hits the mexNI845x('findDevices') module, but doesn't return the correct ResourceName string, which then breaks line 116 in the Utility.m file (Program Files\MATLAB\R2018a\toolbox\instrument\instrument\+instrument\+interface\+spi\+ni845x\Utility.m
This problem is occurring because the incorrect ResourceName is being returned and thus cannot be processed by the code that is designed to split a specific ResourceName string. The NI MAX program shows that the device is functioning and I can see the correct ResourceName in that interface. It just seems like the matlab MEX file is not functioning properly.
Han Du
Han Du 2018년 5월 4일
From the code, it seems that the function is not doing much other than calling the underlying ni845x.h provided by National Instruments to get the resource names for each device. What is the resource name showing in your NI MAX?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Instrument Control Toolbox Supported Hardware에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by