Pellets and constant light

149 views
Skip to first unread message

Samuel Walker

unread,
Feb 10, 2022, 2:34:59 PM2/10/22
to FEDforum
Hi FEDders! I'm just getting set up with my new FED3s (thanks Open Ephys!) and had a couple of questions for folks:

1 - Does anyone have experience using the 5TUL purified 20mg pellets from TestDiet in the FED3? I wondered if they might produce less dust/reduce the risk of jamming compared to the grain-based 5TUM, while still providing full nutrition for longer-term experiments (unlike the sucrose pellets).

2 - I am using the time-restricted FR1 protocol currently. I'm looking to add one additional component, which is to have one LED constantly on during the hours when food is available via nose pokes, and constantly off during the period when nose pokes do not lead to pellet delivery. Could anyone advise on the best way to implement this in Arduino? Firstly, is there a command to just turn on/off the LED, without the tone (unlike fed3.ConditionedStimulus)? Then as for the implementation, I was thinking of something like below - does this make sense or is there an easier way that doesn't involve constantly checking the time?

if (fed3.currentHour >=17) {
    fed3.??(command to turn on LED)
}
else
{
fed3.??(command to turn off LED?)
}

Thanks very much!
Sam

Samuel Walker

unread,
Feb 10, 2022, 2:51:14 PM2/10/22
to FEDforum
For my 2nd question, just came across pixelsOn, leftPixel, rightPixel functions which should do the trick! Still not sure if this is the best implementation though:

if (fed3.currentHour >=17) {
    fed3.pixelsOn(0,0,0,10)
}
else
{
fed3.pixelsOff()
}

Lex Kravitz

unread,
Feb 10, 2022, 4:59:22 PM2/10/22
to FEDforum
Hi Sam!
I think you're on the right track with your 2nd post!  One additional tip is to disable sleep modes if you want to leave the pixels on for long durations - otherwise when FED3 sleeps it will turn them off.  To disable sleep, put fed3.disableSleep(); right after fed3.begin(); in the void setup() loop.  ie:

void setup() {
  fed3.begin();                                    //Setup the FED3 hardware
  fed3.disableSleep();                             //disable sleep
}

If you want to post your FED3code (attach the .ino file here) with the issue you're having I can advise better too. 
Best, -Lex

David Mallet

unread,
Apr 5, 2023, 4:17:46 AM4/5/23
to FEDforum
Hello FEDders,

I would like to re-run this post as I would like to execute a similar idea.

I would like to use a restricted time protocol (for FR1 or also PR) during which the nosepoke LED would be active.
I saw that it was possible to solve the problem by clicking on the two holes of the nose poke when the program starts. But I can't get it to work that way. I can go into the menu, change the device number, set the time, but I can't set a start and end time.

So I would like to go through a code using the command fed3.currentHour >= but I am not sure of the implementation to choose both a start and end time (For example to have an active FED3 from 8am to 11am).

Here is my code for now:

void setup() {
fed3.begin(); //Setup the FED3 hardware
fed3.disableSleep() //Disable sleep
}

void loop() {
fed3.run(); //Call fed.run at least once per loop
if (fed.currentHour >8 and fed.currentHour <11 )
fed3.leftPokePixelsOn(0, 10, 0, 0)
if (fed3.Left) { //If left poke is triggered
fed3.logLeftPoke(); //Log left poke
fed3.ConditionedStimulus(); //Deliver conditioned stimulus (tone and lights for 200ms)
fed3.Feed(); //Deliver pellet
}
if (fed3.Right) { //If right poke is triggered
fed3.logRightPoke(); //Log right poke
}
}
fed3.pixelsOff()
}

Can i use somthing like
if (fed.currentHour >8 and fed.currentHour <11 ) ?

Thank you for your help,
David

Lex

unread,
Apr 6, 2023, 1:34:39 PM4/6/23
to David Mallet, FEDforum
Hi David,
You can start by looking at the FED3 example "Timed_FR1", which I think is close to what you want. This example program sets a variable fed3.setTimed = true in the setup function, which adds the ability to set the time feeding to the little startup menu.  You can also hardcode the times that FED3 is active if you aren't changing it frequently and don't want to deal with the startup menu.  Line 34 shows you the format for setting FED3 to be active within a certain time range:
   if (fed3.currentHour >= fed3.timedStart && fed3.currentHour < fed3.timedEnd)

image.png

You also asked about leaving the Neopixels on during the hours when FED3 is active.  To do so, make sure you disable sleep in the void setup (as you have done):
void setup() {
  fed3.setTimed = true;                 //Set a flag to ask FED3 to edit "Timed Feeding" times when it enters the "Set Device Number" edit menu (this defaults to false)

  fed3.begin();                         //Setup the FED3 hardware
  fed3.disableSleep();                   //Disable sleep
  delay (2000);                         //Delay 2s to allow user time to poke both pokes
  if (fed3.Left && fed3.Right) {        //If both pokes are activated during the mouse running screen
    fed3.SetDeviceNumber();             //Enter "Set Device Number" edit menu to set device number and timed feeding hours
  }
}

And then control the poke LED and dispensing based on the currentHour in the void loop:
void loop() {
  fed3.run();                                                                          //Call fed.run at least once per loop
  if (fed3.currentHour >= fed3.timedStart && fed3.currentHour < fed3.timedEnd) {     //If left poke is triggered and it's between the specified times
    fed3.leftPokePixel(0, 10, 0, 0);
    if (fed3.Left) {

      fed3.logLeftPoke();                                                              //Log left poke
      fed3.ConditionedStimulus();                                                      //Deliver conditioned stimulus (tone and lights for 200ms)
      fed3.Feed();                                                                     //Deliver pellet
    }
  }

  else {                                                                             //If it's not between the specified times
    fed3.pixelsOff();
    if (fed3.Left) {
      fed3.logLeftPoke();                                                              //Log left poke

    }
  }

  if (fed3.Right) {                                                                    //If right poke is triggered
    fed3.logRightPoke();                                                               //Log right poke
  }
}

I'm attaching a modified code that should do what you want, please let me know if it does! Best,
-Lex



--
You received this message because you are subscribed to the Google Groups "FEDforum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fedforum+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fedforum/79297d5b-0843-463e-9c20-d3307e296658n%40googlegroups.com.
Timed_FR1_w_pokelight.ino.ino
Message has been deleted

Lex

unread,
Apr 13, 2023, 9:48:24 AM4/13/23
to David Mallet, FEDforum
Hi David,
Good job editing your script and getting things to work!

It sounds like you are calling the Tone function correctly but your if statement (below) keeps evaluating to True so your Tone call is happening repeatedly:
if (fed3.currentHour >= fed3.timedStart && fed3.currentHour < fed3.timedEnd) {     //If left poke is triggered and it's between the specified times

One solution to this issue is to initialize a new variable named "ToneActive" and set it equal to true only when you want the tone to be available.  This logic can allow the tone to happen just once by setting ToneActive false after you've played one tone. I'm attaching a modified code that does this so you can check out what I mean.  I didn't test this on a FED3 BTW but I think this should do what you want.  Best, -Lex

On Thu, Apr 13, 2023 at 5:59 AM David Mallet <david.m...@gmail.com> wrote:
Hi Lex,

Thanks for your help! I tested it today and I can confirm that it works as expected.
To reinforce the idea of the beginning of the test I would like to add a sound at the beginning (and thus use only the light as a conditioned stimulus).

Thus to replace the conditioned stimulus tone + light I replaced fed3.ConditionedStimulus(); by fed3.pixelsOn(0, 0, 10, 0); (and it works)

To add a sound at the beginning of a session, do I have to add it in a new block and specify the start time?
Because if I put the command fed3.Tone (800, 500); after fed3.leftPokePixel(0, 10, 0, 0) the sound continuously loops during the time. Should i use fed3.stopTone(); ?

Thank you for your help,
Best
David
Timed_FR1_041323.ino

David Mallet

unread,
May 8, 2023, 9:20:13 AM5/8/23
to FEDforum
Hi Lex,

Thank you, it works perfectly as I wanted it to.

I obtained very good results in only 3 hours of activity per day (at the beginning of the night).
So I would like to test progressive ratio with the same protocol (my code is attached). I would like to make several PR with a reset is every day.

Would adding this be enough? Or do I need to create a session notion?

void loop() {
fed3.run(); //Call fed.run at least once per loop
if (fed3.currentHour >= 8 && fed3.currentHour < 11) { //If left poke is triggered and it's between the specified times
if (fed3.currentHour == 8){ // If it's exactly 8 o'clock
pokes_required = 1;

}


Timed_PR_DM.ino

Lex

unread,
May 8, 2023, 11:00:13 AM5/8/23
to David Mallet, FEDforum
Hi David.  The way you have that code written the variable "pokes_required" will keep resetting to 1 for the entire hour of 8am.  So that code will essentially run an FR1 session from 8-9am, and at 9am the PR will start. To reset the PR only one time per day you'll need another variable like "ResetActive" that becomes true at 8am, and false once the reset has happened.  This is similar to what we did with ToneActive.  Let me know if this makes sense! -Lex

David Mallet

unread,
May 12, 2023, 9:14:34 AM5/12/23
to FEDforum
Hi Lex,

Thank you answer.
For a reason that I do not understand, I did not succeed with this solution but I was inspired by the code of close economy with a reset of the pokerequired and of the pelletblockcount only once a day and it seems to work as it should.

I share my code if it can interest people.

Thank you again for your help,
Best,
David
PR_dailyreset_DM.ino

Lex

unread,
May 13, 2023, 10:26:21 AM5/13/23
to David Mallet, FEDforum
Good job getting it to work :)  Thanks for closing out this thread and for sharing your code! 

Reply all
Reply to author
Forward
0 new messages