function PortIn(Addr : Word): Byte;
Assembler;
StdCall;
asm
mov dx, Addr
{ Adresse in DX schreiben }
in al, dx
{ Port lesen. (AL entspricht Result) }
end;
procedure PortOut(Addr : Word; Data : Byte);
Assembler;
StdCAll;
asm
mov dx, Addr
{ Adresse nach DX }
mov al, Data
{ Datenbyte nach AL }
out dx, al
{ Port schreiben }
end;
function ReadMesskarte2(Kanal : byte) : double;
(* $2FC = COM2; $3FC = COM1 *)
type
KAN =
array[1..12]
of byte;
const
DIN :
array[1..8]
of KAN = ((1,1,1,1,0,1,1,1,0,0,0,1),
{ 1 }
(1,1,1,1,0,1,1,1,0,0,1,1),
{ 2 }
(1,1,1,1,0,1,1,1,1,0,0,1),
{ 3 }
(1,1,1,1,0,1,1,1,1,0,1,1),
{ 4 }
(1,1,1,1,0,1,1,1,1,0,1,0),
{ 5 }
(1,1,1,1,0,1,1,1,0,1,1,1),
{ 6 }
(1,1,1,1,0,1,1,1,1,1,0,1),
{ 7 }
(1,1,1,1,0,1,1,1,1,1,1,1)
{ 8 }
);
B : integer = 2048;
Ref : double = 5;
Vout : double = 0;
var
i : integer;
d : byte;
begin
Ref := 5;
Vout := 0;
B := 2048;
D := 0;
for i := 1
to 12
do
begin
PortOut($2FC ,($fe
and PortIn($2FC)));
if DIN[Kanal,13-i] = 0
then PortOut($2FC ,($fd
and PortIn($2FC)))
else PortOut($2FC ,($2
or PortIn($2FC)));
PortOut($2FC ,($1
or PortIn($2FC)));
if (PortIn($2fe)
and 16) = 16
then D := 0
else D := 1;
Vout := Vout +(D*B);
B := B
div 2;
end;
ReadMesskarte2 := (Vout / 1023) *Ref /4;
PortOut($2FC , ($fd
and PortIn($2FC)));
PortOut($2FC ,($2
or PortIn($2FC)));
end;