Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read data from a GPIB when sending a function generator command

I'm using Visual C++ with the ComponentWork ActiveX and I'm tring to plot a
CWGraph using the data coming from a GPIB device. When I write command such
as "*IDN?" to the GPIB device, everythings if fine and I can read what the
GPIB device return me. But when I send a command like "SOUR:FUNC SIN;SENS
DATA?", the writing seems to be okay, but when I try to read the data, I
alway get a "Timeout expired before operation completed" error message. I
have tried with the CWGPIB and with the CWVISA but the result are the same
with both.
My reading code looks like this:

COleVariant vReadBuffer;
vReadBuffer = m_VISA.Read( COleVariant( (short) 2000 ) );

and it work fi
ne for "*IDN?" or for multimeters command.

I want to know how I must read the data for function generator commands.

Thank alot
0 Kudos
Message 1 of 3
(3,866 Views)
It sounds like your device is not accepting that command string as valid. The string you listed above is probably missing a colon between SENS and DATA. "SOUR:FUNC SIN;SENS:DATA" Try sending this string in Measurement & Automation Explorer to the instrument first to make sure it is working.

Best Regards,

Chris Matthews
Measurement Studio Support Manager
0 Kudos
Message 2 of 3
(3,866 Views)
Ares:

My first suggestion is to use VISAIC or IBIC to make similar write/read function calls to see if it works there.

Also, try using NI Spy with your existing code to see what underlying function calls are being made. Do you see the data being returned from the instrument?

It is possible that you are having syntax problems. One correct way to read a buffer is as follows:

CString vReadBuffer;
ViStatus stat;
stat = m_VISA.Read(vReadBuffer,2000);

Dan Mondrik
Senior Software Engineer, VISA
National Instruments
0 Kudos
Message 3 of 3
(3,866 Views)