Ok, I did my homework now.
First: thanks for the code.
I never wrote Visual Basic, but I do use Delphi since 2002.
So I tried to change your code into something in Delphi, but did not succeed. I got zeros all the time. (That would have been nice!)
So I tried some other code from the internet, with QueryPerformanceCounter (counting at processorspeed) and succeeded in getting out some numbers:
K8055 with v4.0 dll: 7.74ms
K8055 with v5.0 dll: 7.74ms
K8055N with v5.0 dll: 2.96ms
K8055N with v4.0 dll: 0.97ms (wow!)
Here is my code:
[code]unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function OpenDevice(CardAddress: Longint): Longint; stdcall; external ‘K8055d.dll’;
procedure ReadAllAnalog(var Data1, Data2: Longint); stdcall; external ‘K8055d.dll’;
function ReadAllDigital: integer; stdcall; external ‘K8055d.dll’;
procedure WriteAllDigital(Data: Longint);stdcall; external ‘K8055d.dll’;
procedure TForm1.Button1Click(Sender: TObject);
var i,Data1,Data2:Integer;
var Freq, StartCount, StopCount: Int64;
begin
QueryPerformanceFrequency(Freq);
QueryPerformanceCounter(StartCount);
For i := 0 To 999 DO
begin
ReadAllAnalog(Data1, Data2);
end;
QueryPerformanceCounter(StopCount);
Label1.Caption := '1000 reads = ’ + floattostr((StopCount - StartCount) / Freq) + ‘ms’;
end;
procedure TForm1.FormCreate(Sender: TObject);
var h,CardAddr:longint;
begin
CardAddr:= 0;
h:= OpenDevice(CardAddr);
case h of
0…3: label2.caption:=‘Card ‘+ inttostr(h)+’ connected’;
-1: begin
label2.caption:=‘Card ‘+ inttostr(CardAddr)+’ not found’;
Label2.Font.Color := clRed;
end;
end;
end;
end.[/code]
My project has to do with speed:
I shoot with an air gun (first trigger moment) and then capture the results with my camera (second trigger moment)
(see for results my stockphoto website detailimages.com)
Because the code above is about reading from the card I had to do another test with writing:
I changed the ReadAllAnalog to:
WriteAllDigital(32);
WriteAllDigital(0);
Changing this I have the situation for one port to switch on and of for a thousand times.
This gives me the result: 4.00ms together so 2ms for one command.
The TTimer component from Delphi has 1ms as minimum value, so my software (after corrections as mentioned above) still will do the trick.
Thanks for your help.
Wim