### Sidebar

Reference

guides:expconsim

The Experimental Control Simulator is designed to mimic an experimental setup, but with all the components placed on a single circuit board so that experimental control scripts can be tested more easily.

The first version (MvdM, June 2013) is equipped with the following INPUTS:

• 2 photobeams (Pololu, note that these need to be powered with a single external 3.3V power supply, plugs in to the jack next to the pushbuttons)
• 2 pushbutton switches (to mimic e.g. a lever press)

The OUTPUTS are:

• 2 LEDs

Interfacing of the simulator board with MATLAB is done through a NI USB I/O module. Thus, to set the state of the LEDs (on/off), do the following:

outputSession = daq.createSession('ni');

%% this turns off the two LEDs
outputSession.outputSingleScan([0 0]);

%% and this turns them on
outputSession.outputSingleScan([1 1]);

Note of course that this assumes you are in fact connecting Lines 0 and 1 on Port 0 to the “LED” header on the simulator board. Also power and ground (+5V and GND) need to be connected.

To read the state of the photobeams and push buttons, do this:

inputSession = daq.createSession('ni');
inputSession.inputSingleScan() % note for photobeams, a return value of 0 means detect; for switches, 1 means detect