;-------------------------------------------------------- ; 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, ;VAR V21, ;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 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,1 ;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 ;-------------------------------------------------------- ; C A L I B R A T I O N ;Moves the target around so the booth can be calibrated. ;It can display at +/-10 degrees or +/-20 degrees. You ;can speed it up or slow it down. ; ;Re-usable Variables: ; V1 = X a/d position ; V2 = Y a/d position ; V3 = loop counter ; V4 = base TABLE pointer ; V5 = number of points ; V6 = feeder request ; V7 = target position TABLE pointer ; ;Table Data Map: ; 1000 = number of points to display (calib=4) ; 1001 = time between target changes (0.01 ms) ; 1002 = primary shutter state (1=on) ; 1003 = secondary shutter state (1=on) ; ;target info stored in array at A=1010,1020,1030,1040 ; A+0 = X galvo d/a value (primary & secondary) ; A+1 = Y galvo d/a value (primary & secondary) ; A+2 = primary LED board number ; A+3 = primary LED address ; A+4 = secondary LED board number ; A+5 = secondary LED address ; ;11/20/02 ;-------------------------------------------------------- CALIB: BEQ PARAMCHG,0,CALIB ;wait for parameters to arrive MOVI PARAMCHG,0 ;new parameters grabbed CALL ZEROVAR ;clear all the re-usable VAR MOVI V2,1 ;so it will update report first time through TABST V2,[ZERO+31] ;report just once MOVI V4,1000 ;data pointer TABLD V5,[V4] ;get the number of data points TABLD SHUT1,[V4+2] ;get the primary shutter TABLD SHUT2,[V4+3] ;get the secondary shutter TABLD V6,[V4+4] ;get the feeder request CALL SHUTTER ;set the shutters CALIB1: BLT V3,V5,CALIB2 ;test if all points shown MOVI V3,0 ;initialize point counter MOVI V7,1010 ;initialize the data pointer CALIB2: TABLD V1,[V7] ;galvo-X TABLD V2,[V7+1] ;galvo-Y TABLD LEDBRD1,[V7+2] ;LED board primary TABLD LEDADD1,[V7+3] ;LED address primary TABLD LEDBRD2,[V7+4] ;LED board secondary TABLD LEDADD2,[V7+5] ;LED address secondary MARK 1 ;SAVE - an initial target step has occured DAC 0,V1 ;primary target DAC 1,V2 DAC 2,V1 ;secondary target DAC 3,V2 CALL LEDS ;display the LEDs DELAY [V4+1] ;wait before requesting another move BEQ V6,0,CALIB4 ;test the feeder? DIGOUT [....0...] ;high activates the SONALERT CALL FEED ;0.103ms, test the feeder JUMP CALIB3 ;leave the SONALERT on CALIB4: DIGOUT [....1...] ;low de-activates the SONALERT CALIB3: BEQ PARAMCHG,1,CALIB ;start at the top whenever new parameters available ADDI V3,1 ;increment the loop counter ADDI V7,10 ;increment the data array pointer JUMP CALIB1 ;let's do it again, never goes to IDLE ;There is no IDLE routine becuase there are no intertrial intervals ;and the animal is not monitored for on-targetness. ;-------------------------------------------------------- ; 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- ;-------------------------------------------------------- ; B R I T E ;Set the LED intensity. ;5/5/06 ;-------------------------------------------------------- BRITE: MARK 38 ;'&' DIGLOW [ZERO+29] ;1- (06...0C) (1...12) LED intensity DELAY 12 ;2-14 microsecond delay BNE SBUFFER,1,BRITE1 ;15- DIGLOW [10001111] ;16-8F send to all boards, #1 buffer MOVI SBUFFER,2 ;17-prepare to use the other buffer next time RETURN ;18- BRITE1: DIGLOW [10011111] ;19-9F send to all boards, #2 buffer loads first by default MOVI SBUFFER,1 ;20-prepare to use the other buffer next time RETURN ;21- ;-------------------------------------------------------- ; 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 V20,0 MOVI V21,0 MOVI V22,0 MOVI V23,0 MOVI V24,0 MOVI V25,0 MOVI V26,0 RETURN