K8055 programming

Hey!
I have Velleman K8055 USB EXPERIMENT INTERFACE BOARD and it’s works with demo software, but now I’d like to build a program of my own. How I can do it? I have “K8055_DLL_manual.pdf”, but I haven’t managed to run any program at all. I think that I haven’t got approriate translate software. I want to get contact to K8055 from computer and open one port. I use windows 7, but I have Linux too. What is simple and fast way to proseed?

Thank you for your help!

[quote]What is simple and fast way to proseed?[/quote]There are example programs written in following languages:
• Microsoft Visual Basic 2008 Express Edition
• Microsoft Visual C++ 2008 Express Edition
• Microsoft Visual C# 2008 Express Edition
• Microsoft Visual Basic 6.0
• Microsoft Excel VBA
• Borland Delphi 5
• Borland C++Builder 6
• Bloodshed Dev-C++

The fastest way is to use one of these languages to program the operations of the K8055.

Is any of these programs available for free and if so could you give me a link?

These programs are free:
• Microsoft Visual Basic 2008 Express Edition
• Microsoft Visual C++ 2008 Express Edition
• Microsoft Visual C# 2008 Express Edition
microsoft.com/express/Downloads/

• Bloodshed Dev-C++
bloodshed.net/devcpp.html

I’m useing Bloodshed Dev-C++. When I tried a program, it got an error refering “#include <K8055D_C.h>”: “No such file or directory.” but the file and the directory does exist. File “K8055D_C.h” is in the same directory as the program file.

#include <iostream>
#include <K8055D_C.h>

using namespace std;

int main (){
FUNCTION int __stdcall OpenDevice(int 0);
FUNCTION void __stdcall SetAllDigital();
FUNCTION void __stdcall CloseDevice();
}

You may try:

#include "K8055D_C.h"

You can also download the latest software package for the K8055.
Here is the link to the download page:
velleman.eu/distributor/supp … code=K8055
Download the: “Complete SDK Pack (Rev 4.0)”.

The package includes new K8055D.DLL and sample projects written in various programming languages.
Dev-C++ example is included.
Please read the “README.TXT” and the “K8055 & VM110 Getting Started.pdf”.

It works almost but now I got error “In file included from Test.cpp” as same line where is “#include “K8055D_C.h””.

#include <iostream>
#include "K8055D_C.h"

using namespace std;

int main (){
FUNCTION int __stdcall OpenDevice(int 0);
FUNCTION void __stdcall SetAllDigital();
FUNCTION void __stdcall CloseDevice();
}

There is syntax error in the K8055D_C.H.
Should look like this:

[code]#ifdef __cplusplus
extern “C” {
#endif

#define FUNCTION __declspec(dllimport)

FUNCTION long __stdcall OpenDevice(long CardAddress);
FUNCTION void __stdcall CloseDevice();
FUNCTION long __stdcall ReadAnalogChannel(long Channel);
FUNCTION void __stdcall ReadAllAnalog(long *Data1, long *Data2);
FUNCTION void __stdcall OutputAnalogChannel(long Channel, long Data);
FUNCTION void __stdcall OutputAllAnalog(long Data1, long Data2);
FUNCTION void __stdcall ClearAnalogChannel(long Channel);
FUNCTION void __stdcall ClearAllAnalog();
FUNCTION void __stdcall SetAnalogChannel(long Channel);
FUNCTION void __stdcall SetAllAnalog();
FUNCTION void __stdcall WriteAllDigital(long Data);
FUNCTION void __stdcall ClearDigitalChannel(long Channel);
FUNCTION void __stdcall ClearAllDigital();
FUNCTION void __stdcall SetDigitalChannel(long Channel);
FUNCTION void __stdcall SetAllDigital();
FUNCTION bool __stdcall ReadDigitalChannel(long Channel);
FUNCTION long __stdcall ReadAllDigital();
FUNCTION long __stdcall ReadCounter(long CounterNr);
FUNCTION void __stdcall ResetCounter(long CounterNr);
FUNCTION void __stdcall SetCounterDebounceTime(long CounterNr, long DebounceTime);

FUNCTION void __stdcall Version();
FUNCTION long __stdcall SearchDevices();
FUNCTION long __stdcall SetCurrentDevice(long lngCardAddress);

#ifdef __cplusplus
}
#endif[/code]

You can’t use this K8055D_C.H and the K8055D_C.lib with the Dev-C++.
The K8055D_C.lib is for Microsoft Visual C++ compiler only.

There in the latest K8055 software package is working Dev-C++ example included…

The K8055D_C.h it wasn’t same as you wrote but now it is and program works, but still nothing happens. Any ideas?

[code]#include
#include “K8055D_C.h”

using namespace std;

int main (){
int OpenDevice(0);
void SetAllDigital();
void CloseDevice();
}
[/code]

The program works but it has no connection to the K8055D.DLL.

There are missing following things:
LoadLibrary(“k8055d”);
GetProcAddress(hDLL, “OpenDevice”);
GetProcAddress(hDLL, “SetAllDigital”);
etc.
FreeLibrary(hDLL);

Also you need to define the DLL function types.

No need not to use the K8055D_C.h file. It can be used only together with the Microsoft .lib file.

Here is slightly modified working code:

[code]#include
#include <windows.h>
#include

typedef void(CALLBACK* VOID2VOID)();
typedef int(CALLBACK* INT2INT)(int );

INT2INT OpenDevice;
VOID2VOID CloseDevice;
VOID2VOID SetAllDigital;
VOID2VOID ClearAllDigital;

HINSTANCE hDLL;

using namespace std;

int main()
{
int h;
hDLL = LoadLibrary(“k8055d”);
OpenDevice = (INT2INT) GetProcAddress(hDLL, “OpenDevice”);
SetAllDigital = (VOID2VOID) GetProcAddress(hDLL, “SetAllDigital”);
ClearAllDigital = (VOID2VOID) GetProcAddress(hDLL, “ClearAllDigital”);
CloseDevice = (VOID2VOID) GetProcAddress(hDLL, “CloseDevice”);

h = OpenDevice(0);
if (h == 0)
{
   cout << "Card 0 opened" << endl;
}
else
{
    cout << "Card not found" << endl;
}
SetAllDigital(); 
cout << "Press Enter to \"CloseDevice\" and to \"FreeLibrary\"" << endl;
cin.get();
ClearAllDigital();              	
CloseDevice(); 
FreeLibrary(hDLL);

} [/code]

Please make sure the program can “find” the K8055D.DLL.
Best to put the .DLL to the same folder with the .exe.

Thank you very much for your great help! Now it works!

Hello :slight_smile:

Could anyone give me any clues on how to use the pwm output? How to adjust the pulse width? i know the frequency is fixed but im not sure how to use the pwm at all. As far as i know the PWM is used together with DAC, so maybe i just output DAC1 and PWM get outputed to? like this:

output DAC1,127, wait 50ms, clear DAC1 and so on…?

The PWM is proportional to the DAC output value.
By setting the DAC output value to 127 you get the PWM ratio 50%.
In this case the PWM output pulse high time and low time are equal.

Increasing the analog output value the PWM ratio increases.

The PWM output is “active low”.
Increasing the DAC output value the PWM output pulse low time increases and high time decreases.

The PWM output is an open collector output.