This is a slightly more complex program than the Basic food hopper training 1; like #1 this program repeatedly raises and lowers the food hopper, but it also watches for the hopper-beam to be broken which signals that the bird is actually eating.  It then gives the bird only 5 seconds to eat before lowering the food hopper.

Note that both the food hopper and the hopper beam are controlled through a Data Translation card added to the computer and then hooked up to an external custom device that controls the actual food hopper and reads from the infra-red hopper bream.

One small problem with this program is that if the bird starts eating in the first phase at 58 seconds, it will only have 2 seconds to eat before the phase ends (because of the “wait for 1min”). This could be easily solved by adding a new variable in the phase – call it “isEating”. Set this variable to false when it is defined. Then, inside the “when” block set this variable to true. Then we can check this variable after the “wait for 1min” line and if it is true then wait for 15 seconds – long enough that the when clause will jump to the HopperDownPhase.
The modified phase looks like the following and it ensures that even if the subject animal waits 59 seconds to start eating that it will be allowed to eat for 5 seconds: