02-08-2013 01:57 AM - edited 02-08-2013 02:04 AM
Hi Everyone,
I am trying to simply communicate with Agilent 34410A device via USB. I am able to see the device on Measurement & Automation suite and on VISA. I am able to communicate with it fine via these two means. I installed the I/O libraries.
However, whenever I run my code, it gives me Err 7. I am not sure what I am doing wrong. I tried many things but failed to get measurements from this device. I was using Agilent Keithley with this code and with USB-GPIB adaptor connector and it was working perfectly.
There must be something that I am not seeing. This is my frist time writing a program to retrieve measurements from this device.
I am using Visual Studio 2012 Premium on Windows 7 64-bit.
I have attached the code. I would appreciate your help.
02-08-2013 09:19 AM
You say you are using USB but your code is written with the low level GPIB functions. I would have thought it would have been obvious that the two are completely different. If you would use VISA functions, then moving between GPIB and USB would be transparent.
02-08-2013 12:29 PM
Hi Dennis
Thanks for the reply. What commands should I be using?
I looked through the manual and I couldn't locate something specific for USB. Also, when I tried this code with Agilent Keithley, which I connected to it via USB-GPIB cable, it worked. What chain in my thought am I missing?
02-08-2013 12:40 PM
As I said, you should be using VISA functions. ViWrite/ViRead, etc. These are documented in the NI-VISA help file. They should have been used for the GPIB version. I have no idea what the low level USB functions are in c++.
There is no such thing as Agilent Keithley. They are two separate companies. An Agilent USB-GPIB controller uses a different set of low level GPIB commands. I believe Keithley's GPIB library uses the same function names as NI (ibdev, ibwrt, ibrd). These commands are specific to a GPIB interface only. If you switched to a serial connection or Ethernet, your code would not have worked either because you were too specific on the interface. VISA abstracts the actual physical interface. When you use VISA, the driver determines the actual physical connection so VISA code is portable.
02-08-2013 04:15 PM
I should also point out that there is already a driver that exists for that instrument. Agilent may have one as well.
03-21-2013 08:38 AM
Hi.
Is this "simply" ?
At first communicating with the device is really easy.I looked your code but its not needed to write a lot of lines.
You can use VISA commands such as viRead,viWrite,viOpen,viOpenDefaultRM etc.
For example first connection ;
#include "visa.h" #define MAX_CNT 200 int main(void) { ViStatus status; ViSession defaultRM,instr; ViUInt32 retCount; ViChar buffer[MAX_CNT]; status = viOpenDefaultRM(&defaultRM); { if (status < VI_SUCCESS) return -1; } status = viOpen(defaultRM,"USB0::xxxxx::xxxxxx::xxxxxxxxx::INSTR",VI_NULL,VI_NULL,&instr); status = viWrite(instr,"*IDN?",6,&retCount); status = viRead(instr,buffer,MAX_CNT,&retCount); status = viClose(instr); status = viClose(defaultRM); return 0; }
This is the example in NI-VISA User Manual.It sends the identification command(*IDN?) to the device and returns the response,stores it in buffer variable.
"USB0::xxxx..." section in the code is your device's name.You can see it in MAX.
For example if you write
printf(buffer);
after the viRead() function you can see the device's name,model,serial number etc in terminal.Or you can use the buffer variable in other type of programming applications.In Visual Studio a forms application may be.In LabWindows which I'm using,a User Interface Application.
I mean you do not need a lot of code to communicate with the device.
I have Agilent 34410A too and drivers of course.You can communicate with this codes i gave or you can communicate with the initialize function(every device driver has one) first and use other functions for example measurement functions...
Have nice coding.