02-14-2006 04:10 PM - edited 02-14-2006 04:10 PM
Message Edited by nyc on 02-14-2006 05:10 PM
02-15-2006 01:15 AM
If you are already familiar with VISA, use it from VB6 too. Especially VISA COM API is easy to use from VB6. VISA COM will work with NI-VISA 3.x or later.
From VB6's Project | References menu, add a reference to VISA COM 3.0 Type Library (C:/VXIpnp/VisaCom/GlobMgr.DLL). Then you can use the following VISA calls.
Private Sub Command2_Click()
Dim rm As IResourceManager
Dim msg As IMessage
Dim rd As String
Set rm = CreateObject("VISA.GlobalRM")
Set msg = rm.Open("GPIB0::2::INSTR")
msg.Clear
msg.WriteString "*IDN?" & vbLf
rd = msg.ReadString(100)
msg.WriteString ":MEAS:VOLT?" & vbLf
rd = msg.ReadString(100)
msg.Close
End Sub
You can also hook up any I/O errors such as "No Listener" or "Timeout" errors by ON ERROR GOTO statement.
02-15-2006 08:17 AM
That is very helpful!
Can I mix the VISA with the older commands such as SendIFC() and ibsre() ?
02-15-2006 09:39 AM
It is possible to mix old NI-488.2M API and VISA, but not recommended. VISA COM has replacement methods for IEEE488.2M SendIFC() and ibsre() on the IGpibIntfc interface.
First you must create a board-level GPIB session using "GPIB0::INTFC" VISA address. The session can be created separately with typical "GPIB0::x::INSTR" sessions at the same time. Then, use SendIFC() and ControlREN() methods for IGpibIntfc interface.
Dim gpIntfc As IGpibIntfc
Set gpIntfc = rm.Open("GPIB0::INTFC")
gpIntfc.SendIFC
gpIntfc.ControlREN GPIB_REN_ASSERT
...
gpIntfc.Close
However, board-level functions such as sending IFC signal and/or enabling/disabling REN line are not needed for typical GPIB applications. These mono-line messages are set up when the device driver or the I/O library DLL is being loaded.
02-28-2014 10:10 AM - edited 02-28-2014 10:11 AM
I tried the example today (just letting it query the IDN) in order to help a customer trying to access our devices from within VB6. Did not work.
Customer has the same problem. Device does not respond or the response is not read with msg.ReadString(100).
As a comparison, I also tried this in LabView (VISA Find, Write, Read, Close) and with the NI Communicator. These both worked, but the NI Spy gave three different log result
for all three methods.
Question now is: what is correct way to access GPIB with or without VISA?
02-28-2014 11:29 AM
t operating system (version of windows) are you on. If windows 7 or 8, VB6 is running in virtual mode and will not access hardware...
03-04-2014 02:25 AM
03-04-2014 02:39 AM
Maik,
What command did you send to the instrument? The NI-MAX's instrument searcher normally sends an *IDN? command with LF(0x0A) termination, and the instrument normally responds as long as it is IEEE-488.2/SCPI compliant.
Also what error code (or exception) was raised in the VB code? You can also see the error status by capturing the traffic with the NI-SPY program and what error log was recorded?
Makoto
03-04-2014 06:54 AM
As I wote above, the IDN query.
I tried three different ways and logged with NI Spy. First was NI Communicator, second was LabView with VISA VIs and third was VB6 example. All gave different result in the log.
Only LabView and Communicator worked.
In VB6, there was no error. It just got no response from the devicse, which could also be seen in the log, but the command was sent through the driver.
But from the log I saw that the Communicator used "ib" commands, rather than the other two tests. Then I found a document from NI regarding GPIB access with those "ib" commands and forwarded it to the customer to use it in VB6. No response so far, but I guess it worked, rather than using those VISA objects.