FR1 program help

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #12598
    Med_Support
    Moderator
    gdillon

    I am trying to write a section of code in an FR1 program that would discriminate between response types. I would like the program to count visits to the receptacle within 30secs following a lever press as chain responses. And visits to the receptacle at any other time as unchained responses. I am having trouble making this work. Any suggestions?

    #12599
    Med_Support
    Moderator
    Filip*

    So what do you have so far?

    #12602
    Med_Support
    Moderator
    gdillon
    \Inputs
    ^LeftLever=1
    ^Receptacle=2
    
    \Outputs
    ^House = 1
    ^Reward=2 \ In this code, this is a Pellet Dispenser
    ^RewardLight=3
    
    \Defined Variables
    \A=# of total lever presses
    \B=# of rewards received
    \C=# Chained responses
    \U=# Unchained responses
    \T=temporary counter for time window after response
    \X=number of receptacle visits during window
    
    S.S.1,
    S1,
    #START: ON ^House --> S2
    
    S2,
    #R^LeftLever: ON ^Reward; ON^RewardLight; Z1 --> S3
    
    S3,
    2": -->S1
    
    S.S.2,
    \This is state set that contains the response count and display. This will now put label the \"Responses" and its value "A" on screen until the START command is issued
    
    S1,
    #START: SHOW 1, Responses, A-->S2
    
    S2,
    #R^LeftLever: ADD A; SHOW 1, Responses, A --> SX
    
    S.S.3,
    \Reward Counter and Timer
    
    S1,
    #Z1: ADD B; SHOW 2, Rewards, B --> S2
    
    S2,
    0.05": OFF ^Reward--> S1
    
    S.S.4,
    \Chained vs unchained responses
    
    S1,
    #Z1: SET T=0-->S2
    
    S2,
    #R^Receptacle: ADD T; ADD X-->S2
    #Z1: SET T=0-->S2
    1": ADD T; IF T<=30 THEN {@Chained; @Unchained}
    @Chain: ADD C; SHOW 3, Chain, C-->S1
    @Unchained: ADD U; SHOW 4, Unchained, U-->S1
    
     
    
    S.S.5,
    \Session Timer
    
    S1,
    #START:-->S2
    
    S2,
    60':-->STOPABORT
    
    #12604
    Med_Support
    Moderator
    Filip*

    1. Why not modify S.S.1/S2 like this:

    S2,
    #R^LeftLever: ON ^Reward; ON^RewardLight; Z1 ---> S2 (NOTE: YOUR REDIRECTION WAS MISSING A '-')
    #R^Magazine: Z2 ---> S2
    
    

    Of course, you need another stateset to count these magazine responses. It will be very similar to your S.S.4.

    2. Also, I’d move all the reward and signal code into a separat states that listens for Z1 only. This way, you keep switching the reward and signal on and off close to each other.

    3. Third, I’d move all user messages to a separate stateset for clarity.

    #12606
    Med_Support
    Moderator
    gdillon

    Filip,
    Thanks for the suggestions.
    In my current program I am trying to count the magazine responses in my If/Then statement, so that every nose poke into the food hooper is measured as either a chain or unchained response, but it doesn’t seem to be working.

    S.S.4,
    \Chained vs unchained responses
    
    S1,
    #Z1: SET T=0-->S2
    
    S2,
    #R^Receptacle: ADD T; ADD X-->S2
    #Z1: SET T=0-->S2
    1": ADD T; IF T<=30 THEN {@Chained; @Unchained}
    @Chain: ADD C; SHOW 3, Chain, C-->S1
    @Unchained: ADD U; SHOW 4, Unchained, U-->S1
    
    #12608
    Med_Support
    Moderator
    Gary Bamberger

    Hi Greg,

    See my response to your other question in the coding help section:

    S1,
      #R1: ADD R; SET T = 0 ---> SX
      #R2: IF (T >= 30) AND (R >= 1) [@Chained, @Unchained]
              @Chained:   ADD C; SHOW 3,Chained,C;   SET R = 0, T = 0 ---> S1
              @Unchained: ADD U; SHOW 4,Unchained,U; SET R = 0, T = 0 ---> S1
      1": ADD T ---> SX
    

    I think that it will answer your question.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.