User Tools

Site Tools


guides:expconsim

This is an old revision of the document!


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)
  • 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');
outputSession.addDigitalChannel('Dev3', 'Port0/Line0:1', 'OutputOnly');
 
%% 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.addDigitalChannel('Dev3', 'Port1/Line0:3', 'InputOnly');
 
%% take a sample of the status of the photobeams and switches
inputSession.inputSingleScan() % note for photobeams, a return value of 0 means detect; for switches, 1 means detect

As above, this assumes that Port 1 lines 0-3 are hooked up to the photobeams and pushbutton switches.

These basic commands can then be combined with appropriate loops and conditional statements, in accordance with your desired experimental logic, to produce a full experimental simulator. The actual running rooms are equipped with either the same NI DIO module (RR2, RR3) or something very similar (RR1, through Neuralynx instead of through NI).

guides/expconsim.1372282369.txt.gz · Last modified: 2018/07/07 10:19 (external edit)