E:\Robot\Mar26lastday1.lst - generated by MGTEK Assembler ASM11 V1.22 Build 137 for WIN32 (x86) - Sat Apr 01 06:38:53 2006

    1:                                 ;**************************************************************************
    2:                                 ;Name:          Robot Library                   PLAN A
    3:                                 ;Version:       0.1b
    4:                                 ;Author:        Dan Kohn
    5:                                 ; Comments By:  Dan Kohn & Adrian Austin
    6:                                 ;Date of Mod):  March, 15, 2006
    7:                                 ;
    8:                                 ;IO Table:
    9:                                 ;
   10:                                 ;PortA          PA7     OC1 / Gripper
   11:                                 ;               PA6     OC2 / RIGHT Motor (PWM for servo) \
   12:                                 ;               PA5     OC3 / LEFT Motor (PWM for servo)  / looking from the back to the front
   13:                                 ;               PA4     OC4 / Arm Servo Output ;mike code Arm motor
   14:                                 ;               PA3     OC5 / USED FOR TRACE - BUFFALO
   15:                                 ;               PA2     IC1 / (plse encoder 1)
   16:                                 ;               PA1     IC2 / 
   17:                                 ;               PA0     IC3/Clock for barcode (Red wire)
   18:                                 ;
   19:                                 ;PortE          PE7     Data for barcode (Brown wire)
   20:                                 ;               PE6     code for the limit switch works here
   21:                                 ;               PE5
   22:                                 ;               PE4
   23:                                 ;               PE3     ADR4/Line Track 3       left   \
   24:                                 ;               PE2     ADR3/Line Track 2       center  - looking from the back of robot
   25:                                 ;               PE1     ADR2/Line Track 1       Right  /
   26:                                 ;               PE0
   27:                                 ;
   28:                                 ;               
   29:                                 ;PortD          PD5     
   30:                                 ;               PD4
   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    led 
   42:                                 ;               BIT7    
   43:                                 ;
   44:                                 ;               Input Circuit // not currently in use
   45:                                 ;$B590          BIT0     
   46:                                 ;               BIT1
   47:                                 ;               BIT2
   48:                                 ;               BIT3
   49:                                 ;               BIT4
   50:                                 ;               BIT5
   51:                                 ;               BIT6
   52:                                 ;               BIT7
   53:                                 ;
   54:                                 ;               Input Circuit // not currently in use
   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 2030                                JMP MAIN
   71:                                 ;Barcode Equates
   72:          =000000E2              IC3IV           EQU $00E2
   73:     2003 +0005                  Barcode         RMB 5
   74:     2008 +0001                  BC_count        RMB 1
   75:     2009 +0001                  Boxcode         RMB 1
   76:          =0000FFB8              outa            equ $ffb8
   77:                                 
   78:                                 ;Buffalo Equates
   79:          =0000FFC1              out2bsp         equ $ffc1               ; prints what is pointed to by x to the screen
   80:          =0000FFC4              outcrlf         equ $ffc4               ; outputs a carrage return and line feed
   81:          =0000FFBE              out1bsp         equ $ffbe               ; prints what is pointed to by x to the screen
   82:                                 
   83:                                 
   84:                                 ;Left Motor Variables and Equates
   85:          =000000D9              TOC3IV          EQU $00D9
   86:     200A +0002                  On_cnts_L       RMB 2
   87:     200C +0002                  Off_cnts_L      RMB 2
   88:                                 
   89:                                 ;Limit Switch Control Byte
   90:     200E +0001                  LS1             rmb 1 
   91:                                 ;Line Track Control Byte
   92:     200F +0001                  LTCB            rmb 1
   93:                                 
   94:                                 ;Line Track Level
   95:          =00000094              LTL             equ $94         ; comparison number for more black and less is white? 
   96:                                 
   97:                                 
   98:                                 ;Sonar variables
   99:     2010 +0002                  Sonar_start     rmb 2
  100:     2012 +0002                  Sonar_end       rmb 2
  101:     2014 +0002                  Sonar_ans       rmb 2
  102:                                 
  103:                                 ;Right Motor Variables and Equates
  104:          =000000DC              TOC2IV          EQU $00DC               
  105:     2016 +0002                  On_cnts_R       RMB 2
  106:     2018 +0002                  Off_cnts_R      RMB 2
  107:                                 ;Gripper (TOC1init) Variables and Equates
  108:          =000000DF              TOC1IV          EQU $00DF
  109:     201A +0002                  On_cnts_Gr      rmb 2
  110:     201C +0002                  Off_cnts_Gr     rmb 2
  111:                                 
  112:                                 ;Arm Motor Variables and Equates                        ;mike code
  113:          =000000D6              TOC4IV          EQU $00D6
  114:     201E +0002                  On_cnts_A       RMB 2
  115:     2020 +0002                  Off_cnts_A      RMB 2
  116:                                 
  117:                                 ;Timer Overflow Counter
  118:          =000000D0              TOFIV           EQU $00D0
  119:     2022 +0001                  Sec_Temp        rmb 1           ;counter 32.77mSec [0-15]
  120:     2023 +0001                  Sec_count       rmb 1           ;counter 0.1Sec [0-255]
  121:     2024 +0002                  plane_temp      rmb 2           ;counter 32.77ms [0-30]
  122:     2026 +0002                  plane1_cd       rmb 2           ;countdown timer - plane 1 [180 -> 0 Sec]
  123:     2028 +0002                  plane2_cd       rmb 2           ;countdown timer - plane 2 [240 -> 0 Sec]
  124:     202A +0002                  plane3_cd       rmb 2           ;countdown timer - plane 3 [300 -> 0 Sec]
  125:                                 
  126:                                 ;Encoder Variable Equates
  127:          =000000E8              IC1IV           equ $00E8
  128:     202C +0002                  Encoder1        rmb 2
  129:     202E +0002                  Armlift         rmb 2
  130:                                 
  131:                                 
  132:                                 
  133:                                 
  134:                                 
  135:                                 
  136:     2030                        MAIN            
  137:                                 
  138:     2030 BD 23EC                                jsr go_stop             ;Set up On/Off times for stop
  139:     2033 BD 276E                                jsr gripC
  140:     2036 BD 2759                                jsr gripO
  141:     2039 BD 2448                                jsr go_astop
  142:                                                 
  143:     203C BD 2600                                jsr TOC4_init           ;init arm motor
  144:     203F BD 25B0                                jsr TOC3_init           ;init left motor
  145:     2042 BD 2560                                jsr TOC2_init           ;init right motor
  146:     2045 BD 24BC                                jsr TOF_init            ;init Timer Overflow (for 0.5 sec Timer)
  147:     2048 BD 2480                                jsr A2D                 ;init A/D PE0..PE3
  148:     204B BD 26FB                                jsr TOC1_init           ;inint TOC1_inint for the gripper               
  149:     204E CE 0000                                ldx #$00                ;inint encoder 1 to accum x
  150:     2051 FF 202C                                stx encoder1
  151:     2054 BD 2783                                jsr IC1_init            ;init IC1_init to encoder 1
  152:                                 
  153:                                 
  154:                                 
  155:     2057 86 32                                  ldaa #50
  156:     2059 BD 2493                                jsr pause
  157:                                 
  158:                                 
  159:                                 
  160:     205C BD 210C                                jsr Start               ;leave the block
  161:                                                 
  162:                                 
  163:                                 
  164:     205F BD 2132                TOP:            jsr LeaveShoot          ; moves robot from shoot to the plane 1 intersection            
  165:                                                                         ; spot to check if need to go to 1st plane
  166:                                 ;               ldaa plane1_cd          ; Go to plane2 If Under 41 Sec.
  167:                                 ;               cmpa #20
  168:                                 ;               BLE P2
  169:                                 
  170:     2062 BD 2169                                jsr Plane1              ; moves the plane to plane one and dumps and returns
  171:                                                                         ; to the 1st t intersection     
  172:                                 
  173:     2065 BD 21DF                                jsr Shoot2              ; this moves the robot back to the shoot
  174:     2068 BD 2132                                jsr LeaveShoot          ; moves from the shoot back to the 1st t intersection
  175:                                 
  176:     206B BD 2169                                jsr Plane1              ; moves the plane to plane one and dumps and returns
  177:                                                                         ; to the 1st t intersection     
  178:                                 
  179:     206E BD 21DF                                jsr Shoot2              ; this moves the robot back to the shoot
  180:     2071 BD 2132                                jsr LeaveShoot          ; moves from the shoot back to the 1st t intersection
  181:                                 
  182:     2074 BD 2169                                jsr Plane1              ; moves the plane to plane one and dumps and returns
  183:                                                                         ; to the 1st t intersection     
  184:                                 
  185:     2077 BD 21DF                                jsr Shoot2              ; this moves the robot back to the shoot
  186:     207A BD 2132                                jsr LeaveShoot          ; moves from the shoot back to the 1st t intersection
  187:                                 
  188:                                 ;               ldaa plane2_cd
  189:                                 ;               cmpa #20
  190:                                 ;               BLE P3
  191:                                 
  192:                                 
  193:     207D BD 2219                P2:             jsr Plane2              ; moves from t intersection an back to t intersection
  194:     2080 BD 21DF                                jsr Shoot2              ; moves back to the shoot
  195:     2083 BD 2132                                jsr LeaveShoot          ; moves back to t intersection
  196:                                 
  197:                                 
  198:                                                 
  199:     2086 BD 2292                P3:             jsr Plane3              ; moves from the t intersection and back from the 3rd plane
  200:     2089 BD 21DF                                jsr Shoot2              ; moves back to the shoot
  201:     208C 7E 205F                                jmp TOP
  202:                                                 
  203:     208F 7E 23EC                                jmp go_stop
  204:     2092 7E E000                                jmp $e000       
  205:                                 ;*******************************************************************
  206:                                 ; test section
  207:                                 ; This test is design to see if the robot will pull the block out
  208:                                 ;
  209:                                 ;
  210:                                 ;******************************************************************
  211:     2095                        test:
  212:     2095 36                                     psha
  213:     2096 37                                     pshb
  214:     2097 3C                                     pshx
  215:                                                 
  216:     2098 BD 2759                                jsr gripO       ;open the gripper from the schute
  217:     209B BD 210C                                jsr Start       ; moves to the shoot
  218:     209E BD 276E                                jsr gripC
  219:     20A1 86 02                                  ldaa #02
  220:     20A3 BD 2493                                jsr pause       ; grabs the first block
  221:     20A6 BD 2404                                jsr go_reverse  ; backs up 
  222:     20A9 86 0F                                  ldaa #15
  223:     20AB BD 2493                                jsr pause
  224:                                                 
  225:     20AE BD 2132                                jsr leaveshoot
  226:     20B1 BD 2169                                jsr plane1  ; moves the block to the t intersection
  227:     20B4 38                                     pulx
  228:     20B5 33                                     pulb
  229:     20B6 32                                     pula
  230:     20B7 39                                     rts
  231:                                 
  232:                                 
  233:                                 ;*****************************************************************************
  234:                                 ; Encoder
  235:                                 ; 
  236:                                 ;
  237:                                 ;
  238:                                 ;****************************************************************************
  239:                                                 
  240:     20B8                        Encoder:        
  241:     20B8 3C                                     pshx
  242:                                 
  243:     20B9 CE 202C                                ldx #encoder1           ;init encoder1 to read screen
  244:     20BC BD FFBE                                jsr out1bsp             
  245:     20BF BD FFC4                                jsr outcrlf
  246:                                 
  247:     20C2 38                                     pulx
  248:     20C3 39                                     rts
  249:                                 
  250:                                 ;***************************************************************************
  251:                                 ; this section will grab block and check and move to the appropriate box
  252:                                 ;***************************************************************************
  253:     20C4                        block_check:
  254:     20C4 36                                     psha
  255:     20C5 37                                     pshb
  256:     20C6 3C                                     pshx
  257:                                                 
  258:     20C7 BD 276E                                jsr gripC               ; grab the block
  259:     20CA BD 2404                                jsr go_reverse          ; back up and take block out of stack
  260:     20CD 86 03                                  ldaa #03
  261:     20CF BD 2493                                jsr pause               
  262:                                                                         ; do barcode scanner here
  263:     20D2 B6 2009                NO_1_Plane:     ldaa Boxcode
  264:     20D5 81 01                                  cmpa #$01               ; if the bacrode read 1 it go to plane 1
  265:     20D7 26 0C                                  bne NO_2_Plane          ;
  266:     20D9 BD 2132                                jsr LeaveShoot
  267:     20DC BD 2169                                jsr plane1
  268:     20DF BD 21DF                                jsr  Shoot2
  269:     20E2 7E 2108                                jmp  end_check                  
  270:     20E5                        NO_2_Plane:
  271:     20E5 B6 2009                                ldaa Boxcode            ;if the barcode read 2 it go to plane 2
  272:     20E8 81 02                                  cmpa #$02
  273:     20EA 26 0C                                  bne No_3_Plane
  274:     20EC BD 2132                                jsr LeaveShoot
  275:     20EF BD 2219                                jsr plane2
  276:     20F2 BD 21DF                                jsr shoot2
  277:     20F5 7E 2108                                jmp end_check
  278:     20F8                        NO_3_Plane:
  279:     20F8 B6 2009                                ldaa Boxcode            ;if the barcode read 3 it go to plane 3
  280:     20FB 81 FF                                  cmpa #$FF
  281:     20FD 27 D3                                  beq NO_1_Plane
  282:     20FF BD 2132                                jsr leaveshoot
  283:     2102 BD 2292                                jsr plane3
  284:     2105 BD 21DF                                jsr shoot2
  285:                                                 
  286:     2108                        end_check:      
  287:                                                         
  288:     2108 38                                     pulx
  289:     2109 33                                     pulb
  290:     210A 32                                     pula
  291:                                                                          ; here light the led  for hey i am done
  292:     210B 39                                     rts
  293:                                                 
  294:                                 ;;**************************************************************************
  295:                                 ; this section moves the robot to the block shoot
  296:                                 ;**************************************************************************
  297:     210C 36                     Start:          psha
  298:                                                 
  299:                                                 
  300:     210D BD 23FE                                jsr go_forward          ;Leaving Block
  301:     2110 86 0A                                  ldaa #10
  302:     2112 BD 2493                                jsr pause
  303:     2115 BD 2302                                jsr LineTrack           ; this line moves forward until the 1st plus intersection
  304:                                                 
  305:                                 
  306:     2118 BD 23FE                                jsr go_forward          ; moves forward so line tracking will work 
  307:     211B 86 1C                                  ldaa #28
  308:     211D BD 2493                                jsr pause
  309:                                                 
  310:     2120 BD 23EC                                jsr go_stop
  311:     2123 86 0A                                  Ldaa #10
  312:     2125 BD 2493                                jsr pause
  313:                                         
  314:                                 
  315:     2128 BD 276E                                jsr GripC
  316:     212B 86 1E                                  ldaa #30
  317:     212D BD 2493                                jsr pause
  318:                                                 
  319:                                 
  320:     2130 32                                     pula
  321:     2131 39                                     rts
  322:                                 ;**************************************************************************
  323:                                 ; this section moves the robot away from the shoot to the intersection for
  324:                                 ; turning to plane 1
  325:                                 ;**************************************************************************
  326:                                                 
  327:     2132 36                     LeaveShoot:     psha
  328:                                         
  329:     2133 BD 2404                                jsr go_reverse
  330:     2136 86 0F                                  ldaa #15
  331:     2138 BD 2493                                jsr pause
  332:                                 
  333:     213B BD 23EC                                jsr go_stop
  334:     213E 86 14                                  ldaa #20
  335:     2140 BD 2493                                jsr pause
  336:                                 
  337:     2143 BD 23C2                                jsr clockw1             ;180 Right Turn to leave the Package shoot
  338:     2146 BD 2302                                jsr LineTrack           ; line track back to the 1st plus
  339:     2149 BD 23FE                                jsr go_forward          ; this section makes the first turn
  340:     214C 86 08                                  ldaa #8
  341:                                                                         ; *
  342:     214E BD 2493                                jsr pause               ; *
  343:     2151 BD 23EC                                jsr go_stop
  344:     2154 86 05                                  ldaa #5
  345:     2156 BD 2493                                jsr pause               ; *
  346:     2159 BD 23D7                                jsr counterclck         ; *
  347:     215C BD 23EC                                jsr go_stop             ; *
  348:     215F 86 05                                  ldaa #5                 ; *
  349:     2161 BD 2493                                jsr pause               ; *
  350:                                 
  351:     2164 BD 2302                                jsr LineTrack           ; moves robot to the 1st t intersection
  352:                                                                         ; ends this section
  353:                                                 
  354:                                 
  355:     2167 32                                     pula
  356:     2168 39                                     rts
  357:                                 ;**************************************************************************
  358:                                 ; this section moves the robot to the first plane and then moves it back to the 1st t intersection
  359:                                 ;**************************************************************************
  360:     2169 36                     Plane1:         psha
  361:                                 
  362:     216A BD 23FE                                jsr go_forward          ; moves forward so turn will work properly
  363:     216D 86 05                                  ldaa #5
  364:     216F BD 2493                                jsr pause
  365:     2172 BD 23EC                                jsr go_stop
  366:     2175 86 05                                  ldaa #5
  367:     2177 BD 2493                                jsr pause
  368:     217A BD 23C2                                jsr clockw1             ;turns right until hits white line for the first plane
  369:                                 
  370:     217D BD 23EC                                jsr go_stop             
  371:     2180 86 14                                  ldaa #20
  372:     2182 BD 2493                                jsr pause
  373:     2185 BD 2302                                jsr Linetrack           ;Stops at 2nd plus by Loading Zone 1
  374:     2188 BD 23FE                                jsr go_forward          
  375:     218B 86 03                                  ldaa #3
  376:     218D BD 2493                                jsr pause
  377:     2190 BD 2302                                jsr Linetrack
  378:                                 
  379:     2193 BD 244E                                jsr go_Aup
  380:     2196 86 32                                  ldaa #50
  381:     2198 BD 2493                                jsr pause
  382:                                 
  383:     219B BD 2448                                jsr go_Astop
  384:     219E 86 14                                  ldaa #20
  385:     21A0 BD 2493                                jsr pause
  386:                                                 
  387:                                 
  388:                                                 
  389:     21A3 BD 24A6                                jsr Left90              ; turns to the airplane
  390:     21A6 BD 23EC                                jsr go_stop             ; right her is where droping will occur         
  391:     21A9 86 19                                  ldaa #25        
  392:     21AB BD 2493                                jsr pause
  393:                                 
  394:                                                         
  395:     21AE BD 2759                                jsr gripO               ; for the simple robot must remove
  396:     21B1 86 0A                                  ldaa #10                        ; and replace with carrage dump section
  397:     21B3 BD 2493                                jsr pause               ;*
  398:                                                 
  399:     21B6 BD 23D7                                jsr counterclck
  400:                                 
  401:                                 
  402:     21B9 BD 2302                                jsr linetrack           ; moves the robot forward to the 2nd plus
  403:     21BC BD 23FE                                jsr go_forward          ; this section moves the robot back to the 
  404:     21BF 86 05                                  ldaa #5         
  405:     21C1 BD 2493                                jsr pause
  406:     21C4 BD 2302                                jsr linetrack
  407:                                 
  408:     21C7 BD 23FE                                jsr go_forward
  409:     21CA 86 05                                  ldaa #5
  410:     21CC BD 2493                                jsr pause
  411:                                                 
  412:                                                 
  413:     21CF BD 23D7                                jsr counterclck
  414:     21D2 BD 23EC                                jsr go_stop
  415:     21D5 86 05                                  ldaa #5         
  416:                                 
  417:     21D7 BD 2302                                jsr Linetrack   ;       
  418:     21DA BD 2493                                jsr pause               ;
  419:                                 
  420:                                                 
  421:                                 
  422:     21DD 32                                     pula
  423:                                 
  424:     21DE 39                                     rts
  425:                                 ;**************************************************************************
  426:                                 ; this section goes back to the shoot from the t intersection
  427:                                 ;
  428:                                 ;
  429:                                 ;**************************************************************************
  430:     21DF 36                     Shoot2:         psha
  431:                                                 
  432:     21E0 BD 2759                                jsr gripO
  433:                                 
  434:     21E3 BD 2302                                jsr Linetrack
  435:     21E6 BD 23FE                                jsr go_forward
  436:     21E9 86 08                                  ldaa #8
  437:     21EB BD 2493                                jsr pause
  438:                                                 
  439:     21EE BD 2302                                jsr Linetrack
  440:                                 
  441:     21F1 BD 23C2                                jsr clockw1             ;Goes back to Shoot
  442:     21F4 BD 23EC                                jsr go_stop             ;
  443:     21F7 86 07                                  ldaa #7
  444:     21F9 BD 2493                                jsr pause
  445:                                 
  446:     21FC BD 245B                                jsr go_Adown
  447:     21FF 86 2D                                  ldaa #45
  448:     2201 BD 2493                                jsr pause
  449:                                 
  450:     2204 BD 2448                                jsr go_Astop
  451:     2207 86 14                                  ldaa #20
  452:     2209 BD 2493                                jsr pause
  453:                                                 
  454:     220C BD 2345                                jsr LineTrackSpec
  455:                                                 
  456:                                 
  457:     220F BD 276E                                jsr gripC
  458:     2212 86 1E                                  ldaa #30
  459:     2214 BD 2493                                jsr pause
  460:                                                 
  461:     2217 32                                     pula
  462:     2218 39                                     rts
  463:                                 ;
  464:                                 ;**************************************************************************
  465:                                 ; this section moves from the t intersection
  466:                                 ; to the second plane and back to the 1st t intersection
  467:                                 ;**************************************************************************
  468:     2219 36                     Plane2:         psha
  469:                                                 
  470:     221A BD 23FE                                jsr go_forward
  471:     221D 86 05                                  ldaa #5
  472:     221F BD 2493                                jsr pause
  473:                                                 
  474:     2222 BD 2302                                jsr Linetrack           ; moves the robot forward until you get to the 3rd plus
  475:                                                                         ; intersection
  476:     2225 BD 23FE                                jsr go_forward          
  477:     2228 86 05                                  ldaa #5
  478:     222A BD 2493                                jsr pause
  479:     222D BD 23C2                                jsr clockw1             ;will trun right until hits the white line agian
  480:                                                 
  481:     2230 BD 23EC                                jsr go_stop
  482:     2233 86 05                                  ldaa #5
  483:     2235 BD 2493                                jsr pause
  484:     2238 BD 2302                                jsr Linetrack           ;Stops at 4th plus by Loading Zone 1
  485:     223B BD 23FE                                jsr go_forward
  486:     223E 86 0A                                  ldaa #10
  487:     2240 BD 2493                                jsr pause
  488:     2243 BD 2302                                jsr Linetrack           ; moves forward until side of board
  489:                                 
  490:     2246 BD 244E                                jsr go_Aup
  491:     2249 86 32                                  ldaa #50
  492:     224B BD 2493                                jsr pause
  493:                                 
  494:     224E BD 2448                                jsr go_Astop
  495:     2251 86 14                                  ldaa #20
  496:     2253 BD 2493                                jsr pause
  497:                                 
  498:     2256 BD 24A6                                jsr Left90              ; turn left to go towards the plane
  499:     2259 BD 23EC                                jsr go_stop
  500:     225C 86 05                                  ldaa #5
  501:     225E BD 2493                                jsr pause
  502:     2261 BD 2759                                jsr gripO               ; this section for the simple robot 
  503:     2264 86 0A                                  ldaa #10                ; this is where the carrage drop occurs
  504:     2266 BD 2493                                jsr pause
  505:                                 
  506:     2269 BD 23D7                                jsr counterclck         ; 
  507:     226C BD 2302                                jsr linetrack           ; move to the 4rd plus intersection
  508:     226F BD 23FE                                jsr go_forward                          
  509:     2272 86 05                                  ldaa #5 
  510:     2274 BD 2493                                jsr pause
  511:     2277 BD 2302                                jsr linetrack           ; here stops at the 3rd plus intersection
  512:                                 
  513:     227A BD 23FE                                jsr go_forward          ; moves the robot forward to get line track off the plus
  514:     227D 86 07                                  ldaa #7
  515:     227F BD 2493                                jsr pause
  516:                                 
  517:     2282 BD 23D7                                jsr counterclck         ; turns the robot to the left until hits the white line
  518:                                                                         ; back towards the t intersection
  519:     2285 BD 2302                                jsr Linetrack           ; moves the robot back to the t intersection
  520:                                 
  521:     2288 BD 23FE                                jsr go_forward          ; 
  522:     228B 86 05                                  ldaa #5
  523:     228D BD 2493                                jsr pause
  524:                                 
  525:                                                 
  526:                                 
  527:     2290 32                                     pula
  528:                                 
  529:     2291 39                                     rts
  530:                                 ;******************************************************************************************************
  531:                                 ; this section moves from the 1st t intersection to the 3rd plane and to the 1st t intersection
  532:                                 ;******************************************************************************************************
  533:     2292                        Plane3:
  534:     2292 BD 23FE                                jsr go_forward          ; moves forward to make linetrack work
  535:     2295 86 05                                  ldaa #5
  536:     2297 BD 2493                                jsr pause               
  537:     229A BD 2302                                jsr Linetrack           ; moves forward until 3th plus
  538:     229D BD 23FE                                jsr go_forward          ; moves forward so line track will work
  539:     22A0 86 05                                  ldaa #5
  540:     22A2 BD 2493                                jsr pause               
  541:                                                 
  542:     22A5 BD 23D7                                jsr counterclck         ; turning left until white line agian           
  543:     22A8 BD 2302                                jsr Linetrack           ; moves to the 5th plus sign
  544:     22AB BD 23FE                                jsr go_forward          ; 
  545:     22AE 86 05                                  ldaa #5
  546:     22B0 BD 2493                                jsr pause
  547:                                 
  548:     22B3 BD 2302                                jsr Linetrack           ; moves to the side of the board
  549:                                 
  550:     22B6 BD 244E                                jsr go_Aup
  551:     22B9 86 32                                  ldaa #50
  552:     22BB BD 2493                                jsr pause
  553:                                 
  554:     22BE BD 2448                                jsr go_Astop
  555:     22C1 86 14                                  ldaa #20
  556:     22C3 BD 2493                                jsr pause
  557:                                 
  558:     22C6 BD 24B1                                jsr Right90             ; turns to move to the plane
  559:     22C9 BD 23EC                                jsr go_stop
  560:     22CC 86 05                                  ldaa #5
  561:     22CE BD 2493                                jsr pause
  562:                                                                 ;sonar goes here
  563:     22D1 BD 2759                                jsr gripO               ; simple robot code here where comp code goes
  564:     22D4 86 0A                                  ldaa #10                ; *
  565:     22D6 BD 2493                                jsr pause               ; this section moves the robot back to the line
  566:                                                 
  567:     22D9 BD 23C2                                jsr clockw1             ; turns the robot back towards the 5th plus sign
  568:                                                 
  569:     22DC BD 2302                                jsr linetrack           ; moves the robot to the 5th plus sign
  570:     22DF BD 23FE                                jsr go_forward          ; moves robot past the 5th plus sign
  571:     22E2 86 05                                  ldaa #5         
  572:     22E4 BD 2493                                jsr pause
  573:     22E7 BD 2302                                jsr linetrack           ; moves robot to the 3rd plus sign
  574:                                 
  575:     22EA BD 23FE                                jsr go_forward  
  576:     22ED 86 05                                  ldaa #5
  577:     22EF BD 2493                                jsr pause
  578:                                 
  579:     22F2 BD 23C2                                jsr clockw1             ; turns back to the t intersection
  580:                                         
  581:     22F5 BD 2302                                jsr Linetrack           ; moves to the t intersection
  582:                                                 
  583:     22F8 BD 23FE                                jsr go_forward          ;
  584:     22FB 86 05                                  ldaa #5
  585:     22FD BD 2493                                jsr pause
  586:                                                 
  587:     2300 32                                     pula
  588:     2301 39                                     rts
  589:                                 ;**************************************************************************
  590:                                 ;Name:          LineTrack
  591:                                 ;Author:        Dominic Lawrence
  592:                                 ;Date:          unknown
  593:                                 ;Modifications: 
  594:                                 ;               
  595:                                 ;               PE3     ADR4/Line Track 3       left   \
  596:                                 ;               PE2     ADR3/Line Track 2       center  - looking from the back of robot
  597:                                 ;               PE1     ADR2/Line Track 1       Right  /
  598:                                 ;               DK 3/4/06 
  599:                                 ;                  add tests for LTCB=6 and LTCB = 3 to improve line
  600:                                 ;                  following. 
  601:                                 ;               LTL             equ $94         ; comparison number for more black and less is white? 
  602:                                 ;Process:       First it calls LT_CONT that sets the LTCB. Then LTCB is  
  603:                                 ;               tested and the appropriate sub routine is called to 
  604:                                 ;               turn turned on/off the drive motors accordingly.
  605:                                 ;**************************************************************************
  606:                                 
  607:     2302 36                     LineTrack:      psha
  608:     2303 3C                                     pshx
  609:                                                 
  610:     2304 BD 2391                Lt_loop:        jsr Lt_cont
  611:                                                                         
  612:     2307 B6 200F                FirstT:         ldaa LTCB       ; checks the center sensors
  613:     230A 81 02                                  cmpa #$02
  614:     230C 27 26                                  beq  FForward
  615:                                                 
  616:     230E 81 04                                  cmpa #$04       ; checks sensors for if to far left
  617:     2310 27 16                                  beq  RTurn
  618:     2312 81 06                                  cmpa #$06
  619:     2314 27 12                                  beq  Rturn
  620:                                                         
  621:     2316 81 01                                  cmpa #$01       ; checks sensors for if to far right
  622:     2318 27 14                                  beq  LTurn
  623:     231A 81 03                                  cmpa #$03
  624:     231C 27 10                                  beq  LTurn
  625:                                                         
  626:     231E 81 07                                  cmpa #$07       ; stops the robot if all three sensors are white
  627:     2320 27 18                                  beq  SStop
  628:                                                 
  629:     2322 BD 23FE                                jsr go_forward
  630:     2325 7E 2304                                jmp Lt_loop
  631:                                                 
  632:                                  
  633:     2328 BD 23F8                RTurn:          jsr  go_right           ; jumps to sub that moves robot to the right    
  634:     232B 7E 2304                                jmp  Lt_loop
  635:                                 
  636:     232E BD 23F2                LTurn:          jsr  go_left            ; jumps to sub that moves robot to the left
  637:     2331 7E 2304                                jmp  Lt_loop
  638:                                 
  639:     2334 BD 23FE                FForward:       jsr  go_Forward         ; jumps to sub that moves robot forward
  640:     2337 7E 2304                                jmp  Lt_loop
  641:                                 
  642:     233A BD 23EC                SStop:          jsr go_stop             ; jumps to stop sub
  643:     233D 86 0A                                  ldaa #10
  644:     233F BD 2493                                jsr pause 
  645:                                                 
  646:     2342 38                                     pulx            
  647:     2343 32                                     pula
  648:     2344 39                                     rts     
  649:                                 ;*******************************
  650:                                 ; this one is special
  651:                                 ; a line track that will work to pick up the blocks
  652:                                 ;**************************************************
  653:     2345                        LineTrackSpec:
  654:     2345 36                                     psha
  655:     2346 3C                                     pshx
  656:                                                 
  657:     2347 BD 2391                Lt_loop1:       jsr Lt_cont
  658:                                 
  659:     234A B6 100A                                ldaa PORTE      ; grab info from port e
  660:     234D 84 40                                  anda #$40               ; compare to the down setting
  661:     234F 81 00                                  cmpa #$0
  662:     2351 26 E7                                  bne  SStop      ; if down stop
  663:                                                                                 
  664:     2353 B6 200F                FirstT1:        ldaa LTCB       ; checks the center sensors
  665:     2356 81 02                                  cmpa #$02
  666:     2358 27 26                                  beq  FForward_s
  667:                                                 
  668:     235A 81 04                                  cmpa #$04       ; checks sensors for if to far left
  669:     235C 27 16                                  beq  RTurn_s
  670:     235E 81 06                                  cmpa #$06
  671:     2360 27 12                                  beq  Rturn_s
  672:                                                         
  673:     2362 81 01                                  cmpa #$01       ; checks sensors for if to far right
  674:     2364 27 14                                  beq  LTurn_s
  675:     2366 81 03                                  cmpa #$03
  676:     2368 27 10                                  beq  LTurn_s
  677:                                                         
  678:     236A 81 07                                  cmpa #$07       ; stops the robot if all three sensors are white
  679:     236C 27 18                                  beq  SStop_s
  680:                                                 
  681:     236E BD 23FE                                jsr go_forward
  682:     2371 7E 2347                                jmp Lt_loop1
  683:                                 
  684:                                  
  685:     2374 BD 23F8                RTurn_s:        jsr  go_right           ; jumps to sub that moves robot to the right    
  686:     2377 7E 2347                                jmp  Lt_loop1
  687:                                 
  688:     237A BD 23F2                LTurn_s:        jsr  go_left            ; jumps to sub that moves robot to the left
  689:     237D 7E 2347                                jmp  Lt_loop1
  690:                                 
  691:     2380 BD 23FE                FForward_s:     jsr  go_Forward         ; jumps to sub that moves robot forward
  692:     2383 7E 2347                                jmp  Lt_loop1
  693:                                 
  694:     2386 BD 23EC                SStop_s:        jsr go_stop             ; jumps to stop sub
  695:     2389 86 0A                                  ldaa #10
  696:     238B BD 2493                                jsr pause 
  697:                                                                 
  698:     238E 38                                     pulx            
  699:     238F 32                                     pula
  700:     2390 39                                     rts             
  701:                                 ;**************************************************************************
  702:                                 ;Name:          Lt_cont - Line Track Control Word
  703:                                 ;Author:        Dominic Lawrence
  704:                                 ;Date:          unknown
  705:                                 ;Modifications: 
  706:                                 ;               AA 03/??/06
  707:                                 ;                  Made into a separate sub routine
  708:                                 ;               PE3     ADR4/Line Track 3       left   \
  709:                                 ;               PE2     ADR3/Line Track 2       center  - looking from the back of robot
  710:                                 ;               PE1     ADR2/Line Track 1       Right  /
  711:                                 ;Function:      Takes the inputs for each linetrack sensor and compares 
  712:                                 ;               it to the LTL (Line Track Limit). If it is below LTL the 
  713:                                 ;               sensor is inidcating it is on the line and the
  714:                                 ;               corresponding bit is set in LTCB (Line Track Control Byte).
  715:                                 ;
  716:                                 ;               LTCB = xxxxx000
  717:                                 ;               LTL             equ $94  comparison number for more black and less is white? 
  718:                                 ;On Return:     LTCL is set as per above
  719:                                 ;**************************************************************************
  720:     2391 36                     Lt_cont:        psha
  721:     2392 3C                                     pshx
  722:                                 
  723:     2393 86 00                                  Ldaa #$0        ; getting the right side info and if wrong setting 
  724:     2395 B7 200F                                Staa LTCB       ; LTCB to reflect this so linetrack sub routine will know       
  725:     2398 B6 1032                                Ldaa Adr2       ;*
  726:     239B 81 94                                  Cmpa #LTL       ;*
  727:     239D 24 06                                  BHS  CheckCenter;*
  728:     239F CE 200F                                Ldx  #LTCB      ;*
  729:     23A2 1C 00 04                               Bset 0,x #$04   ;*
  730:                                 
  731:     23A5 B6 1033                CheckCenter:    Ldaa Adr3       ; get the Center info and if wrong setting 
  732:     23A8 81 9F                                  Cmpa #$9F       ; LTCB to reflect this so Linetrack sub routine will know
  733:     23AA 24 06                                  BHS  CheckLeft  ;*
  734:     23AC CE 200F                                Ldx  #LTCB      ;*
  735:     23AF 1C 00 02                               Bset 0,x #$02   ;*
  736:                                 
  737:     23B2 B6 1034                CheckLeft:      Ldaa Adr4       ;getting the left side info and if wrong setting
  738:     23B5 81 94                                  cmpa #LTL       ; LTCB to reflect this so line track sub routine will know
  739:     23B7 24 06                                  BHS  lt_exit    ;*
  740:     23B9 CE 200F                                Ldx  #LTCB      ;*
  741:     23BC 1C 00 01                               Bset 0,x #$01   ;*
  742:                                 
  743:     23BF 38                     lt_exit:        pulx
  744:     23C0 32                                     pula
  745:                                                 
  746:     23C1 39                                     rts
  747:                                 ;**************************************************************************
  748:                                 ; This section will cause the robot to turn to the right until it hits a 
  749:                                 ; white line with the line tracking sensors
  750:                                 ;**************************************************************************
  751:     23C2                        clockw1:                
  752:     23C2 36                                     psha
  753:     23C3 BD 23F8                                jsr go_right
  754:     23C6 86 05                                  ldaa #5
  755:     23C8 BD 2493                                jsr pause
  756:     23CB BD 2391                clockw_Loop:    jsr LT_cont             
  757:     23CE B6 200F                                ldaa LTCB               
  758:     23D1 81 02                                  cmpa #$02
  759:     23D3 26 F6                                  bne clockw_Loop 
  760:                                                 
  761:     23D5 32                                     pula
  762:     23D6 39                                     rts
  763:                                 ;**************************************************************************
  764:                                 ; This section will cause the robot to turn to the Left until it hits a 
  765:                                 ; white line with the line tracking sensors
  766:                                 ;*************************************************************************
  767:     23D7                        counterclck:    
  768:     23D7 36                                     psha
  769:     23D8 BD 23F2                                jsr go_left
  770:     23DB 86 05                                  ldaa #5
  771:     23DD BD 2493                                jsr pause
  772:     23E0 BD 2391                counter_Loop:   jsr LT_cont             
  773:     23E3 B6 200F                                ldaa LTCB               
  774:     23E6 81 02                                  cmpa #$02
  775:     23E8 26 F6                                  bne  counter_Loop
  776:                                                 
  777:     23EA 32                                     pula
  778:     23EB 39                                     rts
  779:                                 ;**************************************************************************
  780:                                 ;Name:          Drive Motor Functions
  781:                                 ;Author:        Michael McNeill, JR.
  782:                                 ;Date:          Dec 9, 2005
  783:                                 ;Functions:     Each separtate function will do the indicated function 
  784:                                 ;               to the robot drive motors
  785:                                 ;
  786:                                 ;               go_Stop
  787:                                 ;               go_Left
  788:                                 ;               go_Right
  789:                                 ;               go_Forward
  790:                                 ;               go_Reverse
  791:                                 ;               never enter at robot_do! (Stack will be corrupted)
  792:                                 ;
  793:                                 ;       Functions for the arm motors
  794:                                 ;               go_Astop        
  795:                                 ;               go_Aup
  796:                                 ;               go_Adown
  797:                                 ;**************************************************************************
  798:                                 
  799:     23EC 3C                     go_Stop         pshx
  800:     23ED CE 2420                                ldx #Stop
  801:     23F0 20 18                                  bra robot_do1
  802:                                 
  803:     23F2 3C                     go_Left         pshx
  804:     23F3 CE 2440                                ldx #Left
  805:     23F6 20 12                                  bra robot_do1
  806:                                 
  807:     23F8 3C                     go_Right        pshx
  808:     23F9 CE 2438                                ldx #Right
  809:     23FC 20 0C                                  bra robot_do1
  810:                                 
  811:     23FE 3C                     go_Forward      pshx
  812:     23FF CE 2430                                ldx #Forward
  813:     2402 20 06                                  bra robot_do1
  814:                                 
  815:     2404 3C                     go_Reverse      pshx
  816:     2405 CE 2428                                ldx #Reverse
  817:     2408 20 00                                  bra robot_do1
  818:                                 
  819:     240A EC 00                  robot_do1       ldd 0,x
  820:     240C FD 2016                                std On_cnts_R
  821:     240F EC 02                                  ldd 2,x
  822:     2411 FD 2018                                std Off_cnts_R
  823:     2414 EC 04                                  ldd 4,x
  824:     2416 FD 200A                                std On_cnts_L
  825:     2419 EC 06                                  ldd 6,x
  826:     241B FD 200C                                std Off_cnts_L
  827:     241E 38                                     pulx
  828:     241F 39                                     rts
  829:                                 ;Table for Drive Motor Functions
  830:                                 ;                       On_cnts_R       Off_cnts_R      On_cnts_L       Off_cnts_L
  831:                                 
  832:     2420 0BB8 9088 0BB8         Stop            fdb     3000,           37000,          3000,           37000
           2426 9088 
  833:     2428 07D0 9470 0FA0         REVERSE         fdb     2000,           38000,          4000,           36000
           242E 8CA0 
  834:     2430 0FA0 8CA0 07D0         FORWARD         fdb     4000,           36000,          2000,           38000
           2436 9470 
  835:     2438 07D0 9470 07D0         RIGHT           fdb     2000,           38000,          2000,           38000
           243E 9470 
  836:     2440 0FA0 8CA0 0FA0         LEFT            fdb     4000,           36000,          4000,           36000
           2446 8CA0 
  837:                                 
  838:                                 
  839:                                 
  840:                                 ;********************************************************************************
  841:                                 ;       Functions for the arm motors
  842:                                 ;               go_Astop        
  843:                                 ;               go_Aup
  844:                                 ;               go_Adown
  845:                                 ;**************************************************************************
  846:                                 
  847:     2448 3C                     go_Astop        pshx
  848:     2449 CE 2474                                ldx #Astop
  849:     244C 20 1A                                  bra robot_arm
  850:                                 
  851:     244E 3C                     go_Aup          pshx
  852:     244F CE 2478                                ldx #Aup
  853:     2452 20 14                                  bra robot_arm
  854:                                 
  855:                                 
  856:                                                 
  857:     2454 86 01                                  ldaa #$01
  858:     2456 B7 202E                                staa Armlift    ; checks the center sensors
  859:     2459 27 1D                                  beq  Aup
  860:                                 
  861:                                 
  862:                                 
  863:                                 
  864:     245B 3C                     go_Adown        pshx
  865:     245C CE 247C                                ldx #Adown
  866:     245F 20 07                                  bra robot_arm
  867:                                 
  868:                                 
  869:     2461 86 00                                  ldaa #$0
  870:     2463 B7 202E                                staa Armlift
  871:     2466 27 14                                  beq  Adown
  872:                                 
  873:                                 
  874:                                                 
  875:                                 
  876:                                 
  877:                                 
  878:     2468 EC 00                  robot_arm       ldd 0,x
  879:     246A FD 201E                                std On_cnts_A
  880:     246D EC 02                                  ldd 2,x
  881:     246F FD 2020                                std Off_cnts_A
  882:                                                 
  883:     2472 38                                     pulx
  884:     2473 39                                     rts
  885:                                 
  886:                                 ;Table for Drive Motor Functions
  887:                                 ;                       On_cnts_A       Off_cnts_A      
  888:                                 
  889:     2474 0BB8 9088              Astop           fdb     3000,           37000   
  890:     2478 07D0 9470              Aup             fdb     2000,           38000           
  891:     247C 0FA0 8CA0              Adown           fdb     4000,           36000   
  892:                                 
  893:                                 
  894:                                 ;Servo Motor notes:
  895:                                 ;       1ms on time = 2000 counts = forward
  896:                                 ;       2ms on time = 4000 counts = reverse
  897:                                 ;       total counts for a 50hz square wave (20mSec - suggested for servos) is 40000 counts
  898:                                 
  899:                                 ;**************************************************************************
  900:                                 ;Name:          A2D
  901:                                 ;Author:        Dan Kohn
  902:                                 ;Date:          Jan 5, 2006
  903:                                 ;Functions:     Set up A/D to read PE0..PE3 continuously and  
  904:                                 ;               place the converted values in ADR1..ADR4
  905:                                 ;
  906:                                 ;On call:       NONE
  907:                                 ;
  908:                                 ;On Return;     A/D is turned on and running continously 
  909:                                 ;**************************************************************************
  910:                                 
  911:     2480 3C                     A2D:            pshx
  912:     2481 36                                     psha
  913:                                         
  914:     2482 CE 1039                                ldx #option             ;setup A/D
  915:     2485 1C 00 80                               bset 0,x #$80           ;Turn on A/D - ADPU
  916:     2488 1D 00 40                               bclr 0,x #$40           ;Use E clock
  917:                                                 
  918:     248B 86 30                                  ldaa #$30               ;Set up to read PE0..PE3
  919:     248D B7 1030                                staa ADCTL              ;Continuously
  920:                                 
  921:     2490 32                                     pula
  922:     2491 38                                     pulx
  923:                                                 
  924:     2492 39                                     rts
  925:                                 ;**************************************************************************
  926:                                 ;Name:          Pause
  927:                                 ;Author:        Dan Kohn
  928:                                 ;Date:          Dec 19, 2005
  929:                                 ;Functions:     Pause for multiple of 0.1 sec 
  930:                                 ;               (setup for a 0.1 sec counter)
  931:                                 ;
  932:                                 ;On call:       Reg A Contains the number of 0.1 sec to pause
  933:                                 ;
  934:                                 ;On Return;     Sec_Count and Sec_Temp were changed (cleared at start of 
  935:                                 ;               pause.
  936:                                 ;**************************************************************************
  937:     2493 36                     Pause:          psha
  938:     2494 37                                     pshb
  939:     2495 C6 00                                  ldab #$00
  940:     2497 F7 2022                                stab SEC_TEMP
  941:     249A F7 2023                                stab SEC_COUNT
  942:                                                 
  943:     249D F6 2023                PauseL1:        ldab sec_count
  944:     24A0 11                                     cba
  945:     24A1 26 FA                                  bne PauseL1
  946:                                                 
  947:     24A3 33                                     pulb
  948:     24A4 32                                     pula
  949:     24A5 39                                     rts
  950:                                 ;**************************************************************************
  951:                                 ;**************************************************************************
  952:     24A6 36                     Left90: psha
  953:                                                 
  954:     24A7 BD 23F2                                jsr go_left
  955:     24AA 86 0E                                  ldaa #14
  956:     24AC BD 2493                                jsr pause
  957:                                                 
  958:     24AF 32                                     pula 
  959:     24B0 39                                     rts
  960:                                 ;**************************************************************************
  961:                                 ;**************************************************************************
  962:     24B1 36                     Right90:        psha
  963:                                 
  964:     24B2 BD 23F8                                jsr go_right
  965:     24B5 86 0E                                  ldaa #14
  966:     24B7 BD 2493                                jsr pause               
  967:                                                 
  968:     24BA 32                                     pula
  969:     24BB 39                                     rts
  970:                                 ;**************************************************************************
  971:                                 ;Name:          TOF_init
  972:                                 ;Author:        Dan Kohn
  973:                                 ;Date:          Dec 14, 2005
  974:                                 ;Functions:     Initializes the TOF Function 
  975:                                 ;               (setup for a 0.5 sec counter)
  976:                                 ;**************************************************************************
  977:                                 
  978:     24BC 36                     TOF_init        psha
  979:     24BD 3C                                     pshx
  980:     24BE 183C                                   pshy
  981:                                 
  982:     24C0 0F                                     SEI
  983:                                 
  984:     24C1 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
  985:     24C3 97 D0                                  STAA TOFIV
  986:                                 
  987:     24C5 CC 24FB                                LDD #TOF_CNT
  988:     24C8 DD D1                                  STD TOFIV+1
  989:                                 
  990:     24CA 86 80                                  ldaa #$80               ;clear TOF flag
  991:     24CC B7 1025                                staa TFLG2
  992:                                         
  993:     24CF CE 1024                                LDX #TMSK2              ;turn on TOF interrupt
  994:     24D2 1C 00 80                               bset 0,x #$80
  995:                                 
  996:     24D5 0E                                     cli 
  997:                                 
  998:     24D6 18CE 0000                              ldy #0                  ;clear 1 sec counter for planes
  999:     24DA 18FF 2024                              sty plane_temp
 1000:                                 
 1001:     24DE 18CE 00B4                              ldy #180                ;set plane 1's time for 180sec
 1002:     24E2 18FF 2026                              sty plane1_cd
 1003:                                 
 1004:     24E6 18CE 00F0                              ldy #240                ;set plane 2's time for 240sec
 1005:     24EA 18FF 2028                              sty plane2_cd
 1006:                                 
 1007:     24EE 18CE 012C                              ldy #300                ;set plane 3's time for 300sec
 1008:     24F2 18FF 202A                              sty plane3_cd
 1009:                                                 
 1010:     24F6 1838                                   puly
 1011:     24F8 38                                     pulx
 1012:     24F9 32                                     pula
 1013:                                 
 1014:     24FA 39                                     rts
 1015:                                 ;**************************************************************************
 1016:                                 ;Name:          TOF_CNT
 1017:                                 ;Author:        Dan Kohn
 1018:                                 ;Date:          Dec 14, 2005
 1019:                                 ;Functions:     count every 0.1 sec.  
 1020:                                 ;
 1021:                                 ;On Return:     Count of 0.1 sec intervals is in SEC_count
 1022:                                 ;               Count of 32.77mSec intervals is in Sec_Temp
 1023:                                 ;**************************************************************************
 1024:     24FB 86 80                  TOF_CNT         ldaa #$80
 1025:     24FD B7 1025                                staa TFLG2      
 1026:                                                 
 1027:     2500 B6 2022                                ldaa Sec_temp           ;count # of times overflow occures (32.77ms)
 1028:     2503 4C                                     inca 
 1029:     2504 B7 2022                                staa Sec_temp
 1030:                                 
 1031:     2507 81 03                                  cmpa #03                ;if ~0.1sec has NOT gone by -> exit
 1032:     2509 25 0C                                  blo plane_time          ;      [3*32.77mSec = 0.0983100 Sec]
 1033:                                 
 1034:                                 
 1035:     250B 86 00                                  ldaa #$00               ;if ~0.1sec has gone by -> clear Sec_temp
 1036:     250D B7 2022                                staa Sec_temp           ;and add one to the Sec_count
 1037:                                 
 1038:     2510 B6 2023                                ldaa Sec_count
 1039:     2513 4C                                     inca 
 1040:     2514 B7 2023                                staa Sec_count
 1041:                                                 
 1042:     2517 18FE 2024              plane_time:     ldy plane_temp          ;count # of times overflow occures (32.77ms)
 1043:     251B 1808                                   iny 
 1044:     251D 18FF 2024                              sty plane_temp
 1045:                                 
 1046:     2521 188C 001E                              cpy #30                 ;if ~1sec has NOT gone by -> exit
 1047:     2525 25 38                                  blo tof_exit            ;      [30*32.77mSec = .98310 Sec]
 1048:                                 
 1049:                                 
 1050:     2527 18CE 0000                              ldy #$00                ;if ~0.1sec has gone by -> clear Sec_temp
 1051:     252B 18FF 2024                              sty plane_temp          ;and add one to the Sec_count
 1052:                                 
 1053:     252F 18FE 2026                              ldy plane1_cd           ;count down timer for plane 1
 1054:     2533 188C 0000                              cpy #0
 1055:     2537 27 06                                  beq pt_2
 1056:     2539 1809                                   dey
 1057:     253B 18FF 2026                              sty plane1_cd
 1058:                                 
 1059:     253F 18FE 2028              pt_2:           ldy plane2_cd           ;count down timer for plane 2
 1060:     2543 188C 0000                              cpy #0
 1061:     2547 27 06                                  beq pt_3
 1062:     2549 1809                                   dey
 1063:     254B 18FF 2028                              sty plane2_cd
 1064:                                 
 1065:     254F 18FE 202A              pt_3:           ldy plane3_cd           ;count down timer for plane 3
 1066:     2553 188C 0000                              cpy #0
 1067:     2557 27 06                                  beq TOF_exit
 1068:     2559 1809                                   dey
 1069:     255B 18FF 202A                              sty plane3_cd
 1070:                                 
 1071:     255F 3B                     TOF_exit        RTI
 1072:                                 
 1073:                                 ;**************************************************************************
 1074:                                 ;Name:          TOC2_init
 1075:                                 ;Author:        Dan Kohn
 1076:                                 ;Date:          Dec 8, 2005
 1077:                                 ;Functions:     Initalize the Right Motor (OC2) 
 1078:                                 ;
 1079:                                 ;On Call:       go_stop MUST be called before initalizing 
 1080:                                 ;**************************************************************************
 1081:     2560 36                     TOC2_init:      psha
 1082:     2561 37                                     pshb
 1083:     2562 3C                                     pshx
 1084:                                 
 1085:     2563 0F                                     SEI
 1086:                                 
 1087:     2564 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1088:     2566 97 DC                                  STAA TOC2IV
 1089:                                 
 1090:     2568 CC 258F                                LDD #TOC2RT
 1091:     256B DD DD                                  STD TOC2IV+1
 1092:                                 
 1093:     256D FC 100E                                LDD TCNT                ;sets the first time of TOC2
 1094:     2570 F3 2016                                ADDD On_cnts_R
 1095:     2573 FD 1018                                STD TOC2
 1096:                                 
 1097:     2576 86 40                                  LDAA #$40               ;intializing the registers
 1098:     2578 B7 1023                                staa TFLG1
 1099:                                 
 1100:     257B CE 1022                                ldx #TMSK1
 1101:     257E 1C 00 40                               BSET 0,X #$40
 1102:                                 
 1103:     2581 CE 1020                                LDX #TCTL1              ;toggles the output
 1104:     2584 1C 00 40                               BSET 0,X #$40
 1105:     2587 1D 00 80                               BCLR 0,x #$80
 1106:                                 
 1107:                                 
 1108:     258A 0E                                     CLI                     ;turning on the interrupts
 1109:                                 
 1110:     258B 38                                     pulx
 1111:     258C 33                                     pulb
 1112:     258D 32                                     pula 
 1113:                                 
 1114:     258E 39                                     rts
 1115:                                 ;**************************************************************************
 1116:                                 ;Name:          TOC2IV
 1117:                                 ;Author:        Gregory Reeves Jr.
 1118:                                 ;Date:          July 30, 2005
 1119:                                 ;Modified:      Dan Kohn Dec 8, 2005 For Dual Output Compares
 1120:                                 ;Function:      Interrupt for PWM for Right Motor
 1121:                                 ;On Call        On_cnts_R and Off_cnts_R 
 1122:                                 ;**************************************************************************
 1123:     258F 86 40                  TOC2RT:         LDAA #$40               ;resets the OC2F bit
 1124:     2591 B7 1023                                STAA TFLG1
 1125:                                 
 1126:     2594 B6 1000                                LDAA PORTA              ;check oc2 pin for on or off state
 1127:     2597 84 40                                  ANDA #$40
 1128:     2599 26 0B                                  BNE ON_2
 1129:                                 
 1130:     259B FC 1018                                LDD TOC2                ;sets up for the off time sequence
 1131:     259E F3 2018                                ADDD Off_cnts_R
 1132:     25A1 FD 1018                                STD TOC2
 1133:     25A4 20 09                                  BRA EXIT_2
 1134:                                 
 1135:     25A6 FC 1018                ON_2            LDD TOC2                ;sets up for the next ontime sequence
 1136:     25A9 F3 2016                                ADDD On_cnts_R
 1137:     25AC FD 1018                                STD TOC2
 1138:                                 
 1139:     25AF 3B                     EXIT_2          RTI                     ;return from the interrupt
 1140:                                 ;**************************************************************************
 1141:                                 ;Name:          TOC3_init
 1142:                                 ;Author:        Dan Kohn
 1143:                                 ;Date:          Dec 8, 2005
 1144:                                 ;Functions:     Initalize the Left Motor (OC3) 
 1145:                                 ;
 1146:                                 ;On Call:       go_stop MUST be called before initalizing 
 1147:                                 ;**************************************************************************
 1148:     25B0 36                     TOC3_init:      psha
 1149:     25B1 37                                     pshb
 1150:     25B2 3C                                     pshx
 1151:                                 
 1152:     25B3 0F                                     SEI
 1153:                                 
 1154:     25B4 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1155:     25B6 97 D9                                  STAA TOC3IV
 1156:                                 
 1157:     25B8 CC 25DF                                LDD #TOC3RT
 1158:     25BB DD DA                                  STD TOC3IV+1
 1159:                                 
 1160:     25BD FC 100E                                LDD TCNT                ;sets the first time of TOC2
 1161:     25C0 F3 200A                                ADDD On_cnts_L
 1162:     25C3 FD 101A                                STD TOC3
 1163:                                 
 1164:     25C6 86 20                                  LDAA #$20               ;intializing the registers
 1165:     25C8 B7 1023                                staa TFLG1
 1166:                                 
 1167:     25CB CE 1022                                ldx #TMSK1
 1168:     25CE 1C 00 20                               BSET 0,X #$20
 1169:                                 
 1170:     25D1 CE 1020                                LDX #TCTL1              ;toggles the output
 1171:     25D4 1C 00 10                               BSET 0,X #$10
 1172:     25D7 1D 00 20                               BCLR 0,x #$20
 1173:                                 
 1174:     25DA 0E                                     CLI                     ;turning on the interrupts
 1175:                                 
 1176:     25DB 38                                     pulx    
 1177:     25DC 33                                     pulb
 1178:     25DD 32                                     pula 
 1179:                                 
 1180:     25DE 39                                     rts
 1181:                                 ;**************************************************************************
 1182:                                 ;Name:          TOC3IV
 1183:                                 ;Author:        Gregory Reeves Jr.
 1184:                                 ;Date:          July 30, 2005
 1185:                                 ;Modified:      Dan Kohn Dec 8, 2005 For Dual Output Compares
 1186:                                 ;Function:      Interrupt for PWM for Left Motor
 1187:                                 ;On Call        On_cnts_L and Off_cnts_L 
 1188:                                 ;**************************************************************************
 1189:     25DF 86 20                  TOC3RT:         LDAA #$20               ;resets the OC3F bit
 1190:     25E1 B7 1023                                STAA TFLG1
 1191:                                 
 1192:     25E4 B6 1000                                LDAA PORTA              ;check oc3 pin for on or off state
 1193:     25E7 84 20                                  ANDA #$20
 1194:     25E9 26 0B                                  BNE ON_3
 1195:                                 
 1196:     25EB FC 101A                                LDD TOC3                ;sets up for the off time sequence
 1197:     25EE F3 200C                                ADDD Off_cnts_L
 1198:     25F1 FD 101A                                STD TOC3
 1199:     25F4 20 09                                  BRA EXIT_3
 1200:                                 
 1201:     25F6 FC 101A                ON_3            LDD TOC3                ;sets up for the next ontime sequence
 1202:     25F9 F3 200A                                ADDD On_cnts_L
 1203:     25FC FD 101A                                STD TOC3
 1204:                                 
 1205:     25FF 3B                     EXIT_3          RTI                     ;return from the interrupt
 1206:                                 
 1207:                                 ;**************************************************************************
 1208:                                 ;Name:          TOC3_init
 1209:                                 ;Author:        Michael McNeill, Jr.
 1210:                                 ;Date:          ??
 1211:                                 ;Functions:     Initalize the Multiplexed Servo (OC4) 
 1212:                                 ;
 1213:                                 ;On Call:       go_Gstop MUST be called before initalizing 
 1214:                                 ;**************************************************************************
 1215:     2600 36                     TOC4_init:      psha
 1216:     2601 37                                     pshb
 1217:     2602 3C                                     pshx
 1218:                                 
 1219:     2603 0F                                     SEI
 1220:                                 
 1221:     2604 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1222:     2606 97 D6                                  STAA TOC4IV
 1223:                                 
 1224:     2608 CC 262F                                LDD #TOC4RT
 1225:     260B DD D7                                  STD TOC4IV+1
 1226:                                 
 1227:     260D FC 100E                                LDD TCNT                ;sets the first time of TOC4
 1228:     2610 F3 201E                                ADDD On_cnts_A
 1229:     2613 FD 101C                                STD TOC4
 1230:                                 
 1231:     2616 86 10                                  LDAA #$10               ;intializing the registers
 1232:     2618 B7 1023                                staa TFLG1
 1233:                                 
 1234:     261B CE 1022                                ldx #TMSK1
 1235:     261E 1C 00 10                               BSET 0,X #$10
 1236:                                 
 1237:     2621 CE 1020                                LDX #TCTL1              ;toggles the output
 1238:     2624 1C 00 04                               BSET 0,X #$4
 1239:     2627 1D 00 08                               BCLR 0,x #$8
 1240:                                 
 1241:                                 
 1242:     262A 0E                                     CLI                     ;turning on the interrupts
 1243:                                 
 1244:     262B 38                                     pulx
 1245:     262C 33                                     pulb
 1246:     262D 32                                     pula 
 1247:                                 
 1248:     262E 39                                     rts
 1249:                                 ;**************************************************************************
 1250:                                 ;Name:          TOC4IV
 1251:                                 ;Author:        Michael McNeill, Jr.
 1252:                                 ;Date:          Feb 1, 2006
 1253:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1254:                                 ;On Call        On_cnts_G and Off_cnts_G 
 1255:                                 ;**************************************************************************
 1256:     262F 86 10                  TOC4RT:         LDAA #$10
 1257:     2631 B7 1023                                STAA TFLG1
 1258:                                 
 1259:     2634 B6 1000                                LDAA PORTA
 1260:     2637 84 10                                  ANDA #$10
 1261:     2639 26 0B                                  BNE ON_4
 1262:                                 
 1263:     263B FC 101C                                LDD TOC4
 1264:     263E F3 2020                                ADDD off_cnts_A
 1265:     2641 FD 101C                                STD TOC4
 1266:     2644 20 09                                  BRA EXIT_4
 1267:                                 
 1268:     2646 FC 101C                ON_4            LDD TOC4                ;sets up for the next ontime sequence
 1269:     2649 F3 201E                                ADDD On_cnts_A
 1270:     264C FD 101C                                STD TOC4
 1271:                                 
 1272:     264F 3B                     EXIT_4          RTI                     ;return from the interrupt
 1273:                                 
 1274:                                 ;**************************************************************************************************
 1275:                                 ;
 1276:                                 ;Name:          Scanner
 1277:                                 ;Author:        Michael McNeill, Jr.
 1278:                                 ;Date:          ??
 1279:                                 ;Functions:     Clears the Scanner buffer, then waits for the interrupt to 
 1280:                                 ;               recieve 33 bits. It then convers the returned bit pattern into plane
 1281:                                 ;               number based on the table below
 1282:                                 ;
 1283:                                 ;               Scanner reading $26 to $03
 1284:                                 ;                               $1e to $02
 1285:                                 ;                               $16 to $01
 1286:                                 ;
 1287:                                 ;Process:       the barcode scanner is read using the falling edge of PA0 (which is 
 1288:                                 ;               attached to the barcode clock). When a falling edge is detected, it 
 1289:                                 ;               reads the barcode data line (comming in on PE7). This data is placed
 1290:                                 ;               into the buffer from the left and shifted to the right. Each character
 1291:                                 ;               is actually 10 bits long. The first bit coming in is a START BIT, then
 1292:                                 ;               8 bits of data, then a PARITY BIT then a STOP bit. 
 1293:                                 ;
 1294:                                 ;               so the finish data buffer will look like this:
 1295:                                 ;
 1296:                                 ;               Byte        4       3       2       1       0
 1297:                                 ;               Bits 7654321076543210765432107654321076543210 
 1298:                                 ;
 1299:                                 ;                    sPxxxxxxxxSsPxxxxxxxxSsPxxxxxxxxS
 1300:                                 ;                    100010011001111110000010001001100
 1301:                                 ;                                            \      /
 1302:                                 ;                                             data representing plane #
 1303:                                 ;
 1304:                                 ;                            Data shifted -->
 1305:                                 ;
 1306:                                 ;               s=stop
 1307:                                 ;               P=Parity
 1308:                                 ;               S=START
 1309:                                 ;
 1310:                                 ;               the data is then compared to the values returned for planes 1,2,3 and
 1311:                                 ;               converted to the plane number. If the scan is bad, $FF will be the result.
 1312:                                 ;               This value is then stored in BOXCODE.
 1313:                                 ;
 1314:                                 ;On Call:       None
 1315:                                 ;
 1316:                                 ;On Return:     BOXCODE containes the plane number indicated by the barcode read ($FF
 1317:                                 ;               indicates an error when scanned).  
 1318:                                 ;               
 1319:                                 ;               Wiring of the Barcode
 1320:                                 ;               (Red wire - clock) (Brown wire - Data) (Green wire - Ground) (Orange wire - 5volts) (Yellow wire - 5volts)
 1321:                                 ;               (Black wire - 5volts)
 1322:                                 ;               
 1323:                                 ;
 1324:                                 ;
 1325:                                 ;*******************************************************************************************
 1326:                                         
 1327:                                 
 1328:     2650                        Scanner:
 1329:     2650 36                             psha
 1330:     2651 BD 26E2                        jsr BC_clear
 1331:                                 
 1332:                                 
 1333:     2654 86 00                          ldaa #$00
 1334:     2656 B7 2023                        staa sec_count
 1335:                                         
 1336:     2659 B6 2023                sc_0:   ldaa sec_count          ;  watchdog timer for six seconds
 1337:     265C 81 3C                          cmpa #60                ;* exits after 6 seconds if 33 bits not recieved
 1338:     265E 24 34                          bhs  SC_3               ;* will return $ff as barcode error code
 1339:     2660 B6 2008                        lDAA BC_count
 1340:     2663 81 21                          cmpa #33
 1341:     2665 25 F2                          BLO sc_0
 1342:                                 
 1343:     2667 B6 2006                        Ldaa Barcode+3          ;Barcode to read #$26 to plane 3
 1344:     266A 81 26                          cmpa #$26
 1345:     266C 26 08                          Bne  sc_1
 1346:     266E 86 03                          ldaa #$03
 1347:     2670 B7 2009                        staa Boxcode
 1348:                                 
 1349:     2673 7E 2699                        jmp sc_exit
 1350:                                 
 1351:     2676                        Sc_1    
 1352:     2676 B6 2006                        Ldaa Barcode+3          ;Barcode to read #$1e to plane 2
 1353:     2679 81 1E                          cmpa #$1e
 1354:     267B 26 08                          Bne  sc_2
 1355:     267D 86 02                          ldaa #$02
 1356:     267F B7 2009                        staa Boxcode
 1357:                                 
 1358:     2682 7E 2699                        jmp sc_exit
 1359:                                 
 1360:     2685                        Sc_2    
 1361:     2685 B6 2006                        Ldaa Barcode+3          ;Barcode to read #$16 to plane 1
 1362:     2688 81 16                          cmpa #$16
 1363:     268A 26 08                          Bne  sc_3
 1364:     268C 86 01                          ldaa #$01
 1365:     268E B7 2009                        staa Boxcode
 1366:                                 
 1367:     2691 7E 2699                        jmp sc_exit
 1368:                                         
 1369:     2694                        Sc_3    
 1370:                                         
 1371:                                 
 1372:     2694 86 FF                          ldaa #$ff               ;flag for bad scan
 1373:     2696 B7 2009                        staa Boxcode
 1374:                                 
 1375:     2699                        sc_exit
 1376:                                 
 1377:     2699 32                             pula
 1378:     269A 39                             rts
 1379:                                 
 1380:                                 
 1381:                                 
 1382:                                 ;*******************************************************************************
 1383:                                 ;Name:          IC3_init
 1384:                                 ;Author:        Michael McNeill, Jr.
 1385:                                 ;Date:          ??
 1386:                                 ;Functions:     This initializes IC3 to capture a falling edge of the 
 1387:                                 ;               clock for the barcode reader. 
 1388:                                 ;
 1389:                                 ;********************************************************************************
 1390:     269B 36                     IC3_init:       psha
 1391:     269C 3C                                     pshx
 1392:                                                                         
 1393:     269D 0F                                     sei
 1394:                                 
 1395:     269E 86 7E                                  ldaa #$7E
 1396:     26A0 97 E2                                  staa IC3IV
 1397:                                 
 1398:     26A2 CC 26BF                                LDD #IC3RT
 1399:     26A5 DD E3                                  STD IC3IV+1
 1400:                                 
 1401:     26A7 CE 1021                                LDX #TCTL2
 1402:                                 
 1403:     26AA 1C 00 02                               Bset 0,X #$02   ;set for falling edge
 1404:     26AD 1D 00 01                               Bclr 0,X #$01
 1405:                                        
 1406:     26B0 86 01                                  LDAA #$01
 1407:     26B2 B7 1023                                STAA TFLG1      ;clr flag
 1408:                                 
 1409:     26B5 CE 1022                                LDX #TMSK1      ;turn on INT
 1410:     26B8 1C 00 01                               Bset 0,X #$01
 1411:                                 
 1412:     26BB 0E                                     cli
 1413:                                 
 1414:     26BC 38                                     pulx
 1415:     26BD 32                                     pula
 1416:     26BE 39                                     rts
 1417:                                 
 1418:                                 
 1419:                                 ;**************************************************************************
 1420:                                 ;Name:          IC3RT - Barcode interrupt 
 1421:                                 ;Author:        Dan Kohn
 1422:                                 ;Date:          ??
 1423:                                 ;Function:      This interrupt is triggered on a FALLING EDGE of the 
 1424:                                 ;               bar code clk signal. That that time, the data line is
 1425:                                 ;               captured and placed into the CARRY BIT which is then
 1426:                                 ;               shifted from the left into the barcode buffer.
 1427:                                 ;
 1428:                                 ;               [see SCANNER routine for more info]
 1429:                                 ;**************************************************************************
 1430:                                 
 1431:     26BF 86 01                  IC3RT:          ldaa #$01               ;resets the IC3 bit
 1432:     26C1 B7 1023                                staa TFLG1
 1433:                                 
 1434:     26C4 B6 100A                                Ldaa portE              ;check IC3 pin for on or off state
 1435:     26C7 84 80                                  anda #$80
 1436:     26C9 27 03                                  BEQ  BC_High
 1437:     26CB 0D                                     sec
 1438:     26CC 20 01                                  BRA BC_skip
 1439:                                 
 1440:     26CE 0C                     BC_High         clc
 1441:                                 
 1442:     26CF 76 2003                BC_Skip         ROR Barcode
 1443:     26D2 76 2004                                ROR Barcode+1
 1444:     26D5 76 2005                                ROR Barcode+2
 1445:     26D8 76 2006                                ROR Barcode+3
 1446:     26DB 76 2007                                ROR Barcode+4
 1447:     26DE 7C 2008                                INC BC_count
 1448:     26E1 3B                                     RTI                     ;return from the interrupt
 1449:                                 
 1450:                                 
 1451:                                 ;**************************************************************************
 1452:                                 ;Name:          BC_Clear - Clear Bar Code buffer 
 1453:                                 ;Author:        Dan Kohn
 1454:                                 ;Date:          ??
 1455:                                 ;Function:      Clear the buffer for the bar code buffer (fill with all ones)
 1456:                                 ;**************************************************************************
 1457:     26E2 36                     BC_clear:       psha
 1458:     26E3 86 FF                                  LDAA #$FF
 1459:     26E5 B7 2003                                STAA Barcode
 1460:     26E8 B7 2004                                STAA Barcode+1
 1461:     26EB B7 2005                                STAA Barcode+2
 1462:     26EE B7 2006                                STAA Barcode+3
 1463:     26F1 B7 2007                                STAA Barcode+4
 1464:     26F4 86 00                                  LDAA #$0
 1465:     26F6 B7 2008                                STAA BC_count
 1466:                                 
 1467:     26F9 32                                     Pula
 1468:     26FA 39                                     RTS
 1469:                                 ;**************************************************************************
 1470:                                 ;Name:          TOC1_init
 1471:                                 ;Author:        michael mcneill
 1472:                                 ;Date:          4/15/06
 1473:                                 ;Functions:     Initalize the toc1_init 
 1474:                                 ;
 1475:                                 ;On Call:       go_stop MUST be called before initalizing 
 1476:                                 ;**************************************************************************
 1477:     26FB 36                     TOC1_init:      psha
 1478:     26FC 37                                     pshb
 1479:     26FD 3C                                     pshx
 1480:                                 
 1481:     26FE 0F                                     SEI
 1482:                                 
 1483:     26FF 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1484:     2701 97 DF                                  STAA TOC1IV
 1485:                                 
 1486:     2703 CC 272C                                LDD #TOC1RT
 1487:     2706 DD E0                                  STD TOC1IV+1
 1488:                                 
 1489:     2708 FC 100E                                LDD TCNT                ;sets the first time of TOC1
 1490:     270B F3 201A                                ADDD On_cnts_GR
 1491:     270E FD 1016                                STD TOC1
 1492:                                 
 1493:     2711 86 80                                  LDAA #$80               ;intializing the registers
 1494:     2713 B7 1023                                staa TFLG1
 1495:                                 
 1496:     2716 CE 1022                                ldx #TMSK1
 1497:     2719 1C 00 80                               BSET 0,X #$80
 1498:                                 
 1499:     271C 86 80                                  LDAA #$80
 1500:     271E B7 100C                                STAA oc1m
 1501:                                                 
 1502:     2721 CE 1026                                LDx #pactl
 1503:     2724 1C 00 80                               bset 0,x #$80
 1504:                                 
 1505:                                                 
 1506:                                 
 1507:     2727 0E                                     CLI                     ;turning on the interrupts
 1508:                                 
 1509:     2728 38                                     pulx
 1510:     2729 33                                     pulb
 1511:     272A 32                                     pula 
 1512:                                 
 1513:     272B 39                                     rts
 1514:                                 ;**************************************************************************
 1515:                                 
 1516:                                 
 1517:                                 
 1518:                                 
 1519:                                 ;**************************************************************************
 1520:                                 ;Name:          TOCIRT
 1521:                                 ;Author:        Michael McNeill, Jr.
 1522:                                 ;Date:          3/15/06
 1523:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1524:                                 ;On Call        On_cnts_Gr and Off_cnts_Gr 
 1525:                                 ;**************************************************************************
 1526:     272C 86 80                  TOC1RT:         LDAA #$80
 1527:     272E B7 1023                                STAA TFLG1
 1528:                                 
 1529:     2731 B6 1000                                LDAA PORTA
 1530:     2734 84 80                                  ANDA #$80
 1531:     2736 26 11                                  Bne toc1_high
 1532:                                 
 1533:                                 
 1534:                                                 
 1535:                                 
 1536:                                 
 1537:     2738 FC 1016                toc1_low:       LDD TOC1
 1538:     273B F3 201C                                ADDD off_cnts_Gr
 1539:     273E FD 1016                                STD TOC1
 1540:                                 
 1541:     2741 CE 100D                                ldx #oc1d               ;set pin to go high next time TOC=TCNT
 1542:     2744 1C 00 80                               bset 0,x #$80
 1543:                                 
 1544:     2747 20 0F                                  BRA EXIT_1
 1545:                                 
 1546:     2749 FC 1016                toc1_high:      LDD TOC1                ;sets up for the next ontime sequence
 1547:     274C F3 201A                                ADDD on_cnts_Gr
 1548:     274F FD 1016                                STD TOC1
 1549:                                 
 1550:     2752 CE 100D                                ldx #oc1d               ;set pin to go low next time TOC=TCNT
 1551:     2755 1D 00 80                               bclr 0,x #$80
 1552:                                 
 1553:     2758 3B                     EXIT_1:         RTI                     ;return from the interrupt
 1554:                                 
 1555:                                 ;**************************************************************************************************
 1556:                                 ;Name:          grip0
 1557:                                 ;Author:        Michael McNeill, Jr.
 1558:                                 ;Date:          3/15/06
 1559:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1560:                                 ;On Call        On_cnts_Gr 
 1561:                                 ;Gripper (TOC1init) Variables and Equates:
 1562:                                 ;gripppe open
 1563:                                 ;
 1564:                                 ;
 1565:                                 ;
 1566:                                 ;************************************************************************************************************
 1567:     2759 183C                   gripO:          pshy
 1568:                                                         
 1569:                                 
 1570:     275B 18CE 8AAC                              ldy #35500      
 1571:     275F 18FF 201C                              sty off_cnts_Gr
 1572:     2763 18CE 1194                              ldy #4500       
 1573:     2767 18FF 201A                              sty on_cnts_Gr
 1574:                                                 
 1575:                                                 
 1576:     276B 1838                                   puly
 1577:                                                 
 1578:     276D 39                                     rts
 1579:                                 ;**************************************************************************************************
 1580:                                 ;Name:          gripC
 1581:                                 ;Author:        Michael McNeill, Jr.
 1582:                                 ;Date:          3/15/06
 1583:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1584:                                 ;On Call        OFF_cnts_Gr 
 1585:                                 ;Gripper (TOC1init) Variables and Equates:
 1586:                                 ;gripppe close
 1587:                                 ;
 1588:                                 ;
 1589:                                 ;
 1590:                                 ;************************************************************************************************************
 1591:     276E 183C                   gripC:          pshy
 1592:                                 
 1593:                                 
 1594:     2770 18CE 7530                              ldy #30000              ;35400
 1595:     2774 18FF 201C                              sty off_cnts_Gr
 1596:     2778 18CE 2710                              ldy #10000              ;4600
 1597:     277C 18FF 201A                              sty on_cnts_Gr          
 1598:                                 
 1599:                                 
 1600:     2780 1838                                   puly
 1601:     2782 39                                     rts
 1602:                                 ;************************************************************************************************************
 1603:                                 ;*******************************************************************************
 1604:                                 ;Name:          IC1_init
 1605:                                 ;Author:        Michael McNeill, Jr.
 1606:                                 ;Date:          ??
 1607:                                 ;Functions:     This initializes IC1 to capture a rising edge of the 
 1608:                                 ;               encoder. 
 1609:                                 ;
 1610:                                 ;********************************************************************************
 1611:     2783 36                     IC1_init:       psha
 1612:     2784 3C                                     pshx
 1613:                                                                                 
 1614:     2785 0F                                     sei
 1615:                                 
 1616:     2786 86 7E                                  ldaa #$7E               
 1617:     2788 97 E8                                  staa IC1IV
 1618:                                 
 1619:     278A CC 27A7                                LDD #IC1RT
 1620:     278D DD E9                                  STD IC1IV+1
 1621:                                 
 1622:     278F CE 1021                                LDX #TCTL2
 1623:                                 
 1624:     2792 1C 00 10                               Bset 0,X #$10   ;set for rising edge
 1625:     2795 1D 00 20                               Bclr 0,X #$20
 1626:                                        
 1627:     2798 86 04                                  LDAA #$04
 1628:     279A B7 1023                                STAA TFLG1      ;clr flag
 1629:                                 
 1630:     279D CE 1022                                LDX #TMSK1      ;turn on INT
 1631:     27A0 1C 00 04                               Bset 0,X #$04
 1632:                                 
 1633:     27A3 0E                                     cli
 1634:                                 
 1635:     27A4 38                                     pulx
 1636:     27A5 32                                     pula
 1637:     27A6 39                                     rts
 1638:                                 
 1639:                                 
 1640:                                 ;**************************************************************************
 1641:                                 ;Name:          IC1RT - encoder interrupt 
 1642:                                 ;Author:        Dan Kohn
 1643:                                 ;Date:          ??
 1644:                                 ;Function:      
 1645:                                 ;
 1646:                                 ;               
 1647:                                 ;**************************************************************************
 1648:                                 
 1649:     27A7 86 04                  IC1RT:          ldaa #$04               ;resets the IC1 bit
 1650:     27A9 B7 1023                                staa TFLG1
 1651:                                                 
 1652:     27AC B6 202E                                ldaa Armlift
 1653:     27AF 81 01                                  cmpa #$01
 1654:                                 
 1655:     27B1 26 0A                                  bne Fred
 1656:     27B3 FE 202C                                ldx encoder1
 1657:                                 
 1658:     27B6 08                                     inx
 1659:     27B7 FF 202C                                stx encoder1 
 1660:                                 
 1661:     27BA 7E 27C4                                jmp Tom
 1662:                                 
 1663:     27BD FE 202C                Fred:           ldx encoder1
 1664:                                 
 1665:     27C0 09                                     dex
 1666:                                  
 1667:     27C1 FF 202C                                stx encoder1
 1668:                                 
 1669:                                 
 1670:     27C4                        Tom:
 1671:     27C4 3B                                     rti
 1672:                                 

Symbols:
a2d                             *00002480
adctl                           *00001030
adown                           *0000247c
adr2                            *00001032
adr3                            *00001033
adr4                            *00001034
armlift                         *0000202e
astop                           *00002474
aup                             *00002478
barcode                         *00002003
bc_clear                        *000026e2
bc_count                        *00002008
bc_high                         *000026ce
bc_skip                         *000026cf
boxcode                         *00002009
checkcenter                     *000023a5
checkleft                       *000023b2
clockw1                         *000023c2
clockw_loop                     *000023cb
counter_loop                    *000023e0
counterclck                     *000023d7
encoder1                        *0000202c
end_check                       *00002108
exit_1                          *00002758
exit_2                          *000025af
exit_3                          *000025ff
exit_4                          *0000264f
fforward                        *00002334
fforward_s                      *00002380
forward                         *00002430
fred                            *000027bd
go_adown                        *0000245b
go_astop                        *00002448
go_aup                          *0000244e
go_forward                      *000023fe
go_left                         *000023f2
go_reverse                      *00002404
go_right                        *000023f8
go_stop                         *000023ec
gripc                           *0000276e
gripo                           *00002759
ic1_init                        *00002783
ic1iv                           *000000e8
ic1rt                           *000027a7
ic3iv                           *000000e2
ic3rt                           *000026bf
leaveshoot                      *00002132
left                            *00002440
left90                          *000024a6
linetrack                       *00002302
linetrackspec                   *00002345
lt_cont                         *00002391
lt_exit                         *000023bf
lt_loop                         *00002304
lt_loop1                        *00002347
ltcb                            *0000200f
ltl                             *00000094
lturn                           *0000232e
lturn_s                         *0000237a
main                            *00002030
no_1_plane                      *000020d2
no_2_plane                      *000020e5
no_3_plane                      *000020f8
oc1d                            *0000100d
oc1m                            *0000100c
off_cnts_a                      *00002020
off_cnts_gr                     *0000201c
off_cnts_l                      *0000200c
off_cnts_r                      *00002018
on_2                            *000025a6
on_3                            *000025f6
on_4                            *00002646
on_cnts_a                       *0000201e
on_cnts_gr                      *0000201a
on_cnts_l                       *0000200a
on_cnts_r                       *00002016
option                          *00001039
out1bsp                         *0000ffbe
outcrlf                         *0000ffc4
pactl                           *00001026
pause                           *00002493
pausel1                         *0000249d
plane1                          *00002169
plane1_cd                       *00002026
plane2                          *00002219
plane2_cd                       *00002028
plane3                          *00002292
plane3_cd                       *0000202a
plane_temp                      *00002024
plane_time                      *00002517
porta                           *00001000
porte                           *0000100a
pt_2                            *0000253f
pt_3                            *0000254f
reg_base                        *00001000
reverse                         *00002428
right                           *00002438
right90                         *000024b1
robot_arm                       *00002468
robot_do1                       *0000240a
rturn                           *00002328
rturn_s                         *00002374
sc_0                            *00002659
sc_1                            *00002676
sc_2                            *00002685
sc_3                            *00002694
sc_exit                         *00002699
sec_count                       *00002023
sec_temp                        *00002022
shoot2                          *000021df
sstop                           *0000233a
sstop_s                         *00002386
start                           *0000210c
stop                            *00002420
tcnt                            *0000100e
tctl1                           *00001020
tctl2                           *00001021
tflg1                           *00001023
tflg2                           *00001025
tmsk1                           *00001022
tmsk2                           *00001024
toc1                            *00001016
toc1_high                       *00002749
toc1_init                       *000026fb
toc1iv                          *000000df
toc1rt                          *0000272c
toc2                            *00001018
toc2_init                       *00002560
toc2iv                          *000000dc
toc2rt                          *0000258f
toc3                            *0000101a
toc3_init                       *000025b0
toc3iv                          *000000d9
toc3rt                          *000025df
toc4                            *0000101c
toc4_init                       *00002600
toc4iv                          *000000d6
toc4rt                          *0000262f
tof_cnt                         *000024fb
tof_exit                        *0000255f
tof_init                        *000024bc
tofiv                           *000000d0
tom                             *000027c4
top                             *0000205f

