K8016 visual basic problem

When I run PC-lab with my PC function generator everything works fine.
I have some difficulties writing my own VB application for the K8016 function generator.

For simplicity my program looks like this:

Private Declare Sub StartGen lib "FGLink.dll " ()

Private Sub Command1_Click()
  StartGen
End Sub

I suspect that this will light up the power led on the front panel but that does not happen…

I run Microsoft Windos 7
Visual Studio 2010
I run the program with root privilege and XP 32-bit compatible.
The FGLink.dll is situated in the system32 folder

Maybe someone can help me?:slight_smile:

The FGLink.dll needs other files to be located in the same folder with it to operate properly.

Maybe you have downloaded the following package: “SDK to control your PCG10/K8016 from Delphi or VB.” from the Velleman site: velleman.eu/distributor/supp … 8016&type=

Inside this package there is: FGLink_Demo_VB.zip
Extract this package to a folder.
Put the FGLINK.dll either to System32 folder (as you have done) or to your VB project’s subfolder where your application .EXE resides.
If you are using 32 bit version of Windows 7, your .EXE may be in the subfolder \bin\Debug.
If you are using 64 bit version, your .EXE may be in the subfolder : \bin\x86\Debug.

Run manually the FG.EXE before controlling the generator via the FGLink.DLL.

In your code change:

StartGento

StartGen()

If still no response, close the FG.EXE. In the folder where the FG.EXE resides, open the file WinDSO.ini with a text editor and check the lines:[Hardware] LPT_Port=1 DemoMode=0
This is OK if you are using LPT port address 378h.

If you are using 278h change to:
LPT_Port=2

If you are using 3BCh change to:
LPT_Port=3

Here some example code:

[code]Public Class Form1
Private Declare Sub SetGen Lib "FGLink.dll " (ByVal func As Integer, ByVal freq As Single, ByVal ampl As Single, ByVal offset As Single)
Private Declare Sub StartGen Lib "FGLink.dll " ()
Private Declare Sub StopGen Lib "FGLink.dll " ()

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    StartGen()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    Dim iFunc As Integer = 1
    Dim sFreq As Short = 500
    Dim sAmp As Short = 10
    Dim sOff As Short = 0
    SetGen(iFunc, sFreq, sAmp, sOff)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim iFunc As Integer = 2
    Dim sFreq As Short = 5000
    Dim sAmp As Short = 5
    Dim sOff As Short = 1
    SetGen(iFunc, sFreq, sAmp, sOff)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    StopGen()
End Sub

End Class[/code]

Thanks for the help, it works fine now!
So if I want my VB application to work, I need to start the FG.exe first.

Is there a way to write an application without the need of starting the FG.exe first?

thanks

You can use the ShellExecute to run the FG.EXE from within the Visual Basic program.
Add this to the declarations:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _ (ByVal hWnd As Integer, ByVal lpOperation As String, _ ByVal lpFile As String, ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Integer) As Integer

Here is the function call to run the FG.EXE. Specify the path. In this example the FG.EXE is on the root of C:

ShellExecute(0, "open", "C:\FG.exe", "", "", 1)