Synchronizing multiple computers for experiments
In many rigs, multiple computers are used, and they need to talk to each other. For example, one computer handles the imaging, another the electrophysiology, and yet another handles the sensory stimulation; and they all need to be synchronized. There are several ways to handle this.
Digital I/O via DAQs
This is typically the most straightforward solution, but requires that there is some sort of DAQ for each computer. You can use something very simple, like a parallel port interface. Parallel ports are very old fashioned, but they’re still standard issue on most full-sized motherboards (see image above). Wire up the each data pins to a separate BNC and you have an extremely inexpensive digital I/O (the pinout is on Wikipedia and elsewhere on the net). The logic is a TTL-like 0-5v, however, beware that motherboards will vary quite a bit in their logic-high voltage level, and they typically can only source a small amount of current, 10-20 mA. So don’t try to split the signal to a bunch of different devices. (more info).
Alternatively, you can buy an inexpensive USB DAQ. For example, Measurement Computing‘s boxes are supported by MATLAB’s DAQ Toolbox. On that topic, let me briefly mention Dennis Pelli’s excellent MATLAB toolbox for controlling Measurement Computing’s USB-1208FS. It’s one of the simplest ways to do data acquisition in OSX using MATLAB. And be sure to read his explanation about why he programmed it up. It has more to do with the Second Amendment than you might expect. (link)
Ethernet connections
This approach has the advantage of using something that most computers have built in: an ethernet port. There are several protocols that ride on IP networks. You’re probably most familiar with TCP, but only slightly less well known is this: UDP. This is the protocol used for DNS queries. This is a leaner, faster way to send short messages to synchronize computers in an experimental setup. It’s not as tight as using a direct pulse to a DAQ, but it’s fast enough for most applications. The big advantage is that it’s pretty simple to send configuration data in addition to a simple trigger pulse via UDP. Several scientific software packages directly support UDP (e.g., here’s MATLAB’s UDP function).
Single computer solution
Getting programs to talk to each other
Even when a single computer is used, there may be multiple programs that need to talk to each other. In the first intrinsic imaging rig I built, I wrote my own OpenGL-based visual stimulation program which ran on the same computer as the imaging software (pdf). Both programs were written in C++ using Visual Studio. In order to get the two computers to talk to each other, I used custom Windows messages. Most modern operating systems have a messaging system where individual processes can send and receive messages. I was able to use this to pass messages between the two programs. If you want to do the same thing, and are already comfortable dealing with Windows messages in C++, this link can get you started.
I have an example of using UDP to forward spikes from a Plexon system through Matlab available here:
http://xcorr.net/2011/03/09/forwarding-spikes-in-a-plexon-system-to-some-other-computer-over-ip/
Great post! Thanks!
While you are mentioning multi-PC setups:
I have 4 PCs running at the same time – by far one of the most useful things I installed for a long time was microsoft’s “mouse without borders”.
It lets you share one (or many) mouse (or mice) and keyboards over all PCs – it even lets you drag and drop files from one PC to the other as if it would be one Desktop. It also lets you synchronize mousemovements on all PCs, meaning that you can do a poor man’s trigger (synch) by pushing whatever “start” button you have at the same time on all PCs.
Here is the install:
http://aka.ms/MouseWithOutBorders
And here is the promo video:
http://www.youtube.com/watch?v=MNFmXej7jEA
cheers,T
Thanks for the tips, ybot and Patrick!
I should have also referenced the Labrigger post on Wireless:
http://labrigger.com/blog/2011/04/10/wireless/
USB-1208FS data acquisition device from Measurement Computing can also be interfaced in python using the PyUniversalLibrary, an open-source wrapper of Measurement Computing’s Universal Library.
http://www.scipy.org/Cookbook/Data_Acquisition_with_PyUL