VB6 and okFrontPanel.dll

I am trying to use the okFrontpanel.dll with VB6 and I am having no luck in getting it to work. Can anyone that has gotten this to work provide an explanation and example of what they did?

I would like to thank Rainer Malzbender for helping me get okFrontPanel.dll working with VB6. I am going to post (with his permission) the sample code that Rainer supplied to me. I deleted a few lines of code that were commented out, and made some minor changes such as: moving the okUsbXEM3010_Destruct call to Form_Unload, making a specific subroutine for okUsbFrontPanel_ConfigureFPGA. Every possible declare statement is not included, but the ones needed to get a program up and runnig and a few extra examples should be enough to figure the rest out.

'####################################################

Option Explicit

Private Declare Function LoadLibrary Lib “kernel32” Alias “LoadLibraryA” _
(ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib “kernel32” _
(ByVal hLibModule As Long) As Long
Private Declare Function okUsbXEM3010_Construct Lib “okFrontPanel” () As Long
Private Declare Function okUsbXEM3010_Destruct Lib “okFrontPanel” (ByVal xem As Long) As Long
Private Declare Function okUsbFrontPanel_Open Lib “okFrontPanel” _
(ByVal xem As Long, ByVal mychar As Byte) As Long
Private Declare Function okUsbFrontPanel_ConfigureFPGA Lib “okFrontPanel” _
(ByVal xem As Long, ByVal name As String) As Long
Private Declare Function okUsbFrontPanel_SetWireInValue Lib “okFrontPanel” _
(ByVal xem As Long, ByVal ep As Integer, ByVal myval As Integer, ByVal mask As Integer) As Long
Private Declare Sub okUsbFrontPanel_UpdateWireIns Lib “okFrontPanel” _
(ByVal xem As Long)
Private Declare Sub okUsbFrontPanel_UpdateWireOuts Lib “okFrontPanel” _
(ByVal xem As Long)
Private Declare Function okUsbFrontPanel_GetWireOutValue Lib “okFrontPanel” _
(ByVal xem As Long, ByVal ep As Integer) As Integer

Dim xem As Long

'####################################################

Private Sub Form_Load()
Dim hOK As Long
Dim okLoaded As Boolean
Dim okConfig As Boolean

MsgBox “Make sure board is turned on”, vbOKOnly

hOK = LoadLibrary(“c:\windows\system32\okFrontPanel.dll”)
If hOK <> 0 Then
'# Get a handle to the XEM: okUSBFRONTPANEL_HANDLE xem = okUsbXEM3001v2_Construct();
xem = okUsbXEM3010_Construct

  '# Open the XEM: okUsbFrontPanel_Open(xem, 0);
  Call okUsbFrontPanel_Open(xem, 0)
  
  Call FreeLibrary(hOK)

Else
MsgBox “Problem loading okFrontPanel.dll”, vbOKOnly
End If

End Sub

'####################################################

Private Sub Form_Unload()

'# Destroy the XEM instance: okUsbXEM3001v2_Destruct(xem);
Call okUsbXEM3010_Destruct(xem)

End Sub

'####################################################

Private Sub cmdConfigFPGA_Click()

Dim okConfig As Boolean

'# Configure the FPGA: okUsbFrontPanel_ConfigureFPGA(xem, “c:\bitfile.bit”);
okConfig = okUsbFrontPanel_ConfigureFPGA(xem, “c:\bitfile.bit”)
If Not okConfig Then
MsgBox “Couldn’t configure FPGA”, vbOKOnly
End If

End Sub

'####################################################

Thanks for posting that. As I’m sure there are other users interested in VB routines, would you be willing to email the file(s) to [email protected]?

We would like to package them and post them under our “3rd Party Contributions” and include them in our software distribution. Of course, full credit would be given to the author(s) with any requirements for distribution.

hello All,

Anybody has done in VB6 using Opal Kelly XEM3010 board.

Basically i am passing some data from PC to Board & vice-versa using VB.

I want to know what care should i take for my synchronisation of data. I am usign asynchronus data transfer

regds
sunilm