Hi Miguel!
You want the FED3 to send a pulse immediately after the pellet is removed, and then also do a Timeout? There are three functions we need to juggle into the right order. (BTW you can see all the functions for the FED3 library
here). The three relevant functions are:
1) Feed, which runs the feeding routine to drop a pellet.
2) BNC, which controls pulses from the BNC output. For instance, you can call the BNC function as:
fed3.BNC(200,1) to deliver a single 200ms pulse or fed3.BNC(100,10) to deliver ten
100ms pulses
3) Timeout runs a timeout routine, basically pausing the FED3 for a specified time.
The complication you're experiencing is because the Feed routine automatically calls Timeout. But you want Feed, then BNC, and then Timeout. Long-term I should probably make it so Feed doesn't automatically call Timeout but for now that's how it works. I did it that way because it makes the high level code clean. I made the following edits to the Free-feeding script to do what you want (noted in yellow arrows below):
1)
I turned off the Timeout call in the Feed function, by setting fed3.timeout = 0. Now when Feed calls TImeout the timeout duration will be 0s, or essentially off.
2) I added fed3.BNC(200,1) to the void loop() after the Feed function, which will deliver a single 200ms pulse immediately after the pellet is removed. You can edit this pulse call how you want.
3)
I added delay (115000) to the code to replace the timeout function we removed - delay is a built in Arduino function that pauses the microprocessor. So this will pause the FED3 for 115 seconds here, after which it will resume at the top of the void loop().
This should creates the task logic you want. I'm also attaching the Arduino script. Have fun! -Lex