Esempio n. 1
0
#######################################
# Initialize pins
#######################################
GPIO.setmode(GPIO.BCM)
for temp_pin in [pin_pump, pin_speaker, pin_LED, pin_success]:
    GPIO.setup(temp_pin, GPIO.OUT)
pump = GPIO.PWM(pin_pump, 1000)
LED = GPIO.PWM(pin_LED, 1000)

for temp_pin in [pin_v_act_manual, pin_h_act_manual]:
    GPIO.setup(temp_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# Create lever object
lever_obj = Lever(pin_v_act_L,
                  pin_h_act_L,
                  h_positions,
                  v_positions,
                  threshold,
                  verbose=True)
lever_obj.reset_pos()  # Move lever back to initial position
time.sleep(1.5)

####################
# Setup log file
####################

animal_number = raw_input("Input animal number and press ENTER: ")

print('Begin training animal ' + str(animal_number))
fileName = (dt.fromtimestamp(time.time()).strftime("%y,%m,%d,%H,%M,%S") +
            str('_rat_') + str(animal_number) + str('_trainig_') +
            str('stepRandom'))
Esempio n. 2
0
#######################################
# Initialize pins
#######################################
GPIO.setmode(GPIO.BCM)
for temp_pin in [pin_pump, pin_speaker, pin_LED, pin_success]:
    GPIO.setup(temp_pin, GPIO.OUT)
pump = GPIO.PWM(pin_pump, 1000)
LED = GPIO.PWM(pin_LED, 1000)

for temp_pin in [pin_v_act_manual, pin_h_act_manual]:
    GPIO.setup(temp_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# Create lever object
lever_obj = Lever(pin_v_act_L,
                  pin_h_act_L,
                  h_positions,
                  v_positions,
                  threshold,
                  verbose=True)
lever_obj.reset_pos()  # Move lever back to initial position
time.sleep(1.5)

####################
# Setup log file
####################
animal_number = raw_input("Input animal number and press ENTER: ")
print('Begin training animal ' + str(animal_number))
fileName = (dt.fromtimestamp(time.time()).strftime("%y,%m,%d,%H,%M,%S") +
            str('_rat_') + str(animal_number) + str('_training_') +
            str('step2'))

# Make data folder if doesn't exist
Esempio n. 3
0
#######################################
# Initialize pins
#######################################
GPIO.setmode(GPIO.BCM)
for temp_pin in [pin_pump, pin_speaker, pin_LED, pin_success]: 
    GPIO.setup(temp_pin, GPIO.OUT)
pump = GPIO.PWM(pin_pump, 1000)
LED = GPIO.PWM(pin_LED,1000)


for temp_pin in [pin_v_act_manual, pin_h_act_manual]:
    GPIO.setup(temp_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# Create lever object
lever_obj = Lever(pin_v_act_L, pin_h_act_L, h_positions, v_positions, threshold, verbose=True)
lever_obj.reset_pos()  # Move lever back to initial position
time.sleep(1.5)


####################
# Setup log file
####################


def give_reward():
    """Helper function to turn on water"""
    print "Success number %i." % (successes)
    LED_on()
   # time.sleep(0.2)
    pump.start(50)
Esempio n. 4
0
#######################################
GPIO.setmode(GPIO.BCM)
for temp_pin in [pin_pump, pin_speaker, pin_LED, pin_success]:
    GPIO.setup(temp_pin, GPIO.OUT)
pump = GPIO.PWM(pin_pump, 1000)
LED = GPIO.PWM(pin_LED, 1000)

#for temp_pin in [pin_power]:
#    GPIO.setup(temp_pin, GPIO.IN)
for temp_pin in [pin_v_act_manual, pin_h_act_manual]:
    GPIO.setup(temp_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# Create lever object
lever_obj = Lever(pin_v_act_L,
                  pin_h_act_L,
                  h_positions,
                  v_positions,
                  threshold,
                  verbose=True)
lever_obj.reset_pos()  # Move lever back to initial position
time.sleep(1.5)

####################
# Setup log file
####################
##stim_state = raw_input("Will the animal be stimulated? Input ON or OFF and press ENTER: ")
#training_number = raw_imput("Input training step number and press ENTER: "
animal_number = raw_input("Input animal number and press ENTER: ")
print('Begin training animal ' + str(animal_number))
fileName = (dt.fromtimestamp(time.time()).strftime("%y,%m,%d,%H,%M,%S") +
            str('_rat_') + str(animal_number) + str('_Rehab'))
Esempio n. 5
0
#######################################
GPIO.setmode(GPIO.BCM)
for temp_pin in [pin_pump, pin_speaker, pin_LED, pin_success]:
    GPIO.setup(temp_pin, GPIO.OUT)
pump = GPIO.PWM(pin_pump, 1000)
LED = GPIO.PWM(pin_LED, 1000)

#for temp_pin in [pin_power]:
#    GPIO.setup(temp_pin, GPIO.IN)
for temp_pin in [pin_v_act_manual, pin_h_act_manual]:
    GPIO.setup(temp_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# Create lever object
lever_obj = Lever(pin_v_act_L,
                  pin_h_act_L,
                  h_positions,
                  v_positions,
                  threshold,
                  verbose=True)
lever_obj.reset_pos()  # Move lever back to initial position
lever_obj.advance_lever()  #move to the second horizontal position
time.sleep(1.5)

####################
# Setup log file
####################
animal_number = raw_input("Input animal number and press ENTER: ")
print('Begin training animal ' + str(animal_number))
fileName = (dt.fromtimestamp(time.time()).strftime("%y,%m,%d,%H,%M,%S") +
            str('_rat_') + str(animal_number) + str('_training_') +
            str('step3'))
Esempio n. 6
0
# Main program loop
####################
# Initialize lever and nose sensors
adc1 = mcp3208.mcp3208(0)
adc2 = mcp3208.mcp3208(1)

# Set initial position of lever/nose sensors
last_arena_pos = (adc1.readChannel(lever_ch1), adc1.readChannel(nose_ch))

#print " \tLed State Initially: %i" % (LED_state)

# At the last row, it is intersting to start with some easy trials at row 0 and 1 (column 0)
if v_ == 2:

    lever_obj = Lever(pin_v_act_L,
                      pin_h_act_L, [0.00115], [0.00130, 0.00120], [3200],
                      verbose=True)
    lever_obj.reset_pos()  # Move lever back to initial position
    time.sleep(2)

    while successes < 4:
        currentTime = time.time()
        success = 0
        err = 0
        leverL = adc1.readChannel(lever_ch1)
        nose = adc1.readChannel(nose_ch)

        # Look at a peak in the signal (a local maximum) until a max it reached, it computes if it was a Good trials or not a good trial
        if leverL > leverL_old:
            leverL_old = leverL
        elif (LED_state == False and nose < 100
Esempio n. 7
0
#######################################
# Initialize pins
#######################################
GPIO.setmode(GPIO.BCM)
for temp_pin in [pin_pump, pin_speaker, pin_LED, pin_success]: 
    GPIO.setup(temp_pin, GPIO.OUT)
pump = GPIO.PWM(pin_pump, 1000)
LED = GPIO.PWM(pin_LED,1000)

#for temp_pin in [pin_power]:
#    GPIO.setup(temp_pin, GPIO.IN)
for temp_pin in [pin_v_act_manual, pin_h_act_manual]:
    GPIO.setup(temp_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# Create lever object
lever_obj = Lever(pin_v_act_L, pin_h_act_L, h_positions, v_positions, threshold, verbose=True)
lever_obj.reset_pos()  # Move lever back to initial position
time.sleep(1.5)


####################
# Setup log file
####################
animal_number = raw_input("Input animal number and press ENTER: ")
##stim_state = raw_input("Will the animal be stimulated? Input ON or OFF and press ENTER: ")
#training_number = raw_imput("Input training step number and press ENTER: "
print('Begin training animal ' + str(animal_number))
fileName = (dt.fromtimestamp(time.time()).strftime("%y,%m,%d,%H,%M,%S")+str('_rat_')+str(animal_number)+str('_trainig_')+str('step4'))

# Make data folder if doesn't exist
try: