beautypg.com

Running the dsolink in borland c++ builder – Velleman PCSU1000 DSO User Manual

Page 19

background image

Data Transfer

18

© 2005 ... Velleman

Option

Explicit

Dim

DataBuffer(0

To

5000)

As

Long

Private

Declare

Sub

ReadCh1

Lib

"DSOLink.dll " (Buffer

As

Long

)

'This reads the settingsd and 4096 bytes of data from CH1 to the data buffer.
'The first 21 values are displayed.

Private

Sub

Read

_CH1_Click(Index

As

Integer

)

Dim

i

As

Long

List1.Clear
ReadCh1 DataBuffer(0)
List1.AddItem "Sample rate [Hz]" + Chr(9) + Str(DataBuffer(0))
List1.AddItem "Full scale [mV]" + Chr(9) + Str(DataBuffer(1))
List1.AddItem "GND level [counts]" + Chr(9) + Str(DataBuffer(2))
List1.AddItem ""

For

i = 0

To

20

List1.AddItem "Data(" + Str(i) + ")" + Chr(9) + Chr(9) + Str(DataBuffer(i + 3))

Next

End

Sub

Running the DSOLink in Borland C++ Builder

The following files are available in the \PC-Lab2000 tools\PCSU1000 - PCS500 - PCS100 -
K8031\Data transfer DSOLink_DLL\DSOLink_Demo_BCB\
folder on the VELSOFT CD for
development with Borland C++Builder:
DSOLink.dll the dynamically linked library
DSOLink.h the C/C++ header file for function prototypes
DSOLink.lib the import library
DSOLink_demo.cpp demo source

1.

Create a new project in Borland C++ Builder.

2.

Add the import library to your project using Project | Add to Project menu option.

3.

Add a #include statement in the main unit that includes DSOLink.H.

4.

Finally, add code that calls the DLL functions.

DSOLink.h

//---------------------------------------------------------------------------
// DSOLink.h

#ifdef __cplusplus

extern

"C"

{

/* Assume C declarations for C++ */

#endif

#define FUNCTION

__declspec

(dllimport)

FUNCTION __stdcall ReadCh1(int* ptr);
FUNCTION __stdcall ReadCh2(int* ptr);

#ifdef __cplusplus

}

#endif

//---------------------------------------------------------------------------

Example (in Borland C++Builder)

//---------------------------------------------------------------------------
// DSOLink_demo.cpp

#include
#pragma hdrstop
#include

"DSOLink.h"

#include

"DSOLink_demo.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)
#pragma resource

"*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)