Hi everyone,
I am trying to send a TTL pulse via the BNC port when a pellet is taken by a mouse during fiber photometry recordings in order to sync the recordings to the pellet retrieval. I am using the v1.16.3 free feeding timeout fix code update posted
here in the forum, however the TTL pulses do not send with this code.
I am new to the FED3 system and C++ code but I dug around in the FED3.cpp file and found this:
void FED3::BNC(int DELAY_MS, int loops) {
for (int i = 0; i < loops; i++) {
digitalWrite(BNC_OUT, HIGH);
digitalWrite(GREEN_LED, HIGH);
delay(DELAY_MS);
digitalWrite(BNC_OUT, LOW);
digitalWrite(GREEN_LED, LOW);
delay(DELAY_MS);
so I inserted it in the free feeding timeout fix code here (in bold):
void loop() {
controlSleep(); //For free-feeding task, only sleep when pellet is in the well
fed3.run(); //Call fed.run at least once per loop
fed3.Feed(); //Drop pellet
fed3.BNC(0, 1); //FED3::BNC(int DELAY_MS, int loops)
fed3.Timeout(2); //2s timeout
}
setting int DELAY_MS to 0 and int loops to 1, which I think sets the delay between pulses to 0 ms and sends only 1 pulse. However, there is still a slight delay between when I take a pellet from the hopper and when the pulse shows up on the fiber photometry visualizer as a square wave, about 500 ms to 1 second. This delay does not occur with FEDs that I have with an older version of the code (v1.1.44, which I cannot find on the github to compare). The square wave in the visualizer occurs instantaneously for these FEDs.
I want to get rid of this delay because I don't want the syncing to the fiber photometry recordings to be off. I am not sure if I am using the right code, or what the Hz or ms should be for the pulse (i.e., what the default settings are for one square wave pulse). Does anyone know how to do this?
Thanks in advance!
Best,
Cayla Murphy