Usb-6008
From Neural Wiki
The national instruments USB-6008 & 6009 are relatively cheap digital/analog input/output devices. The 6009 samples faster than the 6008 (and is about $100 more expensive) so keep this in mind when choosing one or the other. As an experimentalist, the potential of these devices to be incorporated into experimental applications is extremely exciting. I have successfully used a 6008 to read the output of a neuronal network, and control an electrical feedback stimulator (see below).
Contents |
[edit] Check out the new bulletin board for the 6008 and 6009
[edit] Python Control of the Usb-6008
IF you do not want to use MATLAB, Python can be used to acquire data. I am in the process of testing this and will post more as I get a better handle on the capabilites. There are two ways you can do this. I recommend checking out pyDAQtools this is a really nice little package that just recently came to my attention. Please help make it better by testing it and reporting any problems you have.
Additionally, this page shows how to use Python and NIDAQmx. I am working on establishing a programming guide for the Usb-6008, so if you have any links on the subject please let me know. Mike@neuralwiki.org
[edit] Neuronal Feedback Experiment with the USB-6008
Setup of an experiment performed at CNNS.
Briefly: A USB-6008 controlled by MATLAB is used to generate conditional stimulation pulses from a multichannel systems stimulator.
[edit] Programming the USB-6008 with Matlab
For my first experiment with the USB-6008, I chose MATLAB to control the device. There were two reasons for this choice:
1) The University of North Texas has a full license for MATLAB. This included the Data Acquisition Toolbox which you must have to control the USB-6008 or 6009 from MATLAB. Note that the USB-6008 is supported in Data Acquisition Toolbox 2.8 (MATLAB R2006a) or newer. If you have an older version of MATLAB making the modifications described here may save you the need to upgrade.
2) MATLAB is relatively easy to program.
3) There are many examples and supporting literature that show how to make MATLAB perform many types of data analysis.
[edit] Set up
1) Install Nidaqmx. This is a big file, but it will install the drivers. 2) Plug in your USB-6008. The green light should blink on and off. The Nidaq software that pops up is not terrible if you just want to perform a simple experiment or take a reading. But for performing conditional data analysis with feedback, this program will not work. If you have a full version of LabView from National Instruments, you can also use it to control the device in this manner
3) Close the Nidaq software and start MATLAB
4) test that MATLAB can talk to the device
Type one or more of the following into MATLAB
ai=analoginput('nidaq','Dev1)
AND / OR
dio=digitalio('nidaq',Dev1)
AND / OR
ao=analogoutput('nidaq','Dev1')
if it works, you will see a Display Summary of the analog and / or digital settings. Analog inputs and outputs and digital (digital includes both in and out at the same time) must be assigned separately
Notice that the dio or ai contain no channels, you will have to assign them
Important commands
Digital
dio=digitalio('nidaq',Dev1) |dio can be called anything, but I like it because it stands for digital input/output
You initialize the digital and analog components separately.
digital_channels=addline(dio,0:7,'out') alternatively digital_channels=addline(dio,0:7,'in')
value=[0 0 0 1 1 1 1 0]
putvalue(dio,value)
getvalue(dio)
Analog
analog_channels=addchannel(ai,0:5)
Creating digital inputs
Keep in mind that the 6008 has two digital ports. Each port can only be set to in an 'in' or an 'out.' You cannot mix and match.
For example, if you set
digital_in=(dio,0:1,'in') you CANNOT also set digital_out=(dio,2:3,'OUT') What will happen is that 0:1 will be set to out because they are on the same port.
HOWEVER you CAN do
digital_in=(dio,0:1,'in') AND digital_out=(dio,8:9,'out')
The reason for this is that 0:7 are in one port, and 8:11 are in another port. Each port can be set differently, but channels within the port must be the same type.
[edit] Common Errors
??? Error using ==> daqdevice.addchannel The channel(s) being added are invalid for the current input type. ai.InputType='SingleEnded'
[edit] Links
MATLAB’s resource page for using National Instruments hardware
