Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

GPIB-USB and Matlab

Hi there,
 
I would like to use Matlab for current measurement and control of a Keithely 6517-A using a laptop and NI GPIB-USB-HS. I have NI 488.2 installed on my computer and I just wanna know how can I communicate with the instrument using Matlab.
 
As it is obvious I am new with both NI and Matlab DAQ toolbox 😉
 
 
Message 1 of 51
(27,231 Views)
Hey arkadash,

Unfortunately, our GPIB driver does not offer direct communication in Matlab, but it does contain DLLs that you can use. If MatLab can call DLLs then you can use the driver in this way to communicate directly with these DLL files in Matlab. Unfortunately, I do not know how Matlab uses DLLs, so in order to get help with calling them, you may need to contact their support team. If you have the option of using LabVIEW, communication with NI GPIB cards is very easy and with a few clicks, you can have instant communication with your GPIB Instruments.

I hope this helps,

Regards,
Jason W
Application Engineer
National Instruments
0 Kudos
Message 2 of 51
(27,183 Views)
Arkadash,
 I have been using the GPIB USB HS and B for sometime in windows XP with matlab. You need the instrument control toolbox not the daq toolbox. works great. I had to install the NI drivers and setup up the GPIB USB with a "board" address of 0. I talk to several different instruments including keithley 2000A.

once you get the instrument control toolbox look up the "gpib" command in matlab's help. you then use fopen, fprintf and scanf to open, write and read data. one last peice of advice, if you have an error inside a function that is open and closing the gpib connection and you do not close the gpib connection it does not always work again until you restart matlab. i suggest using try/catch blocks and closing things off if there is an error.

i am waiting for NI to put out 64bit linux drivers so i can use matlab in linux for the same.

good luck to you
Message 3 of 51
(26,938 Views)
Hi


I experience the following problem when trying to connect to a device through a USB port  from Instrument Control ToolBox.2   of Matlab , R .14:

I have managed to create a Visa USB interface object however, when I use the fopen(obj) command, I receive the following error:

A= visa('ni', 'USB::0x104D::0xCEC7::1184::INSTR')

   VISA-USB Object Using NI Adaptor : VISA-USB-0-0x104D-0xCEC7-1184-0

   Communication Address 
      ManufacturerID:     0x104D
      ModelCode:          0xCEC7
      SerialNumber:       1184

   Communication State
      Status:             closed
      RecordStatus:       off

   Read/Write State 
      TransferStatus:     idle
      BytesAvailable:     0
      ValuesReceived:     0
      ValuesSent:         0
 
>> fopen(A)
??? Error using ==> icinterface.fopen
Could not open VISA object. Use INSTRHWINFO for a list of available configurations.


Your help in overcoming this problem would be greatly appreciated and would be huge leap forward towards my PhD.



0 Kudos
Message 4 of 51
(26,178 Views)

Hi Khashibaba,

I am guessing that you are communicating via an NI USB-GPIB controller.  If so, we can establish communication with the device in Measurement and Automation Explorer by selecting Devices and Interfaces>>GPIB>>Instrument X and choosing 'Communicate with Instrument'.  If you can successfully query the instrument for its identification (usually *IDN? although check the device's manual for more information), then the communication is working.

If you can establish that it is communicating properly, I would recommend consulting the manual for the device to ensure that you are using compatible commands, and/or contacting Mathworks at support@mathworks.com.  Otherwise, if you have access to LabVIEW, we can easily set up communication with your instrument.

Regards,

Lauren L.

Applications Engineering
National Instruments
0 Kudos
Message 5 of 51
(26,137 Views)
Hi,

calling instrhwinfo('ni') will likely hep figure out what the valid VISA strings are.  You didn't mention which version of NI-MAX/NI-VISA you are using...

-Rob
-----
Rob Purser
Manager, Test and Measurement
MathWorks
rob.purser@mathworks.com
0 Kudos
Message 6 of 51
(26,116 Views)
thank you all, your help is greatly appreciated.

when I use instrhwinfo('visa','ni'), I get the following:

instrhwinfo('visa','ni')

 

ans =

 

 AdaptorDllName: [1x67 char]


AdaptorDllVersion: 'Version 2.0'


AdaptorName: 'NI'
AvailableChassis: []
AvailableSerialPorts: {'ASRL3'}
 InstalledBoardIds: []
ObjectConstructorName: {[1x27 char]}
SerialPorts: {'ASRL3'}


VendorDllName: 'visa32.dll'


VendorDriverDescription: [1x32 char]


 VendorDriverVersion: 4.2000

On my laptop I have no physical serial port, but I guess my mother has an unconnected port. I am able to establish connection to this,

The NI-Visa that I use is version 4.2. When I detect the USB device ( a powermeter from Newport), I get the following identification tag:

USB0::0x104D::0xCEC7::NI-VISA-0::RAW

However, in matlab examples, I have not seen any connections to RAW devices. Are they supported? Should download any library?


0 Kudos
Message 7 of 51
(26,108 Views)
mother=mother board
0 Kudos
Message 8 of 51
(26,106 Views)
Hi,

I checked on this, and currently, we do not currently support ::RAW devices.

All the best,
-Rob
-----
Rob Purser
Manager, Test and Measurement
MathWorks
rob.purser@mathworks.com
0 Kudos
Message 9 of 51
(26,067 Views)

 I am trying to do the same thing that you, but with an spectrum analyzer, my problem is that matlab says to me that it does not have the necessary controllers to connect the gpib, Do you found some driver or do you know how can i do for to connect my gpib?  My mail is nusim_84@yahoo.com.mx if you have some information for me.

PD: I neither know much about it. Thank You

BYE

 

0 Kudos
Message 10 of 51
(24,185 Views)