This program compiles without the OpenDevice() and SendCommand functions commented out but does not with them in. I just wanted to get it to compile so I can play with the commands in the dll using C++.
My enviroment is as follows:
PC
Windows 7 OS
Cygwin g++ compiler set + MinGW and make.
Netbeans IDE
Any help or a minimum working example of how to call the functions in the .dll using C++ would be really helpful.
The problem you had is that the K8090 functions (SendCommand, OpenDevice, CloseDevice) are not known to your compiler. This is where K8090.h and K8090D.lib come in.
I don’t know anything about Cygwin, so I hope it can use the lib file and compile the code. If not, we can try to get it to work step by step by analysing the errors.
Thanks, thats brilliant. Your code compiles and executes.
I will shorly write up a simple step by step tutorial with what I have learnt on how to include pre-written C libraries using Netbeans IDE and cygwin/minGW compiler set.
Do you have also a solution for the Velleman k8090 in Matlab?
I can’t find any examples.
I would be very helped if you have.
I’m doing some development for a laserpointer driven keyboard (imaging) for people with a handicap (written in Matlab) and the possibility to switch equipment with the k8090 via the laserpointer solution.
An example for a transformation from Visual Basic (VB) to Matlab for such an external board would be usefull, because Velleman delivers two software examples in VB with the board.
any progress?
Did you find out how to send commands to the K8090?
I tried
delete(instrfindall);
s8 = serial('COM8','BaudRate', 19200);
fopen(s8);
% s8.status % shows that it works til here
% how do i transmit commands to K8090??
% tried fprintf and fwrite but didnt succeed
fclose(s8);
delete(s8);
clear s8;
I also tried to load the dlls I found somewhere on this forum
addpath('E:\Programme\Velleman\K8090\Kits.NET');
loadlibrary('K8090.dll','k8090.h');
libisloaded K8090 % works, lib is actually loaded
libfunctionsview K8090 % works too, shows the functions
% but i'm not able to make calllib work, neither with
% calllib('K8090','OpenDevice',8)
% nor anything else like
% calllib('K8090','SendCommand', 11,2,0,0,-12)
I finally loaded the Velleman.Kits.dll
asminfo = NET.addAssembly(‘E:\Programme\Velleman\K8090\Kits.NET\Velleman.Kits.dll’)
and could change the Port to COM8 using
K8090.Port = ‘COM8’
But unfortunately that’s it…
Any ideas how I could send my commands to the cards?
Matlab doesn’t seem to support the dll /header files… i tried different combinations of .dll and headers, nothing worked.
The Velleman.Kits.dll is only for .NET-stuff, but many .NET-“functions” aren’t supported by matlab…
I needed a solution, so I simply used
!E:\Programme\Velleman\K8090\Tools\K8090C.exe -p COM8 -c 1 -f ON && exit & (&& exit & is not necessary, but keeps your command window clean )
and so on. Not the solution I imagined at the begining, but the functions ON, OFF and TOGGLE are sufficient for my purpose.
This might help in some cases, but is far away from an optimal solution…
% Velleman K8090 8-Channel relay board Matlab program via .NET .dll
% Date : 15-12-2010
% Author : Leendert Vermeulen Holland
% Mail : leendert.vermeulen@hccnet.nl
% Version : 0.1
%
%
%
% Make .NET assembly visible to MATLAB and show its Classes
Info = NET.addAssembly('d:\Prive\Ontwikkeling\Matlab\vm8090\MathWorks\Velleman.Kits.dll');
%Info.Classes
%methodsview('Velleman.Kits.K8090Board');
%methods Velleman.Kits.K8090Board;
%% Define a new object check (or modify) ots port ans show applicable methods
objK8090 = Velleman.Kits.K8090Board;
objK8090.Port='COM20'; % In my case. Via Velleman .exe demo program to find out
serialPort = serial('COM20');
set(serialPort, 'BaudRate', 19200,'DataBits', 8, 'Parity', 'None', 'Stopbits', 1, 'FlowControl', 'None');
%% Connecting to the K8090 board
%isvalid(objK8090);%
Connect(objK8090);
%% Setting 8 relays
actief=input('Welke relais wilt u inschakelen? (0 - 255) :');
aan = uint8(actief);
uit = uint8(255-aan);
%%
%ToggleRelay(objK8090, bytewoord); %Werkt 14-12-2010
%%
SwitchRelayOff(objK8090, uit);
SwitchRelayOn(objK8090, aan);
%%
Disconnect(objK8090);
delete(serialPort);
clear serialPort;
It’s only version 0.1, but now we can connect the rest is up to you!
many thanks for your advice. Fine work in Mat-lab!!!
So, I have trying to find some error when I realized the same but in Lab-view 11.
I tried via .Net (Velleman.Kits.dll) and via C++ (k8090d.dll) but I have not any idea how to
make it?
If you have some similar problem please, send me some message or
give me pls some solution.