T:\My Documents\323.lst - generated by MGTEK Assembler ASM11 V1.22 Build 137 for WIN32 (x86) - Thu Mar 23 10:06:42 2006

    1:                                 ;**************************************************************************
    2:                                 ;Name:          Robot Library
    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 / Multiplexed Servo Output ;mike code gripper motor
   14:                                 ;               PA3     OC5 / USED FOR TRACE - BUFFALO
   15:                                 ;               PA2     IC1 / 
   16:                                 ;               PA1     IC2 / Sonar Echo 
   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:                                 
   32:                                 ;               PD3     
   33:                                 ;               PD2     
   34:                                 ;
   35:                                 ;               OUTPUT Circuit
   36:                                 ;$B580          BIT0    LSB Servo Multiplexer 
   37:                                 ;               BIT1    |
   38:                                 ;               BIT2    MSB Servo Multiplexer
   39:                                 ;               BIT3
   40:                                 ;               BIT4
   41:                                 ;               BIT5
   42:                                 ;               BIT6    led 
   43:                                 ;               BIT7    sonar init
   44:                                 ;
   45:                                 ;               Input Circuit // not currently in use
   46:                                 ;$B590          BIT0     
   47:                                 ;               BIT1
   48:                                 ;               BIT2
   49:                                 ;               BIT3
   50:                                 ;               BIT4
   51:                                 ;               BIT5
   52:                                 ;               BIT6
   53:                                 ;               BIT7
   54:                                 ;
   55:                                 ;               Input Circuit // not currently in use
   56:                                 ;$B5A0          BIT0
   57:                                 ;               BIT1
   58:                                 ;               BIT2
   59:                                 ;               BIT3
   60:                                 ;               BIT4
   61:                                 ;               BIT5
   62:                                 ;               BIT6
   63:                                 ;               BIT7
   64:                                 ;**************************************************************************
   65:                                 
   66:                                 
   67:          =00002000                              ORG $2000
   68:                                                 
   69:                                                 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
   70:                                 
   71:     2000 7E 2034                                JMP MAIN
   72:                                 ;Barcode Equates
   73:          =000000E2              IC3IV           EQU $00E2
   74:     2003 +0005                  Barcode         RMB 5
   75:     2008 +0001                  BC_count        RMB 1
   76:     2009 +0001                  Boxcode         RMB 1
   77:          =0000FFB8              outa            equ $ffb8
   78:                                 
   79:                                 ;Buffalo Equates
   80:          =0000FFC1              out2bsp         equ $ffc1               ; prints what is pointed to by x to the screen
   81:          =0000FFC4              outcrlf         equ $ffc4               ; outputs a carrage return and line feed
   82:          =0000FFBE              out1bsp         equ $ffbe               ; prints what is pointed to by x to the screen
   83:                                 
   84:                                 ;Arm Motor Variables and Equates                        ;mike code
   85:          =000000D6              TOC4IV          EQU $00D6
   86:     200A +0002                  On_cnts_G       RMB 2
   87:     200C +0002                  Off_cnts_G      RMB 2
   88:                                 
   89:                                 ;Left Motor Variables and Equates
   90:          =000000D9              TOC3IV          EQU $00D9
   91:     200E +0002                  On_cnts_L       RMB 2
   92:     2010 +0002                  Off_cnts_L      RMB 2
   93:                                 
   94:                                 ;Limit Switch Control Byte
   95:     2012 +0001                  LS1             rmb 1 
   96:                                 ;Line Track Control Byte
   97:     2013 +0001                  LTCB            rmb 1
   98:                                 
   99:                                 ;Line Track Level
  100:          =00000094              LTL             equ $94         ; comparison number for more black and less is white? 
  101:                                 
  102:                                 ;multiplexer values
  103:          =0000B580              cs0             equ $B580
  104:     2014 +0002                  On_cnts_A       RMB 2
  105:     2016 +0002                  Off_cnts_A      RMB 2
  106:     2018 +0002                  On_cnts_B       RMB 2
  107:     201A +0002                  Off_cnts_B      RMB 2
  108:                                 
  109:                                 ;Sonar variables
  110:     201C +0002                  Sonar_start     rmb 2
  111:     201E +0002                  Sonar_end       rmb 2
  112:     2020 +0002                  Sonar_ans       rmb 2
  113:                                 
  114:                                 ;Right Motor Variables and Equates
  115:          =000000DC              TOC2IV          EQU $00DC               
  116:     2022 +0002                  On_cnts_R       RMB 2
  117:     2024 +0002                  Off_cnts_R      RMB 2
  118:                                 ;Gripper (TOC1init) Variables and Equates
  119:          =000000DF              TOC1IV          EQU $00DF
  120:     2026 +0002                  On_cnts_Gr      rmb 2
  121:     2028 +0002                  Off_cnts_Gr     rmb 2
  122:                                 
  123:                                 
  124:                                 ;Timer Overflow Counter
  125:          =000000D0              TOFIV           EQU $00D0
  126:     202A +0001                  Sec_Temp        rmb 1           ;counter 32.77mSec [0-15]
  127:     202B +0001                  Sec_count       rmb 1           ;counter 0.1Sec [0-255]
  128:     202C +0002                  plane_temp      rmb 2           ;counter 32.77ms [0-30]
  129:     202E +0002                  plane1_cd       rmb 2           ;countdown timer - plane 1 [180 -> 0 Sec]
  130:     2030 +0002                  plane2_cd       rmb 2           ;countdown timer - plane 2 [240 -> 0 Sec]
  131:     2032 +0002                  plane3_cd       rmb 2           ;countdown timer - plane 3 [300 -> 0 Sec]
  132:                                 
  133:     2034                        MAIN            
  134:                                 
  135:     2034 BD 235E                                jsr go_stop             ;Set up On/Off times for stop
  136:                                                 ;jsr TOC4_init          ;init gripper motor
  137:     2037 BD 2586                                jsr TOC3_init           ;init left motor
  138:     203A BD 2536                                jsr TOC2_init           ;init right motor
  139:     203D BD 2492                                jsr TOF_init            ;init Timer Overflow (for 0.5 sec Timer)
  140:     2040 BD 23BA                                jsr A2D                 ;init A/D PE0..PE3
  141:     2043 BD 26D1                                jsr TOC1_init           ;inint TOC1_inint for the gripper               
  142:                                                 
  143:                                 
  144:                                                 
  145:                                 ;               jsr gripO
  146:     2046 86 28                                  ldaa #40
  147:     2048 BD 2469                                jsr pause
  148:                                 ;               jsr test
  149:                                 
  150:     204B BD 272F                                jsr gripO
  151:                                                 ;ldaa #40
  152:                                                 ;jsr pause
  153:                                                 
  154:                                 ;Log:           
  155:     204E BD 2744                                jsr grippC
  156:                                                 
  157:     2051 B6 202E                                ldaa plane1_cd          ;Robot goes to Plane2 If Plane1 exceeds time.
  158:     2054 81 28                                  cmpa #40
  159:     2056 2F 00                                  BLE Range1
  160:                                 
  161:     2058 7E 2111                Range1:         jmp Plane1
  162:                                 
  163:                                                 
  164:                                 
  165:                                                 ;jmp Log
  166:                                                 ;ldx #on_cnts_Gr
  167:                                                 ;jsr out2bsp
  168:                                 
  169:                                                 ;ldx #off_cnts_Gr
  170:                                                 ;jsr out2bsp
  171:                                 
  172:                                                 
  173:                                                 ;jsr Start              ;leave the block
  174:                                                 ;jsr grippC             ; grips the first block
  175:                                                 ;jsr LeaveShoot         ; moves robot from shoot to the plane 1 intersection            
  176:                                                                         ; spot to check if need to go to 1st plane
  177:                                                 ;jsr Plane1             ; moves the plane to plane one and dumps and returns
  178:                                                                         ; to the 1st t intersection
  179:                                                 ;jsr gripO              
  180:                                                 
  181:                                                 ;jsr Shoot2             ; this moves the robot back to the shoot
  182:                                                 ;jsr LeaveShoot         ; moves from the shoot back to the 1st t intersection
  183:                                                 ;jsr Plane2             ; moves from t intersection an back to t intersection
  184:                                                 ;jsr Shoot2             ; moves back to the shoot
  185:                                                 ;jsr LeaveShoot         ; moves back to t intersection
  186:                                                 ;jsr Plane3             ; moves from the t intersection and back from the 3rd plane
  187:                                                 ;jsr Shoot2             ; moves back to the shoot
  188:     205B BD 235E                                jsr go_stop
  189:     205E 7E E000                                jmp $e000       
  190:                                 ;*******************************************************************
  191:                                 ; test section
  192:                                 ;******************************************************************
  193:     2061                        test:
  194:     2061 36                                     psha
  195:     2062 37                                     pshb
  196:     2063 3C                                     pshx
  197:                                                 
  198:     2064 BD 272F                                jsr gripO       ;open the gripper from the schute
  199:     2067 BD 20CC                                jsr Start       ; moves to the shoot
  200:     206A BD 2744                                jsr grippC
  201:     206D 86 02                                  ldaa #02
  202:     206F BD 2469                                jsr pause       ; grabs the first block
  203:     2072 BD 2376                                jsr go_reverse  ; backs up 
  204:     2075 86 0F                                  ldaa #15
  205:     2077 BD 2469                                jsr pause
  206:                                                 
  207:     207A BD 20EA                                jsr leaveshoot
  208:     207D BD 2111                                jsr plane1  ; moves the block to the t intersection
  209:     2080 38                                     pulx
  210:     2081 33                                     pulb
  211:     2082 32                                     pula
  212:     2083 39                                     rts
  213:                                 ;***************************************************************************
  214:                                 ; this section will grab block and check and move to the appropriate box
  215:                                 ;***************************************************************************
  216:     2084                        block_check:
  217:     2084 36                                     psha
  218:     2085 37                                     pshb
  219:     2086 3C                                     pshx
  220:                                                 
  221:     2087 BD 2744                                jsr grippC              ; grabs the block
  222:     208A BD 2376                                jsr go_reverse          ; backs up and takes block out of stack
  223:     208D 86 03                                  ldaa #03
  224:     208F BD 2469                                jsr pause               
  225:                                                                         ; do barcode scanner here
  226:     2092 B6 2009                NO_1_Plane:     ldaa Boxcode
  227:     2095 81 01                                  cmpa #$01
  228:     2097 26 0C                                  bne NO_2_Plane
  229:     2099 BD 20EA                                jsr LeaveShoot
  230:     209C BD 2111                                jsr plane1
  231:     209F BD 2177                                jsr  Shoot2
  232:     20A2 7E 20C8                                jmp  end_check                  
  233:     20A5                        NO_2_Plane:
  234:     20A5 B6 2009                                ldaa Boxcode
  235:     20A8 81 02                                  cmpa #$02
  236:     20AA 26 0C                                  bne No_3_Plane
  237:     20AC BD 20EA                                jsr LeaveShoot
  238:     20AF BD 21A6                                jsr plane2
  239:     20B2 BD 2177                                jsr shoot2
  240:     20B5 7E 20C8                                jmp end_check
  241:     20B8                        NO_3_Plane:
  242:     20B8 B6 2009                                ldaa Boxcode            ;Rescans Block If a bad scan is received.
  243:     20BB 81 FF                                  cmpa #$FF
  244:     20BD 27 D3                                  beq NO_1_Plane          ;Create Subroutine to Rescan Block
  245:     20BF BD 20EA                                jsr leaveshoot
  246:     20C2 BD 2214                                jsr plane3
  247:     20C5 BD 2177                                jsr shoot2
  248:                                                 
  249:     20C8                        end_check:      
  250:                                                         
  251:     20C8 38                                     pulx
  252:     20C9 33                                     pulb
  253:     20CA 32                                     pula
  254:                                                                          ; here light the led  for hey i am done
  255:     20CB 39                                     rts
  256:                                                 
  257:                                 ;;**************************************************************************
  258:                                 ; this section moves the robot to the block shoot
  259:                                 ;**************************************************************************
  260:     20CC 36                     Start:          psha
  261:                                                 
  262:                                                 
  263:     20CD BD 2370                                jsr go_forward          ;Leaving Block
  264:     20D0 86 0A                                  ldaa #10
  265:     20D2 BD 2469                                jsr pause
  266:     20D5 BD 2274                                jsr LineTrack           ; this line moves forward until the 1st plus intersection
  267:     20D8 86 0A                                  ldaa #10
  268:     20DA BD 2469                                jsr pause
  269:     20DD BD 2370                                jsr go_forward          ; moves forward so line tracking will work 
  270:     20E0 86 0A                                  ldaa #10
  271:     20E2 BD 2469                                jsr pause
  272:                                 
  273:     20E5 BD 22B7                                jsr Linetrackspecial    ; moves forward to the 1st plus intersection
  274:                                 
  275:     20E8 32                                     pula
  276:     20E9 39                                     rts
  277:                                 ;**************************************************************************
  278:                                 ; this section moves the robot away from the shoot to the intersection for
  279:                                 ; turning to plane 1
  280:                                 ;**************************************************************************
  281:                                                 
  282:     20EA 36                     LeaveShoot:     psha
  283:                                         
  284:                                 
  285:     20EB BD 2334                                jsr clockw              ;180 Right Turn to leave the Package shoot
  286:     20EE BD 2274                                jsr LineTrack           ; line track back to the 1st plus
  287:     20F1 BD 2370                                jsr go_forward          ; this section makes the first turn
  288:     20F4 86 05                                  ldaa #5
  289:                                                                         ; *
  290:     20F6 BD 2469                                jsr pause               ; *
  291:     20F9 BD 235E                                jsr go_stop
  292:     20FC 86 05                                  ldaa #5
  293:     20FE BD 2469                                jsr pause               ; *
  294:     2101 BD 2349                                jsr counterclck         ; *
  295:     2104 BD 235E                                jsr go_stop             ; *
  296:     2107 86 05                                  ldaa #5                 ; *
  297:     2109 BD 2469                                jsr pause               ; *
  298:                                 
  299:     210C BD 2274                                jsr LineTrack           ; moves robot to the 1st t intersection
  300:                                                                         ; ends this section
  301:     210F 32                                     pula
  302:     2110 39                                     rts
  303:                                 ;**************************************************************************
  304:                                 ; this section moves the robot to the first plane and then moves it back to the 1st t intersection
  305:                                 ;**************************************************************************
  306:     2111 36                     Plane1:         psha
  307:                                 
  308:     2112 BD 2370                                jsr go_forward          ; moves forward so turn will work properly
  309:     2115 86 07                                  ldaa #7
  310:     2117 BD 2469                                jsr pause
  311:     211A BD 235E                                jsr go_stop
  312:     211D 86 05                                  ldaa #5
  313:     211F BD 2469                                jsr pause
  314:     2122 BD 2334                                jsr clockw              ;turns right until hits white line for the first plane
  315:                                 
  316:     2125 BD 235E                                jsr go_stop             
  317:     2128 86 14                                  ldaa #20
  318:     212A BD 2469                                jsr pause
  319:     212D BD 2274                                jsr Linetrack           ;Stops at 2nd plus by Loading Zone 1
  320:     2130 BD 2370                                jsr go_forward          
  321:     2133 86 03                                  ldaa #3
  322:     2135 BD 2469                                jsr pause
  323:     2138 BD 2274                                jsr Linetrack
  324:     213B BD 247C                                jsr Left90              ; turns to the airplane
  325:     213E BD 235E                                jsr go_stop             ; right her is where droping will occur         
  326:     2141 86 19                                  ldaa #25        
  327:     2143 BD 2469                                jsr pause
  328:                                 
  329:                                                         
  330:     2146 BD 23D3                                jsr go_Open             ; for the simple robot must remove
  331:     2149 86 0A                                  ldaa #10                        ; and replace with carrage dump section
  332:     214B BD 2469                                jsr pause               ;*
  333:                                                 
  334:     214E BD 2349                                jsr counterclck
  335:                                 
  336:                                 
  337:     2151 BD 2274                                jsr linetrack           ; moves the robot forward to the 2nd plus
  338:     2154 BD 2370                                jsr go_forward          ; this section moves the robot back to the 
  339:     2157 86 05                                  ldaa #5         
  340:     2159 BD 2469                                jsr pause
  341:     215C BD 2274                                jsr linetrack
  342:                                 
  343:     215F BD 2370                                jsr go_forward
  344:     2162 86 07                                  ldaa #7
  345:     2164 BD 2469                                jsr pause
  346:                                                 
  347:                                                 
  348:     2167 BD 2349                                jsr counterclck
  349:     216A BD 235E                                jsr go_stop
  350:     216D 86 05                                  ldaa #5         
  351:                                 
  352:     216F BD 2274                                jsr Linetrack   ;       
  353:     2172 BD 2469                                jsr pause               ;
  354:                                 
  355:                                                 
  356:                                 
  357:     2175 32                                     pula
  358:                                 
  359:     2176 39                                     rts
  360:                                 ;**************************************************************************
  361:                                 ; this section goes back to the shoot from the t intersection
  362:                                 ;
  363:                                 ;
  364:                                 ;**************************************************************************
  365:     2177 36                     Shoot2:         psha
  366:                                                 
  367:     2178 BD 2274                                jsr Linetrack
  368:     217B BD 2370                                jsr go_forward
  369:     217E 86 08                                  ldaa #8
  370:     2180 BD 2469                                jsr pause
  371:                                                 
  372:     2183 BD 2274                                jsr Linetrack
  373:                                 
  374:     2186 BD 2334                                jsr clockw              ;Goes back to Shoot
  375:     2189 BD 235E                                jsr go_stop             ;
  376:     218C 86 08                                  ldaa #8
  377:     218E BD 2469                                jsr pause
  378:                                                 
  379:     2191 BD 22B7                                jsr Linetrackspecial
  380:     2194 BD 235E                                jsr go_stop
  381:     2197 86 0A                                  ldaa #10
  382:     2199 BD 2469                                jsr pause
  383:                                 
  384:     219C BD 23D9                                jsr go_close
  385:     219F 86 14                                  ldaa #20
  386:     21A1 BD 2469                                jsr pause
  387:                                                 
  388:     21A4 32                                     pula
  389:     21A5 39                                     rts
  390:                                 ;
  391:                                 ;**************************************************************************
  392:                                 ; this section moves from the t intersection
  393:                                 ; to the second plane and back to the 1st t intersection
  394:                                 ;**************************************************************************
  395:     21A6 36                     Plane2:         psha
  396:                                                 
  397:     21A7 BD 2370                                jsr go_forward
  398:     21AA 86 05                                  ldaa #5
  399:     21AC BD 2469                                jsr pause
  400:                                                 
  401:     21AF BD 2274                                jsr Linetrack           ; moves the robot forward until you get to the 3rd plus
  402:                                                                         ; intersection
  403:     21B2 BD 2370                                jsr go_forward          
  404:     21B5 86 05                                  ldaa #5
  405:     21B7 BD 2469                                jsr pause
  406:     21BA BD 2334                                jsr clockw              ;will trun right until hits the white line agian
  407:                                                 
  408:     21BD BD 235E                                jsr go_stop
  409:     21C0 86 05                                  ldaa #5
  410:     21C2 BD 2469                                jsr pause
  411:     21C5 BD 2274                                jsr Linetrack           ;Stops at 4th plus by Loading Zone 1
  412:     21C8 BD 2370                                jsr go_forward
  413:     21CB 86 0A                                  ldaa #10
  414:     21CD BD 2469                                jsr pause
  415:     21D0 BD 2274                                jsr Linetrack           ; moves forward until side of board
  416:     21D3 86 05                                  ldaa #5
  417:     21D5 BD 2469                                jsr pause
  418:     21D8 BD 247C                                jsr Left90              ; turn left to go towards the plane
  419:     21DB BD 235E                                jsr go_stop
  420:     21DE 86 05                                  ldaa #5
  421:     21E0 BD 2469                                jsr pause
  422:     21E3 BD 23D3                                jsr go_Open             ; this section for the simple robot 
  423:     21E6 86 0A                                  ldaa #10                ; this is where the carrage drop occurs
  424:     21E8 BD 2469                                jsr pause
  425:                                 
  426:     21EB BD 2349                                jsr counterclck         ; 
  427:     21EE BD 2274                                jsr linetrack           ; move to the 4rd plus intersection
  428:     21F1 BD 2370                                jsr go_forward                          
  429:     21F4 86 05                                  ldaa #5 
  430:     21F6 BD 2469                                jsr pause
  431:     21F9 BD 2274                                jsr linetrack           ; here stops at the 3rd plus intersection
  432:                                 
  433:     21FC BD 2370                                jsr go_forward          ; moves the robot forward to get line track off the plus
  434:     21FF 86 09                                  ldaa #9
  435:     2201 BD 2469                                jsr pause
  436:                                 
  437:     2204 BD 2349                                jsr counterclck         ; turns the robot to the left until hits the white line
  438:                                                                         ; back towards the t intersection
  439:     2207 BD 2274                                jsr Linetrack           ; moves the robot back to the t intersection
  440:                                 
  441:     220A BD 2370                                jsr go_forward          ; 
  442:     220D 86 05                                  ldaa #5
  443:     220F BD 2469                                jsr pause
  444:                                 
  445:                                                 
  446:                                 
  447:     2212 32                                     pula
  448:                                 
  449:     2213 39                                     rts
  450:                                 ;******************************************************************************************************
  451:                                 ; this section moves from the 1st t intersection to the 3rd plane and to the 1st t intersection
  452:                                 ;******************************************************************************************************
  453:     2214                        Plane3:
  454:     2214 BD 2370                                jsr go_forward          ; moves forward to make linetrack work
  455:     2217 86 05                                  ldaa #5
  456:     2219 BD 2469                                jsr pause               
  457:     221C BD 2274                                jsr Linetrack           ; moves forward until 3th plus
  458:     221F BD 2370                                jsr go_forward          ; moves forward so line track will work
  459:     2222 86 05                                  ldaa #5
  460:     2224 BD 2469                                jsr pause               
  461:                                                 
  462:     2227 BD 2349                                jsr counterclck         ; turning left until white line agian           
  463:     222A BD 2274                                jsr Linetrack           ; moves to the 5th plus sign
  464:     222D BD 2370                                jsr go_forward          ; 
  465:     2230 86 05                                  ldaa #5
  466:     2232 BD 2469                                jsr pause
  467:                                 
  468:     2235 BD 2274                                jsr Linetrack           ; moves to the side of the board
  469:                                 
  470:     2238 BD 2487                                jsr Right90             ; turns to move to the plane
  471:     223B BD 235E                                jsr go_stop
  472:     223E 86 05                                  ldaa #5
  473:     2240 BD 2469                                jsr pause
  474:                                                                 ;sonar goes here
  475:     2243 BD 23D3                                jsr go_Open             ; simple robot code here where comp code goes
  476:     2246 86 0A                                  ldaa #10                ; *
  477:     2248 BD 2469                                jsr pause               ; this section moves the robot back to the line
  478:                                                 
  479:     224B BD 2334                                jsr clockw              ; turns the robot back towards the 5th plus sign
  480:                                                 
  481:     224E BD 2274                                jsr linetrack           ; moves the robot to the 5th plus sign
  482:     2251 BD 2370                                jsr go_forward          ; moves robot past the 5th plus sign
  483:     2254 86 05                                  ldaa #5         
  484:     2256 BD 2469                                jsr pause
  485:     2259 BD 2274                                jsr linetrack           ; moves robot to the 3rd plus sign
  486:                                 
  487:     225C BD 2370                                jsr go_forward  
  488:     225F 86 0A                                  ldaa #10
  489:     2261 BD 2469                                jsr pause
  490:                                 
  491:     2264 BD 2334                                jsr clockw              ; turns back to the t intersection
  492:                                         
  493:     2267 BD 2274                                jsr Linetrack           ; moves to the t intersection
  494:                                                 
  495:     226A BD 2370                                jsr go_forward          ;
  496:     226D 86 05                                  ldaa #5
  497:     226F BD 2469                                jsr pause
  498:                                                 
  499:     2272 32                                     pula
  500:     2273 39                                     rts
  501:                                 ;**************************************************************************
  502:                                 ;Name:          LineTrack
  503:                                 ;Author:        Dominic Lawrence
  504:                                 ;Date:          unknown
  505:                                 ;Modifications: 
  506:                                 ;               
  507:                                 ;               PE3     ADR4/Line Track 3       left   \
  508:                                 ;               PE2     ADR3/Line Track 2       center  - looking from the back of robot
  509:                                 ;               PE1     ADR2/Line Track 1       Right  /
  510:                                 ;               DK 3/4/06 
  511:                                 ;                  add tests for LTCB=6 and LTCB = 3 to improve line
  512:                                 ;                  following. 
  513:                                 ;               LTL             equ $94         ; comparison number for more black and less is white? 
  514:                                 ;Process:       First it calls LT_CONT that sets the LTCB. Then LTCB is  
  515:                                 ;               tested and the appropriate sub routine is called to 
  516:                                 ;               turn turned on/off the drive motors accordingly.
  517:                                 ;**************************************************************************
  518:                                 
  519:     2274 36                     LineTrack:      psha
  520:     2275 3C                                     pshx
  521:                                                 
  522:     2276 BD 2303                Lt_loop:        jsr Lt_cont
  523:                                                                         
  524:     2279 B6 2013                FirstT:         ldaa LTCB       ; checks the center sensors
  525:     227C 81 02                                  cmpa #$02
  526:     227E 27 26                                  beq  FForward
  527:                                                 
  528:     2280 81 04                                  cmpa #$04       ; checks sensors for if to far left
  529:     2282 27 16                                  beq  RTurn
  530:     2284 81 06                                  cmpa #$06
  531:     2286 27 12                                  beq  Rturn
  532:                                                         
  533:     2288 81 01                                  cmpa #$01       ; checks sensors for if to far right
  534:     228A 27 14                                  beq  LTurn
  535:     228C 81 03                                  cmpa #$03
  536:     228E 27 10                                  beq  LTurn
  537:                                                         
  538:     2290 81 07                                  cmpa #$07       ; stops the robot if all three sensors are white
  539:     2292 27 18                                  beq  SStop
  540:                                                 
  541:     2294 BD 2370                                jsr go_forward
  542:     2297 7E 2276                                jmp Lt_loop
  543:                                                 
  544:                                  
  545:     229A BD 236A                RTurn:          jsr  go_right           ; jumps to sub that moves robot to the right    
  546:     229D 7E 2276                                jmp  Lt_loop
  547:                                 
  548:     22A0 BD 2364                LTurn:          jsr  go_left            ; jumps to sub that moves robot to the left
  549:     22A3 7E 2276                                jmp  Lt_loop
  550:                                 
  551:     22A6 BD 2370                FForward:       jsr  go_Forward         ; jumps to sub that moves robot forward
  552:     22A9 7E 2276                                jmp  Lt_loop
  553:                                 
  554:     22AC BD 235E                SStop:          jsr go_stop             ; jumps to stop sub
  555:     22AF 86 0A                                  ldaa #10
  556:     22B1 BD 2469                                jsr pause 
  557:                                                 
  558:     22B4 38                                     pulx            
  559:     22B5 32                                     pula
  560:     22B6 39                                     rts     
  561:                                 ;*******************************
  562:                                 ; this one is special
  563:                                 ; a line track that will work to pick up the blocks
  564:                                 ;**************************************************
  565:     22B7                        lineTrackSpecial:
  566:     22B7 36                                     psha
  567:     22B8 3C                                     pshx
  568:                                                 
  569:     22B9 BD 2303                Lt_loop1:       jsr Lt_cont
  570:                                 
  571:     22BC B6 100A                                ldaa PORTE      ; grab info from port e
  572:     22BF 84 40                                  anda #$40               ; compare to the down setting
  573:     22C1 81 00                                  cmpa #$0
  574:     22C3 26 E7                                  bne  SStop      ; if down stop
  575:                                                                                 
  576:     22C5 B6 2013                FirstT1:        ldaa LTCB       ; checks the center sensors
  577:     22C8 81 02                                  cmpa #$02
  578:     22CA 27 26                                  beq  FForward_s
  579:                                                 
  580:     22CC 81 04                                  cmpa #$04       ; checks sensors for if to far left
  581:     22CE 27 16                                  beq  RTurn_s
  582:     22D0 81 06                                  cmpa #$06
  583:     22D2 27 12                                  beq  Rturn_s
  584:                                                         
  585:     22D4 81 01                                  cmpa #$01       ; checks sensors for if to far right
  586:     22D6 27 14                                  beq  LTurn_s
  587:     22D8 81 03                                  cmpa #$03
  588:     22DA 27 10                                  beq  LTurn_s
  589:                                                         
  590:     22DC 81 07                                  cmpa #$07       ; stops the robot if all three sensors are white
  591:     22DE 27 18                                  beq  SStop_s
  592:                                                 
  593:     22E0 BD 2370                                jsr go_forward
  594:     22E3 7E 22B9                                jmp Lt_loop1
  595:                                 
  596:                                  
  597:     22E6 BD 236A                RTurn_s:        jsr  go_right           ; jumps to sub that moves robot to the right    
  598:     22E9 7E 22B9                                jmp  Lt_loop1
  599:                                 
  600:     22EC BD 2364                LTurn_s:        jsr  go_left            ; jumps to sub that moves robot to the left
  601:     22EF 7E 22B9                                jmp  Lt_loop1
  602:                                 
  603:     22F2 BD 2370                FForward_s:     jsr  go_Forward         ; jumps to sub that moves robot forward
  604:     22F5 7E 22B9                                jmp  Lt_loop1
  605:                                 
  606:     22F8 BD 235E                SStop_s:        jsr go_stop             ; jumps to stop sub
  607:     22FB 86 0A                                  ldaa #10
  608:     22FD BD 2469                                jsr pause 
  609:                                                                 
  610:     2300 38                                     pulx            
  611:     2301 32                                     pula
  612:     2302 39                                     rts             
  613:                                 ;**************************************************************************
  614:                                 ;Name:          Lt_cont - Line Track Control Word
  615:                                 ;Author:        Dominic Lawrence
  616:                                 ;Date:          unknown
  617:                                 ;Modifications: 
  618:                                 ;               AA 03/??/06
  619:                                 ;                  Made into a separate sub routine
  620:                                 ;               PE3     ADR4/Line Track 3       left   \
  621:                                 ;               PE2     ADR3/Line Track 2       center  - looking from the back of robot
  622:                                 ;               PE1     ADR2/Line Track 1       Right  /
  623:                                 ;Function:      Takes the inputs for each linetrack sensor and compares 
  624:                                 ;               it to the LTL (Line Track Limit). If it is below LTL the 
  625:                                 ;               sensor is inidcating it is on the line and the
  626:                                 ;               corresponding bit is set in LTCB (Line Track Control Byte).
  627:                                 ;
  628:                                 ;               LTCB = xxxxx000
  629:                                 ;               LTL             equ $94  comparison number for more black and less is white? 
  630:                                 ;On Return:     LTCL is set as per above
  631:                                 ;**************************************************************************
  632:     2303 36                     Lt_cont:        psha
  633:     2304 3C                                     pshx
  634:                                 
  635:     2305 86 00                                  Ldaa #$0        ; getting the right side info and if wrong setting 
  636:     2307 B7 2013                                Staa LTCB       ; LTCB to reflect this so linetrack sub routine will know       
  637:     230A B6 1032                                Ldaa Adr2       ;*
  638:     230D 81 94                                  Cmpa #LTL       ;*
  639:     230F 24 06                                  BHS  CheckCenter;*
  640:     2311 CE 2013                                Ldx  #LTCB      ;*
  641:     2314 1C 00 04                               Bset 0,x #$04   ;*
  642:                                 
  643:     2317 B6 1033                CheckCenter:    Ldaa Adr3       ; get the Center info and if wrong setting 
  644:     231A 81 9F                                  Cmpa #$9F       ; LTCB to reflect this so Linetrack sub routine will know
  645:     231C 24 06                                  BHS  CheckLeft  ;*
  646:     231E CE 2013                                Ldx  #LTCB      ;*
  647:     2321 1C 00 02                               Bset 0,x #$02   ;*
  648:                                 
  649:     2324 B6 1034                CheckLeft:      Ldaa Adr4       ;getting the left side info and if wrong setting
  650:     2327 81 94                                  cmpa #LTL       ; LTCB to reflect this so line track sub routine will know
  651:     2329 24 06                                  BHS  lt_exit    ;*
  652:     232B CE 2013                                Ldx  #LTCB      ;*
  653:     232E 1C 00 01                               Bset 0,x #$01   ;*
  654:                                 
  655:     2331 38                     lt_exit:        pulx
  656:     2332 32                                     pula
  657:                                                 
  658:     2333 39                                     rts
  659:                                 ;**************************************************************************
  660:                                 ; This section will cause the robot to turn to the right until it hits a 
  661:                                 ; white line with the line tracking sensors
  662:                                 ;**************************************************************************
  663:     2334                        clockw:         
  664:     2334 36                                     psha
  665:     2335 BD 236A                                jsr go_right
  666:     2338 86 05                                  ldaa #5
  667:     233A BD 2469                                jsr pause
  668:     233D BD 2303                clockw_Loop:    jsr LT_cont             
  669:     2340 B6 2013                                ldaa LTCB               
  670:     2343 81 02                                  cmpa #$02
  671:     2345 26 F6                                  bne clockw_Loop 
  672:                                                 
  673:     2347 32                                     pula
  674:     2348 39                                     rts
  675:                                 ;**************************************************************************
  676:                                 ; This section will cause the robot to turn to the Left until it hits a 
  677:                                 ; white line with the line tracking sensors
  678:                                 ;*************************************************************************
  679:     2349                        counterclck:    
  680:     2349 36                                     psha
  681:     234A BD 2364                                jsr go_left
  682:     234D 86 05                                  ldaa #5
  683:     234F BD 2469                                jsr pause
  684:     2352 BD 2303                counter_Loop:   jsr LT_cont             
  685:     2355 B6 2013                                ldaa LTCB               
  686:     2358 81 02                                  cmpa #$02
  687:     235A 26 F6                                  bne  counter_Loop
  688:                                                 
  689:     235C 32                                     pula
  690:     235D 39                                     rts
  691:                                 ;**************************************************************************
  692:                                 ;Name:          Drive Motor Functions
  693:                                 ;Author:        Dan Kohn
  694:                                 ;Date:          Dec 9, 2005
  695:                                 ;Functions:     Each separtate function will do the indicated function 
  696:                                 ;               to the robot drive motors
  697:                                 ;
  698:                                 ;               go_Stop
  699:                                 ;               go_Left
  700:                                 ;               go_Right
  701:                                 ;               go_Forward
  702:                                 ;               go_Reverse
  703:                                 ;               never enter at robot_do! (Stack will be corrupted)
  704:                                 ;**************************************************************************
  705:                                 
  706:     235E 3C                     go_Stop         pshx
  707:     235F CE 2392                                ldx #Stop
  708:     2362 20 18                                  bra robot_do
  709:                                 
  710:     2364 3C                     go_Left         pshx
  711:     2365 CE 23B2                                ldx #Left
  712:     2368 20 12                                  bra robot_do
  713:                                 
  714:     236A 3C                     go_Right        pshx
  715:     236B CE 23AA                                ldx #Right
  716:     236E 20 0C                                  bra robot_do
  717:                                 
  718:     2370 3C                     go_Forward      pshx
  719:     2371 CE 23A2                                ldx #Forward
  720:     2374 20 06                                  bra robot_do
  721:                                 
  722:     2376 3C                     go_Reverse      pshx
  723:     2377 CE 239A                                ldx #Reverse
  724:     237A 20 00                                  bra robot_do
  725:                                 
  726:     237C EC 00                  robot_do        ldd 0,x
  727:     237E FD 2022                                std On_cnts_R
  728:     2381 EC 02                                  ldd 2,x
  729:     2383 FD 2024                                std Off_cnts_R
  730:     2386 EC 04                                  ldd 4,x
  731:     2388 FD 200E                                std On_cnts_L
  732:     238B EC 06                                  ldd 6,x
  733:     238D FD 2010                                std Off_cnts_L
  734:     2390 38                                     pulx
  735:     2391 39                                     rts
  736:                                 
  737:                                 ;Table for Drive Motor Functions
  738:                                 ;                       On_cnts_R       Off_cnts_R      On_cnts_L       Off_cnts_L
  739:                                 
  740:     2392 0BB8 9088 0BB8         Stop            fdb     3000,           37000,          3000,           37000
           2398 9088 
  741:     239A 07D0 9470 0FA0         REVERSE         fdb     2000,           38000,          4000,           36000
           23A0 8CA0 
  742:     23A2 0FA0 8CA0 07D0         FORWARD         fdb     4000,           36000,          2000,           38000
           23A8 9470 
  743:     23AA 07D0 9470 07D0         RIGHT           fdb     2000,           38000,          2000,           38000
           23B0 9470 
  744:     23B2 0FA0 8CA0 0FA0         LEFT            fdb     4000,           36000,          4000,           36000
           23B8 8CA0 
  745:                                 
  746:                                 ;Servo Motor notes:
  747:                                 ;       1ms on time = 2000 counts = forward
  748:                                 ;       2ms on time = 4000 counts = reverse
  749:                                 ;       total counts for a 50hz square wave (20mSec - suggested for servos) is 40000 counts
  750:                                 ;**************************************************************************
  751:                                 ;Name:          A2D
  752:                                 ;Author:        Dan Kohn
  753:                                 ;Date:          Jan 5, 2006
  754:                                 ;Functions:     Set up A/D to read PE0..PE3 continuously and  
  755:                                 ;               place the converted values in ADR1..ADR4
  756:                                 ;
  757:                                 ;On call:       NONE
  758:                                 ;
  759:                                 ;On Return;     A/D is turned on and running continously 
  760:                                 ;**************************************************************************
  761:                                 
  762:     23BA 3C                     A2D:            pshx
  763:     23BB 36                                     psha
  764:                                         
  765:     23BC CE 1039                                ldx #option             ;setup A/D
  766:     23BF 1C 00 80                               bset 0,x #$80           ;Turn on A/D - ADPU
  767:     23C2 1D 00 40                               bclr 0,x #$40           ;Use E clock
  768:                                                 
  769:     23C5 86 30                                  ldaa #$30               ;Set up to read PE0..PE3
  770:     23C7 B7 1030                                staa ADCTL              ;Continuously
  771:                                 
  772:     23CA 32                                     pula
  773:     23CB 38                                     pulx
  774:                                                 
  775:     23CC 39                                     rts
  776:                                 ;**************************************************************************
  777:                                 ;Name:          Multiplexed Motor Functions
  778:                                 ;Author:        Michael mcneill
  779:                                 ;Date:          Feb 9, 2006
  780:                                 ;Functions:     Each separtate function will do the indicated function 
  781:                                 ;               to the robot drive motors
  782:                                 ;
  783:                                 ;               go_Gstop
  784:                                 ;               go_Open
  785:                                 ;               go_Close
  786:                                 ;               go_Forward
  787:                                 ;               go_Reverse
  788:                                 ;
  789:                                 ;               never enter at robot_go! (Stack will be corrupted)
  790:                                 ;**************************************************************************
  791:                                 ;Gripper:
  792:                                 
  793:     23CD 3C                     go_Gstop        pshx
  794:     23CE CE 2427                                ldx #Gstop
  795:     23D1 20 0C                                  bra robot_go
  796:                                 
  797:     23D3 3C                     go_Open         pshx
  798:     23D4 CE 2423                                ldx #Open
  799:     23D7 20 06                                  bra robot_go
  800:                                 
  801:     23D9 3C                     go_Close        pshx
  802:     23DA CE 241F                                ldx #Close
  803:     23DD 20 00                                  bra robot_go
  804:                                 
  805:     23DF EC 00                  robot_go        ldd 0,x
  806:                                 ;               std On_cnts_Gr
  807:                                 ;               ldd 2,x
  808:                                 ;               std Off_cnts_Gr
  809:                                                 
  810:     23E1 38                                     pulx
  811:     23E2 39                                     rts
  812:                                 ;******************************************
  813:                                 ; code for movement of the robot arm
  814:                                 ;*************************************
  815:     23E3 3C                     go_Astop        pshx
  816:     23E4 CE 2433                                ldx #Astop
  817:     23E7 20 0C                                  bra robot_arm
  818:                                 
  819:     23E9 3C                     go_Up           pshx
  820:     23EA CE 242B                                ldx #UP
  821:     23ED 20 06                                  bra robot_arm
  822:                                 
  823:     23EF 3C                     go_Down         pshx
  824:     23F0 CE 241F                                ldx #Close
  825:     23F3 20 00                                  bra robot_arm
  826:                                 
  827:                                 
  828:                                 
  829:                                 
  830:     23F5 EC 00                  robot_arm       ldd 0,x
  831:     23F7 FD 2014                                std On_cnts_A
  832:     23FA EC 02                                  ldd 2,x
  833:     23FC FD 2016                                std Off_cnts_A
  834:                                                 
  835:     23FF 38                                     pulx
  836:     2400 39                                     rts
  837:                                 
  838:                                 
  839:                                 
  840:     2401 3C                     go_Bstop        pshx
  841:     2402 CE 243F                                ldx #Bstop
  842:     2405 20 0C                                  bra robot_bin
  843:                                 
  844:     2407 3C                     go_Clockw       pshx
  845:     2408 CE 2437                                ldx #bin_Clockw
  846:     240B 20 06                                  bra robot_bin
  847:                                 
  848:     240D 3C                     go_Counterw     pshx
  849:     240E CE 243B                                ldx #bin_Counterw
  850:     2411 20 00                                  bra robot_bin
  851:                                 
  852:                                 
  853:                                 
  854:                                 
  855:     2413 EC 00                  robot_bin       ldd 0,x
  856:     2415 FD 2018                                std On_cnts_B
  857:     2418 EC 02                                  ldd 2,x
  858:     241A FD 201A                                std Off_cnts_B
  859:                                                 
  860:     241D 38                                     pulx
  861:     241E 39                                     rts
  862:                                 
  863:                                 ;Table for Multiplexed Servo
  864:                                 ;                       On_cnts_G       Off_cnts_G
  865:     241F 0FA0 8CA0              CLOSE           fdb     4000,           36000                           
  866:     2423 07D0 9470              Open            fdb     2000,           38000
  867:     2427 0BB8 9088              Gstop           fdb     3000,           37000
  868:                                 ;Table for arm motor Functions
  869:                                 ;                       On_cnts_A       Off_cnts_A
  870:     242B 07D0 4650              UP              fdb     2000,           18000           
  871:     242F 1194 39D0              DOWN            fdb     4500,           14800
  872:     2433 0BB8 4268              Astop           fdb     3000,           17000
  873:                                 ;Table for bin motor Functions
  874:                                 ;                       On_cnts_B       Off_cnts_B
  875:     2437 07D0 4650              bin_Clockw      fdb     2000,           18000           ;Clockwise maybe
  876:     243B 1194 39D0              bin_Counterw    fdb     4500,           14800           ;Counterwise maybe
  877:     243F 0BB8 4268              Bstop           fdb     3000,           17000
  878:                                 ;Servo Motor notes:
  879:                                 ;       1ms on time = 2000 counts = forward
  880:                                 ;       2ms on time = 4000 counts = reverse
  881:                                 ;       total counts for a 50hz square wave (20mSec - suggested for servos) is 40000 counts
  882:                                 ;**************************************************************************     
  883:                                 ;this section closes the gripper with a small section at the beginning 
  884:                                 ;that deals with a use through a multiplexer
  885:                                 ;
  886:                                 ;**************************************************************************
  887:     2443 36                     gripperC:       psha
  888:                                 
  889:                                                 ;LDAA #$0000            ;this section for a multiplexer
  890:                                                 ;STAA cs0               ;*
  891:                                                 ;ldaa #1                        ;*
  892:                                                 ;jsr pause              ;*
  893:                                                 
  894:     2444 BD 23D9                                jsr go_Close            
  895:     2447 86 03                                  ldaa #3
  896:     2449 BD 2469                                jsr pause
  897:                                 
  898:     244C BD 23CD                                jsr go_GStop
  899:     244F 86 02                                  ldaa #2
  900:     2451 BD 2469                                jsr pause
  901:                                 
  902:     2454 32                                     pula
  903:     2455 39                                     rts
  904:                                 ;**************************************************************************     
  905:                                 ;this section sets the gripper to open 
  906:                                 ;this includes a small section that controls the gripper 
  907:                                 ;through a multiplexer
  908:                                 ;**************************************************************************
  909:     2456 36                     gripperO:       psha
  910:                                 ;
  911:                                 ;               LDAA #$0000
  912:                                 ;               STAA cs0
  913:                                 ;               ldaa #1
  914:                                 ;               jsr pause
  915:                                 
  916:     2457 BD 23D3                                jsr go_Open             ; call sub that Opens the gripper hand
  917:     245A 86 03                                  ldaa #3
  918:     245C BD 2469                                jsr pause
  919:                                 
  920:     245F BD 23CD                                jsr go_GStop
  921:     2462 86 02                                  ldaa #2
  922:     2464 BD 2469                                jsr pause
  923:                                 
  924:     2467 32                                     pula
  925:     2468 39                                     rts
  926:                                 ;**************************************************************************
  927:                                 ;Name:          Pause
  928:                                 ;Author:        Dan Kohn
  929:                                 ;Date:          Dec 19, 2005
  930:                                 ;Functions:     Pause for multiple of 0.1 sec 
  931:                                 ;               (setup for a 0.1 sec counter)
  932:                                 ;
  933:                                 ;On call:       Reg A Contains the number of 0.1 sec to pause
  934:                                 ;
  935:                                 ;On Return;     Sec_Count and Sec_Temp were changed (cleared at start of 
  936:                                 ;               pause.
  937:                                 ;**************************************************************************
  938:     2469 36                     Pause:          psha
  939:     246A 37                                     pshb
  940:     246B C6 00                                  ldab #$00
  941:     246D F7 202A                                stab SEC_TEMP
  942:     2470 F7 202B                                stab SEC_COUNT
  943:                                                 
  944:     2473 F6 202B                PauseL1:        ldab sec_count
  945:     2476 11                                     cba
  946:     2477 26 FA                                  bne PauseL1
  947:                                                 
  948:     2479 33                                     pulb
  949:     247A 32                                     pula
  950:     247B 39                                     rts
  951:                                 ;**************************************************************************
  952:                                 ;**************************************************************************
  953:     247C 36                     Left90: psha
  954:                                                 
  955:     247D BD 2364                                jsr go_left
  956:     2480 86 09                                  ldaa #9
  957:     2482 BD 2469                                jsr pause
  958:                                                 
  959:     2485 32                                     pula 
  960:     2486 39                                     rts
  961:                                 ;**************************************************************************
  962:                                 ;**************************************************************************
  963:     2487 36                     Right90:        psha
  964:                                 
  965:     2488 BD 236A                                jsr go_right
  966:     248B 86 09                                  ldaa #9
  967:     248D BD 2469                                jsr pause               
  968:                                                 
  969:     2490 32                                     pula
  970:     2491 39                                     rts
  971:                                 ;**************************************************************************
  972:                                 ;Name:          TOF_init
  973:                                 ;Author:        Dan Kohn
  974:                                 ;Date:          Dec 14, 2005
  975:                                 ;Functions:     Initializes the TOF Function 
  976:                                 ;               (setup for a 0.5 sec counter)
  977:                                 ;**************************************************************************
  978:                                 
  979:     2492 36                     TOF_init        psha
  980:     2493 3C                                     pshx
  981:     2494 183C                                   pshy
  982:                                 
  983:     2496 0F                                     SEI
  984:                                 
  985:     2497 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
  986:     2499 97 D0                                  STAA TOFIV
  987:                                 
  988:     249B CC 24D1                                LDD #TOF_CNT
  989:     249E DD D1                                  STD TOFIV+1
  990:                                 
  991:     24A0 86 80                                  ldaa #$80               ;clear TOF flag
  992:     24A2 B7 1025                                staa TFLG2
  993:                                         
  994:     24A5 CE 1024                                LDX #TMSK2              ;turn on TOF interrupt
  995:     24A8 1C 00 80                               bset 0,x #$80
  996:                                 
  997:     24AB 0E                                     cli 
  998:                                 
  999:     24AC 18CE 0000                              ldy #0                  ;clear 1 sec counter for planes
 1000:     24B0 18FF 202C                              sty plane_temp
 1001:                                 
 1002:     24B4 18CE 00B4                              ldy #180                ;set plane 1's time for 180sec
 1003:     24B8 18FF 202E                              sty plane1_cd
 1004:                                 
 1005:     24BC 18CE 00F0                              ldy #240                ;set plane 2's time for 240sec
 1006:     24C0 18FF 2030                              sty plane2_cd
 1007:                                 
 1008:     24C4 18CE 012C                              ldy #300                ;set plane 3's time for 300sec
 1009:     24C8 18FF 2032                              sty plane3_cd
 1010:                                                 
 1011:     24CC 1838                                   puly
 1012:     24CE 38                                     pulx
 1013:     24CF 32                                     pula
 1014:                                 
 1015:     24D0 39                                     rts
 1016:                                 ;**************************************************************************
 1017:                                 ;Name:          TOF_CNT
 1018:                                 ;Author:        Dan Kohn
 1019:                                 ;Date:          Dec 14, 2005
 1020:                                 ;Functions:     count every 0.1 sec.  
 1021:                                 ;
 1022:                                 ;On Return:     Count of 0.1 sec intervals is in SEC_count
 1023:                                 ;               Count of 32.77mSec intervals is in Sec_Temp
 1024:                                 ;**************************************************************************
 1025:     24D1 86 80                  TOF_CNT         ldaa #$80
 1026:     24D3 B7 1025                                staa TFLG2      
 1027:                                                 
 1028:     24D6 B6 202A                                ldaa Sec_temp           ;count # of times overflow occures (32.77ms)
 1029:     24D9 4C                                     inca 
 1030:     24DA B7 202A                                staa Sec_temp
 1031:                                 
 1032:     24DD 81 03                                  cmpa #03                ;if ~0.1sec has NOT gone by -> exit
 1033:     24DF 25 0C                                  blo plane_time          ;      [3*32.77mSec = 0.0983100 Sec]
 1034:                                 
 1035:                                 
 1036:     24E1 86 00                                  ldaa #$00               ;if ~0.1sec has gone by -> clear Sec_temp
 1037:     24E3 B7 202A                                staa Sec_temp           ;and add one to the Sec_count
 1038:                                 
 1039:     24E6 B6 202B                                ldaa Sec_count
 1040:     24E9 4C                                     inca 
 1041:     24EA B7 202B                                staa Sec_count
 1042:                                                 
 1043:     24ED 18FE 202C              plane_time:     ldy plane_temp          ;count # of times overflow occures (32.77ms)
 1044:     24F1 1808                                   iny 
 1045:     24F3 18FF 202C                              sty plane_temp
 1046:                                 
 1047:     24F7 188C 001E                              cpy #30                 ;if ~1sec has NOT gone by -> exit
 1048:     24FB 25 38                                  blo tof_exit            ;      [30*32.77mSec = .98310 Sec]
 1049:                                 
 1050:                                 
 1051:     24FD 18CE 0000                              ldy #$00                ;if ~0.1sec has gone by -> clear Sec_temp
 1052:     2501 18FF 202C                              sty plane_temp          ;and add one to the Sec_count
 1053:                                 
 1054:     2505 18FE 202E                              ldy plane1_cd           ;count down timer for plane 1
 1055:     2509 188C 0000                              cpy #0
 1056:     250D 27 06                                  beq pt_2
 1057:     250F 1809                                   dey
 1058:     2511 18FF 202E                              sty plane1_cd
 1059:                                 
 1060:     2515 18FE 2030              pt_2:           ldy plane2_cd           ;count down timer for plane 2
 1061:     2519 188C 0000                              cpy #0
 1062:     251D 27 06                                  beq pt_3
 1063:     251F 1809                                   dey
 1064:     2521 18FF 2030                              sty plane2_cd
 1065:                                 
 1066:     2525 18FE 2032              pt_3:           ldy plane3_cd           ;count down timer for plane 3
 1067:     2529 188C 0000                              cpy #0
 1068:     252D 27 06                                  beq TOF_exit
 1069:     252F 1809                                   dey
 1070:     2531 18FF 2032                              sty plane3_cd
 1071:                                 
 1072:     2535 3B                     TOF_exit        RTI
 1073:                                 
 1074:                                 ;**************************************************************************
 1075:                                 ;Name:          TOC2_init
 1076:                                 ;Author:        Dan Kohn
 1077:                                 ;Date:          Dec 8, 2005
 1078:                                 ;Functions:     Initalize the Right Motor (OC2) 
 1079:                                 ;
 1080:                                 ;On Call:       go_stop MUST be called before initalizing 
 1081:                                 ;**************************************************************************
 1082:     2536 36                     TOC2_init       psha
 1083:     2537 37                                     pshb
 1084:     2538 3C                                     pshx
 1085:                                 
 1086:     2539 0F                                     SEI
 1087:                                 
 1088:     253A 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1089:     253C 97 DC                                  STAA TOC2IV
 1090:                                 
 1091:     253E CC 2565                                LDD #TOC2RT
 1092:     2541 DD DD                                  STD TOC2IV+1
 1093:                                 
 1094:     2543 FC 100E                                LDD TCNT                ;sets the first time of TOC2
 1095:     2546 F3 2022                                ADDD On_cnts_R
 1096:     2549 FD 1018                                STD TOC2
 1097:                                 
 1098:     254C 86 40                                  LDAA #$40               ;intializing the registers
 1099:     254E B7 1023                                staa TFLG1
 1100:                                 
 1101:     2551 CE 1022                                ldx #TMSK1
 1102:     2554 1C 00 40                               BSET 0,X #$40
 1103:                                 
 1104:     2557 CE 1020                                LDX #TCTL1              ;toggles the output
 1105:     255A 1C 00 40                               BSET 0,X #$40
 1106:     255D 1D 00 80                               BCLR 0,x #$80
 1107:                                 
 1108:                                 
 1109:     2560 0E                                     CLI                     ;turning on the interrupts
 1110:                                 
 1111:     2561 38                                     pulx
 1112:     2562 33                                     pulb
 1113:     2563 32                                     pula 
 1114:                                 
 1115:     2564 39                                     rts
 1116:                                 ;**************************************************************************
 1117:                                 ;Name:          TOC2IV
 1118:                                 ;Author:        Gregory Reeves Jr.
 1119:                                 ;Date:          July 30, 2005
 1120:                                 ;Modified:      Dan Kohn Dec 8, 2005 For Dual Output Compares
 1121:                                 ;Function:      Interrupt for PWM for Right Motor
 1122:                                 ;On Call        On_cnts_R and Off_cnts_R 
 1123:                                 ;**************************************************************************
 1124:     2565 86 40                  TOC2RT          LDAA #$40               ;resets the OC2F bit
 1125:     2567 B7 1023                                STAA TFLG1
 1126:                                 
 1127:     256A B6 1000                                LDAA PORTA              ;check oc2 pin for on or off state
 1128:     256D 84 40                                  ANDA #$40
 1129:     256F 26 0B                                  BNE ON_2
 1130:                                 
 1131:     2571 FC 1018                                LDD TOC2                ;sets up for the off time sequence
 1132:     2574 F3 2024                                ADDD Off_cnts_R
 1133:     2577 FD 1018                                STD TOC2
 1134:     257A 20 09                                  BRA EXIT_2
 1135:                                 
 1136:     257C FC 1018                ON_2            LDD TOC2                ;sets up for the next ontime sequence
 1137:     257F F3 2022                                ADDD On_cnts_R
 1138:     2582 FD 1018                                STD TOC2
 1139:                                 
 1140:     2585 3B                     EXIT_2          RTI                     ;return from the interrupt
 1141:                                 ;**************************************************************************
 1142:                                 ;Name:          TOC3_init
 1143:                                 ;Author:        Dan Kohn
 1144:                                 ;Date:          Dec 8, 2005
 1145:                                 ;Functions:     Initalize the Left Motor (OC3) 
 1146:                                 ;
 1147:                                 ;On Call:       go_stop MUST be called before initalizing 
 1148:                                 ;**************************************************************************
 1149:     2586 36                     TOC3_init       psha
 1150:     2587 37                                     pshb
 1151:     2588 3C                                     pshx
 1152:                                 
 1153:     2589 0F                                     SEI
 1154:                                 
 1155:     258A 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1156:     258C 97 D9                                  STAA TOC3IV
 1157:                                 
 1158:     258E CC 25B5                                LDD #TOC3RT
 1159:     2591 DD DA                                  STD TOC3IV+1
 1160:                                 
 1161:     2593 FC 100E                                LDD TCNT                ;sets the first time of TOC2
 1162:     2596 F3 200E                                ADDD On_cnts_L
 1163:     2599 FD 101A                                STD TOC3
 1164:                                 
 1165:     259C 86 20                                  LDAA #$20               ;intializing the registers
 1166:     259E B7 1023                                staa TFLG1
 1167:                                 
 1168:     25A1 CE 1022                                ldx #TMSK1
 1169:     25A4 1C 00 20                               BSET 0,X #$20
 1170:                                 
 1171:     25A7 CE 1020                                LDX #TCTL1              ;toggles the output
 1172:     25AA 1C 00 10                               BSET 0,X #$10
 1173:     25AD 1D 00 20                               BCLR 0,x #$20
 1174:                                 
 1175:     25B0 0E                                     CLI                     ;turning on the interrupts
 1176:                                 
 1177:     25B1 38                                     pulx    
 1178:     25B2 33                                     pulb
 1179:     25B3 32                                     pula 
 1180:                                 
 1181:     25B4 39                                     rts
 1182:                                 ;**************************************************************************
 1183:                                 ;Name:          TOC3IV
 1184:                                 ;Author:        Gregory Reeves Jr.
 1185:                                 ;Date:          July 30, 2005
 1186:                                 ;Modified:      Dan Kohn Dec 8, 2005 For Dual Output Compares
 1187:                                 ;Function:      Interrupt for PWM for Left Motor
 1188:                                 ;On Call        On_cnts_L and Off_cnts_L 
 1189:                                 ;**************************************************************************
 1190:     25B5 86 20                  TOC3RT          LDAA #$20               ;resets the OC3F bit
 1191:     25B7 B7 1023                                STAA TFLG1
 1192:                                 
 1193:     25BA B6 1000                                LDAA PORTA              ;check oc3 pin for on or off state
 1194:     25BD 84 20                                  ANDA #$20
 1195:     25BF 26 0B                                  BNE ON_3
 1196:                                 
 1197:     25C1 FC 101A                                LDD TOC3                ;sets up for the off time sequence
 1198:     25C4 F3 2010                                ADDD Off_cnts_L
 1199:     25C7 FD 101A                                STD TOC3
 1200:     25CA 20 09                                  BRA EXIT_3
 1201:                                 
 1202:     25CC FC 101A                ON_3            LDD TOC3                ;sets up for the next ontime sequence
 1203:     25CF F3 200E                                ADDD On_cnts_L
 1204:     25D2 FD 101A                                STD TOC3
 1205:                                 
 1206:     25D5 3B                     EXIT_3          RTI                     ;return from the interrupt
 1207:                                 
 1208:                                 ;**************************************************************************
 1209:                                 ;Name:          TOC3_init
 1210:                                 ;Author:        Michael McNeill, Jr.
 1211:                                 ;Date:          ??
 1212:                                 ;Functions:     Initalize the Multiplexed Servo (OC4) 
 1213:                                 ;
 1214:                                 ;On Call:       go_Gstop MUST be called before initalizing 
 1215:                                 ;**************************************************************************
 1216:     25D6 36                     TOC4_init       psha
 1217:     25D7 37                                     pshb
 1218:     25D8 3C                                     pshx
 1219:                                 
 1220:     25D9 0F                                     SEI
 1221:                                 
 1222:     25DA 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1223:     25DC 97 D6                                  STAA TOC4IV
 1224:                                 
 1225:     25DE CC 2605                                LDD #TOC4RT
 1226:     25E1 DD D7                                  STD TOC4IV+1
 1227:                                 
 1228:     25E3 FC 100E                                LDD TCNT                ;sets the first time of TOC4
 1229:     25E6 F3 200A                                ADDD On_cnts_G
 1230:     25E9 FD 101C                                STD TOC4
 1231:                                 
 1232:     25EC 86 10                                  LDAA #$10               ;intializing the registers
 1233:     25EE B7 1023                                staa TFLG1
 1234:                                 
 1235:     25F1 CE 1022                                ldx #TMSK1
 1236:     25F4 1C 00 10                               BSET 0,X #$10
 1237:                                 
 1238:     25F7 CE 1020                                LDX #TCTL1              ;toggles the output
 1239:     25FA 1C 00 04                               BSET 0,X #$4
 1240:     25FD 1D 00 08                               BCLR 0,x #$8
 1241:                                 
 1242:                                 
 1243:     2600 0E                                     CLI                     ;turning on the interrupts
 1244:                                 
 1245:     2601 38                                     pulx
 1246:     2602 33                                     pulb
 1247:     2603 32                                     pula 
 1248:                                 
 1249:     2604 39                                     rts
 1250:                                 ;**************************************************************************
 1251:                                 ;Name:          TOC4IV
 1252:                                 ;Author:        Michael McNeill, Jr.
 1253:                                 ;Date:          Feb 1, 2006
 1254:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1255:                                 ;On Call        On_cnts_G and Off_cnts_G 
 1256:                                 ;**************************************************************************
 1257:     2605 86 10                  TOC4RT          LDAA #$10
 1258:     2607 B7 1023                                STAA TFLG1
 1259:                                 
 1260:     260A B6 1000                                LDAA PORTA
 1261:     260D 84 10                                  ANDA #$10
 1262:     260F 26 0B                                  BNE ON_4
 1263:                                 
 1264:     2611 FC 101C                                LDD TOC4
 1265:     2614 F3 200C                                ADDD off_cnts_G
 1266:     2617 FD 101C                                STD TOC4
 1267:     261A 20 09                                  BRA EXIT_4
 1268:                                 
 1269:     261C FC 101C                ON_4            LDD TOC4                ;sets up for the next ontime sequence
 1270:     261F F3 200A                                ADDD On_cnts_G
 1271:     2622 FD 101C                                STD TOC4
 1272:                                 
 1273:     2625 3B                     EXIT_4          RTI                     ;return from the interrupt
 1274:                                 
 1275:                                 ;**************************************************************************************************
 1276:                                 ;
 1277:                                 ;Name:          Scanner
 1278:                                 ;Author:        Michael McNeill, Jr.
 1279:                                 ;Date:          ??
 1280:                                 ;Functions:     Clears the Scanner buffer, then waits for the interrupt to 
 1281:                                 ;               recieve 33 bits. It then convers the returned bit pattern into plane
 1282:                                 ;               number based on the table below
 1283:                                 ;
 1284:                                 ;               Scanner reading $26 to $03
 1285:                                 ;                               $1e to $02
 1286:                                 ;                               $16 to $01
 1287:                                 ;
 1288:                                 ;Process:       the barcode scanner is read using the falling edge of PA0 (which is 
 1289:                                 ;               attached to the barcode clock). When a falling edge is detected, it 
 1290:                                 ;               reads the barcode data line (comming in on PE7). This data is placed
 1291:                                 ;               into the buffer from the left and shifted to the right. Each character
 1292:                                 ;               is actually 10 bits long. The first bit coming in is a START BIT, then
 1293:                                 ;               8 bits of data, then a PARITY BIT then a STOP bit. 
 1294:                                 ;
 1295:                                 ;               so the finish data buffer will look like this:
 1296:                                 ;
 1297:                                 ;               Byte        4       3       2       1       0
 1298:                                 ;               Bits 7654321076543210765432107654321076543210 
 1299:                                 ;
 1300:                                 ;                    sPxxxxxxxxSsPxxxxxxxxSsPxxxxxxxxS
 1301:                                 ;                    100010011001111110000010001001100
 1302:                                 ;                                            \      /
 1303:                                 ;                                             data representing plane #
 1304:                                 ;
 1305:                                 ;                            Data shifted -->
 1306:                                 ;
 1307:                                 ;               s=stop
 1308:                                 ;               P=Parity
 1309:                                 ;               S=START
 1310:                                 ;
 1311:                                 ;               the data is then compared to the values returned for planes 1,2,3 and
 1312:                                 ;               converted to the plane number. If the scan is bad, $FF will be the result.
 1313:                                 ;               This value is then stored in BOXCODE.
 1314:                                 ;
 1315:                                 ;On Call:       None
 1316:                                 ;
 1317:                                 ;On Return:     BOXCODE containes the plane number indicated by the barcode read ($FF
 1318:                                 ;               indicates an error when scanned).  
 1319:                                 ;               
 1320:                                 ;               Wiring of the Barcode
 1321:                                 ;               (Red wire - clock) (Brown wire - Data) (Green wire - Ground) (Orange wire - 5volts) (Yellow wire - 5volts)
 1322:                                 ;               (Black wire - 5volts)
 1323:                                 ;               
 1324:                                 ;
 1325:                                 ;
 1326:                                 ;*******************************************************************************************
 1327:                                         
 1328:                                 
 1329:     2626                        Scanner:
 1330:     2626 36                             psha
 1331:     2627 BD 26B8                        jsr BC_clear
 1332:                                 
 1333:                                 
 1334:     262A 86 00                          ldaa #$00
 1335:     262C B7 202B                        staa sec_count
 1336:                                         
 1337:     262F B6 202B                sc_0:   ldaa sec_count          ;  watchdog timer for six seconds
 1338:     2632 81 3C                          cmpa #60                ;* exits after 6 seconds if 33 bits not recieved
 1339:     2634 24 34                          bhs  SC_3               ;* will return $ff as barcode error code
 1340:     2636 B6 2008                        lDAA BC_count
 1341:     2639 81 21                          cmpa #33
 1342:     263B 25 F2                          BLO sc_0
 1343:                                 
 1344:     263D B6 2006                        Ldaa Barcode+3          ;Barcode to read #$26 to plane 3
 1345:     2640 81 26                          cmpa #$26
 1346:     2642 26 08                          Bne  sc_1
 1347:     2644 86 03                          ldaa #$03
 1348:     2646 B7 2009                        staa Boxcode
 1349:                                 
 1350:     2649 7E 266F                        jmp sc_exit
 1351:                                 
 1352:     264C                        Sc_1    
 1353:     264C B6 2006                        Ldaa Barcode+3          ;Barcode to read #$1e to plane 2
 1354:     264F 81 1E                          cmpa #$1e
 1355:     2651 26 08                          Bne  sc_2
 1356:     2653 86 02                          ldaa #$02
 1357:     2655 B7 2009                        staa Boxcode
 1358:                                 
 1359:     2658 7E 266F                        jmp sc_exit
 1360:                                 
 1361:     265B                        Sc_2    
 1362:     265B B6 2006                        Ldaa Barcode+3          ;Barcode to read #$16 to plane 1
 1363:     265E 81 16                          cmpa #$16
 1364:     2660 26 08                          Bne  sc_3
 1365:     2662 86 01                          ldaa #$01
 1366:     2664 B7 2009                        staa Boxcode
 1367:                                 
 1368:     2667 7E 266F                        jmp sc_exit
 1369:                                         
 1370:     266A                        Sc_3    
 1371:                                         
 1372:                                 
 1373:     266A 86 FF                          ldaa #$ff               ;flag for bad scan
 1374:     266C B7 2009                        staa Boxcode
 1375:                                 
 1376:     266F                        sc_exit
 1377:                                 
 1378:     266F 32                             pula
 1379:     2670 39                             rts
 1380:                                 
 1381:                                 
 1382:                                 
 1383:                                 ;*******************************************************************************
 1384:                                 ;Name:          IC3_init
 1385:                                 ;Author:        Michael McNeill, Jr.
 1386:                                 ;Date:          ??
 1387:                                 ;Functions:     This initializes IC3 to capture a falling edge of the 
 1388:                                 ;               clock for the barcode reader. 
 1389:                                 ;
 1390:                                 ;********************************************************************************
 1391:     2671 36                     IC3_init:       psha
 1392:     2672 3C                                     pshx
 1393:                                                                         
 1394:     2673 0F                                     sei
 1395:                                 
 1396:     2674 86 7E                                  ldaa #$7E
 1397:     2676 97 E2                                  staa IC3IV
 1398:                                 
 1399:     2678 CC 2695                                LDD #IC3RT
 1400:     267B DD E3                                  STD IC3IV+1
 1401:                                 
 1402:     267D CE 1021                                LDX #TCTL2
 1403:                                 
 1404:     2680 1C 00 02                               Bset 0,X #$02   ;set for falling edge
 1405:     2683 1D 00 01                               Bclr 0,X #$01
 1406:                                        
 1407:     2686 86 01                                  LDAA #$01
 1408:     2688 B7 1023                                STAA TFLG1      ;clr flag
 1409:                                 
 1410:     268B CE 1022                                LDX #TMSK1      ;turn on INT
 1411:     268E 1C 00 01                               Bset 0,X #$01
 1412:                                 
 1413:     2691 0E                                     cli
 1414:                                 
 1415:     2692 38                                     pulx
 1416:     2693 32                                     pula
 1417:     2694 39                                     rts
 1418:                                 
 1419:                                 
 1420:                                 ;**************************************************************************
 1421:                                 ;Name:          IC3RT - Barcode interrupt 
 1422:                                 ;Author:        Dan Kohn
 1423:                                 ;Date:          ??
 1424:                                 ;Function:      This interrupt is triggered on a FALLING EDGE of the 
 1425:                                 ;               bar code clk signal. That that time, the data line is
 1426:                                 ;               captured and placed into the CARRY BIT which is then
 1427:                                 ;               shifted from the left into the barcode buffer.
 1428:                                 ;
 1429:                                 ;               [see SCANNER routine for more info]
 1430:                                 ;**************************************************************************
 1431:                                 
 1432:     2695 86 01                  IC3RT:          ldaa #$01               ;resets the IC3 bit
 1433:     2697 B7 1023                                staa TFLG1
 1434:                                 
 1435:     269A B6 100A                                Ldaa portE              ;check IC3 pin for on or off state
 1436:     269D 84 80                                  anda #$80
 1437:     269F 27 03                                  BEQ  BC_High
 1438:     26A1 0D                                     sec
 1439:     26A2 20 01                                  BRA BC_skip
 1440:                                 
 1441:     26A4 0C                     BC_High         clc
 1442:                                 
 1443:     26A5 76 2003                BC_Skip         ROR Barcode
 1444:     26A8 76 2004                                ROR Barcode+1
 1445:     26AB 76 2005                                ROR Barcode+2
 1446:     26AE 76 2006                                ROR Barcode+3
 1447:     26B1 76 2007                                ROR Barcode+4
 1448:     26B4 7C 2008                                INC BC_count
 1449:     26B7 3B                                     RTI                     ;return from the interrupt
 1450:                                 
 1451:                                 
 1452:                                 ;**************************************************************************
 1453:                                 ;Name:          BC_Clear - Clear Bar Code buffer 
 1454:                                 ;Author:        Dan Kohn
 1455:                                 ;Date:          ??
 1456:                                 ;Function:      Clear the buffer for the bar code buffer (fill with all ones)
 1457:                                 ;**************************************************************************
 1458:     26B8 36                     BC_clear        psha
 1459:     26B9 86 FF                                  LDAA #$FF
 1460:     26BB B7 2003                                STAA Barcode
 1461:     26BE B7 2004                                STAA Barcode+1
 1462:     26C1 B7 2005                                STAA Barcode+2
 1463:     26C4 B7 2006                                STAA Barcode+3
 1464:     26C7 B7 2007                                STAA Barcode+4
 1465:     26CA 86 00                                  LDAA #$0
 1466:     26CC B7 2008                                STAA BC_count
 1467:                                 
 1468:     26CF 32                                     Pula
 1469:     26D0 39                                     RTS
 1470:                                 ;*****************************************************
 1471:                                 
 1472:                                 
 1473:                                 ;**************************************************************************
 1474:                                 ;Name:          TOC1_init
 1475:                                 ;Author:        michael mcneill
 1476:                                 ;Date:          4/15/06
 1477:                                 ;Functions:     Initalize the toc1_init 
 1478:                                 ;
 1479:                                 ;On Call:       go_stop MUST be called before initalizing 
 1480:                                 ;**************************************************************************
 1481:     26D1 36                     TOC1_init       psha
 1482:     26D2 37                                     pshb
 1483:     26D3 3C                                     pshx
 1484:                                 
 1485:     26D4 0F                                     SEI
 1486:                                 
 1487:     26D5 86 7E                                  LDAA #$7E               ;setting the interrupt vector table
 1488:     26D7 97 DF                                  STAA TOC1IV
 1489:                                 
 1490:     26D9 CC 2702                                LDD #TOC1RT
 1491:     26DC DD E0                                  STD TOC1IV+1
 1492:                                 
 1493:     26DE FC 100E                                LDD TCNT                ;sets the first time of TOC1
 1494:     26E1 F3 2026                                ADDD On_cnts_GR
 1495:     26E4 FD 1016                                STD TOC1
 1496:                                 
 1497:     26E7 86 80                                  LDAA #$80               ;intializing the registers
 1498:     26E9 B7 1023                                staa TFLG1
 1499:                                 
 1500:     26EC CE 1022                                ldx #TMSK1
 1501:     26EF 1C 00 80                               BSET 0,X #$80
 1502:                                 
 1503:     26F2 86 80                                  LDAA #$80
 1504:     26F4 B7 100C                                STAA oc1m
 1505:                                                 
 1506:     26F7 CE 1026                                LDx #pactl
 1507:     26FA 1C 00 80                               bset 0,x #$80
 1508:                                 
 1509:                                                 
 1510:                                 
 1511:     26FD 0E                                     CLI                     ;turning on the interrupts
 1512:                                 
 1513:     26FE 38                                     pulx
 1514:     26FF 33                                     pulb
 1515:     2700 32                                     pula 
 1516:                                 
 1517:     2701 39                                     rts
 1518:                                 ;**************************************************************************
 1519:                                 
 1520:                                 
 1521:                                 
 1522:                                 
 1523:                                 ;**************************************************************************
 1524:                                 ;Name:          TOCIRT
 1525:                                 ;Author:        Michael McNeill, Jr.
 1526:                                 ;Date:          3/15/06
 1527:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1528:                                 ;On Call        On_cnts_Gr and Off_cnts_Gr 
 1529:                                 ;**************************************************************************
 1530:     2702 86 80                  TOC1RT:         LDAA #$80
 1531:     2704 B7 1023                                STAA TFLG1
 1532:                                 
 1533:     2707 B6 1000                                LDAA PORTA
 1534:     270A 84 80                                  ANDA #$80
 1535:     270C 26 11                                  Bne toc1_high
 1536:                                 
 1537:                                 
 1538:                                                 
 1539:                                 
 1540:                                 
 1541:     270E FC 1016                toc1_low:       LDD TOC1
 1542:     2711 F3 2028                                ADDD off_cnts_Gr
 1543:     2714 FD 1016                                STD TOC1
 1544:                                 
 1545:     2717 CE 100D                                ldx #oc1d               ;set pin to go high next time TOC=TCNT
 1546:     271A 1C 00 80                               bset 0,x #$80
 1547:                                 
 1548:     271D 20 0F                                  BRA EXIT_1
 1549:                                 
 1550:     271F FC 1016                toc1_high:      LDD TOC1                ;sets up for the next ontime sequence
 1551:     2722 F3 2026                                ADDD on_cnts_Gr
 1552:     2725 FD 1016                                STD TOC1
 1553:                                 
 1554:     2728 CE 100D                                ldx #oc1d               ;set pin to go low next time TOC=TCNT
 1555:     272B 1D 00 80                               bclr 0,x #$80
 1556:                                 
 1557:     272E 3B                     EXIT_1:         RTI                     ;return from the interrupt
 1558:                                 
 1559:                                 ;**************************************************************************************************
 1560:                                 ;Name:          grip0
 1561:                                 ;Author:        Michael McNeill, Jr.
 1562:                                 ;Date:          3/15/06
 1563:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1564:                                 ;On Call        On_cnts_Gr 
 1565:                                 ;Gripper (TOC1init) Variables and Equates:
 1566:                                 ;gripppe open
 1567:                                 ;
 1568:                                 ;
 1569:                                 ;
 1570:                                 ;************************************************************************************************************
 1571:     272F 183C                   gripO:          pshy
 1572:                                                         
 1573:                                 
 1574:     2731 18CE 8E30                              ldy #36400      
 1575:     2735 18FF 2028                              sty off_cnts_Gr
 1576:     2739 18CE 0E10                              ldy #3600       
 1577:     273D 18FF 2026                              sty on_cnts_Gr
 1578:                                                 
 1579:                                                 
 1580:     2741 1838                                   puly
 1581:                                                 
 1582:     2743 39                                     rts
 1583:                                 ;**************************************************************************************************
 1584:                                 ;Name:          gripC
 1585:                                 ;Author:        Michael McNeill, Jr.
 1586:                                 ;Date:          3/15/06
 1587:                                 ;Function:      Interrupt for PWM for Gripper Motor
 1588:                                 ;On Call        OFF_cnts_Gr 
 1589:                                 ;Gripper (TOC1init) Variables and Equates:
 1590:                                 ;gripppe close
 1591:                                 ;
 1592:                                 ;
 1593:                                 ;
 1594:                                 ;************************************************************************************************************
 1595:     2744 183C                   grippC:         pshy
 1596:                                 
 1597:                                 
 1598:     2746 18CE 8A48                              ldy #35400
 1599:     274A 18FF 2028                              sty off_cnts_Gr
 1600:     274E 18CE 11F8                              ldy #4600
 1601:     2752 18FF 2026                              sty on_cnts_Gr          
 1602:                                 
 1603:                                 
 1604:     2756 1838                                   puly
 1605:     2758 39                                     rts
 1606:                                 ;************************************************************************************************************
 1607:                                 

Symbols:
a2d                             *000023ba
adctl                           *00001030
adr2                            *00001032
adr3                            *00001033
adr4                            *00001034
astop                           *00002433
barcode                         *00002003
bc_clear                        *000026b8
bc_count                        *00002008
bc_high                         *000026a4
bc_skip                         *000026a5
bin_clockw                      *00002437
bin_counterw                    *0000243b
boxcode                         *00002009
bstop                           *0000243f
checkcenter                     *00002317
checkleft                       *00002324
clockw                          *00002334
clockw_loop                     *0000233d
close                           *0000241f
counter_loop                    *00002352
counterclck                     *00002349
end_check                       *000020c8
exit_1                          *0000272e
exit_2                          *00002585
exit_3                          *000025d5
exit_4                          *00002625
fforward                        *000022a6
fforward_s                      *000022f2
forward                         *000023a2
go_close                        *000023d9
go_forward                      *00002370
go_gstop                        *000023cd
go_left                         *00002364
go_open                         *000023d3
go_reverse                      *00002376
go_right                        *0000236a
go_stop                         *0000235e
gripo                           *0000272f
grippc                          *00002744
gstop                           *00002427
ic3iv                           *000000e2
ic3rt                           *00002695
leaveshoot                      *000020ea
left                            *000023b2
left90                          *0000247c
linetrack                       *00002274
linetrackspecial                *000022b7
lt_cont                         *00002303
lt_exit                         *00002331
lt_loop                         *00002276
lt_loop1                        *000022b9
ltcb                            *00002013
ltl                             *00000094
lturn                           *000022a0
lturn_s                         *000022ec
main                            *00002034
no_1_plane                      *00002092
no_2_plane                      *000020a5
no_3_plane                      *000020b8
oc1d                            *0000100d
oc1m                            *0000100c
off_cnts_a                      *00002016
off_cnts_b                      *0000201a
off_cnts_g                      *0000200c
off_cnts_gr                     *00002028
off_cnts_l                      *00002010
off_cnts_r                      *00002024
on_2                            *0000257c
on_3                            *000025cc
on_4                            *0000261c
on_cnts_a                       *00002014
on_cnts_b                       *00002018
on_cnts_g                       *0000200a
on_cnts_gr                      *00002026
on_cnts_l                       *0000200e
on_cnts_r                       *00002022
open                            *00002423
option                          *00001039
pactl                           *00001026
pause                           *00002469
pausel1                         *00002473
plane1                          *00002111
plane1_cd                       *0000202e
plane2                          *000021a6
plane2_cd                       *00002030
plane3                          *00002214
plane3_cd                       *00002032
plane_temp                      *0000202c
plane_time                      *000024ed
porta                           *00001000
porte                           *0000100a
pt_2                            *00002515
pt_3                            *00002525
range1                          *00002058
reg_base                        *00001000
reverse                         *0000239a
right                           *000023aa
right90                         *00002487
robot_arm                       *000023f5
robot_bin                       *00002413
robot_do                        *0000237c
robot_go                        *000023df
rturn                           *0000229a
rturn_s                         *000022e6
sc_0                            *0000262f
sc_1                            *0000264c
sc_2                            *0000265b
sc_3                            *0000266a
sc_exit                         *0000266f
sec_count                       *0000202b
sec_temp                        *0000202a
shoot2                          *00002177
sstop                           *000022ac
sstop_s                         *000022f8
start                           *000020cc
stop                            *00002392
tcnt                            *0000100e
tctl1                           *00001020
tctl2                           *00001021
tflg1                           *00001023
tflg2                           *00001025
tmsk1                           *00001022
tmsk2                           *00001024
toc1                            *00001016
toc1_high                       *0000271f
toc1_init                       *000026d1
toc1iv                          *000000df
toc1rt                          *00002702
toc2                            *00001018
toc2_init                       *00002536
toc2iv                          *000000dc
toc2rt                          *00002565
toc3                            *0000101a
toc3_init                       *00002586
toc3iv                          *000000d9
toc3rt                          *000025b5
toc4                            *0000101c
toc4iv                          *000000d6
toc4rt                          *00002605
tof_cnt                         *000024d1
tof_exit                        *00002535
tof_init                        *00002492
tofiv                           *000000d0
up                              *0000242b

