LabJack - Psychtoolbox-3/Psychtoolbox-3 GitHub Wiki
LabJack make a range of USB DAQ devices. Their advantage over other manufacturers are modern robust and light-weight cross-platform drivers (Windows, OS X and Linux at least), and very knowledgeable and helpful personal support forums.
There are two generations of devices, the U series exemplified by the U3 and U6, and the newer T-series such as the T4. Both offer [sub]millisecond command-response latency reliably. The T-series offer ethernet/wifi access and an embedded Lua interpreter to run code independent of the host computer.
T-series Devices
IanA: I have a class to control the T4 in MATLAB (would need to be tested in Octave as class support remains incomplete), allowing the generation of single TTLs on the CIO interface and strobed words on the EIO interface (output via the DB-15 port). Command-response times from MATLAB are reliably sub-millisecond (T4 connected via a high-speed USB hub). To allow sub-millisecond latency return to MATLAB even if a TTL is hundreds of milliseconds long, I implemented a small server on the T4 (as it runs Lua), that reads commands on its internal memory then independently executes the digital I/O asynchronously. For streaming analog data, I found that the USB interface via an ethernet switch was more reliable than via USB.
https://github.com/iandol/opticka/blob/master/communication/labJackT.m
lJ = labJackT('openNow',true);
if ~lJ.isServerRunning
initialiseServer(lJ); % we upload the minified Lua code and start the Lua intepreter
end
sendStrobe(lJ, 255) % immediately send 255 as a strobed word on EIO0-7
% we can also stream data:
lJ.streamChannels = 1;
startStream(lJ);
plotStream(lJ);
% when finished, lets close the LabJack
close(lJ)
The T-series supports Linux, macOS and Windows with a unified modbus driver called ljm. I've only used the USB interface, but the T4 also allows the use of ethernet control. Modbus is a nice way to control DAQ devices.
Analog recording is quite straight forward though I haven't implemented it in my code interface as I have no need for it.
U-series Devices
For OS X and Linux, there is a unified exodriver that is based on libusb. The library is easy to build (universal 32/64bit for OS X, important for 32bit Matlab requirements) and use from within MATLAB and PTB. There is a separate interface for Windows. Command-response times from MATLAB are sub-millisecond (connected via a high-speed USB hub). For less demanding timing needs , they even offer a fuse filesystem interface, allowing one to use simple file system paths to interact with the LabJack!
http://labjack.com/support/linux-and-mac-os-x-drivers http://labjack.com/support/ljfuse
Interface code for OS X / Linux
IanA: I am using a U6 to control a Plexon Omniplex electrophysiology system from OS X PTB. It was very easy to make an OOP interface to send both single TTL triggers, and also 12bit strobed words via the LabJack to the Omniplex. The command-response times of the U6 and U3 are sub-millisecond (tested through a high-speed hub), and I've confirmed this for the duration of an experiment using a photodiode. You can see the code over on Github:
https://github.com/iandol/opticka/blob/master/communication/labJack.m
http://144.82.131.18/optickadocs/classlab_jack.html -- minimal documentation To use this labJack object, first ensure you have the exodriver correctly installed, then in Matlab here is some example usage:
lj = labJack('deviceID', 6, 'verbose', true) % open a U6 with verbose logging on
lj.timedTTL(1,10) % send a 10ms TTL from FIO1
lj.toggleFIO(4) % toggle FIO4 (low>high or high>low depending on existing state)
lj.prepareStrobe(1816) % prepare a strobed word with value 1816
lj.strobeWord % send the strobed word, which is 11bit max length on EIO and CIO via the DB15
OS X Specific Details
The exodriver and libusb are both available in homebrew, a lightweight and flexible package manager for OS X. With homebrew installed, installing the latest versions of libusb and exodriver for use with PTB is as easy as this terminal command:
brew install libusb exodriver --universal