Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

A message is read from the Output Queue by addressing the SourceMeter to talk after the

I'm new to programming instruments...

In the manual it says "A message is read from the Output Queue by addressing the SourceMeter to talk after the
appropriate query is sent".  What is the code I need to use in VB in order to "address the SourceMeter to talk"?

Part of my code goes like this:
    Call ibwrt(udDevice, ":sens:func 'Volt:DC'")
    Call ibwrt(udDevice, ":form:elem Voltage")
    Call ibwrt(udDevice, ":read?")
    Call ibrd(udDevice, sBuffer)
 
That code crashes unless I put a 0.6s delay between Call ibwrt(udDevice, ":read?") and Call ibrd(udDevice, sBuffer)
0 Kudos
Message 1 of 4
(4,002 Views)
Hi A_A,

The ":read?" command that you sent your sourcemeter is a query telling the device that you want to read data. It takes time for the data to be ready to be sent to you, hence the need for the delay. Does your program work fine if you put a 0.6s delay? Do you get correct data?

I would advise you to run the basic gpib examples that can be found in this location on your computer:
C:\Documents and Settings\All Users\Documents\National Instruments\NI-488.2\Languages\Visual Basic

Some of them are device-specific but there are a couple that are generic and will work for any device. Please refer to the readme for each example before running.
Rasheel
0 Kudos
Message 2 of 4
(3,976 Views)
Thanks for your reply Rasheel,

Yes the program works if you put a 0.6s delay.  While the program freezes with <0.6s delay, if I press Esc the program breaks but still prints out the correct data.  To me that indicates that the data is read in a time much less than 0.6s.

I've also realised that I'm using VBE (in excel) which is slightly different to VB.  The examples have given me ideas but unfortunately I have not been able to use them to solve my problem.
0 Kudos
Message 3 of 4
(3,963 Views)
Hi A_A,

Could you please perform an NI-Spy capture so that we can see what's going on in the driver level? You can do this by following the instructions here.

Please perform an NI-Spy capture for both more than 0.6s delay, as well as less than 0.6s delay. Could you also please give us the error code and error message that you see when the code crashes? Thanks!
Rasheel
0 Kudos
Message 4 of 4
(3,948 Views)