A Cheap Serial Based TTL Device: Difference between revisions

From Center for Cognitive Neuroscience
Jump to navigation Jump to search
(Created page with "To Initialize the Arduino Box: if DAQ == 1 if IsOSX == 1 if (exist('DIO', 'var') == 0) % the exact address can be figured out using http://arduino.cc/en...")
 
m (7 revisions)
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
To Initialize the Arduino Box:
'''Hardware/Parts:'''
if DAQ == 1
:*[https://www.sparkfun.com/products/8269 Wall Adapter Power Supply - 5VDC 1A'']
  if IsOSX == 1
:*[https://www.sparkfun.com/products/10088 Arduino Project Enclosure'']
:*[https://www.sparkfun.com/products/11021 Arduino Uno - R3'']
:*[https://www.sparkfun.com/products/110 9 Pin Female Serial Connector - Solder Cup'']
 
'''Software/Downloads:'''
:*[http://arduino.cc/en/Main/Software Arduino Software'']
:*[http://www.mathworks.com/matlabcentral/fileexchange/32374-matlab-support-package-for-arduino-aka-arduinoio-package?download=true Matlab Toolbox for Serial interface with Arduino'']
 
 
'''To Initialize the Arduino Box:'''
 
       if (exist('DIO', 'var') == 0)
       if (exist('DIO', 'var') == 0)
                 % the exact address can be figured out using http://arduino.cc/en/Main/Software  
                 % the exact address can be figured out using http://arduino.cc/en/Main/Software  
                 DIO = arduino('/dev/tty.usbmodem621');
                 DIO = arduino('/dev/tty.usbmodem621');
         end
         end
         for i = 2:19
         for i = 2:19 % filp all pins to a low state (0V)
             DIO.pinMode(i,'output');
             DIO.pinMode(i,'output');
             DIO.digitalWrite(i,0)
             DIO.digitalWrite(i,0);
         end
         end
        else
            DIO = digitalio('nidaq','1');
            addline(DIO,0,'out');
            putvalue(DIO,0);
        end
else
    DIO = [];
end


To Send a pulse:


TTLpin = 2; % any pin from 2 through 19 can be used
'''To Send a pulse:'''
DIO.digitalWrite(TTLpin,1); % set pin to 5V wrt to GND
 
DIO.digitalWrite(TTLpin,0); % set pin to 0V wrt to GND
      TTLpin = 2; % any pin from 2 through 19 can be used
      DIO.digitalWrite(TTLpin,1); % set pin to 5V wrt to GND
      DIO.digitalWrite(TTLpin,0); % set pin to 0V wrt to GND




To close the session
'''To close the session:'''
delete DIO;


Below is a list of parts, the Matlab toolbox, and the Brain Products trigger cable pin out.
      delete DIO;
https://www.sparkfun.com/products/8269
https://www.sparkfun.com/products/10088
https://www.sparkfun.com/products/11021
http://www.cablewholesale.com/specs/db25-connector/3530-04025.htm?utm_source=PriceGrabber&utm_medium=cpc&zmam=54972865&zmas=1&zmac=5&zmap=3530-04025

Latest revision as of 03:14, 16 January 2014

Hardware/Parts:

Software/Downloads:


To Initialize the Arduino Box:

      if (exist('DIO', 'var') == 0)
               % the exact address can be figured out using http://arduino.cc/en/Main/Software 
               DIO = arduino('/dev/tty.usbmodem621');
       end
       for i = 2:19 % filp all pins to a low state (0V)
           DIO.pinMode(i,'output');
           DIO.digitalWrite(i,0);
       end


To Send a pulse:

      TTLpin = 2; % any pin from 2 through 19 can be used
      DIO.digitalWrite(TTLpin,1); % set pin to 5V wrt to GND
      DIO.digitalWrite(TTLpin,0); % set pin to 0V wrt to GND


To close the session:

      delete DIO;