The software system created is responsible for governing input/output digital and analog signaling between the behavioral task and reward systems. As shown below, the analog inputs (AI0, AI1) are responsible for reading in the x and y voltage amplitudes. The analog output (AO0) sends a pulse-width modulated (PWM) signal, which specifies the rpm of the motor, to the motor driver on the infusion pump. Lastly, the digital outputs (DO0, DO1) specify the turn direction of the motor.
The software design can be seen below. The sampled position of the joystick is analyzed to determine if the task has been successfully completed. After this, it goes through a series of decisions to determine if and when a reward should be delivered. The length of reward is determined during variable initialization before the trial begins.