Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

a problem with ibrd and ibrda api calls

We are having a problem with ibrd and ibrda api calls used in a VB6 program

to communicate between two GPIB boards. Neither call returns data
to the application; ibrd causes a VB6 application error under some conditions.

Application goal: Pass data between two PCs using the GPIB interface.

Hardware: Compaq Deskpro; PCI-GPIB+ cards

Software versions: NT 4.0 build 1381 SP4
VB6 (SP3)
NIGLOBAL.BAS 1.7 7/29/99 3:38 pm
VBIB32.BAS 1.7 7/29/99 3:38 pm

One PC is configured as a controller, the other as a non-controller
(board 1, primary device address 1) . I created simple forms with
a button and a text box to display status and I/O data. Read/write
operations are instigated by clicking on the buttons.

Code:

Controller

Private Sub cmdWrite_Click()

QuitButton.Enabled = 0
ClearReadingsList 'clears text box
GPIBResults (vbCrLf + "Setup") 'displays gpib status data
Call ibfind("gpib0", Controller)
GPIBResults ("ibfind; controller is " + Str(Controller))
Call ibsic(GPIB0)
GPIBResults ("ibsic; controller is " + Str(Controller))
Call ibdev(0, 1, 0, 10, 1, 0, NonController) 'open interface
to non-controller pc
GPIBResults ("ibdev; controller is " + Str(NonController))
Call ibwrt(NonController, "help me")
GPIBResults ("ibWrt: ")

GPIBResults ("setup complete")
End Sub

Non-Controller


Private Sub cmdRead_Click()

Dim readbuffer1 As String
Dim readbuffer2 As String

Const LocalBoard = "GPIB1"

ClearReadingsList 'clear text box
Call GPIBResults(vbCrLf + "Setup") 'display gpib status data
Call ibfind(LocalBoard, NonController)
GPIBResults ("ibfind; noncontroller is: " + Str(NonController))
Call ibrsc(NonController, 0)
GPIBResults ("ibrsc")
Call ibpad(NonController, 1)
GPIBResults ("ibpad")
readbuffer1 = "ABCDEFG" ' stuff read buffer to force length
Call ibrda(NonController,readbuffer1)
GPIBResults (vbCrLf + "ibrda 1;" + vbCrLf + "RB IS :" + readbuffer1)
Call ibwait(NonController, &H6000)
GPIBResults (vbCrLf + "asynch read 1;" + vbCrLf + "rb1 is " + readbuffer1)

End Sub


VBIB32.BAS

Declare Function ibrda32 Lib "Gpib-32.dll" Alias "ibrda" (ByVal ud As Long,
sstr As Any, ByVal cnt As Long) As Long

Sub ibrda(ByVal ud As Integer, buf As String)
Dim cnt As Long

' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If

cnt = CLng(Len(buf))

' Call the 32-bit DLL.
Call ibrd32(ud, ByVal buf, cnt)

' When Visual Basic remapping buffer problem solved, use this:
' Call ibrda32(ud, ByVal buf, cnt)

Call copy_ibvars
End Sub

Tests and Results

1. Controller to NI Interactive Control utility

Controller program executing on one PC, NI Interactive Control
executing on non-controller PC.

1) Keyed into NI Interactive Control: IBFIND GPIB1
IBRDA 10
IBWAIT 0X6000
2) Clicked on Write button on controller PC

3) Write data ("Help me") displayed in Interactive
Control utility on non-controller PC.

2. IBRDA with ByVal (Call ibrd32(ud, ByVal buf, cnt))

Controller program executing on one PC, Non-controller
program executing on other; NI-Spy executing on Non-controller
PC.

Clicked on Non-controller read button, then clicked on Controller
write button.

Results: No data returned to application; all statii good. NI-Spy
displayed ibrda(GPIB1,"help me",7(0x7))

3. IBRDA without ByVal (Call ibrd32(ud, buf, cnt))

Controller program executing on one PC, Non-controller program
executing on other; NI-Spy executing on Non-controller PC.


Clicked on Non-controller read button, then clicked on Controller
write button.

Results: VB6 application error: Instruction at 0x65343231
referenced memory at 0x706c6564. Memory could
not be read.

4. IBRDA32 with ByVal (Call ibrda32(ud, ByVal buf, cnt))

Commented out ibrd32 call; uncommented ibrda32 call.

Controller program executing on one PC, Non-controller program
executing on other; NI-Spy executing on Non-controller PC.


Clicked on Non-controller read button, then clicked on Controller
write button.

Results: No data returned to application; all statii good.
NI-Spy displayed ibrda(GPIB1,0x001B5274,7(0x7))

5. IBRDA32 without ByVal (Call ibrd32(ud, buf, cnt)

Commented out ibrd32 call; uncommented ibrda32 call.

Controller program executing on one PC, Non-controller
program executing on other; NI-Spy executing on Non-controller
PC.

Clicked on Non-controller read button, then clicked on Controller
write button.

Results: No data returned to application; all statii good.
NI-Spy displayed ibrda(GPIB1,0X0012F4A8,7(0x7))
0 Kudos
Message 1 of 1
(5,248 Views)