-1

Using VBA, I tried to use the NI-488.2 calls directly, instead of using VISA COM. However, when I try to use NI-488.2 commands in VBA, I get the following error message :

''Sub or Function not defined''.

That is, when calling Call SendIFC(BOARD_ID) or Call EnableRemote(BOARD_ID, intAddrList()), Call SendGPIB(osa, ":mmem:stor:grap color,bmp,""test"",int"), = RecieveBinaryGPIB(osa, byteData()), etc...

My first guess would be that I am simply missing the correct library. (Or is there any deeper issue here?). For now, I added the VISA COM 3.0 Type Library and the VISA COM 488.2 Formatted I/O 1.0 to the Excel references.

Here is a sample code from YOKOGAWA (slightly edited) that can be found online and applies to Visual Basics, but that I could not run in VBA. I removed most of the code for clarity purpose. It simply saves a screenshot in internal memory.

Private Sub SaveImage()

Const BOARD_ID = 0 'GP-IB Interface card Address
Const osa = 1 'OSA GP-IB Address

Dim intAddrList(31) As Integer

'----- GP-IB Interface setting
' send IFC
 Call SendIFC(BOARD_ID)

' assert th REN GPIB line
intAddrList(0) = NOADDR
Call EnableRemote(BOARD_ID, intAddrList())

' GPIB time out setting
Call ibtmo(BOARD_ID, T30s) 'Time out = 30sec

'----- send command to OSA
Call SendGPIB(osa, "CFORM1") ' Command mode set(AQ637X mode)
Call SendGPIB(osa, ":mmem:stor:grap color,bmp,""test"",int")

'----- Disconnect
Call EnableLocal(BOARD_ID, intAddrList())

End Sub

  • What have you tried? Do you just need to add the library? – BruceWayne Aug 22 '18 at 14:53
  • I am precisely asking if those NI 488.2 commands require a library to use them in VBA. (And if so, wich one?) I looked on the web without any useful results. I am new to GPIB communication and VBA. – Nicolas Bouchard Aug 22 '18 at 15:06

1 Answers1

0

Now we have the code... you have now edited out the useful bits... I'm going to backtrack a bit and say that even if you get direct calls to work you’re still going to have a problem extracting the files.

I’m going to guess you’re getting "Undefined header" errors if you query the OSA with "SYST:ERR:ALL?" and this is quite possibly because the query command for the data is invalid.

I’ve notice you’re using including the data type your command:

":mmem:data? ""test.bmp"",int"

"test.bmp",int,0 is what you might see if you query the directory, however, it is not needed when extracting the file.

try using:

":mmem:data? ""test.bmp"""

(The number of quotations are to include them in the string)

If not, what is the GPIB error?

Zircatron
  • 126
  • 7
  • My problem for now (Maybe others will come and thanks for forseeing them) is that the code won't compile. The functions from the NI-488.2 standard are not recognized by VBA by default, thus giving the ''Sub or Function not defined''. error. I edited the question again because your answers help me being more precise. – Nicolas Bouchard Aug 22 '18 at 16:40
  • I haven't used the NI drivers this much to know if these files will appear in the references. Locate the following files and make note of their location. These files will be used during the development process of a Visual Basic program. a. Niglobal.bas b. Vbib-32.bas – Zircatron Aug 22 '18 at 17:06
  • Personally, I would go back to using the VISA COM libraries, you shouldn't have any problems with these and they're much more convenient to use. – Zircatron Aug 22 '18 at 17:08