//
----------------------------------------------------
//
Copyright by KOLTER ELECTRONIC
//
Autor Heinrich Kolter
//
Tested 86er PCI
//
System Windows 98 / SP2
//
Progamm Delphi 5
//
----------------------------------------------------
unit
pciadda;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
ListBox1: TListBox;
ListBox2: TListBox;
Label1: TLabel;
Bevel1: TBevel;
StaticText1: TStaticText;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
//
I/O-Abläufe über externe DLLs steuern
procedure
Out32(PortAddress:word;Value:byte);stdcall;export;
external
'inpout32.DLL';
function
Inp32(PortAddress:word):byte;stdcall;export;
external
'inpout32.DLL';
procedure
warte(us:Longword);stdcall;export;
external
'inpout32.DLL';
function
pci_gethead(vendor_id:word; funcdev:byte; bus:byte; reg_number:word):byte;stdcall;export;
external
'pciconf.DLL';
function
pci_getver():word;stdcall;export;
external
'pciconf.DLL';
function
pci_getio(vendor_id:word; device_id:word; index_no:word):longword;stdcall;export;
external
'pciconf.DLL';
const
lsb = 0.3051804379;
// Spannungswert für 1 DIGIT
var
// globale Variable
Form1 : TForm1;
Ausgabe : string;
kanal : integer;
wert : integer;
ADR : longword;
VER : longword;
HB, LB : byte;
digit : word;
millivolt : integer;
implementation
{$R
*.DFM}
//
--- programm code --------------
function
get_pciad(kanal:integer):word;stdcall;export;stdcall;
begin
Out32(adr+4,kanal);
// Multiplexer-Kanal einstellen
Sleep(1);
// warten für MUX
Out32(adr+0,1);
// ADC RC=high = read
Out32(adr+0,0);
// ADC RC=low = convert
//
Status-Bit abfragen ob EOC=TRUE, sonst EOC wieder neu holen
repeat
warte(1);
// 1 us
until
(Inp32(ADR+1) AND 1 = 0);
Out32(adr+0,1);
// ADC umschalten auf read mit higher-byte
HB
:= Inp32(adr + 0); // lese high-byte von A/D Wandler
Out32(adr+0,3);
// ADC umschalten auf lower-byte
LB
:= Inp32(adr + 0); // lese low-byte von A/D-Wandler
digit
:=(HB*256) + LB;
// digit bilden. Werte zwischen 0...65535
get_pciad
:= digit;
end;
procedure
TForm1.Button1Click(Sender: TObject);
begin
For
kanal := 1 to 16 do
begin
wert := get_pciad(kanal-1);
If
(RadioButton1.Checked = True) then millivolt := round(wert * lsb)-10000;
If
(RadioButton2.Checked = True) then millivolt := round(wert * lsb
/ 2)-5000;
If
(RadioButton3.Checked = True) then millivolt := round(wert * lsb
/ 2);
If
(RadioButton4.Checked = True) then millivolt := round(wert * lsb
/ 4);
Ausgabe := 'Kanal ' + IntToStr(kanal) + ' = ' + IntToStr(millivolt);
ListBox1.Items.Add(Ausgabe);
end;
end;
procedure
TForm1.Button2Click(Sender: TObject);
begin
ListBox1.Items.Clear;
end;
procedure
TForm1.Button4Click(Sender: TObject);
begin
ListBox1.Items.Clear;
ListBox1.Items.Add(' ');
ListBox1.Items.Add('KOLTER ELECTRONIC');
ListBox1.Items.Add(' ');
ListBox1.Items.Add('Steinstrasse 22');
ListBox1.Items.Add(' ');
ListBox1.Items.Add('50374 Erftstadt');
ListBox1.Items.Add(' ');
ListBox1.Items.Add('www.pci-card.com');
end;
//
--- Start --------------
procedure
TForm1.FormCreate(Sender: TObject);
begin
//
Karten-Adresse von PCI-Bus lesen und dynamisch zuweisen
ListBox1.Items.Clear;
ListBox2.Items.Clear;
ListBox2.Items.Add('Vendor-ID
= 1001');
ListBox2.Items.Add('Device-ID
= 0012');
ADR
:= pci_getio($1001,$0012,0);
Ausgabe
:= 'I/O-Adr. = ' + IntToStr(ADR);
ListBox2.Items.Add(Ausgabe);
//VER
:= pci_getver();
//Ausgabe
:= 'Version = ' + IntToStr(VER);
//ListBox2.Items.Add(Ausgabe);
//If
VER = 0 then MessageDlg('Keine PCI-Karte gefunden !',mtWarning, [mbOK],0);
end;
//
--- Beenden --------------
procedure
TForm1.Button3Click(Sender: TObject);
begin
Application.Terminate;
end;
end.
KOLTER ELECTRONIC
ist nicht für die Inhalte fremder Seiten verantwortlich.
Es gelten ausschließlich
die AGB der Firma KOLTER ELECTRONIC.
Für die Richtigkeit
der Angaben wird keine Gewähr übernommen.
Alle Preisangaben sind gewerblich.
Das Zahlungsmittel ist EURO.
Alle Rechte vorbehalten.
(c)
copyright H.Kolter
[ Zur
KOLTER ELECTRONIC® Hauptseite ]
|