Ejemplo n.º 1
0
def led_on():
    BoardNum = 0
    PortNum = UL.FIRSTPORTB
    Direction = UL.DIGITALOUT
    UL.cbDConfigPort(BoardNum, PortNum, Direction)
    DataValue = 1
    UL.cbDOut(BoardNum, PortNum, DataValue)
Ejemplo n.º 2
0
    def __init__(self):
        """
        Returns a Measurement Computing daq object, if possible.
        Returns None if
        """
        self.UL = None
        print "MCC DAQ: Connecting..."
        try:
            import UniversalLibrary as UL
            self.UL = UL
        except:
            print "Could not open Measurement Computing DAQ. "
            print "Check that the daq is connected. Also, ensure InstaCal and PyUniversalLibrary are installed."
            print "DAQ output will be unavailable for this session."
            traceback.print_exc()
            return
        print "MCC Daq: Success!"

        # DAQ setup
        self.boardNum = 0
        UL.cbDConfigPort(self.boardNum, UL.FIRSTPORTA, UL.DIGITALOUT)
        UL.cbDConfigPort(self.boardNum, UL.FIRSTPORTB, UL.DIGITALOUT)
        
        # trigger bits for frame onset, stim onset, etc
        self.triggerBits = [0,0,0,0,0,0,0,0]
        self.stimcodeReadBit = 0 # constant telling you which bit tells CED to read the current stimcode
        self.stimBit = 2  # constant telling you which bit is for stim on / off
        self.frameBit = 3  # constant telling you which bit is for frame flip triggers
Ejemplo n.º 3
0
	def __init__(self,dir,cb,port=None):
		self.dir=dir
		self.wait=False
		self.triggerCallback=cb
		self.port=port
		if self.port==None:
			self.port=UL.FIRSTPORTA
		if dir==0: #IN
			print 'Opening input port %d...' % self.port,
			try:
				UL.cbDConfigPort(0, self.port, UL.DIGITALIN)
				self.success=True
				print 'success!'
			except:
				print 'failure to open incoming digital port!'
				self.success=False
		else: #OUT
			print 'Opening output port %d...' % self.port,
			try:
				UL.cbDConfigPort(0, self.port, UL.DIGITALOUT)
				self.success=True
				print 'success!'
			except:
				self.success=False
				print 'failure to open outgoing digital port! (%d)' % self.port
Ejemplo n.º 4
0
def led_on():
    BoardNum = 0
    PortNum = UL.FIRSTPORTB
    Direction = UL.DIGITALOUT
    UL.cbDConfigPort (BoardNum, PortNum, Direction)
    DataValue = 1
    UL.cbDOut(BoardNum, PortNum, DataValue)
    sound_1 = sound.SoundPyo(value='C', secs=0.5, octave=4, stereo=True, volume=1.0, loops=0, sampleRate=44100, bits=16, hamming=True, start=0, stop=-1, name='', autoLog=True)
    sound_1.play()
Ejemplo n.º 5
0
def get_reward(PORTNUM):
    BoardNum = 0
    PortNum = PORTNUM
    Direction = UL.DIGITALOUT
    UL.cbDConfigPort (BoardNum, PortNum, Direction)
    DataValue = 1
    UL.cbDOut(BoardNum, PortNum, DataValue)
    time.sleep(.07)
    BoardNum = 0
    PortNum = PORTNUM
    Direction = UL.DIGITALOUT
    UL.cbDConfigPort (BoardNum, PortNum, Direction)
    DataValue = 0
    UL.cbDOut(BoardNum, PortNum, DataValue)
 def __init__(self, args):
     #serial port setup
     self.boardNum = 0
     self.serialPortName = args
     self.ser = serial.Serial(self.serialPortName, 9600, timeout=0)
     
     #DAQ setup        
     UL.cbDConfigPort(self.boardNum, UL.FIRSTPORTA, UL.DIGITALOUT)
     UL.cbDConfigPort(self.boardNum,UL.FIRSTPORTB, UL.DIGITALOUT)
     
     #CSV logging setup
     self.timer = core.Clock()
     self.triggerTimes = []
     self.stimCodes = []
Ejemplo n.º 7
0
def get_reward(PORTNUM):
    print 'reward'
    BoardNum = 0
    PortNum = PORTNUM
    Direction = UL.DIGITALOUT
    UL.cbDConfigPort (BoardNum, PortNum, Direction)
    DataValue = 1
    UL.cbDOut(BoardNum, PortNum, DataValue)
    #sound_1 = sound.SoundPyo(value='C', secs=0.5, octave=4, stereo=True, volume=1.0, loops=0, sampleRate=44100, bits=16, hamming=True, start=0, stop=-1, name='', autoLog=True)
    #sound_1.play() 
    time.sleep(.1) #time
    BoardNum = 0
    PortNum = PORTNUM
    Direction = UL.DIGITALOUT
    UL.cbDConfigPort (BoardNum, PortNum, Direction)
    DataValue = 0
    UL.cbDOut(BoardNum, PortNum, DataValue)
Ejemplo n.º 8
0
#       disclaimer in the documentation and/or other materials provided
#       with the distribution.

#     * Neither the name of the California Institute of Technology nor
#       the names of its contributors may be used to endorse or promote
#       products derived from this software without specific prior
#       written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Author: Andrew Straw
import UniversalLibrary as UL
BoardNum = 0
PortNum = UL.FIRSTPORTA
Direction = UL.DIGITALIN
UL.cbDConfigPort(BoardNum, PortNum, Direction)
DataValue = 0
while 1:
    DataValue = UL.cbDIn(BoardNum, PortNum, DataValue)
    print "Port Value:", DataValue
def Reset():
    '''Set all digital channels (the entire port) to 0V output'''
    UL.cbDConfigPort(BoardNum, PortNum, UL.DIGITALOUT)
    UL.cbDOut(BoardNum, PortNum, 0)
Ejemplo n.º 10
0
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Author: Andrew Straw
import UniversalLibrary as UL

BoardNum = 0
devNum = 0
FirstPort = 0

FirstPort = UL.cbGetConfig(UL.DIGITALINFO, BoardNum, devNum, UL.DIDEVTYPE, FirstPort)

PortNum = UL.FIRSTPORTA
Direction = UL.DIGITALOUT
UL.cbDConfigPort(BoardNum, PortNum, Direction)

DataValue = 0
UL.cbDOut(BoardNum, PortNum, DataValue)

if FirstPort == UL.AUXPORT:
    devNum = 1
    UL.cbGetConfig(UL.DIGITALINFO, BoardNum, devNum, UL.DIDEVTYPE, FirstPort)

if FirstPort == UL.FIRSTPORTA:
    FirstBit = 0
elif FirstPort == UL.FIRSTPORTB:
    FirstBit = 8
elif FirstPort == UL.FIRSTPORTCL:
    FirstBit = 16
elif FirstPort == UL.FIRSTPORTCH:
import UniversalLibrary as UL
UL.cbDConfigPort(0,10,1)
print('You are starting at angle 0 degrees')
position=0
cmd='b'
angle=0.0
while cmd.lower() != 'q':
    print('Current position = '),position
    print('Current delta angle request = '),angle
    cmd=raw_input('What to do now? (a: choose angle, p:set position value here, g:go,s:stop moving! q:quit) ')
    if cmd.lower() == 'a':
        anglestring=raw_input('Input angle to move by in +- degrees ' )
        angle=float(anglestring)
    elif cmd.lower() == 'p':
        positionstring=raw_input('Input current position angle ' )
        position=float(positionstring)
    elif cmd.lower()=='q' :
        chk=raw_input('Really quit? (y,n) ')
        if chk.lower()!='y':
            cmd='b'
    elif cmd.lower()=='g' :
        npulses=int(abs(angle)*80)
        dir=0
        if angle < 0:
            dir=1 
        UL.cbDBitOut(0,10,1,dir)
        for i in range(0,npulses+1):
            try:
                UL.cbDBitOut(0,10,0,1)
                UL.cbDBitOut(0,10,0,0)
            except KeyboardInterrupt:
Ejemplo n.º 12
0
 def __init__(self, args):  
     #DAQ setup
     self.boardNum = 0
     UL.cbDConfigPort(self.boardNum,UL.FIRSTPORTA, UL.DIGITALIN)
Ejemplo n.º 13
0
 def __init__(self, board, port_id, name, edit_dialog):
     super(PortDO, self).__init__(board, port_id, name)
     self.edit_dialog = edit_dialog
     self.value = 0
     UL.cbDConfigPort(board.id, self.id, UL.DIGITALOUT)
     UL.cbDOut(self.board.id, self.id, self.value)
Ejemplo n.º 14
0
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Author: Andrew Straw
import UniversalLibrary as UL

BoardNum = 0
devNum = 0
FirstPort = 0

FirstPort = UL.cbGetConfig(UL.DIGITALINFO, BoardNum, devNum, UL.DIDEVTYPE,
                           FirstPort)

PortNum = UL.FIRSTPORTA
Direction = UL.DIGITALOUT
UL.cbDConfigPort(BoardNum, PortNum, Direction)

DataValue = 0
UL.cbDOut(BoardNum, PortNum, DataValue)

if FirstPort == UL.AUXPORT:
    devNum = 1
    UL.cbGetConfig(UL.DIGITALINFO, BoardNum, devNum, UL.DIDEVTYPE, FirstPort)

if FirstPort == UL.FIRSTPORTA:
    FirstBit = 0
elif FirstPort == UL.FIRSTPORTB:
    FirstBit = 8
elif FirstPort == UL.FIRSTPORTCL:
    FirstBit = 16
elif FirstPort == UL.FIRSTPORTCH:
Ejemplo n.º 15
0
#     * Neither the name of the California Institute of Technology nor
#       the names of its contributors may be used to endorse or promote
#       products derived from this software without specific prior
#       written permission.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Author: Andrew Straw
import UniversalLibrary as UL
BoardNum = 0
PortNum = UL.FIRSTPORTA
Direction = UL.DIGITALIN
UL.cbDConfigPort(BoardNum, PortNum, Direction)
DataValue = 0
while 1:
    DataValue = UL.cbDIn(BoardNum, PortNum, DataValue)
    print "Port Value:",DataValue