home *** CD-ROM | disk | FTP | other *** search
- (* ------------------------------------------------------ *)
- (* RCMess.PAS *)
- (* Widerstände und Kondensatoren messen *)
- (* mit dem IBM-Gameport *)
- (* *)
- (* (c) 1991 by Andreas Bartels & toolbox *)
- (* ------------------------------------------------------ *)
- {$A-,B-,D-,E-,F-,I-,L-,N-,O-,R-,S-,V- }
-
- PROGRAM Widerstaende_und_Kondensatoren_Messen;
- (* ---- (c) Andreas Bartels o7.12.199o ---- *)
-
- Uses Crt, Dos;
-
- CONST
- MaxZaehler = 10000;
- PortNr = $201;
-
- Einheit : ARRAY[ 0.. 1] OF CHAR = ( 'Ω', 'F' );
- DezimalVorsatz : ARRAY[-6.. 6] OF CHAR = 'afpnµm KMGTPE';
- (* atto,femto,piko,nano,mikro,milli,
- -,Kilo,Mega,Giga,Terra,Peta,Exa *)
-
- MessBereichZahl = 8;
- MessBereichsKonstante : ARRAY[ 0..15] OF REAL =
- ( (* 0 : C für Eichung : *)
- 100e-9,
- (* 1- 7 : C's für R-Mesung : *)
- 1e-3, 100e-6, 10e-6, 1e-6, 100e-9, 10e-9, 1e-9,
- (* 8 : R für Eichung : *)
- 100e+3,
- (* 9-15 : R's für C-Messung : *)
- 10e+6, 1e+6, 100e+3, 10e+3, 1e+3, 100, 10 );
-
- VAR
- Eichen : BOOLEAN;
- MessBereichNr,
- MessModus : BYTE;
- EichFaktor,
- MessFaktor : REAL;
- Ch : CHAR;
-
-
- PROCEDURE CursorOn;
- BEGIN
- INLINE($B4/$01/
- $B9/13/12/ (* Cursoranf. 12.Z, Cursorende 13.Z *)
- $CD/$10);
- END; (* CursorOn *)
-
-
- PROCEDURE CursorOff;
- BEGIN
- INLINE($B4/$01/
- $B9/$FF/$FF/ (* Cursoranfang und -ende auf *)
- $CD/$10); (* 255 setzen löscht den Cursor *)
- END; (* CursorOff *)
-
-
- FUNCTION GamePortRCProdukt : WORD;
- (* Fragt das R*C-Produkt des 3.Gameport-kanals ab *)
- VAR
- IMR21, IMRA1,
- GamePortByte : BYTE;
- w, Zaehler : INTEGER;
-
- BEGIN (* GamePortRCProdukt *)
- (* Erlaubte Interrupts speichern und verbieten *)
- IMR21 := Port[$21];
- IMRA1 := Port[$A1];
- Port[$21]:= $FF;
- Port[$A1]:= $FF;
-
- (* Initialisierung *)
- w := 0;
- REPEAT
- GamePortByte := Port[ PortNr ];
- Inc( w );
- UNTIL ((GamePortByte AND 12) = 0) OR (w > 100);
- Port[PortNr] := GamePortByte;
-
- (* Zähl-Routine zur Messung der Timer-Zeit *)
- Zaehler := 0;
- REPEAT
- GamePortByte := Port[PortNr];
- Inc(Zaehler); (* ... AND 1/2/4/8 für Kanäle 1/2/3/4 *)
- UNTIL (GamePortByte AND 1 = 0) Or (Zaehler >= MaxZaehler);
- GamePortRCProdukt := Zaehler;
-
- (* Interrupts wieder zulassen *)
- Port[$21]:= IMR21;
- Port[$A1]:= IMRA1;
- END; (* GamePortRCProdukt *)
-
-
- FUNCTION MitDezimalVorsatz( Ausgabe : REAL ) : STRING;
- VAR
- Dezimal : SHORTINT;
- AusgabeStr : STRING[7]; (*z.B. 123.4µ*)
-
- BEGIN
- Dezimal := 0;
- WHILE Ausgabe >= 1000 DO BEGIN
- Ausgabe := Ausgabe / 1000;
- INC( Dezimal );
- END; (* While, Ausgabe >= 1000 *)
- WHILE Ausgabe < 1 DO BEGIN
- Ausgabe := Ausgabe * 1000;
- DEC( Dezimal );
- END; (* While, Ausgabe < 1 *)
- Str( Ausgabe:7:3, AusgabeStr );
- MitDezimalVorsatz := AusgabeStr + ' '
- + DezimalVorsatz[Dezimal];
- END; (* MitDezimalVorsatz *)
-
-
- PROCEDURE Eichung;
- VAR
- EichRCProdukt : REAL;
-
- BEGIN
- EichRCProdukt := ( GamePortRCProdukt + GamePortRCProdukt
- + GamePortRCProdukt + GamePortRCProdukt) / 4;
- EichFaktor := MessBereichsKonstante[ 0 ]
- * MessBereichsKonstante[ MessBereichZahl ]
- / EichRCProdukt;
- GoToXY( 4,17 );
- Write( ' R*C(Eichung) : ', EichRCProdukt:4:0, ' ' );
- END; (* Eichung *)
-
-
- PROCEDURE MessBereich;
- BEGIN
- MessFaktor := EichFaktor
- / MessBereichskonstante[MessBereichZahl*MessModus
- + MessBereichNr];
- GoToXY( 21,11 );
- Write( MessBereichNr:1 );
- GoToXY( 29,11 );
- Write( MitDezimalVorsatz( 1 * MessFaktor):5,
- Einheit[MessModus] );
- GoToXY( 46,13 );
- Write( MitDezimalVorsatz( 1/2 * MessFaktor):5,
- Einheit[MessModus] );
- GoToXY( 46,11 );
- Write( MitDezimalVorsatz( MaxZaehler * MessFaktor):5,
- Einheit[MessModus] );
- GoToXY( 26,17 );
- IF MessModus = 0 THEN
- Write('Referenzkondensator : ',
- MitDezimalVorsatz( MessBereichsKonstante[
- MessBereichNr]), 'F ' )
- ELSE
- Write('Referenzwiderstand : ',
- MitDezimalVorsatz( MessBereichsKonstante[
- MessBereichZahl + MessBereichNr]), 'Ω' );
- END; (* MessBereich *)
-
-
- PROCEDURE Messung( MessBereichNr, MessModus : BYTE );
- VAR
- Ausgabe : REAL;
- AusgabeStr : STRING[10]; (*z.B. 123.456 µF*)
-
- BEGIN
- IF Eichen THEN BEGIN
- Eichung;
- Messbereich;
- END;
- Ausgabe := ( GamePortRCProdukt + GamePortRCProdukt +
- GamePortRCProdukt + GamePortRCProdukt ) / 4;
- GoToXY( 17,13 );
- Write( Ausgabe:5:0 );
- Ausgabe := Ausgabe * MessFaktor;
- IF Ausgabe > 0 THEN
- AusgabeStr := MitDezimalVorsatz( Ausgabe )
- + Einheit[MessModus]
- ELSE BEGIN
- Sound( 440 );
- AusgabeStr := 'Zu klein !';
- Delay( 100 );
- NoSound;
- END; (* ELSE *)
- GoToXY( 29,13 );
- Write( AusgabeStr );
- Sound(1000);
- Delay(1);
- NoSound;
- END; (* Messung *)
-
-
- BEGIN (* ---------------- Hauptprogramm ----------------- *)
- ClrScr;
- Window( 9,1, 70,21 );
- CursorOff;
- Write( '╒═════════════════════════════════════'+
- '══════════════════════╕ ');
- Write( '│ '+
- ' │ ');
- Write( '│ Widerstands- und Kapazitätsmessung '+
- 'mit dem IBM-Gameport │ ');
- Write( '│ RCMess Version 1.0 ' +
- ' (c) toolbox & A.Bartels 1990 │ ');
- Write( '│ '+
- ' │ ');
- Write( '│ Befehle : < R >-Messung '+
- ' < +/- > Messbereich │ ');
- Write( '│ < C >-Messung '+
- ' < Esc > Abbrechen │ ');
- Write( '│ < E >ichung '+
- ' │ ');
- Write( '╞════════════════════════════════'+
- '═══════════════════════════╡ ');
- Write( '│ '+
- ' │ ');
- Write( '│ Messbereich ( ) : '+
- ' bis │ ');
- Write( '│ '+
- ' │ ');
- Write( '│ Messwert ( ) : '+
- ' +/- │ ');
- Write( '│ '+
- ' │ ');
- Write( '╞════════════════════════════════'+
- '═══════════════════════════╡ ');
- Write( '│ '+
- ' │ ');
- Write( '│ Bitte Eich-R und Eich-C anschließen '+
- 'und Taste drücken ! │ ');
- Write( '│ '+
- ' │ ');
- Write( '╘══════════════════════════════════════'+
- '═════════════════════╛ ');
- Ch := ReadKey;
- MessBereichNr := 5;
- MessModus := 0;
- Eichen := true;
- REPEAT
- Messung( MessBereichNr, MessModus );
- IF Eichen = true THEN Eichen := false;
- IF KeyPressed THEN BEGIN
- Ch := ReadKey;
- CASE Ch OF
- 'R', 'r' : BEGIN
- MessModus := 0;
- MessBereich;
- END;
- 'C', 'c' : BEGIN
- MessModus := 1;
- MessBereich;
- END;
- 'E', 'e' : Eichen := true;
- '+' : BEGIN
- IF MessBereichNr < 7 THEN
- Inc( MessBereichNr );
- MessBereich;
- END;
- '-' : BEGIN
- IF MessBereichNr > 1 THEN
- Dec( MessBereichNr );
- MessBereich;
- END;
- ELSE END;
- END; (* IF, Keypressed *)
- Until Ch = #27;
- CursorOn;
- END. (* RCMess.PAS *)
-
- (* ------------------------------------------------------- *)
- (* Ende von RCMESS.PAS *)