The byte [0] is always 0.
The byte [1] is 1 to set the debounce time of counter 1.
The byte [1] is 2 to set the debounce time of counter 2.
The byte [1] is 3 to reset counter 1.
The byte [1] is 4 to reset counter 2.
The byte [1] is 5 to send other data to the K8055:
The byte [2] is the digital output byte.
The byte [3] is the analog channel 1 output byte.
The byte [4] is the analog channel 2 output byte.
The byte [7] is the debounce time of counter 1.
The byte [8] is the debounce time of counter 2.
Rx [0]
Rx [1] Digital input
Rx [2] Jumpers
Rx [3] AD 1
Rx [4] AD 2
Rx [5] counter 1 low byte
Rx [6] counter 1 high byte
Rx [7] counter 2 low byte
Rx [8] counter 2 high byte
I hope I read correctly these from the source code…
You may check these from the DLL source code: box.net/shared/dqjnhtjb2t
The source is for the original DLL.
Here a code snippet:
[code]procedure TFormScroll.DoWrite;
var
Written: Cardinal;
ToWrite: Cardinal;
begin
if (ListBox1.Items.Count > 0) then
begin
Buf_tx[0] := 0;
ToWrite := 9;
TheDev := DevList.Items[0];
Written := 0;
TheDev.WriteFile(Buf_tx, ToWrite, Written);
end;
end;
procedure TFormScroll.ReadWrite(k0,k1,k2: longint);
begin
case k0 of
1: begin
Buf_tx[2]:=k1; //digital out
Buf_tx[1]:=5;
dowrite;
end;
2: begin
Buf_tx[2]:=Buf_tx[2] or k1 ; //set bit
Buf_tx[1]:=5;
dowrite;
end;
3: begin
Buf_tx[2]:=Buf_tx[2] and k1 ; //clear bit
Buf_tx[1]:=5;
dowrite;
end;
4: begin
if k1>2 then k1:=2;
if k1<1 then k1:=1;
Buf_tx[2+k1]:=k2;
Buf_tx[1]:=5;
dowrite; //analog 1 or 2
end;
5: begin
Buf_tx[3]:=k1;
Buf_tx[4]:=k2;
Buf_tx[1]:=5;
dowrite; //analog 1 and 2
end;
6: begin
DoRead;
end;
7: begin
Buf_tx[1]:=2+k1;
dowrite; //reset counter
end;
8: begin
Buf_tx[1]:=k1;
if k1=1 then Buf_tx[7]:=k2;
if k1=2 then Buf_tx[8]:=k2;
dowrite; // debounce time
end;
end;
end;[/code]
[code]procedure OutputAnalogChannel(Channel: Longint; Data: Longint); stdcall;
begin
if form_on then FormScroll.ReadWrite(4,Channel,Data);
end;
procedure OutputAllAnalog(Data1: Longint; Data2: Longint); stdcall;
begin
if form_on then FormScroll.ReadWrite(5,Data1,Data2);
end;
procedure ClearAnalogChannel(Channel: Longint); stdcall;
begin
if form_on then FormScroll.ReadWrite(4,Channel,0);
end;
procedure ClearAllAnalog; stdcall;
begin
if form_on then FormScroll.ReadWrite(5,0,0);
end;
procedure SetAnalogChannel(Channel: Longint); stdcall;
begin
if form_on then FormScroll.ReadWrite(4,Channel,255);
end;
procedure SetAllAnalog; stdcall;
begin
if form_on then FormScroll.ReadWrite(5,255,255);
end;
procedure WriteAllDigital(Data: Longint); stdcall;
begin
if form_on then FormScroll.ReadWrite (1,Data,0);
end;
procedure ClearDigitalChannel(Channel: Longint); stdcall;
var k:longint;
begin
k:=255-round(Exp((Channel-1)*ln(2)));
if form_on then FormScroll.ReadWrite(3,k,0);
end;
procedure ClearAllDigital; stdcall;
begin
if form_on then FormScroll.ReadWrite(1,0,0);
end;
procedure SetDigitalChannel(Channel: Longint); stdcall;
var k:longint;
begin
k:=round(Exp((Channel-1)*ln(2)));
if form_on then FormScroll.ReadWrite (2,k,0);
end;
procedure SetAllDigital; stdcall;
begin
if form_on then FormScroll.ReadWrite(1,255,0);
end;
function ReadCounter(CounterNro: Longint): Longint; stdcall;
begin
if CounterNro<1 then CounterNro:=1;
if CounterNro>2 then CounterNro:=2;
if form_on then FormScroll.ReadWrite(6,0,0);
result:=(Buf_rx[3+CounterNro2] + 256Buf_rx[4+CounterNro*2]) and $ffff;
end;
procedure ResetCounter(CounterNro: Longint); stdcall;
begin
if CounterNro<1 then CounterNro:=1;
if CounterNro>2 then CounterNro:=2;
if form_on then FormScroll.ReadWrite(7,CounterNro,0);
end;
procedure SetCounterDebounceTime(CounterNro, DebounceTime:Longint); stdcall;
var t1:Longint;
begin
if CounterNro<1 then CounterNro:=1;
if CounterNro>2 then CounterNro:=2;
t1:= round(0.92.4541POWER(DebounceTime,0.5328));
if t1<1 then t1:=1;
if t1>255 then t1:=255;
if form_on then FormScroll.ReadWrite(8,CounterNro,t1);
end;
function ReadDigitalChannel(Channel: Longint): Boolean; stdcall;
var n1,k:longint;
begin
if form_on then FormScroll.ReadWrite(6,0,0);
n1:=Buf_rx[1];
k:=integer((n1 and 16)>0)*1+
integer((n1 and 32)>0)*2+
integer((n1 and 1)>0)*4+
integer((n1 and 64)>0)*8+
integer((n1 and 128)>0)*16;
if (k and round(Exp((Channel-1)*ln(2)))) > 0 then
result:=true else result:=false;
end;
function ReadAllDigital: Longint; stdcall;
var n1,k:longint;
begin
if form_on then FormScroll.ReadWrite(6,0,0);
n1:=Buf_rx[1];
k:=integer((n1 and 16)>0)*1+
integer((n1 and 32)>0)*2+
integer((n1 and 1)>0)*4+
integer((n1 and 64)>0)*8+
integer((n1 and 128)>0)*16;
result:=k;
end;[/code]