Autor Beitrag
David Armstrong
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
Delphi 7
BeitragVerfasst: Mo 01.05.06 15:36 
hi,wir haben zur zeit in informatik ein projekt bei dem wir mit 2 interfaces eine ampelanlage steuern sollen mit delphi,diese ampelanlage ist auch in dellphi dargestellt
also wenn man am pc eine ampel ausschaltet leuchte die eine ampel bei der interface ampelanlage auch nich mehr usw...

könnt ihr mir da helfen?

das ampelprogramm kann man sich hier runterladen
aktuelles.psi-online...06/interface/ampel2/

und hier ist der quell code um zum interface eine verbindung aufzustellen:
aktuelles.psi-online.../interface/1versuch/

das mit dem verbinden hatte ich versucht bei der ampelanlage einzubauen aber es hatte nich so recht geklappt,ähm und man müsste doch 2 verbindungen aufbauen da es 2 interfaces sind,oder?

schon mal danke für eure hilfe :-)


Zuletzt bearbeitet von David Armstrong am So 07.05.06 17:58, insgesamt 1-mal bearbeitet
aim65
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Mo 01.05.06 16:49 
Ich habe mir mal die Programm-Zips heruntergeladen und angesehen.
Ehrlich gesagt, ich kann keinen Zusammenhang mit dem Programm zur Ampelsteuerung, der Hardware-Anbindung über diese ominöse Karte und dem Programm-3 erkennen. Das Programm3 erzeugt ja nur ein Lauflicht auf der Karte (LED's).
Die Bezeichnung "Interface[]" ist ja nur eine Array-Bezeichnung. Die Definition als Arrays mit 8, bzw. 6 Positionen sieht mir als Vorbereitung zur Ansteuerung eines Parallelports über das Senden eines Datenbytes aus (= 8 bit), wobei der Index einfach die Position eines bits in diesem Byte definiert. Das ist aber bei der Ansteuerungsroutine der Karte mit der DLL nicht ohne weiteres ersichtlich ("WriteAllDigital(x)" --->"// Teste auch mal die Zahlen 2, 4, 8, 16, 32, 64 und 128 aus" bedeutet wohl, das in diesem Byte jeweils ein bit gesetzt ist, bei z.B. "7" eben die 3 niedrigsten bits ). Ist aber nur meine Vermutung.

Leider ist sowieso zu viel unklar, um Dir da vernüntig weiterhelfen zu können:

a) Was ist das für eine Karte?
b) Ist sie über einen Port (parallel oder seriell) angeschlossen,
oder ist es eine PCI-Karte?
c) Habt Ihr diese Karte? Dann müsste ja eine genaue Beschreibung
der Funktionen und der Ansteuerung existieren.

Es wäre sicher sehr sinnvoll, wenn Du Dich einfach auch mal in das psi-online Forum einklinkst, um mit den Urhebern direkt zu sprechen. Viel Erfolg.
David Armstrong Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
Delphi 7
BeitragVerfasst: Mi 03.05.06 16:02 
hi,ja,hast recht,also hier nochmal genauer:

aktuelles.psi-online.../interface_klein.jpg
so sieht das interface aus,das wird über usb mit dem pc verbunden,davon haben wir 2 stück

das foto von dem ampelinterface oder wie das heißt hab ich nich,die 2 interfaces sind am pc angeschlossen und werden mit ampelinterface verbunden,dieses ampelinterface kann man dann vom pc aus steuern

der quelltext für die ampelanlage ist hier:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Shape1: TShape;
    Shape2: TShape;
    Shape3: TShape;
    Shape4: TShape;
    Shape5: TShape;
    Shape6: TShape;
    Shape7: TShape;
    Shape8: TShape;
    Shape9: TShape;
    Shape10: TShape;
    Shape11: TShape;
    Shape12: TShape;
    Shape13: TShape;
    Shape14: TShape;
    Shape15: TShape;
    Timer1: TTimer;
    Timer2: TTimer;
    Button3: TButton;
    procedure Button3Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    PROCEDURE ausgabe_lauflicht;
    PROCEDURE ausgabe_ampel;


  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  tl , ta: integer;
  interfacea: array[1..6of boolean;
  interfacel: array[1..8of boolean;


implementation

{$R *.dfm}



procedure TForm1.Button3Click(Sender: TObject);
begin
  close
end;

PROCEDURE lauflicht;
BEGIN
  if tl = 1 then
    begin
      interfacel[1] := TRUE;
    end;
  if tl = 2 then
    begin
      interfacel[2] := TRUE;
      interfacel[1] := FALSE;
    end;
  if tl = 3 then
    begin
      interfacel[3] := TRUE;
      interfacel[2] := FALSE;
    end;
  if tl = 4 then
    begin
      interfacel[4] := TRUE;
      interfacel[3] := FALSE;
    end;
  if tl = 5 then
    begin
      interfacel[5] := TRUE;
      interfacel[4] := FALSE;
    end;
  if tl = 6 then
    begin
      interfacel[6] := TRUE;
      interfacel[5] := FALSE;
    end;
  if tl = 7 then
    begin
      interfacel[7] := TRUE;
      interfacel[6] := FALSE;
    end;
  if tl = 8 then
    begin
      interfacel[8] := TRUE;
      interfacel[7] := FALSE;
    end;
  if tl = 9 then
    begin
      interfacel[8] := FALSE;
      tl := 0;
    end;
END;

PROCEDURE TForm1.ausgabe_lauflicht;
VAR wert, zahl, i : INTEGER;
BEGIN
{  wert := 1;
  zahl := 0;
  FOR i:=1 TO 8 DO
  BEGIN
    zahl := zahl + wert*abs(interfacel[i]);
    wert := wert*2;
  END; }

  if interfacel[1] = True then shape1.Brush.color := clyellow else shape1.Brush.color := clwhite;
  if interfacel[2] = True then shape2.Brush.color := clyellow else shape2.Brush.color := clwhite;
  if interfacel[3] = True then shape3.Brush.color := clyellow else shape3.Brush.color := clwhite;
  if interfacel[4] = True then shape4.Brush.color := clyellow else shape4.Brush.color := clwhite;
  if interfacel[5] = True then shape5.Brush.color := clyellow else shape5.Brush.color := clwhite;
  if interfacel[6] = True then shape6.Brush.color := clyellow else shape6.Brush.color := clwhite;
  if interfacel[7] = True then shape7.Brush.color := clyellow else shape7.Brush.color := clwhite;
  if interfacel[8] = True then shape8.Brush.color := clyellow else shape8.Brush.color := clwhite;

END ;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  inc(tl);
  lauflicht;
  ausgabe_lauflicht;
end;

procedure TForm1.FormCreate(Sender: TObject);
var z:integer;
begin
  tl := 0;
  ta := 0;
  shape12.brush.color := clred;
  shape15.brush.color := clred;
  for z:=1 to 6 do
    begin
      interfacea[z] := FALSE;

    end;
  for z:=1 to 8 do
    begin
      interfacel[z] := FALSE;

    end;
  interfacea[3] := TRUE;
  interfacea[6] := TRUE;

end;

PROCEDURE ampel;
begin
  if ta = 1 then
    begin
      interfacea[2] := TRUE;
    end;
  if ta = 3 then
    begin
      interfacea[3] := FALSE;
      interfacea[2] := FALSE;
      interfacea[1] := TRUE;
    end;
  if ta = 8 then
    begin
      interfacea[1] := FALSE;
      interfacea[2] := TRUE;
    end;
  if ta = 10 then
    begin
      interfacea[2] := FALSE;
      interfacea[3] := TRUE;
      interfacea[5] := TRUE;
    end;
  if ta = 12 then
    begin
      interfacea[6] := FALSE;
      interfacea[5] := FALSE;
      interfacea[4] := TRUE;
    end;
  if ta = 17 then
    begin
      interfacea[4] := FALSE;
      interfacea[5] := TRUE;
    end;
  if ta = 19 then
    begin
      interfacea[5] := FALSE;
      interfacea[6] := TRUE;
    end;
  if ta = 20 then
    begin
      ta := 0;
    end;
end;

procedure tform1.ausgabe_ampel;
begin
  if interfacea[1] = True then shape10.Brush.color := clgreen else shape10.Brush.color := clwhite;
  if interfacea[2] = True then shape11.Brush.color := clyellow else shape11.Brush.color := clwhite;
  if interfacea[3] = True then shape12.Brush.color := clred else shape12.Brush.color := clwhite;
  if interfacea[4] = True then shape13.Brush.color := clgreen else shape13.Brush.color := clwhite;
  if interfacea[5] = True then shape14.Brush.color := clyellow else shape14.Brush.color := clwhite;
  if interfacea[6] = True then shape15.Brush.color := clred else shape15.Brush.color := clwhite;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
  inc(ta);
  ampel;
  ausgabe_ampel;
end;



end.


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
var h: Longint;
begin
 h:= OpenDevice(0);
  case h of
     0: label1.caption:='Card 0 connected';
    -1: label1.caption:='Card 0 not found';
  end;
end;

damit connectet man zu dem interface,wie macht man das? es sind schließlich 2 interfaces? also 2 mal connecten zu 2 unterschiedlichen interfaces?

wir sollen den quellcode so umschreiben das die ampelanlage die man auf dem pc ist,gleich ist wie die interfaceampelanlage

das heißt: wenn am pc die ampel rot ist,ist bei dem ampelinterface die ampel auch rot

hatte schon einiges probiert und auch versucht zu connecten,aber es wurden fehler angezeigt und ich war einfach ratlos...
David Armstrong Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
Delphi 7
BeitragVerfasst: Do 04.05.06 00:04 
habs allein geschafft,trotzdem danke :)
aim65
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Do 04.05.06 11:17 
Danke, hab's jetzt auch gefunden mit der K8055-karte (hätte ja gleich auf "zurück" auf der PSI-Page klicken können). Hübsches Ding zum Starten, wenn auch ein bißchen langsam für manche Anwendungen (20msec Reaktionszeit):

Würde mich schon interessieren (vll. andere auch), wie Ihr das Ampelprogramm für die beiden Karten jetzt modifiziert habt. Ich hatte ja schon geschrieben, daß man die "Interface[]" in ein Byte umwandeln muß, um das dann über "WriteAllDigital" abzuschicken. Ich vermute, daß Ihr die beiden USB-Karten über verschiedene Adressen ansprechen könnt.
Hoffe, daß Ihr noch genug Schlaf bekommt, und weiter viel Spaß :D

Edit: Hab's grad gesehen: in dem interfaceprogramm (Z.114-120) ist ja die auskommentierte Umwandlung gelistet...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
{  wert := 1;  
  zahl := 0;  
  FOR i:=1 TO 8 DO  
  BEGIN  
    zahl := zahl + wert*abs(interfacel[i]);  
    wert := wert*2;  
  END; }
David Armstrong Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
Delphi 7
BeitragVerfasst: So 07.05.06 11:20 
hi,hab doch noch n paar problemchen

das mit dem verbinden hab ich jetzt ungefär,weiß es aber nicht genau obs richtig ist da ich noch nie ne verbindung zu 2 interfaces aufgebaut hab
hier der quelltext:procedure TForm1.Button1Click(Sender: TObject);
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var h,cardadresse: Longint;
begin
cardadresse:=0;
 h:= OpenDevice(0);
cardadresse :=1;
 cardadresse := OpenDevice(1);
   case h of
   0..3: label2.caption:='Card '+ inttostr(h)+' connected';
    -1: label2.caption:='Card '+ inttostr(CardAdresse)+' not found';
  end;
  case cardadresse of  0..3: label2.caption:='Card 0 connected';
    -1: label1.caption:='Card 0 not found';
end;
end;

ich hab auch noch nen quellcode geschrieben um zu testen ob die einzelnen lichter funktionieren,das hat auch geklappt

jetz die 2 nächsten fragen:
wie schaffe ich dass
ich die einzelnen lämpchen zur richtigen zeit zum laufen kriege und woher weiß ich,welchem interface ich grade einen befehl gebe,kann man das irgendwie zuordnen?
danke