;-------------------------------------------------------- ; R A M P ; ; S A C T R A C K S E Q U E N C E ;-------------------------------------------------------- ;Cannot exceed 1023 lines of instructions. ; SET 0.010 2 0 ;0.01 milliseconds per tick ;+/-10 volts ;0 degree offset; TABSZ 150000 ;set maximum table space ;DELAY command is based on the 100 microsecond clock ticks specified above ;TICKS command is based on the ADC sampling clock rate subject to num channels ;VAR V1 ;RE-USABLE variables for use only within mode subroutines ;VAR V2 ;these variables should not pass parameters between ;VAR V3 ;modes or subroutines ;VAR V4 ;VAR V5 ;VAR V6 ;VAR V7 ;VAR V8 ;VAR V9 ;VAR V10 ;VAR V11 ;VAR V12, ;VAR V13, ;VAR V14, ;VAR V15, ;VAR V16, ;VAR V17, ;VAR V18, ;VAR V19, VAR V20,TEMP3 VAR V21,TEMP4 ;VAR V22, ;VAR V23, ;VAR V24, ;VAR V25, ;VAR V26, ;----------------------------------------------------------- ;above variables are zeroed every time a new mode is entered ;----------------------------------------------------------- VAR V27,ELAPSED=0 ;when OT testing began VAR V28,TIMECURR ;current SPIKE2 time VAR V29,TIMECHEK ;when to check if it is time to move VAR V30,TIMEFEED VAR V31,TEMPTRAK ;OT testing (convert to TABLE field?) VAR V32,TEMPWIND VAR V33,LEDBRD1 ;indicate which LED board (RED) VAR V34,LEDADD1 ;indicate which LED light (RED) VAR V35,LEDBRD2 ;indicate which LED board (GRN) VAR V36,LEDADD2 ;indicate which LED light (GRN) VAR V37,TRACKING ;is he tracking VAR V38,HITTYPE1 ;times all loc shown or step, non-adapt, etc shown VAR V39,HITTYPE2 ;times step-ramp, adapt shown VAR V40,ZERO=0 ;for many branching comparisons VAR V41,NAN=999999999 ;represents "not a number" VAR V42,SHUT1=1 ;primary shutter (normally open) VAR V43,SHUT2=0 ;secondary shutter (normally close) VAR V44,HE ;eye vertical position VAR V45,VE ;eye horizontal position VAR V46,HT2 ;target-2 horizontal position VAR V47,VT2 ;target-2 vertical position VAR V48,HT1 ;target-1 horizontal position VAR V49,VT1 ;target-1 vertical position VAR V50,DURFORG ;how long he has been forgiven VAR V51,DURFEED=0 ;duration he has been on-target before getting fed VAR V52,DURCONT=0 ;contiguously on-target VAR V53,DURON=0 ;total time on-target VAR V54,PARAMCHG=0 ;signals parameters changed -- VAR V55,SUCCESS ;comlete the task? ;we test the Digitial Input so the following VAR is reserved ;VAR V56 ;Collision and Mayhem ;we have DAC 0,1,2,3 so the following VAR are reserved ;V57, last DAC 0 value ;won't work ;V58, last DAC 1 value ;with galvo ;V59, last DAC 2 value ;V60, last DAC 3 value ;we don't have DAC 4,5,6,7 so ok to use the following VAR VAR V61,TEMPTIME ;time counter variable ;VAR V62, VAR V63,SBUFFER=1 ;which serial buffer to use 1 or 2 (must start with 1) VAR V64,FORGIVE=0 ;forgiveness ;the data table transfered to the sequencer ;0000 - 0999 Common parameters ;[0] := gWindowHvgDAC%; HWIND ;[1] := gWindowVvgDAC%; VWIND ;[10] := pRealMinTime*1000; ASSOONAS ;[11] := pRealMaxTime*1000; NOLATER ;[12] := pRealContiguousTime*1000; CONTTON ;[13] := pRealTimeOn*1000; TOTALTON ;[14] := pOnFirst*1000; DURFIRST ;[15] := pOnSubsequent*1000; DURSUB ;[16] := pForgiveness*1000; FORGTIME ;[30] := gWhichBooth ;[31] := update report window info ;1000 - and above = for passing Table parmeters related to this behavioral mode ;-------------------------------------------------------- ; I N I T I A L I Z E L E D A R R A Y ;Initialize the LED array so buffer #1 will be active first. ;3/19/03 ;-------------------------------------------------------- DIGLOW [10101111] ;1-AF CLEAR all boards DELAY 12 ;13-120 microsecond delay DIGLOW [10111111] ;14-BF INTENSITY all boards DELAY 12 ;27-120 microsecond delay ;CALL BRITE doesn't run on the LED array TICKS TIMECURR ;set this up just so the IDLE routine will get started TICKS TIMECHEK,msTick(1) ;1ms, 0.001s later CRATE HZ(0) ;stop the ch 0 sinewave if it is running DRATE HZ(0) ;stop the ch 1 sinewave if it is running DIGOUT [....1...] ;low de-activates the SONALERT MOVI SHUT1,1 ;open the primary shutter MOVI SHUT2,0 ;close the secondary shutter CALL SHUTTER ;-------------------------------------------------------- ; M A I N ;Directs program control to the mode of choice. ;10/11/04 ;-------------------------------------------------------- MAIN: MOVI ELAPSED,0 MOVI DURCONT,0 ;reset accumulators MOVI DURON,0 MOVI DURFORG,0 ;reset forgiveness timer ;-------------------------------------------------------- ; R A M P ;Moves the target in a ramp or step-ramp. ; ;Re-usable Variables: ; V1 = table data address pointer ; V2 = table data holder ; V3 = X increment rate ; V4 = Y increment rate ; V5 = Time to start Ramp ; V6 = Time to end Primary Vel / start Secondary Vel ; V7 = Time to start Second Plateau ; V8 = Time to start new trial ; V9 = unused ; V10 = unused ; V11 = Random vector (primary & secondary share the same vector) ; V12 = Random velocity (var gets primary, later gets secondary) ; V13 = Random duplicate value ; V14 = unused ; V15 = mode within RAMP ; V16 = for computations ; V17 = for computations ; ; TEMPTIME = countdown timer variable ; HITTYPE1 = how many times the adapt step has been presented ; HITTYPE2 = how many times the non-adapt step has been presented ; MYREPORT = signals when it is time to report new data to the user ; ; ;On Target parameter stored in TABLE, ZERO=0000 ; ZERO+10 = pRealMinTime*1000; ASSOONAS ; ZERO+11 = pRealMaxTime*1000; NOLATER ; ZERO+12 = pRealContiguousTime*1000; CONTTON ; ZERO+13 = pRealTimeOn*1000; TOTALTON ; ZERO+14 = pOnFirst*1000; DURFIRST ; ZERO+15 = pOnSubsequent*1000; DURSUB ; ZERO+16 = pForgiveness*1000; FORGTIME ; ;Adapt paradigm info stored in TABLE, A=1000 ; A+0 = ramp:step-ramp ratio 128/128=100% ; A+1 = first plateau duration in milliseconds ; A+2 = second plateau duration in milliseconds ; A+3 = step latency in milliseconds ; A+4 = second velocity start time in milliseconds ; ; A+10-19 TIMES EACH DIRECTION USED ; ; A+20-29 PRIMARY VELOCITY INCREMENT X-VALUES in DAC units ; A+30-39 PRIMARY VELOCITY INCREMENT X-VALUES in DAC units ; A+40-49 PRIMARY VELOCITY INCREMENT X-VALUES in DAC units ; A+50-59 PRIMARY VELOCITY INCREMENT X-VALUES in DAC units ; A+60-69 PRIMARY VELOCITY INCREMENT X-VALUES in DAC units ; A+70-79 PRIMARY VELOCITY INCREMENT X-VALUES in DAC units ; A+80-89 PRIMARY VELOCITY INCREMENT X-VALUES in DAC units ; A+90-99 PRIMARY VELOCITY INCREMENT X-VALUES in DAC units ; A+100-109 PRIMARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+110-119 PRIMARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+120-129 PRIMARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+130-139 PRIMARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+140-149 PRIMARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+150-159 PRIMARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+160-169 PRIMARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+170-179 PRIMARY VELOCITY INCREMENT Y-VALUES in DAC units ; ; A+180-189 SECONDARY VELOCITY INCREMENT X-VALUES in DAC units ; A+190-199 SECONDARY VELOCITY INCREMENT X-VALUES in DAC units ; A+200-209 SECONDARY VELOCITY INCREMENT X-VALUES in DAC units ; A+210-219 SECONDARY VELOCITY INCREMENT X-VALUES in DAC units ; A+220-229 SECONDARY VELOCITY INCREMENT X-VALUES in DAC units ; A+230-239 SECONDARY VELOCITY INCREMENT X-VALUES in DAC units ; A+240-249 SECONDARY VELOCITY INCREMENT X-VALUES in DAC units ; A+250-259 SECONDARY VELOCITY INCREMENT X-VALUES in DAC units ; A+260-269 SECONDARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+270-279 SECONDARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+280-289 SECONDARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+290-299 SECONDARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+300-309 SECONDARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+310-319 SECONDARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+320-329 SECONDARY VELOCITY INCREMENT Y-VALUES in DAC units ; A+330-339 SECONDARY VELOCITY INCREMENT Y-VALUES in DAC units ; ; A+340-349 EXCURSION LIMIT in X DAC units ; A+350-359 EXCURSION LIMIT in Y DAC units ; ;Randomly chosen parameters: ; A+500 Primary X increment value ; A+501 Primary Y increment value ; A+502 Secondary X increment value ; A+503 Secondary Y increment value ; A+504 largest increment, X=0, Y=1 ; A+505 pre-step size X ; A+506 pre-step size Y ; A+507 full ramp duration at primary rate ; A+508 full ramp duration at secondary rate ; ;1/1/03 ;-------------------------------------------------------- RAMP0: BEQ PARAMCHG,0,RAMP0 ;wait for parameters to arrive BEQ PARAMCHG,2,RAMP14 ;skip if not the first time through ;first time only ;--------------- MOVI PARAMCHG,2 ;new parameters grabbed CALL ZEROVAR ;clear all the re-usable VAR MOVI HITTYPE1,0 ;reset the ramp counter MOVI HITTYPE2,0 ;reset the stepramp counter MOVI V1,1000 ;data pointer ;make calculations to run a whole trial ;----------------------------------------------------- ;pick a random direction and a random primary velocity RAMP14: MOVRND V11,3 ;get a random vector between 0-7 (hard-coded) MOVRND V12,3 ;get a random velocity between 0-7 (hard-coded) ;MARK 82 ;R ; delay 200 ; MARK v11 ; delay 100 ; MARK v12 ;verify that it is a valid choice MOV V13,V11 ;load the vector MULI V13,10 ;multiply it by 10 ADDI V13,20 ;add vector table offset ADD V13,V12 ;add primary velocity offset ADD V13,V1 ;add table offset TABLD V2,[V13] ;get the primary X increment from the table TABST V2,[V1+500] ;store the primary X increment MOV V16,V2 ;save a temporary copy of X increment ADDI V13,80 ;add offset to primary Y increment TABLD V2,[V13] ;get the primary Y increment from the table TABST V2,[V1+501] ;store the primary Y increment ;MARK 55 ;7 MOV V17,V2 ;save a temporary copy of Y increment BEQ V2,NAN,RAMP14 ;test if a valid velocity is in this part of the table ;inc the counter for the selected ramp vector ;--------------------------------------------------------------------- MOVI V13,600 ;offset to vector counter table area ADD V13,V11 ;offset to specific vector TABLD V2,[V13] ;get the vector use counter from the table ADDI V2,1 ;increment vector use counter TABST V2,[V13] ;set the vector use counter from the table ;determine if the X or Y increment is larger (for timing calculations) ;--------------------------------------------------------------------- BGE V16,0,RAMP21 ;skip if X increment positive MULI V16,-1 ;make positive RAMP21: BGE V17,0,RAMP22 ;skip if Y increment positive MULI V17,-1 ;make positive RAMP22: MOVI V2,0 ;X=0, default ;MARK 54 ;6 BGE V16,V17,RAMP24 ;test if delta Y is bigger than delta X ;MARK 53 ;5 MOVI V2,1 ;Y=1 RAMP24: TABST V2,[V1+504] ;set whether delta X is larger than delta Y ;test if there are any valid second velocities to choose from ;------------------------------------------------------------ TABLD V2,[V1+4] ;secondary velocity time BEQ V2,0,RAMP17 ;branch if NO secondary velocity time (zero=no) RAMP16: MOVRND V12,3 ;get a random vector between 0-7 (hard-coded) MOV V13,V11 ;load the vector MULI V13,10 ;multiply it by 10 ADDI V13,180 ;add vector table offset ADD V13,V12 ;add primary velocity offset ADD V13,V1 ;add table offset TABLD V2,[V13] ;get the secondary X increment from the table TABST V2,[V1+502] ;store the secondary X increment ADDI V13,80 ;add offset to secondary Y increment TABLD V2,[V13] ;get the secondary Y increment from the table TABST V2,[V1+503] ;store the secondary Y increment ;MARK 66 ;B BEQ V2,NAN,RAMP16 ;test if a valid velocity is in this part of the table ;compute the ramp durations ;-------------------------- RAMP17: TABLD V2,[V1+4] ;get the secondary velocity time BGT V2,0,RAMP37 ;branch if there is a secondary velocity time ;compute ramp duration with just the primary velocity ;using X increment compute the durations TABLD V2,[V1+504] ;X or Y larger BGT V2,0,RAMP38 ;test if X or Y increment is larger MOVI V2,340 ;get X excursion limit 34X+V11 ADD V2,V11 ;add vector offset to get the right X limit ADD V2,V1 ;add table offset TABLD V14,[V2] ;get the X excursion limit TABLD V16,[V1+500] ;get primary X increment DIV V14,V16 ;divide it by primary x increment rate TABST V14,[V1+507] ;save the ms duration of whole ramp at primary velocity ;MARK 51 ;3 JUMP RAMP19 ;using Y increment compute the durations RAMP38: MOVI V2,350 ;get Y excursion limit 35X+V11 ADD V2,V11 ;add vector offset to get the right Y limit ADD V2,V1 ;add table offset TABLD V14,[V2] ;get the Y excursion limit TABLD V16,[V1+501] ;get primary Y increment DIV V14,V16 ;divide it by primary Y increment rate TABST V14,[V1+507] ;save the ms duration of whole ramp at primary velocity ;MARK 52 ;4 JUMP RAMP19 ;compute ramp duration with primary and secondary velocity ;using X increment compute the durations RAMP37: TABLD V2,[V1+504] ;X or Y larger BGT V2,0,RAMP23 ;test if X or Y increment is larger MOVI V2,340 ;get X excursion limit 34X+V11 ADD V2,V11 ;add vector offset to get the right X limit ADD V2,V1 ;add table offset TABLD V14,[V2] ;get the X excursion limit TABLD V16,[V1+500] ;get primary X increment DIV V14,V16 ;divide it by primary x increment rate TABST V14,[V1+507] ;save the ms duration of whole ramp at primary velocity ;MARK 56 ;8 TABLD V14,[V2] ;reload the X excursion limit TABLD V16,[V1+502] ;get secondary X increment DIV V14,V16 ;divide it by secondary x increment rate TABST V14,[V1+508] ;save the ms duration of whole ramp at secondary velocity JUMP RAMP19 ;using Y increment compute the durations RAMP23: MOVI V2,350 ;get Y excursion limit 35X+V11 ADD V2,V11 ;add vector offset to get the right Y limit ADD V2,V1 ;add table offset TABLD V14,[V2] ;get the Y excursion limit TABLD V16,[V1+501] ;get primary Y increment DIV V14,V16 ;divide it by primary Y increment rate TABST V14,[V1+507] ;save the ms duration of whole ramp at primary velocity ;MARK 57 ;9 TABLD V14,[V2] ;get the Y excursion limit TABLD V16,[V1+503] ;get secondary Y increment DIV V14,V16 ;divide it by secondary Y increment rate TABST V14,[V1+508] ;save the ms duration of whole ramp at pirmary velocity ;randomly pick a ramp or a stepramp, compute step size if necessary ;------------------------------------------------------------------ RAMP19: MOVRND V2,7 ;get a random vector between 0-127 (hard-coded) TABST ZERO,[V1+505] ;store the default X pre-step, 0=none TABST ZERO,[V1+506] ;store the default Y pre-step, 0=none ;MARK 83 ;S ADDI HITTYPE1,1 ;inc ramp counter BGT V2,[V1],RAMP18 ;low steps, high does not step ADDI HITTYPE1,-1 ;undo inc ramp counter ADDI HITTYPE2,1 ;inc stepramp counter ;MARK 82 ;R ;compute the step offset for X & Y TABLD V2,[V1+3] ;get the ramp latency TABLD V16,[V1+500] ;get the primary X increment from the table MULI V16,-1 ;must use opposite sign MUL V16,V2 ;mult by latency duration TABST V16,[V1+505] ;store the default X backstep TABLD V17,[V1+501] ;get the primary Y increment from the table MULI V17,-1 ;must use opposite sign MUL V17,V2 ;mult by latency duration TABST V17,[V1+506] ;store the default Y backstep ;compute the transistion times ;----------------------------- RAMP18: TICKS TIMECURR ;compute time to start ramp TABLD V5,[V1+1] ;load plateau duration in ms MULI V5,msTick(1) ADD V5,TIMECURR ;add current time in ms ;computations with NO secondary velocity TABLD V2,[V1+4] ;get the secondary velocity time BGT V2,0,RAMP47 ;branch if there is a secondary velocity time ;MARK 49 ;1 TABLD V6,[V1+507] ;primary full ramp duration MULI V6,msTick(1) ADD V6,V5 ;add last time period in ms MOV V7,V6 ;V7 unused, fill it with V6 so it has a value TABLD V8,[V1+2] ;load plateau duration in ms MULI V8,msTick(1) ADD V8,V6 ;add onto the time the primary ramp ends JUMP RAMP48 ;computations WITH a secondary velocity RAMP47: TABLD V6,[V1+4] ;secondary velocity time (end of primary velocity time) MULI V6,msTick(1) ;MARK 50 ;2 ADD V6,V5 ;add to last period ;compute time to start second plateau TABLD V7,[V1+4] ;secondary velocity time (end of primary velocity time) TABLD V2,[V1+508] ;secondary full ramp duration MUL V7,V2 TABLD V2,[V1+507] ;primary full ramp duration DIV V7,V2 ;when primary velocity is over TABLD V2,[V1+508] ;secondary full ramp duration SUB V2,V7 ;determine how much of secondary velocity time remains MOV V7,V2 ;load the time into V7 MULI V7,msTick(1) ADD V7,V6 ;add to last period ;compute time to start next trial, end of plateau 2 TABLD V8,[V1+2] ;load plateau duration in ms MULI V8,msTick(1) ADD V8,V7 ;add onto the time the secondary ramp ends ;set the initial starting point in the center and set velocity to zero RAMP48: DAC 0,0 ;X center DAC 1,0 ;Y center MOVI V3,0 ;X increment rate, bits/ms MOVI V4,0 ;Y increment rate, bits/ms ;get the current time and the when the next ms is over MOV TIMECHEK,TIMECURR ;base next move time on the current time ADDI TIMECHEK,msTick(1) ;1ms, 0.001s later (much more accurate! no time drift) MOVI V15,1 ;set the mode to first plateau ;begin the trial loop, comes here every millisecond ;-------------------------------------------------- RAMP1: NOP ;determine if he is on target (should take less than 1ms (about 0.5 ms including feeding)) ;---------------------------------------------------------------- ADDI ELAPSED,1 CALL OTTEST ;read target and eye values then compare (takes < 0.24 ms) ;is he being forgiven? BEQ FORGIVE,0,RAMP5 ADDI DURFORG,1 ;keep track of the forgiveness period BLT DURFORG,[ZERO+16],RAMP6 ;FORGTIME, still forgiving? MOVI FORGIVE,0 ;turn off forgiveness MOVI DURFORG,0 ;reset forgiveness timer ;is he on-target? RAMP5: BLT TRACKING,2,RAMP7 ;confirm both H & V are on target DIGOUT [....0...] ;high activates the SONALERT ;comes directly here if in a FORGIVE period RAMP6: ADDI DURON,1 ;increase time on accumulator ADDI DURCONT,1 ;increase contiguous time on accumulator ADDI DURFEED,1 ;increase feed accumulator ;has he been OT long enough to be fed? BLT DURFEED,TIMEFEED,RAMP2 ;test if it is time to feed ;MARK 70 ;F CALL FEED ;0.103ms, feed him MOVI DURFEED,0 ;reset the accumulator TABLD TIMEFEED,[ZERO+15] ;DURSUB, use shorter subsequent time on-target dur JUMP RAMP2 ;he's fed, now keep going ;he is off target reset everything but the total time on move accumulator RAMP7: NOP DIGOUT [....1...] ;low de-activates the SONALERT MOVI DURCONT,0 ;reset the contiguous time on MOVI DURFEED,0 ;reset the feed time on TABLD TIMEFEED,[ZERO+14] ;DURFIRST, subsequent time on-target duration ;get the time and move the target ;-------------------------------- RAMP2: NOP ;MARK 65 ;A TICKS TIMECURR ;get the current time BLT TIMECURR,TIMECHEK,RAMP2 ;kill time until next millisecond arrives ADDI TIMECHEK,msTick(1) ;1ms, 0.001s later (much more accurate! no time drift) ;move target at the current amount per ms ADDAC 0,V3 ;1-move X ADDAC 1,V4 ;2-move Y ;modes: ;1=doing first plateau ;2=doing primary velocity ;3=doing secondary velocity ;4=doing second plateau ;first plateau finished -- start primary velocity ramp ;----------------------------------------------------- BNE V15,1,RAMP12 ;enter only if presenting first plateau BLT TIMECURR,V5,RAMP1 ;end of PLAT1? ;MARK 66 ;B MOVI FORGIVE,1 ;begin forgiving before moving the target ;change to primary velocity activity TABLD V3,[V1+500] ;X increment rate, bits/ms TABLD V4,[V1+501] ;X increment rate, bits/ms DAC 0,V16 ;X pre-ramp step? DAC 1,V17 ;Y pre-ramp step? MOVI V15,2 TABLD V2,[V1+4] ;get the secondary velocity time BGT V2,0,RAMP1 ;branch if there is a secondary velocity time MOVI V15,3 ;no secondary velocity, time for second plateau JUMP RAMP1 ;primary velocity finished--start secondary velocity ;--------------------------------------------------- RAMP12: BNE V15,2,RAMP10 ;enter only if need to the second velocity BLT TIMECURR,V6,RAMP1 ;end of the primary velocity ;MARK 67 ;C ;change to secondary velocity activity TABLD V3,[V1+502] ;X increment rate, bits/ms TABLD V4,[V1+503] ;Y increment rate, bits/ms MOVI V15,3 ;presenting secondary velocity JUMP RAMP1 ;all velocities done--start second plateau ;----------------------------------------- RAMP10: BNE V15,3,RAMP13 ;enter only if presenting primary velocity ramp BLT TIMECURR,V7,RAMP1 ;end of all velocities ;MARK 68 ;D ;change to second plateau activity MOVI V3,0 ;X increment rate, bits/ms MOVI V4,0 ;Y increment rate, bits/ms MOVI V15,4 ;presenting second plateau JUMP RAMP1 ;second plateau finished? ;------------------------ RAMP13: BNE V15,4,RAMP1 ;enter only if presenting second plateau BLT TIMECURR,V8,RAMP1 ;end of Plateau2 ;MARK 69 ;E ;MOVI MYREPORT,1 ;signal that it is time to show the user some numbers MOVI V2,1 ;signal that it is time to show the user some numbers TABST V2,[ZERO+31] MOVI FORGIVE,1 ;begin forgiving before moving target JUMP RAMP0 ;-------------------------------------------------------- ; I D L E ;Control spends most of the time here. It leaves when new ;choices have been made or when it is time to move. ;9/28/04 ;Table Data Map: ; ;On Target parameter stored in TABLE, ZERO=0000 ; ZERO+10 = pRealMinTime*1000; ASSOONAS ; ZERO+11 = pRealMaxTime*1000; NOLATER ; ZERO+12 = pRealContiguousTime*1000; CONTTON ; ZERO+13 = pRealTimeOn*1000; TOTALTON ; ZERO+14 = pOnFirst*1000; DURFIRST ; ZERO+15 = pOnSubsequent*1000; DURSUB ; ZERO+16 = pForgiveness*1000; FORGTIME ;-------------------------------------------------------- ;IDLE: BEQ PARAMCHG,1,MAIN ;the user choices have changed ;no idle routine because it is all handled by RAMP0: ;-------------------------------------------------------- ; G E T P O S ;Load the eye and target positions for processing by ;script routine TimeToMoveOrFeed. ;10/1/03 ;-------------------------------------------------------- GETPOS: CHAN HE,2 ;1-read the current H eye CHAN VE,3 ;2-read the current V eye CHAN HT1,4 ;3-read the current H primary target CHAN VT1,5 ;4-read the current V primary target CHAN HT2,8 ;5-read the current H secondary target CHAN VT2,9 ;6-read the current V secondary target RETURN ;7- ;-------------------------------------------------------- ; O T T E S T ;Tests if the animal is on-target horizontally and ;vertically and reports the result. Requires 0.26ms or less. ; ;Sequence Variable Map: ; TEMPWIND = window size ; TEMPTRAK = target position ; TRACKING = 0, 1 or 2 depending if he is OT or not ; V2 = holds data from table ; ;On Target parameter stored in TABLE, ZERO=0000 ; ZERO+0 = gWindowHvgDAC%; HWIND ; ZERO+1 = gWindowVvgDAC%; VWIND ; ZERO+17= pForceOT%; 'override, make him OT at all times ; ;10/7/04 ;-------------------------------------------------------- OTTEST: MOVI TRACKING,0 ;1-initialize CALL GETPOS ;8-find out where targ & eye are TABLD TEMPWIND,[ZERO] ;9-HWIND MOV TEMPTRAK,HT1 ;10-load horizontal target SUB TEMPTRAK,HE ;11-subtract horizonal eye BGT TEMPTRAK,0,OTTEST1 ;12-test if result is negative MULI TEMPTRAK,-1 ;13-abs() OTTEST1: BGT TEMPTRAK,TEMPWIND,OTTEST2 ;14-test if he is H-OT ADDI TRACKING,1 ;15-horizontally on-target OTTEST2: TABLD TEMPWIND,[ZERO+1] ;16-VWIND MOV TEMPTRAK,VT1 ;17-load vertical target SUB TEMPTRAK,VE ;18-subtract vertical eye BGT TEMPTRAK,0,OTTEST3 ;19-test if result is negative MULI TEMPTRAK,-1 ;20-abs() OTTEST3: BGT TEMPTRAK,TEMPWIND,OTTEST4 ;21-test if he is V-OT ADDI TRACKING,1 ;22-vertically on-target OTTEST4: TABLD V2,[ZERO+17] ;23-test if using OT override BEQ V2,0,OTTEST5 ;24-do it the old fashioned way, earn it! MOVI TRACKING,2 ;25-force him to be on-target, cheater! OTTEST5: RETURN ;26- ;-------------------------------------------------------- ; S H U T T E R ;Sets the shutters open or closed. ;12/17/02 ;-------------------------------------------------------- SHUTTER: CALL SHUTTER1 ;set the primary shutter CALL SHUTTER2 ;set the secondary shutter RETURN ;-------------------------------------------------------- ; S H U T T E R 1 ;Sets primary shutter open or closed. ; 0 = HIGH OUTPUT ; 1 = LOW OUTPUT ;9/4/03 ;-------------------------------------------------------- SHUTTER1: TABLD V2,[ZERO+30] BEQ V2,0,SHUT1ROB ;Robinson convention is opposite of the Fuchs convention ;BEQ V2,3,SHUT1ROB ;Visual convention is opposite of the Fuchs convention ;0=ROB,1=OKN,2=LED,3=VIS ;Fuchs shutters BEQ SHUT1,1,OPENF DIGOUT [.......1] ;close the primary shutter MARK 70 ;"F" for "OFF" RETURN OPENF: DIGOUT [.......0] ;open the primary shutter MARK 78 ;"N" for "ON" RETURN ;Robinson shutters SHUT1ROB: BEQ SHUT1,1,OPENR DIGOUT [.......0] ;close the primary shutter MARK 70 ;"F" for "OFF" RETURN OPENR: DIGOUT [.......1] ;open the primary shutter MARK 78 ;"N" for "ON" RETURN ;-------------------------------------------------------- ; S H U T T E R 2 ;Sets secondary shutter open or closed. ; 0 = HIGH OUTPUT ; 1 = LOW OUTPUT ;9/4/03 ;-------------------------------------------------------- SHUTTER2: BEQ SHUT2,1,S2OPEN DIGOUT [......0.] ;close the secondary shutter MARK 102 ;"f" for "off" RETURN S2OPEN: DIGOUT [......1.] ;open the secondary shutter MARK 110 ;"n" for "on" RETURN ;-------------------------------------------------------- ; F E E D ;Sends a feeder pulse. ;10/12/04 ;-------------------------------------------------------- FEED: DIGOUT [.....1..] ;1-high triggers the feeder DELAY 100 ;101-1 ms pulse width DIGOUT [.....0..] ;102-low is the feeder off state MARK 64 ;@ RETURN ;103- ;-------------------------------------------------------- ; L E D S ;Activate a red or a green LED. Seems that the parallel- ;to-serial interface requires 120 microsec between ;characters. The buffering is not as fast as Frank Miles ;had hoped. The time it takes to complete this command ;varies: ; RED only = 0.44 ms ; GRN only = 0.45 ms ; RED & GRN = 0.71 ms ;3/19/03 ;-------------------------------------------------------- LEDS: DIGLOW [10101111] ;1-AF clear all boards DELAY 12 ;13-120 microsecond delay BEQ SHUT1,0,LEDS2 ;14-present a red LED? DIGLOW LEDBRD1 ;15-C0 add address + deg theta DELAY 12 ;27-120 microsecond delay DIGLOW LEDADD1 ;28-radius in lower nibble DELAY 12 ;40-120 microsecond delay ;MARK 18 ;12x LEDS2: BEQ SHUT2,0,LEDS3 ;41-present a green LED? DIGLOW LEDBRD2 ;42-C0 add address + deg theta DELAY 12 ;54-120 microsecond delay DIGLOW LEDADD2 ;55-radius in lower nibble DELAY 12 ;67-120 microsecond delay ;MARK 19 ;13x LEDS3: BNE SBUFFER,1,LEDS1 ;68- DIGLOW [10001111] ;69-8F send to all boards, #1 buffer MOVI SBUFFER,2 ;70-prepare to use the other buffer next time RETURN ;71- LEDS1: DIGLOW [10011111] ;69-9F send to all boards, #2 buffer loads first by default MOVI SBUFFER,1 ;70-prepare to use the other buffer next time RETURN ;71- ;-------------------------------------------------------- ; Z E R O V A R ; ;Zeros all the re-usable VAR so that they are empty before ;using. ; ;11/8/04 ;-------------------------------------------------------- ZEROVAR: MOVI V1,0 MOVI V2,0 MOVI V3,0 MOVI V4,0 MOVI V5,0 MOVI V6,0 MOVI V7,0 MOVI V8,0 MOVI V9,0 MOVI V10,0 MOVI V11,0 MOVI V12,0 MOVI V11,0 MOVI V14,0 MOVI V15,0 MOVI V16,0 MOVI V17,0 MOVI V18,0 MOVI V19,0 MOVI TEMP3,0 MOVI TEMP4,0 MOVI V22,0 MOVI V23,0 MOVI V24,0 MOVI V25,0 MOVI V26,0 RETURN