F:\Robot\Mar14int3.lst - generated by MGTEK Assembler ASM11 V1.22 Build 137 for WIN32 (x86) - Wed Mar 15 11:54:11 2006

    1:                                 ;**************************************************************************
    2:                                 ;Name:          Robot Library
    3:                                 ;Version:       0.1b
    4:                                 ;Author:        Dan Kohn
    5:                                 ;Date of Mod):  Dec 8, 2005
    6:                                 ;
    7:                                 ;IO Table:
    8:                                 ;
    9:                                 ;PortA          PA7     Output / Sonar Init
   10:                                 ;               PA6     OC2 / RIGHT Motor (PWM for servo)
   11:                                 ;               PA5     OC3 / LEFT Motor (PWM for servo)
   12:                                 ;               PA4     OC4 / Multiplexed Servo Output ;mike code gripper motor
   13:                                 ;               PA3     OC5 / USED FOR TRACE - BUFFALO
   14:                                 ;               PA2
   15:                                 ;               PA1     IC2 / Sonar Echo 
   16:                                 ;               PA0     IC3/Clock for barcode
   17:                                 ;
   18:                                 ;PortE          PE7     Data for barcode
   19:                                 ;               PE6
   20:                                 ;               PE5
   21:                                 ;               PE4
   22:                                 ;               PE3     ADR4/Line Track 3       left   \
   23:                                 ;               PE2     ADR3/Line Track 2       center  - looking from the back of robot
   24:                                 ;               PE1     ADR2/Line Track 1       Right  /
   25:                                 ;               PE0
   26:                                 ;
   27:                                 ;               
   28:                                 ;PortD          PD5     
   29:                                 ;               PD4
   30:                                 
   31:                                 ;               PD3     
   32:                                 ;               PD2     
   33:                                 ;
   34:                                 ;               OUTPUT Circuit
   35:                                 ;$B580          BIT0    LSB Servo Multiplexer 
   36:                                 ;               BIT1    |
   37:                                 ;               BIT2    MSB Servo Multiplexer
   38:                                 ;               BIT3
   39:                                 ;               BIT4
   40:                                 ;               BIT5
   41:                                 ;               BIT6
   42:                                 ;               BIT7
   43:                                 ;
   44:                                 ;               Input Circuit
   45:                                 ;$B590          BIT0
   46:                                 ;               BIT1
   47:                                 ;               BIT2
   48:                                 ;               BIT3
   49:                                 ;               BIT4
   50:                                 ;               BIT5
   51:                                 ;               BIT6
   52:                                 ;               BIT7
   53:                                 ;
   54:                                 ;               Input Circuit
   55:                                 ;$B5A0          BIT0
   56:                                 ;               BIT1
   57:                                 ;               BIT2
   58:                                 ;               BIT3
   59:                                 ;               BIT4
   60:                                 ;               BIT5
   61:                                 ;               BIT6
   62:                                 ;               BIT7
   63:                                 ;**************************************************************************
   64:                                 
   65:                                 
   66:          =00002000                              ORG $2000
   67:                                                 
   68:                                                 include Hc11.inc        ;definds all HC11 Registers
    1:                                 * Define Register Locations for ASM Portion of Code
    2:                                 
    3:          =00001000              REG_BASE        equ     $1000
    4:                                 
    5:          =00001000              PORTA           equ     REG_BASE+$0000
    6:          =00001002              PIOC            equ     REG_BASE+$0002
    7:          =00001003              PORTC           equ     REG_BASE+$0003
    8:          =00001004              PORTB           equ     REG_BASE+$0004
    9:          =00001005              PORTCL          equ     REG_BASE+$0005
   10:          =00001007              DDRC            equ     REG_BASE+$0007
   11:          =00001008              PORTD           equ     REG_BASE+$0008
   12:          =00001009              DDRD            equ     REG_BASE+$0009
   13:          =0000100A              PORTE           equ     REG_BASE+$000A
   14:          =0000100B              CFORC           equ     REG_BASE+$000B
   15:          =0000100C              OC1M            equ     REG_BASE+$000C
   16:          =0000100D              OC1D            equ     REG_BASE+$000D
   17:          =0000100E              TCNT            equ     REG_BASE+$000E
   18:          =00001010              TIC1            equ     REG_BASE+$0010
   19:          =00001012              TIC2            equ     REG_BASE+$0012
   20:          =00001014              TIC3            equ     REG_BASE+$0014
   21:          =00001016              TOC1            equ     REG_BASE+$0016
   22:          =00001018              TOC2            equ     REG_BASE+$0018
   23:          =0000101A              TOC3            equ     REG_BASE+$001A
   24:          =0000101C              TOC4            equ     REG_BASE+$001C
   25:          =0000101E              TOC5            equ     REG_BASE+$001E
   26:          =00001020              TCTL1           equ     REG_BASE+$0020
   27:          =00001021              TCTL2           equ     REG_BASE+$0021
   28:          =00001022              TMSK1           equ     REG_BASE+$0022
   29:          =00001023              TFLG1           equ     REG_BASE+$0023
   30:          =00001024              TMSK2           equ     REG_BASE+$0024
   31:          =00001025              TFLG2           equ     REG_BASE+$0025
   32:          =00001026              PACTL           equ     REG_BASE+$0026
   33:          =00001027              PACNT           equ     REG_BASE+$0027
   34:          =00001028              SPCR            equ     REG_BASE+$0028
   35:          =00001029              SPSR            equ     REG_BASE+$0029
   36:          =0000102A              SPDR            equ     REG_BASE+$002A
   37:          =0000102B              BAUD            equ     REG_BASE+$002B
   38:          =0000102C              SCCR1           equ     REG_BASE+$002C
   39:          =0000102D              SCCR2           equ     REG_BASE+$002D
   40:          =0000102E              SCSR            equ     REG_BASE+$002E
   41:          =0000102F              SCDR            equ     REG_BASE+$002F
   42:          =00001030              ADCTL           equ     REG_BASE+$0030
   43:          =00001031              ADR1            equ     REG_BASE+$0031
   44:          =00001032              ADR2            equ     REG_BASE+$0032
   45:          =00001033              ADR3            equ     REG_BASE+$0033
   46:          =00001034              ADR4            equ     REG_BASE+$0034
   47:          =00001039              OPTION          equ     REG_BASE+$0039
   48:          =0000103A              COPRST          equ     REG_BASE+$003A
   49:          =0000103B              PPROG           equ     REG_BASE+$003B
   50:          =0000103C              HPRIO           equ     REG_BASE+$003C
   51:          =0000103D              INIT            equ     REG_BASE+$003D
   52:          =0000103E              TEST1           equ     REG_BASE+$003E
   53:          =0000103F              CONFIG          equ     REG_BASE+$003F
   69:                                 
   70:     2000 7E 2027                                JMP MAIN
   71:                                 
   72:                                 ;Buffalo Equates
   73:          =0000FFC1              out2bsp         equ $ffc1               ; prints what is pointed to by x to the screen
   74:          =0000FFC4              outcrlf         equ $ffc4               ; outputs a carrage return and line feed
   75:          =0000FFBE              out1bsp         equ $ffbe               ; prints what is pointed to by x to the screen
   76:                                 
   77:                                 ;Right Motor Variables and Equates
   78:          =000000DC              TOC2IV          EQU $00DC               
   79:     2003 +0002                  On_cnts_R       RMB 2
   80:     2005 +0002                  Off_cnts_R      RMB 2
   81:                                 
   82:                                 
   83:                                 ;Left Motor Variables and Equates
   84:          =000000D9              TOC3IV          EQU $00D9
   85:     2007 +0002                  On_cnts_L       RMB 2
   86:     2009 +0002                  Off_cnts_L      RMB 2
   87:                                 
   88:                                 
   89:                                 ;Gipper Motor Variables and Equates                     ;mike code
   90:          =000000D6              TOC4IV          EQU $00D6
   91:     200B +0002                  On_cnts_G       RMB 2
   92:     200D +0002                  Off_cnts_G      RMB 2
   93:                                 
   94:                                 ;List of variables for Sonar 
   95:     200F +0002                  Sonar_start     rmb 2
   96:     2011 +0002                  Sonar_end       rmb 2
   97:     2013 +0002                  Sonar_ans       rmb 2
   98:                                 
   99:                                 ;Timer Overflow Counter
  100:          =000000D0              TOFIV           EQU $00D0
  101:     2015 +0001                  Sec_Temp        rmb 1           ;counter 32.77mSec [0-15]
  102:     2016 +0001                  Sec_count       rmb 1           ;counter 0.1Sec [0-255]
  103:     2017 +0002                  plane_temp      rmb 2           ;counter 32.77ms [0-30]
  104:     2019 +0002                  plane1_cd       rmb 2           ;countdown timer - plane 1 [180 -> 0 Sec]
  105:     201B +0002                  plane2_cd       rmb 2           ;countdown timer - plane 2 [240 -> 0 Sec]
  106:     201D +0002                  plane3_cd       rmb 2           ;countdown timer - plane 3 [300 -> 0 Sec]
  107:                                 
  108:                                 ;Line Track Control Byte
  109:     201F +0001                  LTCB            rmb 1
  110:                                 
  111:                                 ;Line Track Level
  112:          =00000094              LTL             equ $94         ; comparison number for more black and less is white? 
  113:                                 
  114:                                 
  115:                                 ;Barcode Equates
  116:          =000000E2              IC3IV           EQU $00E2
  117:     2020 +0005                  Barcode         RMB 5
  118:     2025 +0001                  BC_count        RMB 1
  119:     2026 +0001                  Boxcode         RMB 1
  120:          =0000FFB8              outa            equ $ffb8
  121:                                 
  122:                                 
  123:                                 
  124:     2027                        MAIN            
  125:                                 
  126:     2027 BD 22DF                                jsr go_stop             ;Set up On/Off times for stop
  127:     202A BD 24E5                                jsr TOC4_init           ;init gripper motor
  128:     202D BD 2495                                jsr TOC3_init           ;init left motor
  129:     2030 BD 2445                                jsr TOC2_init           ;init right motor
  130:     2033 BD 23A1                                jsr TOF_init            ;init Timer Overflow (for 0.5 sec Timer)
  131:     2036 BD 233B                                jsr A2D                 ;init A/D PE0..PE3
  132:     2039 86 96                  Lop:            ldaa #150               ; pause robot for placement at beginning
  133:     203B BD 2378                                jsr pause
  134:     203E BD 2065                                jsr Start               ;leave the block
  135:     2041 BD 2086                                jsr LeaveShoot          ; moves robot from shoot to the plane 1 intersection            
  136:                                                                         ; spot to check if need to go to 1st plane
  137:     2044 BD 20C8                                jsr Plane1
  138:     2047 BD 212E                                jsr Shoot2
  139:     204A BD 2086                                jsr LeaveShoot
  140:     204D BD 2173                                jsr Plane2
  141:     2050 BD 212E                                jsr Shoot2
  142:     2053 BD 2086                                jsr LeaveShoot
  143:     2056 BD 21E1                                jsr Plane3
  144:     2059 BD 212E                                jsr Shoot2
  145:                                 
  146:     205C 7E 2039                                jmp Lop
  147:     205F BD 22DF                                jsr go_stop
  148:     2062 7E E000                                jmp $e000
  149:                                 ;**************************************************************************
  150:                                 ; this section moves the robot to the block shoot
  151:                                 ;**************************************************************************
  152:     2065 36                     Start:          psha
  153:                                 
  154:                                 
  155:     2066 BD 22F1                                jsr go_forward          ;Leaving Block
  156:     2069 86 0A                                  ldaa #10
  157:     206B BD 2378                                jsr pause
  158:                                 
  159:     206E BD 2241                                jsr LineTrack           ; this line moves forward until the 1st plus intersection
  160:                                                 
  161:                                                 
  162:     2071 BD 22F1                                jsr go_forward
  163:     2074 86 0A                                  ldaa #10
  164:     2076 BD 2378                                jsr pause
  165:                                                 
  166:     2079 BD 2241                                jsr Linetrack
  167:                                                 ;jsr go_stop
  168:                                                                         ; kill switch or sonar goes here
  169:                                                 ;ldaa #20                       
  170:                                                 ;jsr pause
  171:                                 
  172:     207C BD 235A                                jsr go_Close            ;call sub that close the gripper hand
  173:     207F 86 14                                  ldaa #20
  174:     2081 BD 2378                                jsr pause
  175:                                                 
  176:                                                 ;jsr arm up
  177:                                                 ;jsr scanner            ;barcode scanner
  178:                                                 ;ldaa barcode
  179:                                                 ;cmpa #01
  180:                                                 ;beq barplane1
  181:                                 
  182:                                                 ;cmpa #02
  183:                                                 ;beq barplane2
  184:                                 
  185:                                                 ;cmpa #03
  186:                                                 ;beq barplane3
  187:                                                 
  188:                                                 ;jsr go_stop            ;call stop for the gripper
  189:                                                 ;ldaa #10
  190:                                                 ;jsr pause
  191:                                 
  192:                                                 ;jsr go_reverse         ;Reverse for 1 Sec.
  193:                                                 ;ldaa #1
  194:                                                 ;jsr pause
  195:                                                 
  196:                                                 ;jsr go_stop
  197:                                                                         ; sorting barcode info here
  198:                                                 ;ldaa #1
  199:                                                 ;jsr pause
  200:                                 
  201:     2084 32                                     pula
  202:     2085 39                                     rts
  203:                                 ;**************************************************************************
  204:                                 ; this section moves the robot away from the shoot to the intersection for
  205:                                 ; turning to plane 1
  206:                                 ;**************************************************************************
  207:                                                 
  208:     2086 36                     LeaveShoot:     psha
  209:                                         
  210:                                 
  211:     2087 BD 22B5                                jsr clockw              ;180 Right Turn to leave the Package shoot
  212:     208A BD 2241                                jsr LineTrack           ; line track back to the 1st plus
  213:                                                 
  214:     208D BD 22F1                                jsr go_forward          ; this section makes the first turn
  215:     2090 86 05                                  ldaa #5
  216:                                                                         ; *
  217:     2092 BD 2378                                jsr pause               ; *
  218:     2095 BD 22DF                                jsr go_stop
  219:     2098 86 05                                  ldaa #5
  220:     209A BD 2378                                jsr pause               ; *
  221:     209D BD 22CA                                jsr counterclck         ; *
  222:     20A0 BD 22DF                                jsr go_stop             ; *
  223:     20A3 86 05                                  ldaa #5                 ; *
  224:     20A5 BD 2378                                jsr pause               ; *
  225:                                 
  226:     20A8 BD 2241                                jsr LineTrack           ; moves robot to the 1st t intersection
  227:                                                                         ; ends this section
  228:     20AB 32                                     pula
  229:     20AC 39                                     rts
  230:                                 ;**************************************************************************
  231:                                 ;Subroutine for the Barcodes output(Plane 1)
  232:                                 ;
  233:                                 ;**************************************************************************
  234:                                                 
  235:     20AD 36                     BarPlane1:      psha
  236:                                         
  237:     20AE BD 2086                                jsr LeaveShoot                  
  238:                                                                         
  239:     20B1 BD 20C8                                jsr Plane1
  240:                                                 
  241:     20B4 32                                     pula
  242:     20B5 39                                     rts
  243:                                 ;**************************************************************************
  244:                                 ;Subroutine for the Barcodes output(Plane 2)
  245:                                 ;
  246:                                 ;**************************************************************************
  247:                                                 
  248:     20B6 36                     BarPlane2:      psha
  249:                                         
  250:     20B7 BD 2086                                jsr LeaveShoot                  
  251:                                                                         
  252:     20BA BD 2173                                jsr Plane2
  253:                                                 
  254:     20BD 32                                     pula
  255:     20BE 39                                     rts
  256:                                 ;**************************************************************************
  257:                                 ;Subroutine for the Barcodes output(Plane 3)
  258:                                 ;
  259:                                 ;**************************************************************************
  260:                                                 
  261:     20BF 36                     BarPlane3:      psha
  262:                                         
  263:     20C0 BD 2086                                jsr LeaveShoot                  
  264:                                                                         
  265:     20C3 BD 21E1                                jsr Plane3
  266:                                                 
  267:     20C6 32                                     pula
  268:     20C7 39                                     rts
  269:                                 ;**************************************************************************
  270:                                 ; this section moves the robot to the first plane and then moves it back to the 1st t intersection
  271:                                 ;**************************************************************************
  272:     20C8 36                     Plane1:         psha
  273:                                 
  274:     20C9 BD 22F1                                jsr go_forward
  275:     20CC 86 07                                  ldaa #7
  276:     20CE BD 2378                                jsr pause
  277:     20D1 BD 22DF                                jsr go_stop
  278:     20D4 86 05                                  ldaa #5
  279:     20D6 BD 2378                                jsr pause
  280:     20D9 BD 22B5                                jsr clockw              ;90 Right Turn from 1st T
  281:                                 
  282:     20DC BD 22DF                                jsr go_stop
  283:     20DF 86 14                                  ldaa #20
  284:     20E1 BD 2378                                jsr pause
  285:     20E4 BD 2241                                jsr Linetrack           ;Stops at 2nd plus by Loading Zone 1
  286:     20E7 BD 22F1                                jsr go_forward          
  287:     20EA 86 03                                  ldaa #3
  288:     20EC BD 2378                                jsr pause
  289:                                                 
  290:     20EF BD 2241                                jsr Linetrack
  291:                                                 
  292:     20F2 BD 238B                                jsr Left90              ; turns to the airplane
  293:     20F5 BD 22DF                                jsr go_stop             
  294:     20F8 86 19                                  ldaa #25        
  295:     20FA BD 2378                                jsr pause
  296:                                 
  297:                                                         
  298:     20FD BD 2354                                jsr go_Open             ; for the simple robot must remove
  299:     2100 86 0A                                  ldaa #10                        ; and replace with carrage dump section
  300:     2102 BD 2378                                jsr pause               ;*
  301:                                 
  302:                                                 
  303:                                 
  304:                                 ;firstl:        jsr LT_cont             ; this section turns robot back to the line
  305:                                 ;               ldaa LTCB               ; *
  306:                                 ;               cmpa #$07               ; *
  307:                                 ;               bne  firstl             ; *
  308:                                 ;secondl:       jsr LT_cont             ; *
  309:                                 ;               ldaa LTCB               ; *
  310:                                 ;               cmpa #$07               ; *
  311:                                 ;               bne  secondl            ; *
  312:                                                 
  313:     2105 BD 22CA                                jsr counterclck
  314:                                 
  315:                                 
  316:     2108 BD 2241                                jsr linetrack           ; moves the robot forward to the 2nd plus
  317:     210B BD 22F1                                jsr go_forward          ; this section moves the robot back to the 
  318:     210E 86 05                                  ldaa #5         
  319:     2110 BD 2378                                jsr pause
  320:     2113 BD 2241                                jsr linetrack
  321:                                 
  322:     2116 BD 22F1                                jsr go_forward
  323:     2119 86 07                                  ldaa #7
  324:     211B BD 2378                                jsr pause
  325:                                                 
  326:                                                 
  327:     211E BD 22CA                                jsr counterclck
  328:     2121 BD 22DF                                jsr go_stop
  329:     2124 86 05                                  ldaa #5         
  330:                                 
  331:     2126 BD 2241                                jsr Linetrack           ;       
  332:     2129 BD 2378                                jsr pause               ;
  333:                                 
  334:                                                 
  335:                                 
  336:     212C 32                                     pula
  337:                                 
  338:     212D 39                                     rts
  339:                                 ;**************************************************************************
  340:                                 ; this section just moves the robot from the first t intersection 
  341:                                 ; to the 3rd plus intersection between robots 2 and 3
  342:                                 ;
  343:                                 ;
  344:                                 ;******************************************************************************
  345:     212E 36                     Shoot2:         psha
  346:                                                 
  347:     212F BD 2241                                jsr Linetrack
  348:     2132 BD 22F1                                jsr go_forward
  349:     2135 86 08                                  ldaa #8
  350:     2137 BD 2378                                jsr pause
  351:                                                 
  352:     213A BD 2241                                jsr Linetrack
  353:                                 
  354:     213D BD 22B5                                jsr clockw              ;Goes back to Shoot
  355:     2140 BD 22DF                                jsr go_stop             ;
  356:     2143 86 0A                                  ldaa #10
  357:     2145 BD 2378                                jsr pause
  358:                                 
  359:     2148 BD 22F1                                jsr go_forward
  360:     214B 86 0F                                  ldaa #15
  361:     214D BD 2378                                jsr pause
  362:                                 
  363:     2150 BD 22DF                                jsr go_stop
  364:     2153 86 0A                                  ldaa #10
  365:     2155 BD 2378                                jsr pause
  366:                                 
  367:     2158 BD 235A                                jsr go_close
  368:     215B 86 14                                  ldaa #20
  369:     215D BD 2378                                jsr pause
  370:                                 
  371:                                                 ;jsr arm up
  372:                                                 ;jsr scanner            ;barcode scanner
  373:                                                 ;ldaa barcode
  374:                                                 ;cmpa #01
  375:                                                 ;beq barplane1
  376:                                 
  377:                                                 ;cmpa #02
  378:                                                 ;beq barplane2
  379:                                 
  380:                                                 ;cmpa #03
  381:                                                 ;beq barplane3
  382:                                                 
  383:     2160 32                                     pula
  384:     2161 39                                     rts
  385:                                 ;
  386:                                 ;                       
  387:                                 ;**************************************************************************
  388:                                 ; this section just moves the robot from the first t intersection 
  389:                                 ; to the 3rd plus intersection between robots 2 and 3
  390:                                 ;
  391:                                 ;
  392:                                 ;******************************************************************************
  393:     2162 36                     GoToPlanes23:   psha
  394:     2163 BD 22F1                                jsr go_forward  
  395:     2166 86 05                                  ldaa #5
  396:     2168 BD 2378                                jsr pause
  397:     216B BD 22B5                                jsr clockw
  398:     216E BD 2241                                jsr linetrack
  399:     2171 32                                     pula
  400:     2172 39                                     rts
  401:                                 ;
  402:                                 ;                       
  403:                                 ;**************************************************************************
  404:                                 ; this section moves to the second plane and back to the 3rd plus intersection
  405:                                 ;**************************************************************************
  406:     2173 36                     Plane2:         psha
  407:                                                 
  408:     2174 BD 22F1                                jsr go_forward
  409:     2177 86 05                                  ldaa #5
  410:     2179 BD 2378                                jsr pause
  411:                                                 
  412:     217C BD 2241                                jsr Linetrack
  413:                                                 
  414:     217F BD 22F1                                jsr go_forward
  415:     2182 86 0A                                  ldaa #10
  416:     2184 BD 2378                                jsr pause
  417:                                 
  418:     2187 BD 22B5                                jsr clockw              ;90 Right Turn from 3rd plus
  419:                                                 
  420:     218A BD 22DF                                jsr go_stop
  421:     218D 86 14                                  ldaa #20
  422:     218F BD 2378                                jsr pause
  423:     2192 BD 2241                                jsr Linetrack           ;Stops at 4th plus by Loading Zone 1
  424:     2195 BD 22F1                                jsr go_forward
  425:     2198 86 0A                                  ldaa #10
  426:     219A BD 2378                                jsr pause
  427:     219D BD 2241                                jsr Linetrack           ; moves forward until side of board
  428:     21A0 86 05                                  ldaa #5
  429:     21A2 BD 2378                                jsr pause
  430:                                                 
  431:     21A5 BD 238B                                jsr Left90
  432:     21A8 BD 22DF                                jsr go_stop
  433:     21AB 86 05                                  ldaa #5
  434:     21AD BD 2378                                jsr pause
  435:                                         
  436:     21B0 BD 2354                                jsr go_Open             ; this section for the simple robot 
  437:     21B3 86 0A                                  ldaa #10                        ; this is where the carrage drop occurs
  438:     21B5 BD 2378                                jsr pause
  439:                                                 
  440:                                 ;AlmostThere:   jsr LT_cont             ; the robot moves forward to the line here
  441:                                 ;               ldaa LTCB               ; *
  442:                                 ;               cmpa #$07               ; *
  443:                                 ;               bne  AlmostThere        ; *
  444:                                                                         ; *
  445:     21B8 BD 22CA                                jsr counterclck
  446:                                                                         ; here turn towards the 4th plus
  447:                                                         
  448:     21BB BD 2241                                jsr linetrack           ; move to the 3rd plus intersection
  449:     21BE BD 22F1                                jsr go_forward                          
  450:     21C1 86 05                                  ldaa #5 
  451:     21C3 BD 2378                                jsr pause
  452:     21C6 BD 2241                                jsr linetrack           ; here stops at the 3rd plus intersection
  453:                                 
  454:     21C9 BD 22F1                                jsr go_forward
  455:     21CC 86 09                                  ldaa #9
  456:     21CE BD 2378                                jsr pause
  457:                                 
  458:     21D1 BD 22CA                                jsr counterclck
  459:     21D4 BD 2241                                jsr Linetrack
  460:                                 
  461:     21D7 BD 22F1                                jsr go_forward
  462:     21DA 86 05                                  ldaa #5
  463:     21DC BD 2378                                jsr pause
  464:                                 
  465:                                                 
  466:                                 
  467:     21DF 32                                     pula
  468:                                 
  469:     21E0 39                                     rts
  470:                                 ;******************************************************************************************************
  471:                                 ; this section moves from the 3rd plus to the 3rd plane and back
  472:                                 ;******************************************************************************************************
  473:     21E1                        Plane3:
  474:     21E1 BD 22F1                                jsr go_forward          ; moves forward to make linetrack work
  475:     21E4 86 05                                  ldaa #5
  476:     21E6 BD 2378                                jsr pause
  477:     21E9 BD 2241                                jsr Linetrack           ; moves forward until 5th plus
  478:     21EC BD 22F1                                jsr go_forward          ; moves forward so line track will work
  479:     21EF 86 05                                  ldaa #5
  480:     21F1 BD 2378                                jsr pause
  481:                                                 
  482:     21F4 BD 22CA                                jsr counterclck         ; moves forward to edge of board
  483:                                                 
  484:     21F7 BD 2241                                jsr Linetrack
  485:                                                 
  486:     21FA BD 22F1                                jsr go_forward
  487:     21FD 86 05                                  ldaa #5
  488:     21FF BD 2378                                jsr pause
  489:                                 
  490:     2202 BD 2241                                jsr Linetrack
  491:                                 
  492:     2205 BD 2396                                jsr Right90             ; turns to back up to back up to plane
  493:     2208 BD 22DF                                jsr go_stop
  494:     220B 86 05                                  ldaa #5
  495:     220D BD 2378                                jsr pause
  496:                                                                 ;sonar goes here
  497:     2210 BD 2354                                jsr go_Open             ; simple robot code here where comp code goes
  498:     2213 86 0A                                  ldaa #10                ; *
  499:     2215 BD 2378                                jsr pause               ; this section moves the robot back to the line
  500:                                                 
  501:                                 ;NotThereYet:   jsr LT_cont             ; *
  502:                                         ;       ldaa LTCB               ; *
  503:                                         ;       cmpa #$07               ; *
  504:                                         ;       bne  NotThereYet        ; *
  505:                                                                         ; *
  506:     2218 BD 22B5                                jsr clockw              ; turns the robot back towards the 5th plus sign
  507:                                                 
  508:                                 
  509:     221B BD 2241                                jsr linetrack           ; moves the robot to the 5th plus sign
  510:     221E BD 22F1                                jsr go_forward          ; moves robot past the 5th plus sign
  511:     2221 86 05                                  ldaa #5         
  512:     2223 BD 2378                                jsr pause
  513:     2226 BD 2241                                jsr linetrack           ; moves robot to the 3rd plus sign
  514:                                 
  515:     2229 BD 22F1                                jsr go_forward  
  516:     222C 86 0A                                  ldaa #10
  517:     222E BD 2378                                jsr pause
  518:                                 
  519:     2231 BD 22B5                                jsr clockw
  520:                                         
  521:     2234 BD 2241                                jsr Linetrack
  522:                                                 
  523:     2237 BD 22F1                                jsr go_forward
  524:     223A 86 05                                  ldaa #5
  525:     223C BD 2378                                jsr pause
  526:                                 
  527:                                 
  528:                                                 
  529:     223F 32                                     pula
  530:     2240 39                                     rts
  531:                                 ;**************************************************************************
  532:                                 ;Name:          LineTrack
  533:                                 ;Author:        Dominic Lawrence
  534:                                 ;Date:          unknown
  535:                                 ;Modifications: 
  536:                                 ;               DK 3/4/06 
  537:                                 ;                  add tests for LTCB=6 and LTCB = 3 to improve line
  538:                                 ;                  following. 
  539:                                 ;
  540:                                 ;Process:       First it calls LT_CONT that sets the LTCB. Then LTCB is  
  541:                                 ;               tested and the appropriate sub routine is called to 
  542:                                 ;               turn turned on/off the drive motors accordingly.
  543:                                 ;**************************************************************************
  544:                                 
  545:     2241 36                     LineTrack:      psha
  546:     2242 3C                                     pshx
  547:                                                 
  548:     2243 BD 2284                Lt_loop:        jsr Lt_cont
  549:                                                 
  550:     2246 B6 201F                FirstT:         ldaa LTCB       ; checks the center sensors
  551:     2249 81 02                                  cmpa #$02
  552:     224B 27 26                                  beq  FForward
  553:                                                 
  554:     224D 81 04                                  cmpa #$04       ; checks sensors for if to far left
  555:     224F 27 16                                  beq  RTurn
  556:     2251 81 06                                  cmpa #$06
  557:     2253 27 12                                  beq  Rturn
  558:                                                         
  559:     2255 81 01                                  cmpa #$01       ; checks sensors for if to far right
  560:     2257 27 14                                  beq  LTurn
  561:     2259 81 03                                  cmpa #$03
  562:     225B 27 10                                  beq  LTurn
  563:     225D 81 07                                  cmpa #$07
  564:     225F 27 18                                  beq  SStop
  565:                                                 
  566:     2261 BD 22F1                                jsr go_forward
  567:     2264 7E 2243                                jmp Lt_loop
  568:                                                 
  569:                                  
  570:     2267 BD 22EB                RTurn:          jsr  go_right           ; jumps to sub that moves robot to the right    
  571:     226A 7E 2243                                jmp  Lt_loop
  572:                                 
  573:     226D BD 22E5                LTurn:          jsr  go_left            ; jumps to sub that moves robot to the left
  574:     2270 7E 2243                                jmp  Lt_loop
  575:                                 
  576:     2273 BD 22F1                FForward:       jsr  go_Forward         ; jumps to sub that moves robot forward
  577:     2276 7E 2243                                jmp  Lt_loop
  578:                                 
  579:     2279 BD 22DF                SStop:          jsr go_stop             ; jumps to stop sub
  580:     227C 86 14                                  ldaa #20
  581:     227E BD 2378                                jsr pause 
  582:                                                 
  583:     2281 38                                     pulx            
  584:     2282 32                                     pula
  585:     2283 39                                     rts             
  586:                                 ;**************************************************************************
  587:                                 ;Name:          Lt_cont - Line Track Control Word
  588:                                 ;Author:        Dominic Lawrence
  589:                                 ;Date:          unknown
  590:                                 ;Modifications: 
  591:                                 ;               AA 03/??/06
  592:                                 ;                  Made into a separate sub routine
  593:                                 ;
  594:                                 ;Function:      Takes the inputs for each linetrack sensor and compares 
  595:                                 ;               it to the LTL (Line Track Limit). If it is below LTL the 
  596:                                 ;               sensor is inidcating it is on the line and the
  597:                                 ;               corresponding bit is set in LTCB (Line Track Control Byte).
  598:                                 ;
  599:                                 ;               LTCB = xxxxx000
  600:                                 ;                           ||=>  Left Linetrack Sensor
  601:                                 ;                           |==>  center Linetrack sensor
  602:                                 ;                           |==>  right Line track
  603:                                 ;
  604:                                 ;On Return:     LTCL is set as per above
  605:                                 ;**************************************************************************
  606:     2284 36                     Lt_cont:        psha
  607:     2285 3C                                     pshx
  608:                                 
  609:     2286 86 00                                  Ldaa #$0
  610:     2288 B7 201F                                Staa LTCB
  611:     228B B6 1032                                Ldaa Adr2
  612:     228E 81 94                                  Cmpa #LTL
  613:     2290 24 06                                  BHS  CheckCenter
  614:     2292 CE 201F                                Ldx  #LTCB
  615:     2295 1C 00 04                               Bset 0,x #$04
  616:                                 
  617:     2298 B6 1033                CheckCenter:    Ldaa Adr3
  618:     229B 81 9F                                  Cmpa #$9F
  619:     229D 24 06                                  BHS  CheckLeft
  620:     229F CE 201F                                Ldx  #LTCB
  621:     22A2 1C 00 02                               Bset 0,x #$02
  622:                                 
  623:     22A5 B6 1034                CheckLeft:      Ldaa Adr4
  624:     22A8 81 94                                  cmpa #LTL
  625:     22AA 24 06                                  BHS  lt_exit
  626:     22AC CE 201F                                Ldx  #LTCB
  627:     22AF 1C 00 01                               Bset 0,x #$01
  628:                                 
  629:     22B2 38                     lt_exit:        pulx
  630:     22B3 32                                     pula
  631:                                                 
  632:     22B4 39                                     rts
  633:                                 ;**************************************************************************
  634:                                 ; This section will cause the robot to turn to the right until it hits a 
  635:                                 ; white line with the line tracking sensors
  636:                                 ;**************************************************************************
  637:     22B5                        clockw:         
  638:     22B5 36                                     psha
  639:     22B6 BD 22EB                                jsr go_right
  640:     22B9 86 05                                  ldaa #5
  641:     22BB BD 2378                                jsr pause
  642:     22BE BD 2284                clockw_Loop:    jsr LT_cont             
  643:     22C1 B6 201F                                ldaa LTCB               
  644:     22C4 81 02                                  cmpa #$02
  645:     22C6 26 F6                                  bne clockw_Loop 
  646:                                                 
  647:     22C8 32                                     pula
  648:     22C9 39                                     rts
  649:                                 ;**************************************************************************
  650:                                 ; This section will cause the robot to turn to the Left until it hits a 
  651:                                 ; white line with the line tracking sensors
  652:                                 ;*************************************************************************
  653:     22CA                        counterclck:    
  654:     22CA 36                                     psha
  655:     22CB BD 22E5                                jsr go_left
  656:     22CE 86 05                                  ldaa #5
  657:     22D0 BD 2378                                jsr pause
  658:     22D3 BD 2284                counter_Loop:   jsr LT_cont             
  659:     22D6 B6 201F                                ldaa LTCB               
  660:     22D9 81 02                                  cmpa #$02
  661:     22DB 26 F6                                  bne  counter_Loop
  662:                                                 
  663:     22DD 32                                     pula
  664:     22DE 39                                     rts
  665:                                 ;**************************************************************************
  666:                                 ;Name:          Drive Motor Functions
  667:                                 ;Author:        Dan Kohn
  668:                                 ;Date:          Dec 9, 2005
  669:                                 ;Functions:     Each separtate function will do the indicated function 
  670:                                 ;               to the robot drive motors
  671:                                 ;
  672:                                 ;               go_Stop
  673:                                 ;               go_Left
  674:                                 ;               go_Right
  675:                                 ;               go_Forward
  676:                                 ;               go_Reverse
  677:                                 ;               never enter at robot_do! (Stack will be corrupted)
  678:                                 ;**************************************************************************
  679:                                 
  680:     22DF 3C                     go_Stop         pshx
  681:     22E0 CE 2313                                ldx #Stop
  682:     22E3 20 18                                  bra robot_do
  683:                                 
  684:     22E5 3C                     go_Left         pshx
  685:     22E6 CE 2333                                ldx #Left
  686:     22E9 20 12                                  bra robot_do
  687:                                 
  688:     22EB 3C                     go_Right        pshx
  689:     22EC CE 232B                                ldx #Right
  690:     22EF 20 0C                                  bra robot_do
  691:                                 
  692:     22F1 3C                     go_Forward      pshx
  693:     22F2 CE 2323                                ldx #Forward
  694:     22F5 20 06                                  bra robot_do
  695:                                 
  696:     22F7 3C                     go_Reverse      pshx
  697:     22F8 CE 231B                                ldx #Reverse
  698:     22FB 20 00                                  bra robot_do
  699:                                 
  700:     22FD EC 00                  robot_do        ldd 0,x
  701:     22FF FD 2003                                std On_cnts_R
  702:     2302 EC 02                                  ldd 2,x
  703:     2304 FD 2005                                std Off_cnts_R
  704:     2307 EC 04                                  ldd 4,x
  705:     2309 FD 2007                                std On_cnts_L
  706:     230C EC 06                                  ldd 6,x
  707:     230E FD 2009                                std Off_cnts_L
  708:     2311 38                                     pulx
  709:     2312 39                                     rts
  710:                                 
  711:                                 ;Table for Drive Motor Functions
  712:                                 ;                       On_cnts_R       Off_cnts_R      On_cnts_L       Off_cnts_L
  713:                                 
  714:     2313 0BB8 9088 0BB8         Stop            fdb     3000,           37000,          3000,           37000
           2319 9088 
  715:     231B 07D0 9470 0FA0         REVERSE         fdb     2000,           38000,          4000,           36000
           2321 8CA0 
  716:     2323 0FA0 8CA0 07D0         FORWARD         fdb     4000,           36000,          2000,           38000
           2329 9470 
  717:     232B 07D0 9470 07D0         RIGHT           fdb     2000,           38000,          2000,           38000
           2331 9470 
  718:     2333 0FA0 8CA0 0FA0         LEFT            fdb     4000,           36000,          4000,           36000
           2339 8CA0 
  719:                                 
  720:                                 ;Servo Motor notes:
  721:                                 ;       1ms on time = 2000 counts = forward
  722:                                 ;       2ms on time = 4000 counts = reverse
  723:                                 ;       total counts for a 50hz square wave (20mSec - suggested for servos) is 40000 counts
  724:                                 ;**************************************************************************
  725:                                 ;Name:          A2D
  726:                                 ;Author:        Dan Kohn
  727:                                 ;Date:          Jan 5, 2006
  728:                                 ;Functions:     Set up A/D to read PE0..PE3 continuously and  
  729:                                 ;               place the converted values in ADR1..ADR4
  730:                                 ;
  731:                                 ;On call:       NONE
  732:                                 ;
  733:                                 ;On Return;     A/D is turned on and running continously 
  734:                                 ;**************************************************************************
  735:                                 
  736:     233B 3C                     A2D:            pshx
  737:     233C 36                                     psha
  738:                                         
  739:     233D CE 1039                                ldx #option             ;setup A/D
  740:     2340 1C 00 80                               bset 0,x #$80           ;Turn on A/D - ADPU
  741:     2343 1D 00 40                               bclr 0,x #$40           ;Use E clock
  742:                                                 
  743:     2346 86 30                                  ldaa #$30               ;Set up to read PE0..PE3
  744:     2348 B7 1030                                staa ADCTL              ;Continuously
  745:                                 
  746:     234B 32                                     pula
  747:     234C 38                                     pulx
  748:                                                 
  749:     234D 39                                     rts
  750:                                 ;**************************************************************************
  751:                                 ;Name:          Multiplexed Motor Functions
  752:                                 ;Author:        Michael mcneill
  753:                                 ;Date:          Feb 9, 2006
  754:                                 ;Functions:     Each separtate function will do the indicated function 
  755:                                 ;               to the robot drive motors
  756:                                 ;
  757:                                 ;               go_Gstop
  758:                                 ;               go_Open
  759:                                 ;               go_Close
  760:                                 ;               go_Forward
  761:                                 ;               go_Reverse
  762:                                 ;
  763:                                 ;               never enter at robot_go! (Stack will be corrupted)
  764:                                 ;**************************************************************************
  765:     234E                        Gripper:
  766:                                 
  767:     234E 3C                     go_Gstop        pshx
  768:     234F CE 2374                                ldx #Gstop
  769:     2352 20 0C                                  bra robot_go
  770:                                 
  771:     2354 3C                     go_Open         pshx
  772:     2355 CE 2370                                ldx #Open
  773:     2358 20 06                                  bra robot_go
  774:                                 
  775:     235A 3C                     go_Close        pshx
  776:     235B CE 236C                                ldx #Close
  777:     235E 20 00                                  bra robot_go
  778:                                 
  779:     2360 EC 00                  robot_go        ldd 0,x
  780:     2362 FD 200B                                std On_cnts_G
  781:     2365 EC 02                                  ldd 2,x
  782:     2367 FD 200D                                std Off_cnts_G
  783:                                                 
  784:     236A 38                                     pulx
  785:     236B 39                                     rts
  786:                                 ;Table for Multiplexed Servo
  787:                                 ;                       On_cnts_G       Off_cnts_G
  788:     236C 0FA0 8CA0              CLOSE           fdb     4000,           36000                           
  789:     2370 07D0 9470              Open            fdb     2000,           38000
  790:     2374 0BB8 9088              Gstop           fdb     3000,           37000
  791:                                 ;Servo Motor notes:
  792:                                 ;       1ms on time = 2000 counts = forward
  793:                                 ;       2ms on time = 4000 counts = reverse
  794:                                 ;       total counts for a 50hz square wave (20mSec - suggested for servos) is 40000 counts
  795:                                 ;**************************************************************************
  796:                                 ;Name:          Pause
  797:                                 ;Author:        Dan Kohn
  798:                                 ;Date:          Dec 19, 2005
  799:                                 ;Functions:     Pause for multiple of 0.1 sec 
  800:                                 ;               (setup for a 0.1 sec counter)
  801:                                 ;
  802:                                 ;On call:       Reg A Contains the number of 0.1 sec to pause
  803:                                 ;
  804:                                 ;On Return;     Sec_Count and Sec_Temp were changed (cleared at start of 
  805:                                 ;               pause.
  806:                                 ;**************************************************************************
  807:     2378 36                     Pause:          psha
  808:     2379 37                                     pshb
  809:     237A C6 00                                  ldab #$00
  810:     237C F7 2015                                stab SEC_TEMP
  811:     237F F7 2016                                stab SEC_COUNT
  812:                                                 
  813:     2382 F6 2016                PauseL1:        ldab sec_count
  814:     2385 11                                     cba
  815:     2386 26 FA                                  bne PauseL1
  816:                                                 
  817:     2388 33                                     pulb
  818:     2389 32                                     pula
  819:     238A 39                                     rts
  820:                                 ;**************************************************************************
  821:                                 ;**************************************************************************
  822:     238B 36                     Left90: psha
  823:                                                 
  824:     238C BD 22E5                                jsr go_left
  825:     238F 86 09                                  ldaa #9
  826:     2391 BD 2378                                jsr pause
  827:                                                 
  828:     2394 32                                     pula 
  829:     2395 39                                     rts
  830:                                 ;**************************************************************************
  831:                                 ;**************************************************************************
  832:     2396 36                     Right90:        psha
  833:                                 
  834:     2397 BD 22EB                                jsr go_right
  835:     239A 86 09                                  ldaa #9
  836:     239C BD 2378                                jsr pause               
  837:                                                 
  838:     239F 32                                     pula
  839:     23A0 39                                     rts
  840:                                 ;**************************************************************************
  841:                                 ;Name:          TOF_init
  842:                                 ;Author:        Dan Kohn
  843:                                 ;Date:          Dec 14, 2005
  844:                                 ;Functions:     Initializes the TOF Function 
  845:                                 ;               (setup for a 0.5 sec counter)
  846:                                 ;**************************************************************************
  847:                                 
  848:     23A1 36                     TOF_init        psha
  849:     23A2 3C                                     pshx
  850:     23A3 183C                                   pshy
  851:                                 
  852:     23A5 0F                                     SEI
  853:                                 
  854:     23A6 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
  855:     23A8 97 D0                                  STAA TOFIV
  856:                                 
  857:     23AA CC 23E0                                LDD #TOF_CNT
  858:     23AD DD D1                                  STD TOFIV+1
  859:                                 
  860:     23AF 86 80                                  ldaa #$80               ;clear TOF flag
  861:     23B1 B7 1025                                staa TFLG2
  862:                                         
  863:     23B4 CE 1024                                LDX #TMSK2              ;turn on TOF interrupt
  864:     23B7 1C 00 80                               bset 0,x #$80
  865:                                 
  866:     23BA 0E                                     cli 
  867:                                 
  868:     23BB 18CE 0000                              ldy #0                  ;clear 1 sec counter for planes
  869:     23BF 18FF 2017                              sty plane_temp
  870:                                 
  871:     23C3 18CE 00B4                              ldy #180                ;set plane 1's time for 180sec
  872:     23C7 18FF 2019                              sty plane1_cd
  873:                                 
  874:     23CB 18CE 00F0                              ldy #240                ;set plane 2's time for 240sec
  875:     23CF 18FF 201B                              sty plane2_cd
  876:                                 
  877:     23D3 18CE 0168                              ldy #360                ;set plane 3's time for 300sec
  878:     23D7 18FF 201D                              sty plane3_cd
  879:                                                 
  880:     23DB 1838                                   puly
  881:     23DD 38                                     pulx
  882:     23DE 32                                     pula
  883:                                 
  884:     23DF 39                                     rts
  885:                                 ;**************************************************************************
  886:                                 ;Name:          TOF_CNT
  887:                                 ;Author:        Dan Kohn
  888:                                 ;Date:          Dec 14, 2005
  889:                                 ;Functions:     count every 0.1 sec.  
  890:                                 ;
  891:                                 ;On Return:     Count of 0.1 sec intervals is in SEC_count
  892:                                 ;               Count of 32.77mSec intervals is in Sec_Temp
  893:                                 ;**************************************************************************
  894:     23E0 86 80                  TOF_CNT         ldaa #$80
  895:     23E2 B7 1025                                staa TFLG2      
  896:                                                 
  897:     23E5 B6 2015                                ldaa Sec_temp           ;count # of times overflow occures (32.77ms)
  898:     23E8 4C                                     inca 
  899:     23E9 B7 2015                                staa Sec_temp
  900:                                 
  901:     23EC 81 03                                  cmpa #03                ;if ~0.1sec has NOT gone by -> exit
  902:     23EE 25 0C                                  blo plane_time          ;      [3*32.77mSec = 0.0983100 Sec]
  903:                                 
  904:                                 
  905:     23F0 86 00                                  ldaa #$00               ;if ~0.1sec has gone by -> clear Sec_temp
  906:     23F2 B7 2015                                staa Sec_temp           ;and add one to the Sec_count
  907:                                 
  908:     23F5 B6 2016                                ldaa Sec_count
  909:     23F8 4C                                     inca 
  910:     23F9 B7 2016                                staa Sec_count
  911:                                                 
  912:     23FC 18FE 2017              plane_time:     ldy plane_temp          ;count # of times overflow occures (32.77ms)
  913:     2400 1808                                   iny 
  914:     2402 18FF 2017                              sty plane_temp
  915:                                 
  916:     2406 188C 001E                              cpy #30                 ;if ~1sec has NOT gone by -> exit
  917:     240A 25 38                                  blo tof_exit            ;      [30*32.77mSec = .98310 Sec]
  918:                                 
  919:                                 
  920:     240C 18CE 0000                              ldy #$00                ;if ~0.1sec has gone by -> clear Sec_temp
  921:     2410 18FF 2017                              sty plane_temp          ;and add one to the Sec_count
  922:                                 
  923:     2414 18FE 2019                              ldy plane1_cd           ;count down timer for plane 1
  924:     2418 188C 0000                              cpy #0
  925:     241C 27 06                                  beq pt_2
  926:     241E 1809                                   dey
  927:     2420 18FF 2019                              sty plane1_cd
  928:                                 
  929:     2424 18FE 201B              pt_2:           ldy plane2_cd           ;count down timer for plane 2
  930:     2428 188C 0000                              cpy #0
  931:     242C 27 06                                  beq pt_3
  932:     242E 1809                                   dey
  933:     2430 18FF 201B                              sty plane2_cd
  934:                                 
  935:     2434 18FE 201D              pt_3:           ldy plane3_cd           ;count down timer for plane 3
  936:     2438 188C 0000                              cpy #0
  937:     243C 27 06                                  beq TOF_exit
  938:     243E 1809                                   dey
  939:     2440 18FF 201D                              sty plane3_cd
  940:                                 
  941:     2444 3B                     TOF_exit        RTI
  942:                                 
  943:                                 ;**************************************************************************
  944:                                 ;Name:          TOC2_init
  945:                                 ;Author:        Dan Kohn
  946:                                 ;Date:          Dec 8, 2005
  947:                                 ;Functions:     Initalize the Right Motor (OC2) 
  948:                                 ;
  949:                                 ;On Call:       go_stop MUST be called before initalizing 
  950:                                 ;**************************************************************************
  951:     2445 36                     TOC2_init       psha
  952:     2446 37                                     pshb
  953:     2447 3C                                     pshx
  954:                                 
  955:     2448 0F                                     SEI
  956:                                 
  957:     2449 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
  958:     244B 97 DC                                  STAA TOC2IV
  959:                                 
  960:     244D CC 2474                                LDD #TOC2RT
  961:     2450 DD DD                                  STD TOC2IV+1
  962:                                 
  963:     2452 FC 100E                                LDD TCNT                ;sets the first time of TOC2
  964:     2455 F3 2003                                ADDD On_cnts_R
  965:     2458 FD 1018                                STD TOC2
  966:                                 
  967:     245B 86 40                                  LDAA #$40               ;intializing the registers
  968:     245D B7 1023                                staa TFLG1
  969:                                 
  970:     2460 CE 1022                                ldx #TMSK1
  971:     2463 1C 00 40                               BSET 0,X #$40
  972:                                 
  973:     2466 CE 1020                                LDX #TCTL1              ;toggles the output
  974:     2469 1C 00 40                               BSET 0,X #$40
  975:     246C 1D 00 80                               BCLR 0,x #$80
  976:                                 
  977:                                 
  978:     246F 0E                                     CLI                     ;turning on the interrupts
  979:                                 
  980:     2470 38                                     pulx
  981:     2471 33                                     pulb
  982:     2472 32                                     pula 
  983:                                 
  984:     2473 39                                     rts
  985:                                 ;**************************************************************************
  986:                                 ;Name:          TOC2IV
  987:                                 ;Author:        Gregory Reeves Jr.
  988:                                 ;Date:          July 30, 2005
  989:                                 ;Modified:      Dan Kohn Dec 8, 2005 For Dual Output Compares
  990:                                 ;Function:      Interrupt for PWM for Right Motor
  991:                                 ;On Call        On_cnts_R and Off_cnts_R 
  992:                                 ;**************************************************************************
  993:     2474 86 40                  TOC2RT          LDAA #$40               ;resets the OC2F bit
  994:     2476 B7 1023                                STAA TFLG1
  995:                                 
  996:     2479 B6 1000                                LDAA PORTA              ;check oc2 pin for on or off state
  997:     247C 84 40                                  ANDA #$40
  998:     247E 26 0B                                  BNE ON_2
  999:                                 
 1000:     2480 FC 1018                                LDD TOC2                ;sets up for the off time sequence
 1001:     2483 F3 2005                                ADDD Off_cnts_R
 1002:     2486 FD 1018                                STD TOC2
 1003:     2489 20 09                                  BRA EXIT_2
 1004:                                 
 1005:     248B FC 1018                ON_2            LDD TOC2                ;sets up for the next ontime sequence
 1006:     248E F3 2003                                ADDD On_cnts_R
 1007:     2491 FD 1018                                STD TOC2
 1008:                                 
 1009:     2494 3B                     EXIT_2          RTI                     ;return from the interrupt
 1010:                                 ;**************************************************************************
 1011:                                 ;Name:          TOC3_init
 1012:                                 ;Author:        Dan Kohn
 1013:                                 ;Date:          Dec 8, 2005
 1014:                                 ;Functions:     Initalize the Left Motor (OC3) 
 1015:                                 ;
 1016:                                 ;On Call:       go_stop MUST be called before initalizing 
 1017:                                 ;**************************************************************************
 1018:     2495 36                     TOC3_init       psha
 1019:     2496 37                                     pshb
 1020:     2497 3C                                     pshx
 1021:                                 
 1022:     2498 0F                                     SEI
 1023:                                 
 1024:     2499 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1025:     249B 97 D9                                  STAA TOC3IV
 1026:                                 
 1027:     249D CC 24C4                                LDD #TOC3RT
 1028:     24A0 DD DA                                  STD TOC3IV+1
 1029:                                 
 1030:     24A2 FC 100E                                LDD TCNT                ;sets the first time of TOC2
 1031:     24A5 F3 2007                                ADDD On_cnts_L
 1032:     24A8 FD 101A                                STD TOC3
 1033:                                 
 1034:     24AB 86 20                                  LDAA #$20               ;intializing the registers
 1035:     24AD B7 1023                                staa TFLG1
 1036:                                 
 1037:     24B0 CE 1022                                ldx #TMSK1
 1038:     24B3 1C 00 20                               BSET 0,X #$20
 1039:                                 
 1040:     24B6 CE 1020                                LDX #TCTL1              ;toggles the output
 1041:     24B9 1C 00 10                               BSET 0,X #$10
 1042:     24BC 1D 00 20                               BCLR 0,x #$20
 1043:                                 
 1044:     24BF 0E                                     CLI                     ;turning on the interrupts
 1045:                                 
 1046:     24C0 38                                     pulx    
 1047:     24C1 33                                     pulb
 1048:     24C2 32                                     pula 
 1049:                                 
 1050:     24C3 39                                     rts
 1051:                                 ;**************************************************************************
 1052:                                 ;Name:          TOC3IV
 1053:                                 ;Author:        Gregory Reeves Jr.
 1054:                                 ;Date:          July 30, 2005
 1055:                                 ;Modified:      Dan Kohn Dec 8, 2005 For Dual Output Compares
 1056:                                 ;Function:      Interrupt for PWM for Left Motor
 1057:                                 ;On Call        On_cnts_L and Off_cnts_L 
 1058:                                 ;**************************************************************************
 1059:     24C4 86 20                  TOC3RT          LDAA #$20               ;resets the OC3F bit
 1060:     24C6 B7 1023                                STAA TFLG1
 1061:                                 
 1062:     24C9 B6 1000                                LDAA PORTA              ;check oc3 pin for on or off state
 1063:     24CC 84 20                                  ANDA #$20
 1064:     24CE 26 0B                                  BNE ON_3
 1065:                                 
 1066:     24D0 FC 101A                                LDD TOC3                ;sets up for the off time sequence
 1067:     24D3 F3 2009                                ADDD Off_cnts_L
 1068:     24D6 FD 101A                                STD TOC3
 1069:     24D9 20 09                                  BRA EXIT_3
 1070:                                 
 1071:     24DB FC 101A                ON_3            LDD TOC3                ;sets up for the next ontime sequence
 1072:     24DE F3 2007                                ADDD On_cnts_L
 1073:     24E1 FD 101A                                STD TOC3
 1074:                                 
 1075:     24E4 3B                     EXIT_3          RTI                     ;return from the interrupt
 1076:                                 
 1077:                                 ;**************************************************************************
 1078:                                 ;Name:          TOC3_init
 1079:                                 ;Author:        Michael McNeill, Jr.
 1080:                                 ;Date:          ??
 1081:                                 ;Functions:     Initalize the Multiplexed Servo (OC4) 
 1082:                                 ;
 1083:                                 ;On Call:       go_Gstop MUST be called before initalizing 
 1084:                                 ;**************************************************************************
 1085:     24E5 36                     TOC4_init       psha
 1086:     24E6 37                                     pshb
 1087:     24E7 3C                                     pshx
 1088:                                 
 1089:     24E8 0F                                     SEI
 1090:                                 
 1091:     24E9 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1092:     24EB 97 D6                                  STAA TOC4IV
 1093:                                 
 1094:     24ED CC 2514                                LDD #TOC4RT
 1095:     24F0 DD D7                                  STD TOC4IV+1
 1096:                                 
 1097:     24F2 FC 100E                                LDD TCNT                ;sets the first time of TOC4
 1098:     24F5 F3 200B                                ADDD On_cnts_G
 1099:     24F8 FD 101C                                STD TOC4
 1100:                                 
 1101:     24FB 86 10                                  LDAA #$10               ;intializing the registers
 1102:     24FD B7 1023                                staa TFLG1
 1103:                                 
 1104:     2500 CE 1022                                ldx #TMSK1
 1105:     2503 1C 00 10                               BSET 0,X #$10
 1106:                                 
 1107:     2506 CE 1020                                LDX #TCTL1              ;toggles the output
 1108:     2509 1C 00 04                               BSET 0,X #$4
 1109:     250C 1D 00 08                               BCLR 0,x #$8
 1110:                                 
 1111:                                 
 1112:     250F 0E                                     CLI                     ;turning on the interrupts
 1113:                                 
 1114:     2510 38                                     pulx
 1115:     2511 33                                     pulb
 1116:     2512 32                                     pula 
 1117:                                 
 1118:     2513 39                                     rts
 1119:                                 ;**************************************************************************
 1120:                                 ;Name:          TOC4IV
 1121:                                 ;Author:        Michael McNeill, Jr.
 1122:                                 ;Date:          Feb 1, 2006
 1123:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1124:                                 ;On Call        On_cnts_G and Off_cnts_G 
 1125:                                 ;**************************************************************************
 1126:     2514 86 10                  TOC4RT          LDAA #$10
 1127:     2516 B7 1023                                STAA TFLG1
 1128:                                 
 1129:     2519 B6 1000                                LDAA PORTA
 1130:     251C 84 10                                  ANDA #$10
 1131:     251E 26 0B                                  BNE ON_4
 1132:                                 
 1133:     2520 FC 101C                                LDD TOC4
 1134:     2523 F3 200D                                ADDD off_cnts_G
 1135:     2526 FD 101C                                STD TOC4
 1136:     2529 20 09                                  BRA EXIT_4
 1137:                                 
 1138:     252B FC 101C                ON_4            LDD TOC4                ;sets up for the next ontime sequence
 1139:     252E F3 200B                                ADDD On_cnts_G
 1140:     2531 FD 101C                                STD TOC4
 1141:                                 
 1142:     2534 3B                     EXIT_4          RTI                     ;return from the interrupt
 1143:                                 
 1144:                                 ;**************************************************************************************************
 1145:                                 ;
 1146:                                 ;Name:          Scanner
 1147:                                 ;Author:        Michael McNeill, Jr.
 1148:                                 ;Date:          ??
 1149:                                 ;Functions:     Clears the Scanner buffer, then waits for the interrupt to 
 1150:                                 ;               recieve 33 bits. It then convers the returned bit pattern into plane
 1151:                                 ;               number based on the table below
 1152:                                 ;
 1153:                                 ;               Scanner reading $26 to $03
 1154:                                 ;                               $1e to $02
 1155:                                 ;                               $16 to $01
 1156:                                 ;
 1157:                                 ;Process:       the barcode scanner is read using the falling edge of PA0 (which is 
 1158:                                 ;               attached to the barcode clock). When a falling edge is detected, it 
 1159:                                 ;               reads the barcode data line (comming in on PE7). This data is placed
 1160:                                 ;               into the buffer from the left and shifted to the right. Each character
 1161:                                 ;               is actually 10 bits long. The first bit coming in is a START BIT, then
 1162:                                 ;               8 bits of data, then a PARITY BIT then a STOP bit. 
 1163:                                 ;
 1164:                                 ;               so the finish data buffer will look like this:
 1165:                                 ;
 1166:                                 ;               Byte        4       3       2       1       0
 1167:                                 ;               Bits 7654321076543210765432107654321076543210 
 1168:                                 ;
 1169:                                 ;                    sPxxxxxxxxSsPxxxxxxxxSsPxxxxxxxxS
 1170:                                 ;                    100010011001111110000010001001100
 1171:                                 ;                                            \      /
 1172:                                 ;                                             data representing plane #
 1173:                                 ;
 1174:                                 ;                            Data shifted -->
 1175:                                 ;
 1176:                                 ;               s=stop
 1177:                                 ;               P=Parity
 1178:                                 ;               S=START
 1179:                                 ;
 1180:                                 ;               the data is then compared to the values returned for planes 1,2,3 and
 1181:                                 ;               converted to the plane number. If the scan is bad, $FF will be the result.
 1182:                                 ;               This value is then stored in BOXCODE.
 1183:                                 ;
 1184:                                 ;On Call:       None
 1185:                                 ;
 1186:                                 ;On Return:     BOXCODE containes the plane number indicated by the barcode read ($FF
 1187:                                 ;               indicates an error when scanned).  
 1188:                                 ;*******************************************************************************************
 1189:                                         
 1190:                                 
 1191:     2535                        Scanner:
 1192:     2535 36                             psha
 1193:     2536 BD 25BB                        jsr BC_clear
 1194:                                 
 1195:                                 
 1196:     2539 B6 2025                sc_0:   lDAA BC_count
 1197:     253C 81 21                          cmpa #33
 1198:     253E 25 F9                          BLO sc_0
 1199:                                 
 1200:     2540 B6 2023                        Ldaa Barcode+3          ;Barcode to read #$26 to plane 3
 1201:     2543 81 26                          cmpa #$26
 1202:     2545 26 08                          Bne  sc_1
 1203:     2547 86 03                          ldaa #$03
 1204:     2549 B7 2026                        staa Boxcode
 1205:                                         
 1206:     254C 7E 2572                        jmp sc_exit
 1207:                                 
 1208:     254F                        Sc_1    
 1209:     254F B6 2023                        Ldaa Barcode+3          ;Barcode to read #$1e to plane 2
 1210:     2552 81 1E                          cmpa #$1e
 1211:     2554 26 08                          Bne  sc_2
 1212:     2556 86 02                          ldaa #$02
 1213:     2558 B7 2026                        staa Boxcode
 1214:                                 
 1215:     255B 7E 2572                        jmp sc_exit
 1216:                                 
 1217:     255E                        Sc_2    
 1218:     255E B6 2023                        Ldaa Barcode+3          ;Barcode to read #$16 to plane 1
 1219:     2561 81 16                          cmpa #$16
 1220:     2563 26 08                          Bne  sc_3
 1221:     2565 86 01                          ldaa #$01
 1222:     2567 B7 2026                        staa Boxcode
 1223:                                 
 1224:     256A 7E 2572                        jmp sc_exit
 1225:                                         
 1226:     256D                        Sc_3    
 1227:                                         
 1228:                                 
 1229:     256D 86 FF                          ldaa #$ff               ;flag for bad scan
 1230:     256F B7 2026                        staa Boxcode
 1231:                                 
 1232:     2572                        sc_exit
 1233:                                 
 1234:     2572 32                             pula
 1235:     2573 39                             rts
 1236:                                 
 1237:                                 
 1238:                                 
 1239:                                 ;*******************************************************************************
 1240:                                 ;Name:          IC3_init
 1241:                                 ;Author:        Michael McNeill, Jr.
 1242:                                 ;Date:          ??
 1243:                                 ;Functions:     This initializes IC3 to capture a falling edge of the 
 1244:                                 ;               clock for the barcode reader. 
 1245:                                 ;
 1246:                                 ;********************************************************************************
 1247:     2574 36                     IC3_init:       psha
 1248:     2575 3C                                     pshx
 1249:                                                                         
 1250:     2576 0F                                     sei
 1251:                                 
 1252:     2577 86 7E                                  ldaa #$7E
 1253:     2579 97 E2                                  staa IC3IV
 1254:                                 
 1255:     257B CC 2598                                LDD #IC3RT
 1256:     257E DD E3                                  STD IC3IV+1
 1257:                                 
 1258:     2580 CE 1021                                LDX #TCTL2
 1259:                                 
 1260:     2583 1C 00 02                               Bset 0,X #$02   ;set for falling edge
 1261:     2586 1D 00 01                               Bclr 0,X #$01
 1262:                                        
 1263:     2589 86 01                                  LDAA #$01
 1264:     258B B7 1023                                STAA TFLG1      ;clr flag
 1265:                                 
 1266:     258E CE 1022                                LDX #TMSK1      ;turn on INT
 1267:     2591 1C 00 01                               Bset 0,X #$01
 1268:                                 
 1269:     2594 0E                                     cli
 1270:                                 
 1271:     2595 38                                     pulx
 1272:     2596 32                                     pula
 1273:     2597 39                                     rts
 1274:                                 
 1275:                                 
 1276:                                 ;**************************************************************************
 1277:                                 ;Name:          IC3RT - Barcode interrupt 
 1278:                                 ;Author:        Dan Kohn
 1279:                                 ;Date:          ??
 1280:                                 ;Function:      This interrupt is triggered on a FALLING EDGE of the 
 1281:                                 ;               bar code clk signal. That that time, the data line is
 1282:                                 ;               captured and placed into the CARRY BIT which is then
 1283:                                 ;               shifted from the left into the barcode buffer.
 1284:                                 ;
 1285:                                 ;               [see SCANNER routine for more info]
 1286:                                 ;**************************************************************************
 1287:                                 
 1288:     2598 86 01                  IC3RT:          ldaa #$01               ;resets the IC3 bit
 1289:     259A B7 1023                                staa TFLG1
 1290:                                 
 1291:     259D B6 100A                                Ldaa portE              ;check IC3 pin for on or off state
 1292:     25A0 84 80                                  anda #$80
 1293:     25A2 27 03                                  BEQ  BC_High
 1294:     25A4 0D                                     sec
 1295:     25A5 20 01                                  BRA BC_skip
 1296:                                 
 1297:     25A7 0C                     BC_High         clc
 1298:                                 
 1299:     25A8 76 2020                BC_Skip         ROR Barcode
 1300:     25AB 76 2021                                ROR Barcode+1
 1301:     25AE 76 2022                                ROR Barcode+2
 1302:     25B1 76 2023                                ROR Barcode+3
 1303:     25B4 76 2024                                ROR Barcode+4
 1304:     25B7 7C 2025                                INC BC_count
 1305:     25BA 3B                                     RTI                     ;return from the interrupt
 1306:                                 
 1307:                                 
 1308:                                 ;**************************************************************************
 1309:                                 ;Name:          BC_Clear - Clear Bar Code buffer 
 1310:                                 ;Author:        Dan Kohn
 1311:                                 ;Date:          ??
 1312:                                 ;Function:      Clear the buffer for the bar code buffer (fill with all ones)
 1313:                                 ;**************************************************************************
 1314:     25BB 36                     BC_clear        psha
 1315:     25BC 86 FF                                  LDAA #$FF
 1316:     25BE B7 2020                                STAA Barcode
 1317:     25C1 B7 2021                                STAA Barcode+1
 1318:     25C4 B7 2022                                STAA Barcode+2
 1319:     25C7 B7 2023                                STAA Barcode+3
 1320:     25CA B7 2024                                STAA Barcode+4
 1321:     25CD 86 00                                  LDAA #$0
 1322:     25CF B7 2025                                STAA BC_count
 1323:                                 
 1324:     25D2 32                                     Pula
 1325:     25D3 39                                     RTS
 1326:                                 ;*****************************************************

Symbols:
a2d                             *0000233b
adctl                           *00001030
adr2                            *00001032
adr3                            *00001033
adr4                            *00001034
barcode                         *00002020
bc_clear                        *000025bb
bc_count                        *00002025
bc_high                         *000025a7
bc_skip                         *000025a8
boxcode                         *00002026
checkcenter                     *00002298
checkleft                       *000022a5
clockw                          *000022b5
clockw_loop                     *000022be
close                           *0000236c
counter_loop                    *000022d3
counterclck                     *000022ca
exit_2                          *00002494
exit_3                          *000024e4
exit_4                          *00002534
fforward                        *00002273
forward                         *00002323
go_close                        *0000235a
go_forward                      *000022f1
go_left                         *000022e5
go_open                         *00002354
go_right                        *000022eb
go_stop                         *000022df
gstop                           *00002374
ic3iv                           *000000e2
ic3rt                           *00002598
leaveshoot                      *00002086
left                            *00002333
left90                          *0000238b
linetrack                       *00002241
lop                             *00002039
lt_cont                         *00002284
lt_exit                         *000022b2
lt_loop                         *00002243
ltcb                            *0000201f
ltl                             *00000094
lturn                           *0000226d
main                            *00002027
off_cnts_g                      *0000200d
off_cnts_l                      *00002009
off_cnts_r                      *00002005
on_2                            *0000248b
on_3                            *000024db
on_4                            *0000252b
on_cnts_g                       *0000200b
on_cnts_l                       *00002007
on_cnts_r                       *00002003
open                            *00002370
option                          *00001039
pause                           *00002378
pausel1                         *00002382
plane1                          *000020c8
plane1_cd                       *00002019
plane2                          *00002173
plane2_cd                       *0000201b
plane3                          *000021e1
plane3_cd                       *0000201d
plane_temp                      *00002017
plane_time                      *000023fc
porta                           *00001000
porte                           *0000100a
pt_2                            *00002424
pt_3                            *00002434
reg_base                        *00001000
reverse                         *0000231b
right                           *0000232b
right90                         *00002396
robot_do                        *000022fd
robot_go                        *00002360
rturn                           *00002267
sc_0                            *00002539
sc_1                            *0000254f
sc_2                            *0000255e
sc_3                            *0000256d
sc_exit                         *00002572
sec_count                       *00002016
sec_temp                        *00002015
shoot2                          *0000212e
sstop                           *00002279
start                           *00002065
stop                            *00002313
tcnt                            *0000100e
tctl1                           *00001020
tctl2                           *00001021
tflg1                           *00001023
tflg2                           *00001025
tmsk1                           *00001022
tmsk2                           *00001024
toc2                            *00001018
toc2_init                       *00002445
toc2iv                          *000000dc
toc2rt                          *00002474
toc3                            *0000101a
toc3_init                       *00002495
toc3iv                          *000000d9
toc3rt                          *000024c4
toc4                            *0000101c
toc4_init                       *000024e5
toc4iv                          *000000d6
toc4rt                          *00002514
tof_cnt                         *000023e0
tof_exit                        *00002444
tof_init                        *000023a1
tofiv                           *000000d0

