Hi all! I made multiple updates to the FED3 library this month, just released in FED3 library v1.16!
1) Set the FED3 clock without re-flashing! The FED3 has an internal real-time clock chip called the
PCF8523. Unfortunately this clock does not have high precision and can drift a couple seconds per week, which adds up over time. You can flash the
SetClock script (in the FED3
Examples) to re-set the clock to your computer's local time but this requires re-flashing the FED3. There is now a simple way to adjust the clock on the device itself! At startup, hold both pokes while the mouse is running across the screen. This will enter a settings menu, where you can first set the number of the device with the Left and Right pokes. Once the device number is set, wait 3s and it will switch to a clock adjust mode. Here, the pokes will set the time forwards or backwards. Then wait 3s and the FED3 will reset itself, keeping the new time.
2) Logging all pokes! FED3 now logs
all pokes, even while FED3 is doing other things like dispensing pellets or in a
Timeout. To keep the different types of pokes straight in the logfile they are labeled in the "Event" column as:
Left (The original! This means an active Left poke was detected)
LeftShort (If you've set a
minPokeTime and the duration of the Left poke is not long enough it will still log the short poke - see program example
here)
LeftDuringDispense (Left poke during dispensing, but before the Pellet has dropped)
LeftWithPellet (Left poke while a Pellet is in the well)
LeftinTimeout (Left poke during a timeout)
These same Event variants are also logged for
Right pokes.
3) New arguments for the Feed() function.
a) Control an output pulse when the pellet is removed. The
Feed() function now has an optional argument to send a pulse
on the output port after the pellet is taken. This is useful for aligning with fiber
photometry or other recordings. To send a pulse, give the fed3.Feed()
function an optional argument for the duration of the pulse. Useage:
fed3.Feed(100); will send a 100ms pulse when the pellet is taken.
fed3.Feed(500); will send a 500ms pulse when the pellet is taken.
fed3.Feed(); still works, and will not send a pulse.
b)
Leaving the Neopixels on during the Feed() function.
Due to
this question,
I added a second optional argument to the Feed() function to control whether the Neopixels turn off or not. Normally, the Feed() function extinguishes the Neopixels
when it detects a pellet. However, if you don't want them to turn off you can set a second optional second argument to
false in the Feed() function. To do this, you need to set both optional arguments in the Feed() function. Useage:
fed3.Feed(100, false);
will send a 100ms pulse and
leave pixels on
fed3.Feed(0, false);
will not send a pulse, but will leave the pixels on
fed3.Feed(); still works, and will do neither
You will also have to call
fed3.disableSleep()
in your setup loop if you plan to leave the Neopixels on for long
durations, as power to them gets cut when sleep modes are active.
To update your FED3 library to v1.16.0: Open the Arduino IDE and go to the library
manger. Search for "FED3" and click "Update" (or "Install" if you've never installed it). Then re-flash
your FED3 devices to start using the latest code.
This update is backwards compatible with prior FED3 code.
However, please test this update yourself before running it with
mice, and let me know if you discover any bugs! -Lex