;Steffen Ast / Joerg Navratil ;Treiber fuer Fischer-Roboter ;Projekt im Fach Robotik II ;Stellt Routinen zur Ansteuerung eines ’Computing Interface’s ;der Firma ’fischertechnik’ bereit ;Version 2.0.0.0 vom 17.01.2003 ;HTWK Leipzig Fachbereich Informatik, Mathematik und Naturwissenschaften ;public ; function createRob(LPT, Max1, Max2, Max3, Min3: Word): Word; ; function freeRob: Word; ; function defRob: Word; ; function testRob(Motoren: Word; var Endsch, Geber1, Geber2, Geber3: Word): Word; ; ;;; neu ;;; ;;; function readRob(var Endsch, Geber1, Geber2, Geber3: Word): Word; ;;; ;;; neu ;;; ; ; function openRob: Word; ; function cntlRob(Motoren: Word; var Endsch, Geber1, Geber2, Geber3: Word): Word; ; function closeRob: Word; ; ;private ; procedure isrRob; .model small .stack 256 .data lpt DW 378h motor DB 0 endschalter DB 0 geber1 DW 0 geber2 DW 0 geber3 DW 0 action DB 0 savedx DW ? saveds DW ? rsw DW 0 sw DW 2 wahr4 DB 0;merkt sich letzte Fahrtrichtung des Freiheitsgrates wahr3 DB 0;0=aus 1=links 2=rechts wahr2 DB 0 Geber1Last DB 0 Geber2Last DB 0 Geber3Last DB 0 Geber1MAX DW 3000 Geber2MAX DW 1140 Geber3MAX DW 1200 Geber3MIN DW 740 .code dataOut MACRO LOCAL isNull, return push cx mov ch, 128 ;CH als Vergleichsgroesse Bit 7=1 and ch, ah ;CH==1 wenn Motor angesteuert werden soll jz IsNull ;Motorrichtung ist nicht angewaehlt springe zu Marke or al, 4 ;dataOut auf 1 setzen jmp return isNull: and al, 251 ;dataOut auf 0 setzen return: pop cx ENDM dataIn MACRO LOCAL return mov bl, al ;push(BL, AL) inc dx ;LPT um 1 erhoehen in al, dx ;Datum einschwingen lassen in al, dx ;Datum einschwingen lassen in al, dx ;eingeschwungenes Datum vom Interface holen and al, 128 ;nur Bit 7 wird weiterverarbeitet or ah, al ;E(x) wird an die passende Stelle in AH eingefuegt rol ah, 1 ;naechste Position in AH an die vorderste Stelle schieben return: dec dx ;LPT wieder auf Datenuebertragung zurueckschalten mov al, bl ;AL=pop(BL) ENDM erstwert MACRO LOCAL rotat, zur1, zur0, return push ax push cx push dx mov cx, 8 ;Zaehlervariable CX auf 8 setzen mov ax, 0 ;AX saeubern or al, 50 ;loadInH ;triggAus out dx, al ;Impuls an Interface, dass Daten angefordert werden rotat: or al, 56 ;clockH ;triggAus out dx, al ;E(CX) Auslesezyklus anmelden dataIn ;liest E(CX) in AH and al, 245 ;loadInL ;clockL or al, 48 ;triggAus out dx, al ;E(CX) Auslesezyklus beendet loop rotat mov bl, 4 ;BL als Vergleichsgroesse Bit 2=1 and bl, ah ;wenn E3==1 dann BL=1 sonst BL=0 cmp bl, Geber1Last;hat sich E3(t) zu E3(t-1) veraendert je zur1 ;wenn nein gehe zu Marke sonst xor Geber1Last, 1;toggeln des letzten gespeicherten Geberzustandes zur1: mov bl, 2 ;BL als Vergleichsgroesse Bit 1=1 and bl, ah ;wenn E2==1 dann BL=1 sonst BL=0 cmp bl, Geber2Last;hat sich E2(t) zu E2(t-1) veraendert je zur0 ;wenn nein gehe zu Marke sonst xor Geber2Last, 1;toggeln des letzten gespeicherten Geberzustandes zur0: mov bl, 1 ;BL als Vergleichsgroesse Bit 0=1 and bl, ah ;wenn E1==1 dann BL=1 sonst BL=0 cmp bl, Geber3Last;hat sich E1(t) zu E1(t-1) veraendert je return ;wenn nein gehe zu Marke sonst xor Geber3Last, 1;toggeln des letzten gespeicherten Geberzustandes return: pop dx pop cx pop ax ENDM eingabe MACRO LOCAL rotat, zur6, zur7, notli1, notli2, notli3, rechts1, rechts2,rechts3, setLast1, setLast2, setLast3, return, setre1, setre2,setre3, bearb1, bearb2, raus1, raus2, setast1, setast2, setast3,links1, links2, links3 push ax push cx push dx mov cx, 5 ;Zaehlervariable CX auf 5 setzen mov ax, 0 ;AX saeubern or al, 50 ;loadInH ;triggAus out dx, al ;Impuls an Interface, dass Daten angefordert werden mov bh, motor ;in BH die letzte Motorenansteuerung laden rotat: or al, 56 ;clockH ;triggAus out dx, al ;E(3+CX) Auslesezyklus anmelden dataIn ;liest E(3+CX) in AH and al, 245 ;loadInL ;clockL or al, 48 ;triggAus out dx, al ;E(3+CX) Auslesezyklus beendet loop rotat or al, 56 ;clockH ;triggAus out dx, al ;E3 Auslesezyklus anmelden dataIn ;liest E3 in AH and al, 245 ;loadInL ;clockL or al, 48 ;triggAus out dx, al ;E3 Auslesezyklus beendet mov bl, 1 ;BL als Vergleichsgroesse Bit 0=1 and bl, ah ;wenn E3==1 dann BL=1 sonst BL=0 cmp bl, Geber1Last;hat sich E3(t) zu E3(t-1) veraendert je zur6 ;wenn nein gehe zu Marke sonst mov bl, 64 ;BL als Vergleichsgroesse Bit 7=1 and bl, bh ;!=0 falls M4 links angesteuert jnz rechts1 ;springe zu Marke falls M4 rechts angesteuert sonst mov bl, 128 ;BL als Vergleichsgroesse Bit 6=1 and bl, bh ;!=0 falls M4 rechts angesteuert jz setast1 ;springe zu Marke falls M4 nicht links angesteuert sonst links1: dec Geber1 ;Geber M4 um 1 verringern mov bl, 32 ;BL als Vergleichsgroesse Bit 5=1 and bl, ah ;kontrolliert ob E8 angesprochen hat jz notli1 ;wenn nicht springe zu Marke sonst mov Geber1, 0 ;Geber M4 auf 0 setzen notli1: jmp setre1 setast1: mov bl, 0 cmp bl, wahr4 je setLast1 mov bl, 1 cmp bl, wahr4 je links1 rechts1: inc Geber1 ;Geber M4 um 1 erhoehen mov si, Geber1Max cmp si, Geber1 jg setre1 or ah, 1 jmp setLast1 setre1: and ah, 254 setLast1: xor Geber1Last, 1;toggeln des letzten gespeicherten Geberzustandes zur6: or al, 56 ;clockH ;triggAus out dx, al ;E2 Auslesezyklus anmelden dataIn ;liest E2 in AH and al, 245 ;loadInL ;clockL or al, 48 ;triggAus out dx, al ;E2 Auslesezyklus beendet mov bl, 1 ;BL als Vergleichsgroesse Bit 0=1 and bl, ah ;wenn E2==1 dann BL=1 sonst BL=0 cmp bl, Geber2Last;hat sich E2(t) zu E2(t-1) veraendert je zur7 ;wenn nein gehe zu Marke sonst mov bl, 16 ;BL als Vergleichsgroesse Bit 5=1 and bl, bh ;!=0 falls M3 links angesteuert jnz rechts2 ;springe zu Marke falls M3 rechts angesteuert sonst mov bl, 32 ;BL als Vergleichsgroesse Bit 4=1 and bl, bh ;!=0 falls M3 rechts angesteuert jz setast2 ;springe zu Marke falls M3 nicht links angesteuert sonst links2: dec Geber2 ;Geber M3 um 1 verringern mov bl, 32 ;BL als Vergleichsgroesse Bit 5=1 and bl, ah ;kontrolliert ob E7 angesprochen hat jz notli2 ;wenn nicht springe zu Marke sonst mov Geber2, 0 ;Geber M4 auf 0 setzen notli2: jmp setre2 setast2: mov bl, 0 cmp bl, wahr3 je setLast2 mov bl, 1 cmp bl, wahr3 je links2 rechts2: inc Geber2 ;Geber M3 um 1 erhoehen mov si, Geber2Max cmp si, Geber2 jg setre2 or ah, 1 jmp setLast2 setre2: and ah, 254 setLast2: xor Geber2Last, 1;toggeln des letzten gespeicherten Geberzustandes zur7: or al, 56 ;clockH ;triggAus out dx, al ;E1 Auslesezyklus anmelden dataIn ;liest E1 in AH and al, 245 ;loadInL ;clockL or al, 48 ;triggAus out dx, al ;E1 Auslesezyklus beendet mov bl, 1 ;BL als Vergleichsgroesse Bit 0=1 and bl, ah ;wenn E1==1 dann BL=1 sonst BL=0 cmp bl, Geber3Last;hat sich E1(t) zu E1(t-1) veraendert je return ;wenn nein gehe zu Marke sonst mov bl, 4 ;BL als Vergleichsgroesse Bit 3=1 and bl, bh ;!=0 falls M2 links angesteuert jnz rechts3 ;springe zu Marke falls M2 rechts angesteuert sonst mov bl, 8 ;BL als Vergleichsgroesse Bit 2=1 and bl, bh ;!=0 falls M2 rechts angesteuert jz setast3 ;springe zu Marke falls M2 nichtlinks angesteuert sonst links3: dec Geber3 ;Geber M2 um 1 verringern mov bl, 32 ;BL als Vergleichsgroesse Bit 5=1 and bl, ah ;kontrolliert ob E6 angesprochen hat jz notli3 ;wenn nicht springe zu Marke sonst mov Geber3, 0 ;Geber M2 auf 0 setzen notli3: jmp setre3 setast3: mov bl, 0 cmp bl, wahr2 je setLast3 mov bl, 1 cmp bl, wahr2 je links3 rechts3: inc Geber3 ;Geber M2 um 1 erhoehen mov si, Geber3Max cmp si, Geber3 jg setre3 or ah, 1 jmp setLast3 setre3: and ah, 254 setLast3: xor Geber3Last, 1;toggeln des letzten gespeicherten Geberzustandes return: mov endschalter, ah;AH in Variable Endschalter speichern pop dx pop cx pop ax ENDM ausgabe MACRO LOCAL isleft1, isleft2, isleft3, isrigth1, isrigth2, isrigth3, tstundr1,tstundr2, tstundr3, tstover1, tstover2, tstover3, behind1, behind1r,behind2, behind2r, behind3, behind3r, isright1, isright2, isright3,greifer, iszu, isauf, tstzu, tstauf, behind4, behind4z push ax push cx push dx mov ax, 0 ;AX saeubern mov ah, motor ;in AH die letzte Motorenansteuerung laden mov bl, endschalter;in BL die letzten Endschalterwerte laden and al, 254 ;loadOutL or al, 48 ;triggAus out dx, al ;Ausgabe der Motordaten ankuendigen mov al, 0 ;AL saeubern dataOut ;Datenleitung DataOut anpassen isleft1: mov bh, 128 ;BH als Vergleichsgroesse Bit 7=1 and bh, ah ;BH Bit 7==1 wenn M4 links fahren soll jz behind1 ;wenn Bit 7==0 springe zu Marke sonst tstundr1: and bh, bl ;Bit 7==1 wenn Endschalter M4 angefahren jz behind1 ;wenn Endschalter nicht angefahren springe zu Marke sonst and al, 251 ;dataOut auf 0 setzen behind1: and al, 254 ;loadOutL or al, 48 ;triggAus out dx, al ;M4 links Ausgabe vorbereiten and al, 254 ;loadOutL or al, 56 ;clockH ;triggAus out dx, al ;einschwingen lassen out dx, al ;einschwingen lassen out dx, al ;M4 links ausgeben and al, 246 ;clockL ;loadOutL or al, 48 ;triggAus out dx, al ;M4 links Ausgabe beenden rol ah, 1 ;naechste Position in AH an die vorderste Stelle schieben mov al, 0 ;AL saeubern dataOut ;Datenleitung DataOut anpassen isright1: mov bh, 128 ;BH als Vergleichsgroesse Bit 7=1 and bh, ah ;BH Bit 7==1 wenn M4 rechts fahren soll jz behind1r ;wenn Bit 7==0 springe zu Marke sonst tstover1: mov si, geber1 ;M4 Geber-inkrement in SI schreiben cmp si, Geber1Max;aktuellen Geberwert mit max Wert vergleichen jle behind1r ;wenn Geber