E:\Robot\Mar26lastday.lst - generated by MGTEK Assembler ASM11 V1.22 Build 137 for WIN32 (x86) - Sat Apr 01 05:10:04 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 202E                                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:                                 
  130:     202E                        MAIN            
  131:                                 
  132:     202E BD 2383                                jsr go_stop             ;Set up On/Off times for stop
  133:     2031 BD 26F7                                jsr gripC
  134:     2034 BD 26E2                                jsr gripO
  135:     2037 BD 23DF                                jsr go_astop
  136:                                                 
  137:     203A BD 2589                                jsr TOC4_init           ;init arm motor
  138:     203D BD 2539                                jsr TOC3_init           ;init left motor
  139:     2040 BD 24E9                                jsr TOC2_init           ;init right motor
  140:     2043 BD 2445                                jsr TOF_init            ;init Timer Overflow (for 0.5 sec Timer)
  141:     2046 BD 2409                                jsr A2D                 ;init A/D PE0..PE3
  142:     2049 BD 2684                                jsr TOC1_init           ;inint TOC1_inint for the gripper               
  143:                                                 ;ldx #$00               ;inint encoder 1 to accum x
  144:                                                 ;stx encoder1
  145:                                                 ;jsr IC1_init           ;init IC1_init to encoder 1
  146:                                 
  147:                                 
  148:     204C 86 1E                                  ldaa #30
  149:     204E BD 241C                                jsr pause
  150:                                                 
  151:     2051 BD 2057                                jsr test
  152:                                 
  153:                                 
  154:                                 ;               
  155:                                 ;POLP:          jsr go_Adown
  156:                                 ;               jsr Encoder
  157:                                 ;               
  158:                                 ;               jmp POLP
  159:                                 
  160:                                 
  161:                                 
  162:                                         ;       jsr Start               ;leave the block
  163:                                         ;       
  164:                                         ;       jsr GripC               ;grips the first block
  165:                                         ;       ldaa #30
  166:                                         ;       jsr pause
  167:                                 ;
  168:                                 ;               jsr LeaveShoot          ; moves robot from shoot to the plane 1 intersection            
  169:                                 ;                                       ; spot to check if need to go to 1st plane
  170:                                 ;               jsr Plane1              ; moves the plane to plane one and dumps and returns
  171:                                 ;                                       ; to the 1st t intersection
  172:                                 ;               jsr gripO               
  173:                                 ;;
  174:                                 ;               
  175:                                 ;;              jsr Shoot2              ; this moves the robot back to the shoot
  176:                                 ;;              jsr LeaveShoot          ; moves from the shoot back to the 1st t intersection
  177:                                 ;               jsr Plane2              ; moves from t intersection an back to t intersection
  178:                                 ;               jsr Shoot2              ; moves back to the shoot
  179:                                 ;               jsr LeaveShoot          ; moves back to t intersection
  180:                                 ;               jsr Plane3              ; moves from the t intersection and back from the 3rd plane
  181:                                 ;               jsr Shoot2              ; moves back to the shoot
  182:                                                 
  183:     2054 7E 2383                                jmp go_stop
  184:                                 ;               jmp $e000       
  185:                                 ;*******************************************************************
  186:                                 ; test section
  187:                                 ; This test is design to see if the robot will pull the block out
  188:                                 ;
  189:                                 ;
  190:                                 ;******************************************************************
  191:     2057                        test:
  192:     2057 36                                     psha
  193:     2058 37                                     pshb
  194:     2059 3C                                     pshx
  195:                                                 
  196:     205A BD 26E2                                jsr gripO       ;open the gripper from the schute
  197:     205D BD 20CE                                jsr Start       ; moves to the shoot
  198:     2060 BD 26F7                                jsr gripC
  199:     2063 86 02                                  ldaa #02
  200:     2065 BD 241C                                jsr pause       ; grabs the first block
  201:     2068 BD 239B                                jsr go_reverse  ; backs up 
  202:     206B 86 0F                                  ldaa #15
  203:     206D BD 241C                                jsr pause
  204:                                                 
  205:     2070 BD 20E7                                jsr leaveshoot
  206:     2073 BD 211E                                jsr plane1  ; moves the block to the t intersection
  207:     2076 38                                     pulx
  208:     2077 33                                     pulb
  209:     2078 32                                     pula
  210:     2079 39                                     rts
  211:                                 
  212:                                 
  213:                                 ;*****************************************************************************
  214:                                 ; Encoder
  215:                                 ; 
  216:                                 ;
  217:                                 ;
  218:                                 ;****************************************************************************
  219:                                                 
  220:     207A                        Encoder:        
  221:     207A 3C                                     pshx
  222:                                 
  223:     207B CE 202C                                ldx #encoder1           ;init encoder1 to read screen
  224:     207E BD FFBE                                jsr out1bsp             
  225:     2081 BD FFC4                                jsr outcrlf
  226:                                 
  227:     2084 38                                     pulx
  228:     2085 39                                     rts
  229:                                 
  230:                                 ;***************************************************************************
  231:                                 ; this section will grab block and check and move to the appropriate box
  232:                                 ;***************************************************************************
  233:     2086                        block_check:
  234:     2086 36                                     psha
  235:     2087 37                                     pshb
  236:     2088 3C                                     pshx
  237:                                                 
  238:     2089 BD 26F7                                jsr gripC               ; grab the block
  239:     208C BD 239B                                jsr go_reverse          ; back up and take block out of stack
  240:     208F 86 03                                  ldaa #03
  241:     2091 BD 241C                                jsr pause               
  242:                                                                         ; do barcode scanner here
  243:     2094 B6 2009                NO_1_Plane:     ldaa Boxcode
  244:     2097 81 01                                  cmpa #$01               ; if the bacrode read 1 it go to plane 1
  245:     2099 26 0C                                  bne NO_2_Plane          ;
  246:     209B BD 20E7                                jsr LeaveShoot
  247:     209E BD 211E                                jsr plane1
  248:     20A1 BD 218C                                jsr  Shoot2
  249:     20A4 7E 20CA                                jmp  end_check                  
  250:     20A7                        NO_2_Plane:
  251:     20A7 B6 2009                                ldaa Boxcode            ;if the barcode read 2 it go to plane 2
  252:     20AA 81 02                                  cmpa #$02
  253:     20AC 26 0C                                  bne No_3_Plane
  254:     20AE BD 20E7                                jsr LeaveShoot
  255:     20B1 BD 21CB                                jsr plane2
  256:     20B4 BD 218C                                jsr shoot2
  257:     20B7 7E 20CA                                jmp end_check
  258:     20BA                        NO_3_Plane:
  259:     20BA B6 2009                                ldaa Boxcode            ;if the barcode read 3 it go to plane 3
  260:     20BD 81 FF                                  cmpa #$FF
  261:     20BF 27 D3                                  beq NO_1_Plane
  262:     20C1 BD 20E7                                jsr leaveshoot
  263:     20C4 BD 2239                                jsr plane3
  264:     20C7 BD 218C                                jsr shoot2
  265:                                                 
  266:     20CA                        end_check:      
  267:                                                         
  268:     20CA 38                                     pulx
  269:     20CB 33                                     pulb
  270:     20CC 32                                     pula
  271:                                                                          ; here light the led  for hey i am done
  272:     20CD 39                                     rts
  273:                                                 
  274:                                 ;;**************************************************************************
  275:                                 ; this section moves the robot to the block shoot
  276:                                 ;**************************************************************************
  277:     20CE 36                     Start:          psha
  278:                                                 
  279:                                                 
  280:     20CF BD 2395                                jsr go_forward          ;Leaving Block
  281:     20D2 86 0A                                  ldaa #10
  282:     20D4 BD 241C                                jsr pause
  283:     20D7 BD 2299                                jsr LineTrack           ; this line moves forward until the 1st plus intersection
  284:                                                 
  285:                                 
  286:     20DA BD 2395                                jsr go_forward          ; moves forward so line tracking will work 
  287:     20DD 86 0A                                  ldaa #10
  288:     20DF BD 241C                                jsr pause
  289:                                                 
  290:                                                 
  291:                                 
  292:     20E2 BD 2299                                jsr LineTrack   ; moves forward to the 1st plus intersection
  293:                                                 
  294:                                 
  295:     20E5 32                                     pula
  296:     20E6 39                                     rts
  297:                                 ;**************************************************************************
  298:                                 ; this section moves the robot away from the shoot to the intersection for
  299:                                 ; turning to plane 1
  300:                                 ;**************************************************************************
  301:                                                 
  302:     20E7 36                     LeaveShoot:     psha
  303:                                         
  304:     20E8 BD 239B                                jsr go_reverse
  305:     20EB 86 08                                  ldaa #8
  306:     20ED BD 241C                                jsr pause
  307:                                 
  308:     20F0 BD 2383                                jsr go_stop
  309:     20F3 86 14                                  ldaa #20
  310:     20F5 BD 241C                                jsr pause
  311:                                 
  312:     20F8 BD 2359                                jsr clockw1             ;180 Right Turn to leave the Package shoot
  313:     20FB BD 2299                                jsr LineTrack           ; line track back to the 1st plus
  314:     20FE BD 2395                                jsr go_forward          ; this section makes the first turn
  315:     2101 86 07                                  ldaa #7
  316:                                                                         ; *
  317:     2103 BD 241C                                jsr pause               ; *
  318:     2106 BD 2383                                jsr go_stop
  319:     2109 86 05                                  ldaa #5
  320:     210B BD 241C                                jsr pause               ; *
  321:     210E BD 236E                                jsr counterclck         ; *
  322:     2111 BD 2383                                jsr go_stop             ; *
  323:     2114 86 05                                  ldaa #5                 ; *
  324:     2116 BD 241C                                jsr pause               ; *
  325:                                 
  326:     2119 BD 2299                                jsr LineTrack           ; moves robot to the 1st t intersection
  327:                                                                         ; ends this section
  328:                                                 
  329:                                 
  330:     211C 32                                     pula
  331:     211D 39                                     rts
  332:                                 ;**************************************************************************
  333:                                 ; this section moves the robot to the first plane and then moves it back to the 1st t intersection
  334:                                 ;**************************************************************************
  335:     211E 36                     Plane1:         psha
  336:                                 
  337:     211F BD 2395                                jsr go_forward          ; moves forward so turn will work properly
  338:     2122 86 07                                  ldaa #7
  339:     2124 BD 241C                                jsr pause
  340:     2127 BD 2383                                jsr go_stop
  341:     212A 86 05                                  ldaa #5
  342:     212C BD 241C                                jsr pause
  343:     212F BD 2359                                jsr clockw1             ;turns right until hits white line for the first plane
  344:                                 
  345:     2132 BD 2383                                jsr go_stop             
  346:     2135 86 14                                  ldaa #20
  347:     2137 BD 241C                                jsr pause
  348:     213A BD 2299                                jsr Linetrack           ;Stops at 2nd plus by Loading Zone 1
  349:     213D BD 2395                                jsr go_forward          
  350:     2140 86 03                                  ldaa #3
  351:     2142 BD 241C                                jsr pause
  352:     2145 BD 2299                                jsr Linetrack
  353:                                 
  354:     2148 BD 23E5                                jsr go_Aup
  355:     214B 86 14                                  ldaa #20
  356:     214D BD 241C                                jsr pause
  357:                                                 
  358:                                 
  359:                                                 
  360:     2150 BD 242F                                jsr Left90              ; turns to the airplane
  361:     2153 BD 2383                                jsr go_stop             ; right her is where droping will occur         
  362:     2156 86 19                                  ldaa #25        
  363:     2158 BD 241C                                jsr pause
  364:                                 
  365:                                                         
  366:     215B BD 26E2                                jsr gripO               ; for the simple robot must remove
  367:     215E 86 0A                                  ldaa #10                        ; and replace with carrage dump section
  368:     2160 BD 241C                                jsr pause               ;*
  369:                                                 
  370:     2163 BD 236E                                jsr counterclck
  371:                                 
  372:                                 
  373:     2166 BD 2299                                jsr linetrack           ; moves the robot forward to the 2nd plus
  374:     2169 BD 2395                                jsr go_forward          ; this section moves the robot back to the 
  375:     216C 86 05                                  ldaa #5         
  376:     216E BD 241C                                jsr pause
  377:     2171 BD 2299                                jsr linetrack
  378:                                 
  379:     2174 BD 2395                                jsr go_forward
  380:     2177 86 07                                  ldaa #7
  381:     2179 BD 241C                                jsr pause
  382:                                                 
  383:                                                 
  384:     217C BD 236E                                jsr counterclck
  385:     217F BD 2383                                jsr go_stop
  386:     2182 86 05                                  ldaa #5         
  387:                                 
  388:     2184 BD 2299                                jsr Linetrack   ;       
  389:     2187 BD 241C                                jsr pause               ;
  390:                                 
  391:                                                 
  392:                                 
  393:     218A 32                                     pula
  394:                                 
  395:     218B 39                                     rts
  396:                                 ;**************************************************************************
  397:                                 ; this section goes back to the shoot from the t intersection
  398:                                 ;
  399:                                 ;
  400:                                 ;**************************************************************************
  401:     218C 36                     Shoot2:         psha
  402:                                                 
  403:     218D BD 2299                                jsr Linetrack
  404:     2190 BD 2395                                jsr go_forward
  405:     2193 86 08                                  ldaa #8
  406:     2195 BD 241C                                jsr pause
  407:                                                 
  408:     2198 BD 2299                                jsr Linetrack
  409:                                 
  410:     219B BD 2359                                jsr clockw1             ;Goes back to Shoot
  411:     219E BD 2383                                jsr go_stop             ;
  412:     21A1 86 08                                  ldaa #8
  413:     21A3 BD 241C                                jsr pause
  414:                                                 
  415:     21A6 BD 2299                                jsr LineTrack
  416:                                                 
  417:     21A9 BD 23EB                                jsr go_Adown
  418:     21AC 86 14                                  ldaa #20
  419:     21AE BD 241C                                jsr pause
  420:                                                 
  421:                                 
  422:     21B1 BD 2395                                jsr go_forward
  423:     21B4 86 12                                  ldaa #18
  424:     21B6 BD 241C                                jsr pause
  425:                                 
  426:     21B9 BD 2383                                jsr go_stop
  427:     21BC 86 0A                                  ldaa #10
  428:     21BE BD 241C                                jsr pause
  429:                                 
  430:     21C1 BD 26F7                                jsr gripC
  431:     21C4 86 14                                  ldaa #20
  432:     21C6 BD 241C                                jsr pause
  433:                                                 
  434:     21C9 32                                     pula
  435:     21CA 39                                     rts
  436:                                 ;
  437:                                 ;**************************************************************************
  438:                                 ; this section moves from the t intersection
  439:                                 ; to the second plane and back to the 1st t intersection
  440:                                 ;**************************************************************************
  441:     21CB 36                     Plane2:         psha
  442:                                                 
  443:     21CC BD 2395                                jsr go_forward
  444:     21CF 86 05                                  ldaa #5
  445:     21D1 BD 241C                                jsr pause
  446:                                                 
  447:     21D4 BD 2299                                jsr Linetrack           ; moves the robot forward until you get to the 3rd plus
  448:                                                                         ; intersection
  449:     21D7 BD 2395                                jsr go_forward          
  450:     21DA 86 05                                  ldaa #5
  451:     21DC BD 241C                                jsr pause
  452:     21DF BD 2359                                jsr clockw1             ;will trun right until hits the white line agian
  453:                                                 
  454:     21E2 BD 2383                                jsr go_stop
  455:     21E5 86 05                                  ldaa #5
  456:     21E7 BD 241C                                jsr pause
  457:     21EA BD 2299                                jsr Linetrack           ;Stops at 4th plus by Loading Zone 1
  458:     21ED BD 2395                                jsr go_forward
  459:     21F0 86 0A                                  ldaa #10
  460:     21F2 BD 241C                                jsr pause
  461:     21F5 BD 2299                                jsr Linetrack           ; moves forward until side of board
  462:     21F8 86 05                                  ldaa #5
  463:     21FA BD 241C                                jsr pause
  464:     21FD BD 242F                                jsr Left90              ; turn left to go towards the plane
  465:     2200 BD 2383                                jsr go_stop
  466:     2203 86 05                                  ldaa #5
  467:     2205 BD 241C                                jsr pause
  468:     2208 BD 26E2                                jsr gripO               ; this section for the simple robot 
  469:     220B 86 0A                                  ldaa #10                ; this is where the carrage drop occurs
  470:     220D BD 241C                                jsr pause
  471:                                 
  472:     2210 BD 236E                                jsr counterclck         ; 
  473:     2213 BD 2299                                jsr linetrack           ; move to the 4rd plus intersection
  474:     2216 BD 2395                                jsr go_forward                          
  475:     2219 86 05                                  ldaa #5 
  476:     221B BD 241C                                jsr pause
  477:     221E BD 2299                                jsr linetrack           ; here stops at the 3rd plus intersection
  478:                                 
  479:     2221 BD 2395                                jsr go_forward          ; moves the robot forward to get line track off the plus
  480:     2224 86 09                                  ldaa #9
  481:     2226 BD 241C                                jsr pause
  482:                                 
  483:     2229 BD 236E                                jsr counterclck         ; turns the robot to the left until hits the white line
  484:                                                                         ; back towards the t intersection
  485:     222C BD 2299                                jsr Linetrack           ; moves the robot back to the t intersection
  486:                                 
  487:     222F BD 2395                                jsr go_forward          ; 
  488:     2232 86 05                                  ldaa #5
  489:     2234 BD 241C                                jsr pause
  490:                                 
  491:                                                 
  492:                                 
  493:     2237 32                                     pula
  494:                                 
  495:     2238 39                                     rts
  496:                                 ;******************************************************************************************************
  497:                                 ; this section moves from the 1st t intersection to the 3rd plane and to the 1st t intersection
  498:                                 ;******************************************************************************************************
  499:     2239                        Plane3:
  500:     2239 BD 2395                                jsr go_forward          ; moves forward to make linetrack work
  501:     223C 86 05                                  ldaa #5
  502:     223E BD 241C                                jsr pause               
  503:     2241 BD 2299                                jsr Linetrack           ; moves forward until 3th plus
  504:     2244 BD 2395                                jsr go_forward          ; moves forward so line track will work
  505:     2247 86 05                                  ldaa #5
  506:     2249 BD 241C                                jsr pause               
  507:                                                 
  508:     224C BD 236E                                jsr counterclck         ; turning left until white line agian           
  509:     224F BD 2299                                jsr Linetrack           ; moves to the 5th plus sign
  510:     2252 BD 2395                                jsr go_forward          ; 
  511:     2255 86 05                                  ldaa #5
  512:     2257 BD 241C                                jsr pause
  513:                                 
  514:     225A BD 2299                                jsr Linetrack           ; moves to the side of the board
  515:                                 
  516:     225D BD 243A                                jsr Right90             ; turns to move to the plane
  517:     2260 BD 2383                                jsr go_stop
  518:     2263 86 05                                  ldaa #5
  519:     2265 BD 241C                                jsr pause
  520:                                                                 ;sonar goes here
  521:     2268 BD 26E2                                jsr gripO               ; simple robot code here where comp code goes
  522:     226B 86 0A                                  ldaa #10                ; *
  523:     226D BD 241C                                jsr pause               ; this section moves the robot back to the line
  524:                                                 
  525:     2270 BD 2359                                jsr clockw1             ; turns the robot back towards the 5th plus sign
  526:                                                 
  527:     2273 BD 2299                                jsr linetrack           ; moves the robot to the 5th plus sign
  528:     2276 BD 2395                                jsr go_forward          ; moves robot past the 5th plus sign
  529:     2279 86 05                                  ldaa #5         
  530:     227B BD 241C                                jsr pause
  531:     227E BD 2299                                jsr linetrack           ; moves robot to the 3rd plus sign
  532:                                 
  533:     2281 BD 2395                                jsr go_forward  
  534:     2284 86 0A                                  ldaa #10
  535:     2286 BD 241C                                jsr pause
  536:                                 
  537:     2289 BD 2359                                jsr clockw1             ; turns back to the t intersection
  538:                                         
  539:     228C BD 2299                                jsr Linetrack           ; moves to the t intersection
  540:                                                 
  541:     228F BD 2395                                jsr go_forward          ;
  542:     2292 86 05                                  ldaa #5
  543:     2294 BD 241C                                jsr pause
  544:                                                 
  545:     2297 32                                     pula
  546:     2298 39                                     rts
  547:                                 ;**************************************************************************
  548:                                 ;Name:          LineTrack
  549:                                 ;Author:        Dominic Lawrence
  550:                                 ;Date:          unknown
  551:                                 ;Modifications: 
  552:                                 ;               
  553:                                 ;               PE3     ADR4/Line Track 3       left   \
  554:                                 ;               PE2     ADR3/Line Track 2       center  - looking from the back of robot
  555:                                 ;               PE1     ADR2/Line Track 1       Right  /
  556:                                 ;               DK 3/4/06 
  557:                                 ;                  add tests for LTCB=6 and LTCB = 3 to improve line
  558:                                 ;                  following. 
  559:                                 ;               LTL             equ $94         ; comparison number for more black and less is white? 
  560:                                 ;Process:       First it calls LT_CONT that sets the LTCB. Then LTCB is  
  561:                                 ;               tested and the appropriate sub routine is called to 
  562:                                 ;               turn turned on/off the drive motors accordingly.
  563:                                 ;**************************************************************************
  564:                                 
  565:     2299 36                     LineTrack:      psha
  566:     229A 3C                                     pshx
  567:                                                 
  568:     229B BD 2328                Lt_loop:        jsr Lt_cont
  569:                                                                         
  570:     229E B6 200F                FirstT:         ldaa LTCB       ; checks the center sensors
  571:     22A1 81 02                                  cmpa #$02
  572:     22A3 27 26                                  beq  FForward
  573:                                                 
  574:     22A5 81 04                                  cmpa #$04       ; checks sensors for if to far left
  575:     22A7 27 16                                  beq  RTurn
  576:     22A9 81 06                                  cmpa #$06
  577:     22AB 27 12                                  beq  Rturn
  578:                                                         
  579:     22AD 81 01                                  cmpa #$01       ; checks sensors for if to far right
  580:     22AF 27 14                                  beq  LTurn
  581:     22B1 81 03                                  cmpa #$03
  582:     22B3 27 10                                  beq  LTurn
  583:                                                         
  584:     22B5 81 07                                  cmpa #$07       ; stops the robot if all three sensors are white
  585:     22B7 27 18                                  beq  SStop
  586:                                                 
  587:     22B9 BD 2395                                jsr go_forward
  588:     22BC 7E 229B                                jmp Lt_loop
  589:                                                 
  590:                                  
  591:     22BF BD 238F                RTurn:          jsr  go_right           ; jumps to sub that moves robot to the right    
  592:     22C2 7E 229B                                jmp  Lt_loop
  593:                                 
  594:     22C5 BD 2389                LTurn:          jsr  go_left            ; jumps to sub that moves robot to the left
  595:     22C8 7E 229B                                jmp  Lt_loop
  596:                                 
  597:     22CB BD 2395                FForward:       jsr  go_Forward         ; jumps to sub that moves robot forward
  598:     22CE 7E 229B                                jmp  Lt_loop
  599:                                 
  600:     22D1 BD 2383                SStop:          jsr go_stop             ; jumps to stop sub
  601:     22D4 86 0A                                  ldaa #10
  602:     22D6 BD 241C                                jsr pause 
  603:                                                 
  604:     22D9 38                                     pulx            
  605:     22DA 32                                     pula
  606:     22DB 39                                     rts     
  607:                                 ;*******************************
  608:                                 ; this one is special
  609:                                 ; a line track that will work to pick up the blocks
  610:                                 ;**************************************************
  611:     22DC                        LineTrackSpec:
  612:     22DC 36                                     psha
  613:     22DD 3C                                     pshx
  614:                                                 
  615:     22DE BD 2328                Lt_loop1:       jsr Lt_cont
  616:                                 
  617:     22E1 B6 100A                                ldaa PORTE      ; grab info from port e
  618:     22E4 84 40                                  anda #$40               ; compare to the down setting
  619:     22E6 81 00                                  cmpa #$0
  620:     22E8 26 E7                                  bne  SStop      ; if down stop
  621:                                                                                 
  622:     22EA B6 200F                FirstT1:        ldaa LTCB       ; checks the center sensors
  623:     22ED 81 02                                  cmpa #$02
  624:     22EF 27 26                                  beq  FForward_s
  625:                                                 
  626:     22F1 81 04                                  cmpa #$04       ; checks sensors for if to far left
  627:     22F3 27 16                                  beq  RTurn_s
  628:     22F5 81 06                                  cmpa #$06
  629:     22F7 27 12                                  beq  Rturn_s
  630:                                                         
  631:     22F9 81 01                                  cmpa #$01       ; checks sensors for if to far right
  632:     22FB 27 14                                  beq  LTurn_s
  633:     22FD 81 03                                  cmpa #$03
  634:     22FF 27 10                                  beq  LTurn_s
  635:                                                         
  636:     2301 81 07                                  cmpa #$07       ; stops the robot if all three sensors are white
  637:     2303 27 18                                  beq  SStop_s
  638:                                                 
  639:     2305 BD 2395                                jsr go_forward
  640:     2308 7E 22DE                                jmp Lt_loop1
  641:                                 
  642:                                  
  643:     230B BD 238F                RTurn_s:        jsr  go_right           ; jumps to sub that moves robot to the right    
  644:     230E 7E 22DE                                jmp  Lt_loop1
  645:                                 
  646:     2311 BD 2389                LTurn_s:        jsr  go_left            ; jumps to sub that moves robot to the left
  647:     2314 7E 22DE                                jmp  Lt_loop1
  648:                                 
  649:     2317 BD 2395                FForward_s:     jsr  go_Forward         ; jumps to sub that moves robot forward
  650:     231A 7E 22DE                                jmp  Lt_loop1
  651:                                 
  652:     231D BD 2383                SStop_s:        jsr go_stop             ; jumps to stop sub
  653:     2320 86 0A                                  ldaa #10
  654:     2322 BD 241C                                jsr pause 
  655:                                                                 
  656:     2325 38                                     pulx            
  657:     2326 32                                     pula
  658:     2327 39                                     rts             
  659:                                 ;**************************************************************************
  660:                                 ;Name:          Lt_cont - Line Track Control Word
  661:                                 ;Author:        Dominic Lawrence
  662:                                 ;Date:          unknown
  663:                                 ;Modifications: 
  664:                                 ;               AA 03/??/06
  665:                                 ;                  Made into a separate sub routine
  666:                                 ;               PE3     ADR4/Line Track 3       left   \
  667:                                 ;               PE2     ADR3/Line Track 2       center  - looking from the back of robot
  668:                                 ;               PE1     ADR2/Line Track 1       Right  /
  669:                                 ;Function:      Takes the inputs for each linetrack sensor and compares 
  670:                                 ;               it to the LTL (Line Track Limit). If it is below LTL the 
  671:                                 ;               sensor is inidcating it is on the line and the
  672:                                 ;               corresponding bit is set in LTCB (Line Track Control Byte).
  673:                                 ;
  674:                                 ;               LTCB = xxxxx000
  675:                                 ;               LTL             equ $94  comparison number for more black and less is white? 
  676:                                 ;On Return:     LTCL is set as per above
  677:                                 ;**************************************************************************
  678:     2328 36                     Lt_cont:        psha
  679:     2329 3C                                     pshx
  680:                                 
  681:     232A 86 00                                  Ldaa #$0        ; getting the right side info and if wrong setting 
  682:     232C B7 200F                                Staa LTCB       ; LTCB to reflect this so linetrack sub routine will know       
  683:     232F B6 1032                                Ldaa Adr2       ;*
  684:     2332 81 94                                  Cmpa #LTL       ;*
  685:     2334 24 06                                  BHS  CheckCenter;*
  686:     2336 CE 200F                                Ldx  #LTCB      ;*
  687:     2339 1C 00 04                               Bset 0,x #$04   ;*
  688:                                 
  689:     233C B6 1033                CheckCenter:    Ldaa Adr3       ; get the Center info and if wrong setting 
  690:     233F 81 9F                                  Cmpa #$9F       ; LTCB to reflect this so Linetrack sub routine will know
  691:     2341 24 06                                  BHS  CheckLeft  ;*
  692:     2343 CE 200F                                Ldx  #LTCB      ;*
  693:     2346 1C 00 02                               Bset 0,x #$02   ;*
  694:                                 
  695:     2349 B6 1034                CheckLeft:      Ldaa Adr4       ;getting the left side info and if wrong setting
  696:     234C 81 94                                  cmpa #LTL       ; LTCB to reflect this so line track sub routine will know
  697:     234E 24 06                                  BHS  lt_exit    ;*
  698:     2350 CE 200F                                Ldx  #LTCB      ;*
  699:     2353 1C 00 01                               Bset 0,x #$01   ;*
  700:                                 
  701:     2356 38                     lt_exit:        pulx
  702:     2357 32                                     pula
  703:                                                 
  704:     2358 39                                     rts
  705:                                 ;**************************************************************************
  706:                                 ; This section will cause the robot to turn to the right until it hits a 
  707:                                 ; white line with the line tracking sensors
  708:                                 ;**************************************************************************
  709:     2359                        clockw1:                
  710:     2359 36                                     psha
  711:     235A BD 238F                                jsr go_right
  712:     235D 86 0A                                  ldaa #10
  713:     235F BD 241C                                jsr pause
  714:     2362 BD 2328                clockw_Loop:    jsr LT_cont             
  715:     2365 B6 200F                                ldaa LTCB               
  716:     2368 81 02                                  cmpa #$02
  717:     236A 26 F6                                  bne clockw_Loop 
  718:                                                 
  719:     236C 32                                     pula
  720:     236D 39                                     rts
  721:                                 ;**************************************************************************
  722:                                 ; This section will cause the robot to turn to the Left until it hits a 
  723:                                 ; white line with the line tracking sensors
  724:                                 ;*************************************************************************
  725:     236E                        counterclck:    
  726:     236E 36                                     psha
  727:     236F BD 2389                                jsr go_left
  728:     2372 86 0A                                  ldaa #10
  729:     2374 BD 241C                                jsr pause
  730:     2377 BD 2328                counter_Loop:   jsr LT_cont             
  731:     237A B6 200F                                ldaa LTCB               
  732:     237D 81 02                                  cmpa #$02
  733:     237F 26 F6                                  bne  counter_Loop
  734:                                                 
  735:     2381 32                                     pula
  736:     2382 39                                     rts
  737:                                 ;**************************************************************************
  738:                                 ;Name:          Drive Motor Functions
  739:                                 ;Author:        Michael McNeill, JR.
  740:                                 ;Date:          Dec 9, 2005
  741:                                 ;Functions:     Each separtate function will do the indicated function 
  742:                                 ;               to the robot drive motors
  743:                                 ;
  744:                                 ;               go_Stop
  745:                                 ;               go_Left
  746:                                 ;               go_Right
  747:                                 ;               go_Forward
  748:                                 ;               go_Reverse
  749:                                 ;               never enter at robot_do! (Stack will be corrupted)
  750:                                 ;
  751:                                 ;       Functions for the arm motors
  752:                                 ;               go_Astop        
  753:                                 ;               go_Aup
  754:                                 ;               go_Adown
  755:                                 ;**************************************************************************
  756:                                 
  757:     2383 3C                     go_Stop         pshx
  758:     2384 CE 23B7                                ldx #Stop
  759:     2387 20 18                                  bra robot_do1
  760:                                 
  761:     2389 3C                     go_Left         pshx
  762:     238A CE 23D7                                ldx #Left
  763:     238D 20 12                                  bra robot_do1
  764:                                 
  765:     238F 3C                     go_Right        pshx
  766:     2390 CE 23CF                                ldx #Right
  767:     2393 20 0C                                  bra robot_do1
  768:                                 
  769:     2395 3C                     go_Forward      pshx
  770:     2396 CE 23C7                                ldx #Forward
  771:     2399 20 06                                  bra robot_do1
  772:                                 
  773:     239B 3C                     go_Reverse      pshx
  774:     239C CE 23BF                                ldx #Reverse
  775:     239F 20 00                                  bra robot_do1
  776:                                 
  777:     23A1 EC 00                  robot_do1       ldd 0,x
  778:     23A3 FD 2016                                std On_cnts_R
  779:     23A6 EC 02                                  ldd 2,x
  780:     23A8 FD 2018                                std Off_cnts_R
  781:     23AB EC 04                                  ldd 4,x
  782:     23AD FD 200A                                std On_cnts_L
  783:     23B0 EC 06                                  ldd 6,x
  784:     23B2 FD 200C                                std Off_cnts_L
  785:     23B5 38                                     pulx
  786:     23B6 39                                     rts
  787:                                 ;Table for Drive Motor Functions
  788:                                 ;                       On_cnts_R       Off_cnts_R      On_cnts_L       Off_cnts_L
  789:                                 
  790:     23B7 0BB8 9088 0BB8         Stop            fdb     3000,           37000,          3000,           37000
           23BD 9088 
  791:     23BF 07D0 9470 0FA0         REVERSE         fdb     2000,           38000,          4000,           36000
           23C5 8CA0 
  792:     23C7 0FA0 8CA0 07D0         FORWARD         fdb     4000,           36000,          2000,           38000
           23CD 9470 
  793:     23CF 07D0 9470 07D0         RIGHT           fdb     2000,           38000,          2000,           38000
           23D5 9470 
  794:     23D7 0FA0 8CA0 0FA0         LEFT            fdb     4000,           36000,          4000,           36000
           23DD 8CA0 
  795:                                 
  796:                                 
  797:                                 
  798:                                 ;********************************************************************************
  799:                                 ;       Functions for the arm motors
  800:                                 ;               go_Astop        
  801:                                 ;               go_Aup
  802:                                 ;               go_Adown
  803:                                 ;**************************************************************************
  804:                                 
  805:     23DF 3C                     go_Astop        pshx
  806:     23E0 CE 23FD                                ldx #Astop
  807:     23E3 20 0C                                  bra robot_arm
  808:                                 
  809:     23E5 3C                     go_Aup          pshx
  810:     23E6 CE 2401                                ldx #Aup
  811:     23E9 20 06                                  bra robot_arm
  812:                                 
  813:     23EB 3C                     go_Adown        pshx
  814:     23EC CE 2405                                ldx #Adown
  815:     23EF 20 00                                  bra robot_arm
  816:                                 
  817:                                 
  818:     23F1 EC 00                  robot_arm       ldd 0,x
  819:     23F3 FD 201E                                std On_cnts_A
  820:     23F6 EC 02                                  ldd 2,x
  821:     23F8 FD 2020                                std Off_cnts_A
  822:                                                 
  823:     23FB 38                                     pulx
  824:     23FC 39                                     rts
  825:                                 
  826:                                 ;Table for Drive Motor Functions
  827:                                 ;                       On_cnts_A       Off_cnts_A      
  828:                                 
  829:     23FD 0BB8 9088              Astop           fdb     3000,           37000   
  830:     2401 07D0 9470              Aup             fdb     2000,           38000           
  831:     2405 0FA0 8CA0              Adown           fdb     4000,           36000   
  832:                                 
  833:                                 
  834:                                 ;Servo Motor notes:
  835:                                 ;       1ms on time = 2000 counts = forward
  836:                                 ;       2ms on time = 4000 counts = reverse
  837:                                 ;       total counts for a 50hz square wave (20mSec - suggested for servos) is 40000 counts
  838:                                 
  839:                                 ;**************************************************************************
  840:                                 ;Name:          A2D
  841:                                 ;Author:        Dan Kohn
  842:                                 ;Date:          Jan 5, 2006
  843:                                 ;Functions:     Set up A/D to read PE0..PE3 continuously and  
  844:                                 ;               place the converted values in ADR1..ADR4
  845:                                 ;
  846:                                 ;On call:       NONE
  847:                                 ;
  848:                                 ;On Return;     A/D is turned on and running continously 
  849:                                 ;**************************************************************************
  850:                                 
  851:     2409 3C                     A2D:            pshx
  852:     240A 36                                     psha
  853:                                         
  854:     240B CE 1039                                ldx #option             ;setup A/D
  855:     240E 1C 00 80                               bset 0,x #$80           ;Turn on A/D - ADPU
  856:     2411 1D 00 40                               bclr 0,x #$40           ;Use E clock
  857:                                                 
  858:     2414 86 30                                  ldaa #$30               ;Set up to read PE0..PE3
  859:     2416 B7 1030                                staa ADCTL              ;Continuously
  860:                                 
  861:     2419 32                                     pula
  862:     241A 38                                     pulx
  863:                                                 
  864:     241B 39                                     rts
  865:                                 ;**************************************************************************
  866:                                 ;Name:          Pause
  867:                                 ;Author:        Dan Kohn
  868:                                 ;Date:          Dec 19, 2005
  869:                                 ;Functions:     Pause for multiple of 0.1 sec 
  870:                                 ;               (setup for a 0.1 sec counter)
  871:                                 ;
  872:                                 ;On call:       Reg A Contains the number of 0.1 sec to pause
  873:                                 ;
  874:                                 ;On Return;     Sec_Count and Sec_Temp were changed (cleared at start of 
  875:                                 ;               pause.
  876:                                 ;**************************************************************************
  877:     241C 36                     Pause:          psha
  878:     241D 37                                     pshb
  879:     241E C6 00                                  ldab #$00
  880:     2420 F7 2022                                stab SEC_TEMP
  881:     2423 F7 2023                                stab SEC_COUNT
  882:                                                 
  883:     2426 F6 2023                PauseL1:        ldab sec_count
  884:     2429 11                                     cba
  885:     242A 26 FA                                  bne PauseL1
  886:                                                 
  887:     242C 33                                     pulb
  888:     242D 32                                     pula
  889:     242E 39                                     rts
  890:                                 ;**************************************************************************
  891:                                 ;**************************************************************************
  892:     242F 36                     Left90: psha
  893:                                                 
  894:     2430 BD 2389                                jsr go_left
  895:     2433 86 09                                  ldaa #9
  896:     2435 BD 241C                                jsr pause
  897:                                                 
  898:     2438 32                                     pula 
  899:     2439 39                                     rts
  900:                                 ;**************************************************************************
  901:                                 ;**************************************************************************
  902:     243A 36                     Right90:        psha
  903:                                 
  904:     243B BD 238F                                jsr go_right
  905:     243E 86 09                                  ldaa #9
  906:     2440 BD 241C                                jsr pause               
  907:                                                 
  908:     2443 32                                     pula
  909:     2444 39                                     rts
  910:                                 ;**************************************************************************
  911:                                 ;Name:          TOF_init
  912:                                 ;Author:        Dan Kohn
  913:                                 ;Date:          Dec 14, 2005
  914:                                 ;Functions:     Initializes the TOF Function 
  915:                                 ;               (setup for a 0.5 sec counter)
  916:                                 ;**************************************************************************
  917:                                 
  918:     2445 36                     TOF_init        psha
  919:     2446 3C                                     pshx
  920:     2447 183C                                   pshy
  921:                                 
  922:     2449 0F                                     SEI
  923:                                 
  924:     244A 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
  925:     244C 97 D0                                  STAA TOFIV
  926:                                 
  927:     244E CC 2484                                LDD #TOF_CNT
  928:     2451 DD D1                                  STD TOFIV+1
  929:                                 
  930:     2453 86 80                                  ldaa #$80               ;clear TOF flag
  931:     2455 B7 1025                                staa TFLG2
  932:                                         
  933:     2458 CE 1024                                LDX #TMSK2              ;turn on TOF interrupt
  934:     245B 1C 00 80                               bset 0,x #$80
  935:                                 
  936:     245E 0E                                     cli 
  937:                                 
  938:     245F 18CE 0000                              ldy #0                  ;clear 1 sec counter for planes
  939:     2463 18FF 2024                              sty plane_temp
  940:                                 
  941:     2467 18CE 00B4                              ldy #180                ;set plane 1's time for 180sec
  942:     246B 18FF 2026                              sty plane1_cd
  943:                                 
  944:     246F 18CE 00F0                              ldy #240                ;set plane 2's time for 240sec
  945:     2473 18FF 2028                              sty plane2_cd
  946:                                 
  947:     2477 18CE 012C                              ldy #300                ;set plane 3's time for 300sec
  948:     247B 18FF 202A                              sty plane3_cd
  949:                                                 
  950:     247F 1838                                   puly
  951:     2481 38                                     pulx
  952:     2482 32                                     pula
  953:                                 
  954:     2483 39                                     rts
  955:                                 ;**************************************************************************
  956:                                 ;Name:          TOF_CNT
  957:                                 ;Author:        Dan Kohn
  958:                                 ;Date:          Dec 14, 2005
  959:                                 ;Functions:     count every 0.1 sec.  
  960:                                 ;
  961:                                 ;On Return:     Count of 0.1 sec intervals is in SEC_count
  962:                                 ;               Count of 32.77mSec intervals is in Sec_Temp
  963:                                 ;**************************************************************************
  964:     2484 86 80                  TOF_CNT         ldaa #$80
  965:     2486 B7 1025                                staa TFLG2      
  966:                                                 
  967:     2489 B6 2022                                ldaa Sec_temp           ;count # of times overflow occures (32.77ms)
  968:     248C 4C                                     inca 
  969:     248D B7 2022                                staa Sec_temp
  970:                                 
  971:     2490 81 03                                  cmpa #03                ;if ~0.1sec has NOT gone by -> exit
  972:     2492 25 0C                                  blo plane_time          ;      [3*32.77mSec = 0.0983100 Sec]
  973:                                 
  974:                                 
  975:     2494 86 00                                  ldaa #$00               ;if ~0.1sec has gone by -> clear Sec_temp
  976:     2496 B7 2022                                staa Sec_temp           ;and add one to the Sec_count
  977:                                 
  978:     2499 B6 2023                                ldaa Sec_count
  979:     249C 4C                                     inca 
  980:     249D B7 2023                                staa Sec_count
  981:                                                 
  982:     24A0 18FE 2024              plane_time:     ldy plane_temp          ;count # of times overflow occures (32.77ms)
  983:     24A4 1808                                   iny 
  984:     24A6 18FF 2024                              sty plane_temp
  985:                                 
  986:     24AA 188C 001E                              cpy #30                 ;if ~1sec has NOT gone by -> exit
  987:     24AE 25 38                                  blo tof_exit            ;      [30*32.77mSec = .98310 Sec]
  988:                                 
  989:                                 
  990:     24B0 18CE 0000                              ldy #$00                ;if ~0.1sec has gone by -> clear Sec_temp
  991:     24B4 18FF 2024                              sty plane_temp          ;and add one to the Sec_count
  992:                                 
  993:     24B8 18FE 2026                              ldy plane1_cd           ;count down timer for plane 1
  994:     24BC 188C 0000                              cpy #0
  995:     24C0 27 06                                  beq pt_2
  996:     24C2 1809                                   dey
  997:     24C4 18FF 2026                              sty plane1_cd
  998:                                 
  999:     24C8 18FE 2028              pt_2:           ldy plane2_cd           ;count down timer for plane 2
 1000:     24CC 188C 0000                              cpy #0
 1001:     24D0 27 06                                  beq pt_3
 1002:     24D2 1809                                   dey
 1003:     24D4 18FF 2028                              sty plane2_cd
 1004:                                 
 1005:     24D8 18FE 202A              pt_3:           ldy plane3_cd           ;count down timer for plane 3
 1006:     24DC 188C 0000                              cpy #0
 1007:     24E0 27 06                                  beq TOF_exit
 1008:     24E2 1809                                   dey
 1009:     24E4 18FF 202A                              sty plane3_cd
 1010:                                 
 1011:     24E8 3B                     TOF_exit        RTI
 1012:                                 
 1013:                                 ;**************************************************************************
 1014:                                 ;Name:          TOC2_init
 1015:                                 ;Author:        Dan Kohn
 1016:                                 ;Date:          Dec 8, 2005
 1017:                                 ;Functions:     Initalize the Right Motor (OC2) 
 1018:                                 ;
 1019:                                 ;On Call:       go_stop MUST be called before initalizing 
 1020:                                 ;**************************************************************************
 1021:     24E9 36                     TOC2_init:      psha
 1022:     24EA 37                                     pshb
 1023:     24EB 3C                                     pshx
 1024:                                 
 1025:     24EC 0F                                     SEI
 1026:                                 
 1027:     24ED 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1028:     24EF 97 DC                                  STAA TOC2IV
 1029:                                 
 1030:     24F1 CC 2518                                LDD #TOC2RT
 1031:     24F4 DD DD                                  STD TOC2IV+1
 1032:                                 
 1033:     24F6 FC 100E                                LDD TCNT                ;sets the first time of TOC2
 1034:     24F9 F3 2016                                ADDD On_cnts_R
 1035:     24FC FD 1018                                STD TOC2
 1036:                                 
 1037:     24FF 86 40                                  LDAA #$40               ;intializing the registers
 1038:     2501 B7 1023                                staa TFLG1
 1039:                                 
 1040:     2504 CE 1022                                ldx #TMSK1
 1041:     2507 1C 00 40                               BSET 0,X #$40
 1042:                                 
 1043:     250A CE 1020                                LDX #TCTL1              ;toggles the output
 1044:     250D 1C 00 40                               BSET 0,X #$40
 1045:     2510 1D 00 80                               BCLR 0,x #$80
 1046:                                 
 1047:                                 
 1048:     2513 0E                                     CLI                     ;turning on the interrupts
 1049:                                 
 1050:     2514 38                                     pulx
 1051:     2515 33                                     pulb
 1052:     2516 32                                     pula 
 1053:                                 
 1054:     2517 39                                     rts
 1055:                                 ;**************************************************************************
 1056:                                 ;Name:          TOC2IV
 1057:                                 ;Author:        Gregory Reeves Jr.
 1058:                                 ;Date:          July 30, 2005
 1059:                                 ;Modified:      Dan Kohn Dec 8, 2005 For Dual Output Compares
 1060:                                 ;Function:      Interrupt for PWM for Right Motor
 1061:                                 ;On Call        On_cnts_R and Off_cnts_R 
 1062:                                 ;**************************************************************************
 1063:     2518 86 40                  TOC2RT:         LDAA #$40               ;resets the OC2F bit
 1064:     251A B7 1023                                STAA TFLG1
 1065:                                 
 1066:     251D B6 1000                                LDAA PORTA              ;check oc2 pin for on or off state
 1067:     2520 84 40                                  ANDA #$40
 1068:     2522 26 0B                                  BNE ON_2
 1069:                                 
 1070:     2524 FC 1018                                LDD TOC2                ;sets up for the off time sequence
 1071:     2527 F3 2018                                ADDD Off_cnts_R
 1072:     252A FD 1018                                STD TOC2
 1073:     252D 20 09                                  BRA EXIT_2
 1074:                                 
 1075:     252F FC 1018                ON_2            LDD TOC2                ;sets up for the next ontime sequence
 1076:     2532 F3 2016                                ADDD On_cnts_R
 1077:     2535 FD 1018                                STD TOC2
 1078:                                 
 1079:     2538 3B                     EXIT_2          RTI                     ;return from the interrupt
 1080:                                 ;**************************************************************************
 1081:                                 ;Name:          TOC3_init
 1082:                                 ;Author:        Dan Kohn
 1083:                                 ;Date:          Dec 8, 2005
 1084:                                 ;Functions:     Initalize the Left Motor (OC3) 
 1085:                                 ;
 1086:                                 ;On Call:       go_stop MUST be called before initalizing 
 1087:                                 ;**************************************************************************
 1088:     2539 36                     TOC3_init:      psha
 1089:     253A 37                                     pshb
 1090:     253B 3C                                     pshx
 1091:                                 
 1092:     253C 0F                                     SEI
 1093:                                 
 1094:     253D 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1095:     253F 97 D9                                  STAA TOC3IV
 1096:                                 
 1097:     2541 CC 2568                                LDD #TOC3RT
 1098:     2544 DD DA                                  STD TOC3IV+1
 1099:                                 
 1100:     2546 FC 100E                                LDD TCNT                ;sets the first time of TOC2
 1101:     2549 F3 200A                                ADDD On_cnts_L
 1102:     254C FD 101A                                STD TOC3
 1103:                                 
 1104:     254F 86 20                                  LDAA #$20               ;intializing the registers
 1105:     2551 B7 1023                                staa TFLG1
 1106:                                 
 1107:     2554 CE 1022                                ldx #TMSK1
 1108:     2557 1C 00 20                               BSET 0,X #$20
 1109:                                 
 1110:     255A CE 1020                                LDX #TCTL1              ;toggles the output
 1111:     255D 1C 00 10                               BSET 0,X #$10
 1112:     2560 1D 00 20                               BCLR 0,x #$20
 1113:                                 
 1114:     2563 0E                                     CLI                     ;turning on the interrupts
 1115:                                 
 1116:     2564 38                                     pulx    
 1117:     2565 33                                     pulb
 1118:     2566 32                                     pula 
 1119:                                 
 1120:     2567 39                                     rts
 1121:                                 ;**************************************************************************
 1122:                                 ;Name:          TOC3IV
 1123:                                 ;Author:        Gregory Reeves Jr.
 1124:                                 ;Date:          July 30, 2005
 1125:                                 ;Modified:      Dan Kohn Dec 8, 2005 For Dual Output Compares
 1126:                                 ;Function:      Interrupt for PWM for Left Motor
 1127:                                 ;On Call        On_cnts_L and Off_cnts_L 
 1128:                                 ;**************************************************************************
 1129:     2568 86 20                  TOC3RT:         LDAA #$20               ;resets the OC3F bit
 1130:     256A B7 1023                                STAA TFLG1
 1131:                                 
 1132:     256D B6 1000                                LDAA PORTA              ;check oc3 pin for on or off state
 1133:     2570 84 20                                  ANDA #$20
 1134:     2572 26 0B                                  BNE ON_3
 1135:                                 
 1136:     2574 FC 101A                                LDD TOC3                ;sets up for the off time sequence
 1137:     2577 F3 200C                                ADDD Off_cnts_L
 1138:     257A FD 101A                                STD TOC3
 1139:     257D 20 09                                  BRA EXIT_3
 1140:                                 
 1141:     257F FC 101A                ON_3            LDD TOC3                ;sets up for the next ontime sequence
 1142:     2582 F3 200A                                ADDD On_cnts_L
 1143:     2585 FD 101A                                STD TOC3
 1144:                                 
 1145:     2588 3B                     EXIT_3          RTI                     ;return from the interrupt
 1146:                                 
 1147:                                 ;**************************************************************************
 1148:                                 ;Name:          TOC3_init
 1149:                                 ;Author:        Michael McNeill, Jr.
 1150:                                 ;Date:          ??
 1151:                                 ;Functions:     Initalize the Multiplexed Servo (OC4) 
 1152:                                 ;
 1153:                                 ;On Call:       go_Gstop MUST be called before initalizing 
 1154:                                 ;**************************************************************************
 1155:     2589 36                     TOC4_init:      psha
 1156:     258A 37                                     pshb
 1157:     258B 3C                                     pshx
 1158:                                 
 1159:     258C 0F                                     SEI
 1160:                                 
 1161:     258D 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1162:     258F 97 D6                                  STAA TOC4IV
 1163:                                 
 1164:     2591 CC 25B8                                LDD #TOC4RT
 1165:     2594 DD D7                                  STD TOC4IV+1
 1166:                                 
 1167:     2596 FC 100E                                LDD TCNT                ;sets the first time of TOC4
 1168:     2599 F3 201E                                ADDD On_cnts_A
 1169:     259C FD 101C                                STD TOC4
 1170:                                 
 1171:     259F 86 10                                  LDAA #$10               ;intializing the registers
 1172:     25A1 B7 1023                                staa TFLG1
 1173:                                 
 1174:     25A4 CE 1022                                ldx #TMSK1
 1175:     25A7 1C 00 10                               BSET 0,X #$10
 1176:                                 
 1177:     25AA CE 1020                                LDX #TCTL1              ;toggles the output
 1178:     25AD 1C 00 04                               BSET 0,X #$4
 1179:     25B0 1D 00 08                               BCLR 0,x #$8
 1180:                                 
 1181:                                 
 1182:     25B3 0E                                     CLI                     ;turning on the interrupts
 1183:                                 
 1184:     25B4 38                                     pulx
 1185:     25B5 33                                     pulb
 1186:     25B6 32                                     pula 
 1187:                                 
 1188:     25B7 39                                     rts
 1189:                                 ;**************************************************************************
 1190:                                 ;Name:          TOC4IV
 1191:                                 ;Author:        Michael McNeill, Jr.
 1192:                                 ;Date:          Feb 1, 2006
 1193:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1194:                                 ;On Call        On_cnts_G and Off_cnts_G 
 1195:                                 ;**************************************************************************
 1196:     25B8 86 10                  TOC4RT:         LDAA #$10
 1197:     25BA B7 1023                                STAA TFLG1
 1198:                                 
 1199:     25BD B6 1000                                LDAA PORTA
 1200:     25C0 84 10                                  ANDA #$10
 1201:     25C2 26 0B                                  BNE ON_4
 1202:                                 
 1203:     25C4 FC 101C                                LDD TOC4
 1204:     25C7 F3 2020                                ADDD off_cnts_A
 1205:     25CA FD 101C                                STD TOC4
 1206:     25CD 20 09                                  BRA EXIT_4
 1207:                                 
 1208:     25CF FC 101C                ON_4            LDD TOC4                ;sets up for the next ontime sequence
 1209:     25D2 F3 201E                                ADDD On_cnts_A
 1210:     25D5 FD 101C                                STD TOC4
 1211:                                 
 1212:     25D8 3B                     EXIT_4          RTI                     ;return from the interrupt
 1213:                                 
 1214:                                 ;**************************************************************************************************
 1215:                                 ;
 1216:                                 ;Name:          Scanner
 1217:                                 ;Author:        Michael McNeill, Jr.
 1218:                                 ;Date:          ??
 1219:                                 ;Functions:     Clears the Scanner buffer, then waits for the interrupt to 
 1220:                                 ;               recieve 33 bits. It then convers the returned bit pattern into plane
 1221:                                 ;               number based on the table below
 1222:                                 ;
 1223:                                 ;               Scanner reading $26 to $03
 1224:                                 ;                               $1e to $02
 1225:                                 ;                               $16 to $01
 1226:                                 ;
 1227:                                 ;Process:       the barcode scanner is read using the falling edge of PA0 (which is 
 1228:                                 ;               attached to the barcode clock). When a falling edge is detected, it 
 1229:                                 ;               reads the barcode data line (comming in on PE7). This data is placed
 1230:                                 ;               into the buffer from the left and shifted to the right. Each character
 1231:                                 ;               is actually 10 bits long. The first bit coming in is a START BIT, then
 1232:                                 ;               8 bits of data, then a PARITY BIT then a STOP bit. 
 1233:                                 ;
 1234:                                 ;               so the finish data buffer will look like this:
 1235:                                 ;
 1236:                                 ;               Byte        4       3       2       1       0
 1237:                                 ;               Bits 7654321076543210765432107654321076543210 
 1238:                                 ;
 1239:                                 ;                    sPxxxxxxxxSsPxxxxxxxxSsPxxxxxxxxS
 1240:                                 ;                    100010011001111110000010001001100
 1241:                                 ;                                            \      /
 1242:                                 ;                                             data representing plane #
 1243:                                 ;
 1244:                                 ;                            Data shifted -->
 1245:                                 ;
 1246:                                 ;               s=stop
 1247:                                 ;               P=Parity
 1248:                                 ;               S=START
 1249:                                 ;
 1250:                                 ;               the data is then compared to the values returned for planes 1,2,3 and
 1251:                                 ;               converted to the plane number. If the scan is bad, $FF will be the result.
 1252:                                 ;               This value is then stored in BOXCODE.
 1253:                                 ;
 1254:                                 ;On Call:       None
 1255:                                 ;
 1256:                                 ;On Return:     BOXCODE containes the plane number indicated by the barcode read ($FF
 1257:                                 ;               indicates an error when scanned).  
 1258:                                 ;               
 1259:                                 ;               Wiring of the Barcode
 1260:                                 ;               (Red wire - clock) (Brown wire - Data) (Green wire - Ground) (Orange wire - 5volts) (Yellow wire - 5volts)
 1261:                                 ;               (Black wire - 5volts)
 1262:                                 ;               
 1263:                                 ;
 1264:                                 ;
 1265:                                 ;*******************************************************************************************
 1266:                                         
 1267:                                 
 1268:     25D9                        Scanner:
 1269:     25D9 36                             psha
 1270:     25DA BD 266B                        jsr BC_clear
 1271:                                 
 1272:                                 
 1273:     25DD 86 00                          ldaa #$00
 1274:     25DF B7 2023                        staa sec_count
 1275:                                         
 1276:     25E2 B6 2023                sc_0:   ldaa sec_count          ;  watchdog timer for six seconds
 1277:     25E5 81 3C                          cmpa #60                ;* exits after 6 seconds if 33 bits not recieved
 1278:     25E7 24 34                          bhs  SC_3               ;* will return $ff as barcode error code
 1279:     25E9 B6 2008                        lDAA BC_count
 1280:     25EC 81 21                          cmpa #33
 1281:     25EE 25 F2                          BLO sc_0
 1282:                                 
 1283:     25F0 B6 2006                        Ldaa Barcode+3          ;Barcode to read #$26 to plane 3
 1284:     25F3 81 26                          cmpa #$26
 1285:     25F5 26 08                          Bne  sc_1
 1286:     25F7 86 03                          ldaa #$03
 1287:     25F9 B7 2009                        staa Boxcode
 1288:                                 
 1289:     25FC 7E 2622                        jmp sc_exit
 1290:                                 
 1291:     25FF                        Sc_1    
 1292:     25FF B6 2006                        Ldaa Barcode+3          ;Barcode to read #$1e to plane 2
 1293:     2602 81 1E                          cmpa #$1e
 1294:     2604 26 08                          Bne  sc_2
 1295:     2606 86 02                          ldaa #$02
 1296:     2608 B7 2009                        staa Boxcode
 1297:                                 
 1298:     260B 7E 2622                        jmp sc_exit
 1299:                                 
 1300:     260E                        Sc_2    
 1301:     260E B6 2006                        Ldaa Barcode+3          ;Barcode to read #$16 to plane 1
 1302:     2611 81 16                          cmpa #$16
 1303:     2613 26 08                          Bne  sc_3
 1304:     2615 86 01                          ldaa #$01
 1305:     2617 B7 2009                        staa Boxcode
 1306:                                 
 1307:     261A 7E 2622                        jmp sc_exit
 1308:                                         
 1309:     261D                        Sc_3    
 1310:                                         
 1311:                                 
 1312:     261D 86 FF                          ldaa #$ff               ;flag for bad scan
 1313:     261F B7 2009                        staa Boxcode
 1314:                                 
 1315:     2622                        sc_exit
 1316:                                 
 1317:     2622 32                             pula
 1318:     2623 39                             rts
 1319:                                 
 1320:                                 
 1321:                                 
 1322:                                 ;*******************************************************************************
 1323:                                 ;Name:          IC3_init
 1324:                                 ;Author:        Michael McNeill, Jr.
 1325:                                 ;Date:          ??
 1326:                                 ;Functions:     This initializes IC3 to capture a falling edge of the 
 1327:                                 ;               clock for the barcode reader. 
 1328:                                 ;
 1329:                                 ;********************************************************************************
 1330:     2624 36                     IC3_init:       psha
 1331:     2625 3C                                     pshx
 1332:                                                                         
 1333:     2626 0F                                     sei
 1334:                                 
 1335:     2627 86 7E                                  ldaa #$7E
 1336:     2629 97 E2                                  staa IC3IV
 1337:                                 
 1338:     262B CC 2648                                LDD #IC3RT
 1339:     262E DD E3                                  STD IC3IV+1
 1340:                                 
 1341:     2630 CE 1021                                LDX #TCTL2
 1342:                                 
 1343:     2633 1C 00 02                               Bset 0,X #$02   ;set for falling edge
 1344:     2636 1D 00 01                               Bclr 0,X #$01
 1345:                                        
 1346:     2639 86 01                                  LDAA #$01
 1347:     263B B7 1023                                STAA TFLG1      ;clr flag
 1348:                                 
 1349:     263E CE 1022                                LDX #TMSK1      ;turn on INT
 1350:     2641 1C 00 01                               Bset 0,X #$01
 1351:                                 
 1352:     2644 0E                                     cli
 1353:                                 
 1354:     2645 38                                     pulx
 1355:     2646 32                                     pula
 1356:     2647 39                                     rts
 1357:                                 
 1358:                                 
 1359:                                 ;**************************************************************************
 1360:                                 ;Name:          IC3RT - Barcode interrupt 
 1361:                                 ;Author:        Dan Kohn
 1362:                                 ;Date:          ??
 1363:                                 ;Function:      This interrupt is triggered on a FALLING EDGE of the 
 1364:                                 ;               bar code clk signal. That that time, the data line is
 1365:                                 ;               captured and placed into the CARRY BIT which is then
 1366:                                 ;               shifted from the left into the barcode buffer.
 1367:                                 ;
 1368:                                 ;               [see SCANNER routine for more info]
 1369:                                 ;**************************************************************************
 1370:                                 
 1371:     2648 86 01                  IC3RT:          ldaa #$01               ;resets the IC3 bit
 1372:     264A B7 1023                                staa TFLG1
 1373:                                 
 1374:     264D B6 100A                                Ldaa portE              ;check IC3 pin for on or off state
 1375:     2650 84 80                                  anda #$80
 1376:     2652 27 03                                  BEQ  BC_High
 1377:     2654 0D                                     sec
 1378:     2655 20 01                                  BRA BC_skip
 1379:                                 
 1380:     2657 0C                     BC_High         clc
 1381:                                 
 1382:     2658 76 2003                BC_Skip         ROR Barcode
 1383:     265B 76 2004                                ROR Barcode+1
 1384:     265E 76 2005                                ROR Barcode+2
 1385:     2661 76 2006                                ROR Barcode+3
 1386:     2664 76 2007                                ROR Barcode+4
 1387:     2667 7C 2008                                INC BC_count
 1388:     266A 3B                                     RTI                     ;return from the interrupt
 1389:                                 
 1390:                                 
 1391:                                 ;**************************************************************************
 1392:                                 ;Name:          BC_Clear - Clear Bar Code buffer 
 1393:                                 ;Author:        Dan Kohn
 1394:                                 ;Date:          ??
 1395:                                 ;Function:      Clear the buffer for the bar code buffer (fill with all ones)
 1396:                                 ;**************************************************************************
 1397:     266B 36                     BC_clear:       psha
 1398:     266C 86 FF                                  LDAA #$FF
 1399:     266E B7 2003                                STAA Barcode
 1400:     2671 B7 2004                                STAA Barcode+1
 1401:     2674 B7 2005                                STAA Barcode+2
 1402:     2677 B7 2006                                STAA Barcode+3
 1403:     267A B7 2007                                STAA Barcode+4
 1404:     267D 86 00                                  LDAA #$0
 1405:     267F B7 2008                                STAA BC_count
 1406:                                 
 1407:     2682 32                                     Pula
 1408:     2683 39                                     RTS
 1409:                                 ;**************************************************************************
 1410:                                 ;Name:          TOC1_init
 1411:                                 ;Author:        michael mcneill
 1412:                                 ;Date:          4/15/06
 1413:                                 ;Functions:     Initalize the toc1_init 
 1414:                                 ;
 1415:                                 ;On Call:       go_stop MUST be called before initalizing 
 1416:                                 ;**************************************************************************
 1417:     2684 36                     TOC1_init:      psha
 1418:     2685 37                                     pshb
 1419:     2686 3C                                     pshx
 1420:                                 
 1421:     2687 0F                                     SEI
 1422:                                 
 1423:     2688 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1424:     268A 97 DF                                  STAA TOC1IV
 1425:                                 
 1426:     268C CC 26B5                                LDD #TOC1RT
 1427:     268F DD E0                                  STD TOC1IV+1
 1428:                                 
 1429:     2691 FC 100E                                LDD TCNT                ;sets the first time of TOC1
 1430:     2694 F3 201A                                ADDD On_cnts_GR
 1431:     2697 FD 1016                                STD TOC1
 1432:                                 
 1433:     269A 86 80                                  LDAA #$80               ;intializing the registers
 1434:     269C B7 1023                                staa TFLG1
 1435:                                 
 1436:     269F CE 1022                                ldx #TMSK1
 1437:     26A2 1C 00 80                               BSET 0,X #$80
 1438:                                 
 1439:     26A5 86 80                                  LDAA #$80
 1440:     26A7 B7 100C                                STAA oc1m
 1441:                                                 
 1442:     26AA CE 1026                                LDx #pactl
 1443:     26AD 1C 00 80                               bset 0,x #$80
 1444:                                 
 1445:                                                 
 1446:                                 
 1447:     26B0 0E                                     CLI                     ;turning on the interrupts
 1448:                                 
 1449:     26B1 38                                     pulx
 1450:     26B2 33                                     pulb
 1451:     26B3 32                                     pula 
 1452:                                 
 1453:     26B4 39                                     rts
 1454:                                 ;**************************************************************************
 1455:                                 
 1456:                                 
 1457:                                 
 1458:                                 
 1459:                                 ;**************************************************************************
 1460:                                 ;Name:          TOCIRT
 1461:                                 ;Author:        Michael McNeill, Jr.
 1462:                                 ;Date:          3/15/06
 1463:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1464:                                 ;On Call        On_cnts_Gr and Off_cnts_Gr 
 1465:                                 ;**************************************************************************
 1466:     26B5 86 80                  TOC1RT:         LDAA #$80
 1467:     26B7 B7 1023                                STAA TFLG1
 1468:                                 
 1469:     26BA B6 1000                                LDAA PORTA
 1470:     26BD 84 80                                  ANDA #$80
 1471:     26BF 26 11                                  Bne toc1_high
 1472:                                 
 1473:                                 
 1474:                                                 
 1475:                                 
 1476:                                 
 1477:     26C1 FC 1016                toc1_low:       LDD TOC1
 1478:     26C4 F3 201C                                ADDD off_cnts_Gr
 1479:     26C7 FD 1016                                STD TOC1
 1480:                                 
 1481:     26CA CE 100D                                ldx #oc1d               ;set pin to go high next time TOC=TCNT
 1482:     26CD 1C 00 80                               bset 0,x #$80
 1483:                                 
 1484:     26D0 20 0F                                  BRA EXIT_1
 1485:                                 
 1486:     26D2 FC 1016                toc1_high:      LDD TOC1                ;sets up for the next ontime sequence
 1487:     26D5 F3 201A                                ADDD on_cnts_Gr
 1488:     26D8 FD 1016                                STD TOC1
 1489:                                 
 1490:     26DB CE 100D                                ldx #oc1d               ;set pin to go low next time TOC=TCNT
 1491:     26DE 1D 00 80                               bclr 0,x #$80
 1492:                                 
 1493:     26E1 3B                     EXIT_1:         RTI                     ;return from the interrupt
 1494:                                 
 1495:                                 ;**************************************************************************************************
 1496:                                 ;Name:          grip0
 1497:                                 ;Author:        Michael McNeill, Jr.
 1498:                                 ;Date:          3/15/06
 1499:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1500:                                 ;On Call        On_cnts_Gr 
 1501:                                 ;Gripper (TOC1init) Variables and Equates:
 1502:                                 ;gripppe open
 1503:                                 ;
 1504:                                 ;
 1505:                                 ;
 1506:                                 ;************************************************************************************************************
 1507:     26E2 183C                   gripO:          pshy
 1508:                                                         
 1509:                                 
 1510:     26E4 18CE 8AAC                              ldy #35500      
 1511:     26E8 18FF 201C                              sty off_cnts_Gr
 1512:     26EC 18CE 1194                              ldy #4500       
 1513:     26F0 18FF 201A                              sty on_cnts_Gr
 1514:                                                 
 1515:                                                 
 1516:     26F4 1838                                   puly
 1517:                                                 
 1518:     26F6 39                                     rts
 1519:                                 ;**************************************************************************************************
 1520:                                 ;Name:          gripC
 1521:                                 ;Author:        Michael McNeill, Jr.
 1522:                                 ;Date:          3/15/06
 1523:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1524:                                 ;On Call        OFF_cnts_Gr 
 1525:                                 ;Gripper (TOC1init) Variables and Equates:
 1526:                                 ;gripppe close
 1527:                                 ;
 1528:                                 ;
 1529:                                 ;
 1530:                                 ;************************************************************************************************************
 1531:     26F7 183C                   gripC:          pshy
 1532:                                 
 1533:                                 
 1534:     26F9 18CE 7530                              ldy #30000              ;35400
 1535:     26FD 18FF 201C                              sty off_cnts_Gr
 1536:     2701 18CE 2710                              ldy #10000              ;4600
 1537:     2705 18FF 201A                              sty on_cnts_Gr          
 1538:                                 
 1539:                                 
 1540:     2709 1838                                   puly
 1541:     270B 39                                     rts
 1542:                                 ;************************************************************************************************************
 1543:                                 ;*******************************************************************************
 1544:                                 ;Name:          IC1_init
 1545:                                 ;Author:        Michael McNeill, Jr.
 1546:                                 ;Date:          ??
 1547:                                 ;Functions:     This initializes IC1 to capture a rising edge of the 
 1548:                                 ;               encoder. 
 1549:                                 ;
 1550:                                 ;********************************************************************************
 1551:     270C 36                     IC1_init:       psha
 1552:     270D 3C                                     pshx
 1553:                                                                                 
 1554:     270E 0F                                     sei
 1555:                                 
 1556:     270F 86 7E                                  ldaa #$7E               
 1557:     2711 97 E8                                  staa IC1IV
 1558:                                 
 1559:     2713 CC 2730                                LDD #IC1RT
 1560:     2716 DD E9                                  STD IC1IV+1
 1561:                                 
 1562:     2718 CE 1021                                LDX #TCTL2
 1563:                                 
 1564:     271B 1C 00 10                               Bset 0,X #$10   ;set for rising edge
 1565:     271E 1D 00 20                               Bclr 0,X #$20
 1566:                                        
 1567:     2721 86 04                                  LDAA #$04
 1568:     2723 B7 1023                                STAA TFLG1      ;clr flag
 1569:                                 
 1570:     2726 CE 1022                                LDX #TMSK1      ;turn on INT
 1571:     2729 1C 00 04                               Bset 0,X #$04
 1572:                                 
 1573:     272C 0E                                     cli
 1574:                                 
 1575:     272D 38                                     pulx
 1576:     272E 32                                     pula
 1577:     272F 39                                     rts
 1578:                                 
 1579:                                 
 1580:                                 ;**************************************************************************
 1581:                                 ;Name:          IC1RT - encoder interrupt 
 1582:                                 ;Author:        Dan Kohn
 1583:                                 ;Date:          ??
 1584:                                 ;Function:      
 1585:                                 ;
 1586:                                 ;               
 1587:                                 ;**************************************************************************
 1588:                                 
 1589:     2730 86 04                  IC1RT:          ldaa #$04               ;resets the IC1 bit
 1590:     2732 B7 1023                                staa TFLG1
 1591:                                                 
 1592:     2735 FE 202C                                ldx encoder1
 1593:     2738 08                                     inx
 1594:     2739 FF 202C                                stx encoder1 
 1595:                                 
 1596:     273C 3B                                     rti
 1597:                                 

Symbols:
a2d                             *00002409
adctl                           *00001030
adown                           *00002405
adr2                            *00001032
adr3                            *00001033
adr4                            *00001034
astop                           *000023fd
aup                             *00002401
barcode                         *00002003
bc_clear                        *0000266b
bc_count                        *00002008
bc_high                         *00002657
bc_skip                         *00002658
boxcode                         *00002009
checkcenter                     *0000233c
checkleft                       *00002349
clockw1                         *00002359
clockw_loop                     *00002362
counter_loop                    *00002377
counterclck                     *0000236e
encoder1                        *0000202c
end_check                       *000020ca
exit_1                          *000026e1
exit_2                          *00002538
exit_3                          *00002588
exit_4                          *000025d8
fforward                        *000022cb
fforward_s                      *00002317
forward                         *000023c7
go_adown                        *000023eb
go_astop                        *000023df
go_aup                          *000023e5
go_forward                      *00002395
go_left                         *00002389
go_reverse                      *0000239b
go_right                        *0000238f
go_stop                         *00002383
gripc                           *000026f7
gripo                           *000026e2
ic1iv                           *000000e8
ic1rt                           *00002730
ic3iv                           *000000e2
ic3rt                           *00002648
leaveshoot                      *000020e7
left                            *000023d7
left90                          *0000242f
linetrack                       *00002299
lt_cont                         *00002328
lt_exit                         *00002356
lt_loop                         *0000229b
lt_loop1                        *000022de
ltcb                            *0000200f
ltl                             *00000094
lturn                           *000022c5
lturn_s                         *00002311
main                            *0000202e
no_1_plane                      *00002094
no_2_plane                      *000020a7
no_3_plane                      *000020ba
oc1d                            *0000100d
oc1m                            *0000100c
off_cnts_a                      *00002020
off_cnts_gr                     *0000201c
off_cnts_l                      *0000200c
off_cnts_r                      *00002018
on_2                            *0000252f
on_3                            *0000257f
on_4                            *000025cf
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                           *0000241c
pausel1                         *00002426
plane1                          *0000211e
plane1_cd                       *00002026
plane2                          *000021cb
plane2_cd                       *00002028
plane3                          *00002239
plane3_cd                       *0000202a
plane_temp                      *00002024
plane_time                      *000024a0
porta                           *00001000
porte                           *0000100a
pt_2                            *000024c8
pt_3                            *000024d8
reg_base                        *00001000
reverse                         *000023bf
right                           *000023cf
right90                         *0000243a
robot_arm                       *000023f1
robot_do1                       *000023a1
rturn                           *000022bf
rturn_s                         *0000230b
sc_0                            *000025e2
sc_1                            *000025ff
sc_2                            *0000260e
sc_3                            *0000261d
sc_exit                         *00002622
sec_count                       *00002023
sec_temp                        *00002022
shoot2                          *0000218c
sstop                           *000022d1
sstop_s                         *0000231d
start                           *000020ce
stop                            *000023b7
tcnt                            *0000100e
tctl1                           *00001020
tctl2                           *00001021
test                            *00002057
tflg1                           *00001023
tflg2                           *00001025
tmsk1                           *00001022
tmsk2                           *00001024
toc1                            *00001016
toc1_high                       *000026d2
toc1_init                       *00002684
toc1iv                          *000000df
toc1rt                          *000026b5
toc2                            *00001018
toc2_init                       *000024e9
toc2iv                          *000000dc
toc2rt                          *00002518
toc3                            *0000101a
toc3_init                       *00002539
toc3iv                          *000000d9
toc3rt                          *00002568
toc4                            *0000101c
toc4_init                       *00002589
toc4iv                          *000000d6
toc4rt                          *000025b8
tof_cnt                         *00002484
tof_exit                        *000024e8
tof_init                        *00002445
tofiv                           *000000d0

