Trial initiation via nose poke in the Pellet Well

27 views
Skip to first unread message

Christine Liu

unread,
Apr 2, 2024, 2:21:11 PMApr 2
to FEDforum
I got this to work without removing the metal piece that holds the pellet, and it works with mice that have neural implants too. Have not yet tested it with animals with implants plugged into patch cords but I think it should still work. 

Basically, you need to disable the FED from going to Sleep, and add interrupt functions so that the FED is always "listening" for the beam to be broken in the Pellet Well. This drains the battery quickly, and batteries need to be changed every ~24 hours.

initialize this variable at the beginning of your sketch:
int centerPoke;                             // centerPoke log to initiate trials

Put this function somewhere in your sketch:
void centerPokeISR(){                                             // interrupt function required for center poke detection outside of Feed function
  int a = 1;
}
Put this in your setup function:
  fed3.disableSleep();                                 //need to disable or won't run continuously
Put this in your loop function. This is a sketch for training, where any time the animal pokes their nose into the Pellet Well, a pellet will be delivered. I have this set to occur after animals have gotten 20 pellets from Freefeeding.
if (fed3.FEDmode == 1)  {
    fed3.sessiontype = "Poke_Hab";    //The text in "sessiontype" will appear on the screen and in the logfile
    fed3.disableSleep();                               // allows monitoring of pelletWell for CenterPoke to initiate trial  

    centerPoke = 0;

    if (centerPoke == 0 && fed3.PelletAvailable == false) {
      attachInterrupt(digitalPinToInterrupt(PELLET_WELL),centerPokeISR, FALLING);
      if (digitalRead(PELLET_WELL) == LOW) { //centerport poked
        centerPoke = 1;
        delay(1000);
      }
    }

    if (centerPoke == 1) {
      fed3.Feed(50);
      delay(3000);                //give time to eat so pellet retrieval is not considered a center port poke
    }
  } //end Poke_hab


Reply all
Reply to author
Forward
0 new messages