I’ve need the program of the PIC 18f2550 for connect the K8061 at another PIC card, or for change its program for implement the function.
Can you gave me the program, please?
Thanks
I’ve need the program of the PIC 18f2550 for connect the K8061 at another PIC card, or for change its program for implement the function.
Can you gave me the program, please?
Thanks
Sorry, we never release source code.
I’ve another question.
Last year i’ve do a program for K8055 and i want recicle it for pilot the K8061, it’s possible? And whats do I change?
In most of the K8061 DLL functions you have to use the Card Address to send the command to right card. Also some functions have different names.
Here an example of K8061 function declaration in Visual Basic 6.0:
Private Declare Sub OutputAllDigital Lib "k8061.dll" (ByVal CardAddress As Long, ByVal Data As
Long)
And here the same for the K8055:
Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal data As Long)
Please download this new software package for the K8061:
velleman.eu/downloads/files/ … k_2011.zip
The package includes new driver and new DLL.
There are example projects written in many programming languages included.
There is also manual K8061_DLL_manual.pdf included describing all the DLL functions
You have to remove the previous driver and install the new driver (v1.0.0.6) from this download package. Please read the Getting_Started.pdf and the README.TXT.
To compare the DLL function declarations you can download also the latest software package for the K8055.
Here is the link to 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.
Pleas read the “README.TXT” and the “K8055 & VM110 Getting Started.pdf”.
I’ve writing my program for K8055 in C++ Borland, it is similar for K8061?
Here are the function declarations for the K8061:
[code]#ifdef __cplusplus
extern “C” {
#endif
#define FUNCTION __declspec(dllimport)
FUNCTION int __stdcall OpenDevice();
FUNCTION void __stdcall CloseDevices();
FUNCTION void __stdcall CloseDevice(int CardAddress);
FUNCTION int __stdcall ReadAnalogChannel(int CardAddress,int Channel);
FUNCTION void __stdcall ReadAllAnalog(int CardAddress, int *Buffer);
FUNCTION void __stdcall OutputAnalogChannel(int CardAddress, int Channel, int Data);
FUNCTION void __stdcall OutputAllAnalog(int CardAddress, int *Buffer);
FUNCTION void __stdcall ClearAnalogChannel(int CardAddress, int Channel);
FUNCTION void __stdcall ClearAllAnalog(int CardAddress);
FUNCTION void __stdcall SetAnalogChannel(int CardAddress,int Channel);
FUNCTION void __stdcall SetAllAnalog(int CardAddress);
FUNCTION void __stdcall OutputAllDigital(int CardAddress, int Data);
FUNCTION void __stdcall ClearDigitalChannel(int CardAddress, int Channel);
FUNCTION void __stdcall ClearAllDigital(int CardAddress);
FUNCTION void __stdcall SetDigitalChannel(int CardAddress, int Channel);
FUNCTION void __stdcall SetAllDigital(int CardAddress);
FUNCTION bool __stdcall ReadDigitalChannel(int CardAddress, int Channel);
FUNCTION int __stdcall ReadAllDigital(int CardAddress);
FUNCTION void __stdcall OutputPWM(int CardAddress, int Data);
FUNCTION bool __stdcall PowerGood(int CardAddress);
FUNCTION bool __stdcall Connected(int CardAddress);
FUNCTION void __stdcall ReadVersion(int CardAddress, int *Buffer);
FUNCTION int __stdcall ReadBackDigitalOut(int CardAddress);
FUNCTION void __stdcall ReadBackAnalogOut(int CardAddress, int *Buffer);
FUNCTION int __stdcall ReadBackPWMOut(int CardAddress);
#ifdef __cplusplus
}
#endif[/code]
You’ll find the Borland C++ Builder example in the Examples folder of the download package.
I’ve k8055d.cpp and K8055D.h , whats change?
k8055d.cpp
#include "StdAfx.h"
#include "k8055d.h"
k8055d::k8055d(void)
{
}
k8055d::~k8055d(void)
{
}
long k8055d::init()
{
long alldigital = 0;
hDLL = LoadLibrary(L"k8055d");
if (hDLL != NULL)
{
pOpenDevice = (LONG2LONG)GetProcAddress(hDLL,"OpenDevice");
if (!pOpenDevice)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pCloseDevice = (VOID2VOID)GetProcAddress(hDLL,"CloseDevice");
if (!pCloseDevice)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pReadAnalogChannel = (LONG2LONG)GetProcAddress(hDLL,"ReadAnalogChannel");
if (!pReadAnalogChannel)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pReadAllAnalog = (LONGPLONGP2VOID)GetProcAddress(hDLL,"ReadAllAnalog");
if (!pReadAllAnalog)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pOutputAnalogChannel = (LONGLONG2VOID)GetProcAddress(hDLL,"OutputAnalogChannel");
if (!pOutputAnalogChannel)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pOutputAllAnalog = (LONGLONG2VOID)GetProcAddress(hDLL,"OutputAllAnalog");
if (!pOutputAllAnalog)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pClearAnalogChannel = (LONG2VOID)GetProcAddress(hDLL,"ClearAnalogChannel");
if (!pClearAnalogChannel)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pClearAllAnalog = (VOID2VOID)GetProcAddress(hDLL,"ClearAllAnalog");
if (!pClearAllAnalog)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pSetAnalogChannel = (LONG2VOID)GetProcAddress(hDLL,"SetAnalogChannel");
if (!pSetAnalogChannel)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pSetAllAnalog = (VOID2VOID)GetProcAddress(hDLL,"SetAllAnalog");
if (!pSetAllAnalog)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pWriteAllDigital = (LONG2VOID)GetProcAddress(hDLL,"WriteAllDigital");
if (!pWriteAllDigital)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pClearDigitalChannel = (LONG2VOID)GetProcAddress(hDLL,"ClearDigitalChannel");
if (!pClearDigitalChannel)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pClearAllDigital = (VOID2VOID)GetProcAddress(hDLL,"ClearAllDigital");
if (!pClearAllDigital)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pSetDigitalChannel = (LONG2VOID)GetProcAddress(hDLL,"SetDigitalChannel");
if (!pSetDigitalChannel)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pSetAllDigital = (VOID2VOID)GetProcAddress(hDLL,"SetAllDigital");
if (!pSetAllDigital)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pReadDigitalChannel = (LONG2BOOL)GetProcAddress(hDLL,"ReadDigitalChannel");
if (!pReadDigitalChannel)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pReadAllDigital = (VOID2LONG)GetProcAddress(hDLL,"ReadAllDigital");
if (!pReadAllDigital)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pReadCounter = (LONG2LONG)GetProcAddress(hDLL,"ReadCounter");
if (!pReadCounter)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pResetCounter = (LONG2VOID)GetProcAddress(hDLL,"ResetCounter");
if (!pResetCounter)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
pSetCounterDebounceTime = (LONGLONG2VOID)GetProcAddress(hDLL,"SetCounterDebounceTime");
if (!pSetCounterDebounceTime)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
initialized = 1;
dout1 = 0;
dout2 = 0;
dout3 = 0;
dout4 = 0;
dout5 = 0;
dout6 = 0;
dout7 = 0;
dout8 = 0;
din1 = 0;
din2 = 0;
din3 = 0;
din4 = 0;
din5 = 0;
ct1 = 0;
ct2 = 0;
dbct1 = 0;
dbct2 = 0;
da1 = 0;
da2 = 0;
ad1 = 0;
ad2 = 0;
}
return 1;
}
long k8055d::OpenDevice(long CardAddress)
{
if (!initialized) return -1;
if ((CardAddress >= 0) && (CardAddress <= 3))
return pOpenDevice(CardAddress);
else
return -1;
}
void k8055d::CloseDevice()
{
pCloseDevice();
}
long k8055d::ReadAnalogChannel(long Channel)
{
if (!initialized)
return -1;
if (Channel == 1)
return ad1 = pReadAnalogChannel(Channel);
else
return ad2 = pReadAnalogChannel(Channel);
}
void k8055d::ReadAllAnalog(long *Data1, long *Data2)
{
if (initialized)
{
pReadAllAnalog(Data1, Data2);
ad1 = *Data1;
ad2 = *Data2;
}
}
void k8055d::OutputAnalogChannel(long Channel, long Data)
{
if (initialized)
{
if (Channel == 1)
{
if (da1 != Data)
{
pOutputAnalogChannel(Channel, Data);
da1 = Data;
}
}
else
{
if (da2 != Data)
{
pOutputAnalogChannel(Channel, Data);
da2 = Data;
}
}
}
}
void k8055d::OutputAllAnalog(long Data1, long Data2)
{
if (initialized && ((Data1 != da1) || (Data2 != da2)))
{
pOutputAllAnalog(Data1, Data2);
da1 = Data1;
da2 = Data2;
}
}
void k8055d::ClearAnalogChannel(long Channel)
{
if (initialized)
{
pClearAnalogChannel(Channel);
if (Channel == 1)
da1 = 0;
else
da2 = 0;
}
}
void k8055d::ClearAllAnalog()
{
if (initialized)
{
pClearAllAnalog();
da1 = 0;
da2 = 0;
}
}
void k8055d::SetAnalogChannel(long Channel)
{
if (initialized)
{
pSetAnalogChannel(Channel);
if (Channel == 1)
da1 = 255;
else
da2 = 255;
}
}
void k8055d::SetAllAnalog()
{
if (initialized)
pSetAllAnalog();
da1 = 255;
da2 = 255;
}
void k8055d::WriteAllDigital(long Data)
{
long old = 0;
old = dout1+dout2*2+dout3*4+dout4*8+dout5*16+dout6*32+dout7*64+dout8*128;
if (initialized && (old != Data))
{
pWriteAllDigital(Data);
dout1 = (Data & 1) && 1;
dout2 = (Data & 2) && 1;
dout3 = (Data & 4) && 1;
dout4 = (Data & 8) && 1;
dout5 = (Data & 16) && 1;
dout6 = (Data & 32) && 1;
dout7 = (Data & 64) && 1;
dout8 = (Data & 128) && 1;
}
}
void k8055d::ClearDigitalChannel(long Channel)
{
if (initialized)
{
switch (Channel)
{
case 1:
if (dout1) pClearDigitalChannel(Channel);
dout1 = 0;
break;
case 2:
if (dout2) pClearDigitalChannel(Channel);
dout2 = 0;
break;
case 3:
if (dout3) pClearDigitalChannel(Channel);
dout3 = 0;
break;
case 4:
if (dout4) pClearDigitalChannel(Channel);
dout4 = 0;
break;
case 5:
if (dout5) pClearDigitalChannel(Channel);
dout5 = 0;
break;
case 6:
if (dout6) pClearDigitalChannel(Channel);
dout6 = 0;
break;
case 7:
if (dout7) pClearDigitalChannel(Channel);
dout7 = 0;
break;
case 8:
if (dout8) pClearDigitalChannel(Channel);
dout8 = 0;
break;
}
}
}
void k8055d::ClearAllDigital()
{
if (initialized)
{
pClearAllDigital();
dout1 = 0;
dout2 = 0;
dout3 = 0;
dout4 = 0;
dout5 = 0;
dout6 = 0;
dout7 = 0;
dout8 = 0;
}
}
void k8055d::SetDigitalChannel(long Channel)
{
if (initialized && ((Channel > 0) && (Channel <= 8)))
{
switch (Channel)
{
case 1:
if (!dout1) pSetDigitalChannel(Channel);
dout1 = 1;
break;
case 2:
if (!dout2) pSetDigitalChannel(Channel);
dout2 = 1;
break;
case 3:
if (!dout3) pSetDigitalChannel(Channel);
dout3 = 1;
break;
case 4:
if (!dout4) pSetDigitalChannel(Channel);
dout4 = 1;
break;
case 5:
if (!dout5) pSetDigitalChannel(Channel);
dout5 = 1;
break;
case 6:
if (!dout6) pSetDigitalChannel(Channel);
dout6 = 1;
break;
case 7:
if (!dout7) pSetDigitalChannel(Channel);
dout7 = 1;
break;
case 8:
if (!dout8) pSetDigitalChannel(Channel);
dout8 = 1;
break;
}
}
}
void k8055d::SetAllDigital()
{
if (initialized)
{
pSetAllDigital();
dout1 = dout2 = dout3 = dout4 = dout5 = dout6 = dout7 = dout8 = true;
}
}
bool k8055d::ReadDigitalChannel(long Channel)
{
if (initialized && ((Channel > 0) && (Channel <= 5)))
switch (Channel)
{
case 1:
return din1 = pReadDigitalChannel(Channel);
break;
case 2:
return din2 = pReadDigitalChannel(Channel);
break;
case 3:
return din3 = pReadDigitalChannel(Channel);
break;
case 4:
return din4 = pReadDigitalChannel(Channel);
break;
case 5:
return din5 = pReadDigitalChannel(Channel);
break;
}
else return 0;
return 0;
}
long k8055d::ReadAllDigital()
{
long ret = 0;
if (initialized)
{
ret = pReadAllDigital();
din1 = (ret & 1) && 1;
din1 = (ret & 2) && 1;
din1 = (ret & 4) && 1;
din1 = (ret & 8) && 1;
din1 = (ret & 16) && 1;
return ret;
}
else return -1;
}
long k8055d::ReadCounter(long CounterNr)
{
if (initialized)
if (CounterNr == 1)
return ct1 = pReadCounter(CounterNr);
else
return ct2 = pReadCounter(CounterNr);
else return -1;
}
void k8055d::ResetCounter(long CounterNr)
{
if (initialized && ((CounterNr == 1) || (CounterNr == 2)))
pResetCounter(CounterNr);
if (CounterNr == 1)
ct1 = 0;
else
ct2 = 0;
}
void k8055d::SetCounterDebounceTime(long CounterNr, long DebounceTime)
{
if (initialized && ((CounterNr == 1) || (CounterNr == 2)))
{
pSetCounterDebounceTime(CounterNr, DebounceTime);
if (CounterNr == 1)
dbct1 = DebounceTime;
else
dbct2 = DebounceTime;
}
}
K8055D.h
typedef long (CALLBACK* LONG2LONG)(long);
typedef void (CALLBACK* VOID2VOID)(void);
typedef void (CALLBACK* LONGPLONGP2VOID)(long *, long *);
typedef void (CALLBACK* LONGLONG2VOID)(long, long);
typedef void (CALLBACK* LONG2VOID)(long);
typedef bool (CALLBACK* LONG2BOOL)(long);
typedef long (CALLBACK* VOID2LONG)(void);
class k8055d
{
public:
k8055d(void);
~k8055d(void);
long init(void);
long OpenDevice(long CardAddress);
void CloseDevice();
long ReadAnalogChannel(long Channel);
void ReadAllAnalog(long *Data1, long *Data2);
void OutputAnalogChannel(long Channel, long Data);
void OutputAllAnalog(long Data1, long Data2);
void ClearAnalogChannel(long Channel);
void ClearAllAnalog();
void SetAnalogChannel(long Channel);
void SetAllAnalog();
void WriteAllDigital(long Data);
void ClearDigitalChannel(long Channel);
void ClearAllDigital();
void SetDigitalChannel(long Channel);
void SetAllDigital();
bool ReadDigitalChannel(long Channel);
long ReadAllDigital();
long ReadCounter(long CounterNr);
void ResetCounter(long CounterNr);
void SetCounterDebounceTime(long CounterNr, long DebounceTime);
bool dout1;
bool dout2;
bool dout3;
bool dout4;
bool dout5;
bool dout6;
bool dout7;
bool dout8;
bool din1;
bool din2;
bool din3;
bool din4;
bool din5;
long da1;
long da2;
long ad1;
long ad2;
long ct1;
long ct2;
long dbct1;
long dbct2;
private:
bool initialized;
HINSTANCE hDLL;
LONG2LONG pOpenDevice;
VOID2VOID pCloseDevice;
LONG2LONG pReadAnalogChannel;
LONGPLONGP2VOID pReadAllAnalog;
LONGLONG2VOID pOutputAnalogChannel;
LONGLONG2VOID pOutputAllAnalog;
LONG2VOID pClearAnalogChannel;
VOID2VOID pClearAllAnalog;
LONG2VOID pSetAnalogChannel;
VOID2VOID pSetAllAnalog;
LONG2VOID pWriteAllDigital;
LONG2VOID pClearDigitalChannel;
VOID2VOID pClearAllDigital;
LONG2VOID pSetDigitalChannel;
VOID2VOID pSetAllDigital;
LONG2BOOL pReadDigitalChannel;
VOID2LONG pReadAllDigital;
LONG2LONG pReadCounter;
LONG2VOID pResetCounter;
LONGLONG2VOID pSetCounterDebounceTime;
};
Here you can download a Borland C++Builder project for the K8061.
box.net/shared/bfkufxiay2
In this example there is used run-time dynamic DLL linking.
See also: http://msdn.microsoft.com/en-us/library/ms685090(v=vs.85).aspx
Here some code snippets from the project:
Unit1.h
[code]typedef int (CALLBACK* VOID2INT)(void);
typedef int (CALLBACK* INT2INT)(int);
typedef int (CALLBACK* INTINT2INT)(int, int);
typedef bool (CALLBACK* INT2BOOL)(int);
typedef bool (CALLBACK* INTINT2BOOL)(int, int);
typedef void (CALLBACK* VOID2VOID)(void);
typedef void (CALLBACK* INT2VOID)(int);
typedef void (CALLBACK* INTINTP2VOID)(int, int );
typedef void (CALLBACK INTINT2VOID)(int, int);
typedef void (CALLBACK* INTINTINT2VOID)(int, int, int);
VOID2INT OpenDevice;
VOID2VOID CloseDevices;
INT2VOID CloseDevice;
INTINT2INT ReadAnalogChannel;
INTINTP2VOID ReadAllAnalog;
INTINTINT2VOID OutputAnalogChannel;
INTINTP2VOID OutputAllAnalog;
INTINTP2VOID ClearAnalogChannel;
INT2VOID ClearAllAnalog;
INTINT2VOID SetAnalogChannel;
INT2VOID SetAllAnalog;
INTINT2VOID OutputAllDigital;
INTINT2VOID ClearDigitalChannel;
INT2VOID ClearAllDigital;
INTINT2VOID SetDigitalChannel;
INT2VOID SetAllDigital;
INTINT2BOOL ReadDigitalChannel;
INT2INT ReadAllDigital;
INTINT2VOID OutputPWM;
INT2BOOL PowerGood;
INT2BOOL Connected;
INTINTP2VOID ReadVersion;
INT2INT ReadBackDigitalOut;
INTINTP2VOID ReadBackAnalogOut;
INT2INT ReadBackPWMOut;
HINSTANCE hDLL;
int CardAddr;[/code]
Unit1.cpp
[code] hDLL = LoadLibrary(“K8061.dll”);
if (hDLL == NULL)
{
Application->MessageBox( “Error: K8061.dll not found”, “Error”, MB_OK);
Close();
}
else
{
OpenDevice = (VOID2INT) GetProcAddress(hDLL, “OpenDevice”);
CloseDevices = (VOID2VOID) GetProcAddress(hDLL, “CloseDevices”);
CloseDevice = (INT2VOID) GetProcAddress(hDLL, “CloseDevice”);
ReadAnalogChannel = (INTINT2INT) GetProcAddress(hDLL, “ReadAnalogChannel”);
ReadAllAnalog = (INTINTP2VOID) GetProcAddress(hDLL, “ReadAllAnalog”);
OutputAnalogChannel = (INTINTINT2VOID) GetProcAddress(hDLL, “OutputAnalogChannel”);
OutputAllAnalog = (INTINTP2VOID) GetProcAddress(hDLL, “OutputAllAnalog”);
ClearAnalogChannel = (INTINTP2VOID) GetProcAddress(hDLL, “ClearAnalogChannel”);
ClearAllAnalog = (INT2VOID) GetProcAddress(hDLL, “ClearAllAnalog”);
SetAnalogChannel = (INTINT2VOID) GetProcAddress(hDLL, “SetAnalogChannel”);
SetAllAnalog = (INT2VOID) GetProcAddress(hDLL, “SetAllAnalog”);
OutputAllDigital = (INTINT2VOID) GetProcAddress(hDLL, “OutputAllDigital”);
ClearDigitalChannel = (INTINT2VOID) GetProcAddress(hDLL, “ClearDigitalChannel”);
ClearAllDigital = (INT2VOID) GetProcAddress(hDLL, “ClearAllDigital”);
SetDigitalChannel = (INTINT2VOID) GetProcAddress(hDLL, “SetDigitalChannel”);
SetAllDigital = (INT2VOID) GetProcAddress(hDLL, “SetAllDigital”);
ReadDigitalChannel = (INTINT2BOOL) GetProcAddress(hDLL, “ReadDigitalChannel”);
ReadAllDigital = (INT2INT) GetProcAddress(hDLL, “ReadAllDigital”);
OutputPWM = (INTINT2VOID) GetProcAddress(hDLL, “OutputPWM”);
PowerGood = (INT2BOOL) GetProcAddress(hDLL, “PowerGood”);
Connected = (INT2BOOL) GetProcAddress(hDLL, “Connected”);
ReadVersion = (INTINTP2VOID) GetProcAddress(hDLL, “ReadVersion”);
ReadBackDigitalOut = (INT2INT) GetProcAddress(hDLL, “ReadBackDigitalOut”);
ReadBackAnalogOut = (INTINTP2VOID) GetProcAddress(hDLL, “ReadBackAnalogOut”);
ReadBackPWMOut = (INT2INT) GetProcAddress(hDLL, “ReadBackPWMOut”);
if (!OpenDevice || !CloseDevices || !CloseDevice || !ReadAnalogChannel || !ReadAllAnalog
|| !OutputAnalogChannel || !OutputAllAnalog || !ClearAnalogChannel || !SetAnalogChannel
|| !SetAllAnalog || !OutputAllDigital || !ClearDigitalChannel || !ClearAllDigital
|| !SetDigitalChannel || !SetAllDigital || !ReadDigitalChannel || !ReadAllDigital || !OutputPWM
|| !PowerGood || !Connected || !ReadVersion || !ReadBackDigitalOut || !ReadBackAnalogOut || !ReadBackPWMOut)
{
Application->MessageBox( "Error: Reading K8061.dll functions failed", "Error", MB_OK);
FreeLibrary(hDLL);
Close();
}
else
Application->MessageBox( "K8061.dll loaded successfully.", "OK", MB_OK);
}[/code]
Thanks, I understood that the functions should be used through direct calls
but I still can not get it to work.
It would be possible to send the program written for the K8055 up to you to make you change to use the k8061?
Will later (just figured out where wrong) to complete the program.
Are you using Borland C++Builder? - version?
If yes, please download this project for the K8061 and try if you get it compiled and running:
box.net/shared/bfkufxiay2
You can use this project as a reference when converting your K8055 program for K8061.
I’m sorry we can’t do your project conversion K8055 --> K8061.