Skip to content

Commit 73b9b2e

Browse files
committed
Improved dispense functions
1 parent a02b755 commit 73b9b2e

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

examples/Bandit_Task/Bandit_Task.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
String ver = "Force"; //unique identifier text
2121
Force force(ver); //start FORCE object
2222

23-
int prob_left = 70; // Probability of pellet on the high-reward poke
24-
int prob_right = 30; // Probability of pellet on the low-reward poke
23+
int prob_left = 100; // Probability of pellet on the high-reward poke
24+
int prob_right = 100; // Probability of pellet on the low-reward poke
2525
int trialsToSwitch = 20; // # of trials before probabilities on the pokes switch
2626
int trial_counter = 0; // Tracks how many pellets have been obtained in this set of probabilities
2727
int highp_counter = 0; // Tracks how many pokes in a row in high probability poke
@@ -62,7 +62,7 @@ void loop() {
6262

6363
force.ver = prob_left;
6464
force.FRC = prob_right;
65-
force.dispense_delay = highp_counter;
65+
//force.dispense_delay = highp_counter;
6666
force.dispense_amount = trial_counter;
6767
}
6868

@@ -94,7 +94,7 @@ void loop() {
9494
else {
9595
highp_counter = 0;
9696
}
97-
force.dispense_delay = highp_counter;
97+
//force.dispense_delay = highp_counter;
9898
force.loglite_Left();
9999

100100
if (random(100) < prob_left) {
@@ -121,7 +121,7 @@ void loop() {
121121
else {
122122
highp_counter = 0;
123123
}
124-
force.dispense_delay = highp_counter;
124+
//force.dispense_delay = highp_counter;
125125
force.loglite_Right();
126126

127127
if (random(100) < prob_right) {

src/Force.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,10 +1456,11 @@ void Force::DispenseLeft() {
14561456
}
14571457
//digitalWrite(A2,HIGH); //A2 will be "reward dispensed" pin
14581458
//digitalWrite(13,HIGH); // RED LED
1459-
for (int i=0; i < 30; i++) {
1459+
for (int i=0; i < 20; i++) {
14601460
digitalWrite(PUMP1, HIGH);
1461-
delayMicroseconds(100);
1461+
delayMicroseconds(600);
14621462
digitalWrite(PUMP1, LOW);
1463+
delayMicroseconds(200);
14631464
}
14641465
DateTime now = rtc.now();
14651466
dispenseTime = now.unixtime();
@@ -1492,10 +1493,11 @@ void Force::DispenseRight() {
14921493
tft.fillRect(12, 0, 38, 24, ST7735_BLACK); // clear the text after label
14931494
}
14941495
}
1495-
for (int i=0; i < 30; i++) {
1496+
for (int i=0; i < 20; i++) {
14961497
digitalWrite(PUMP2, HIGH);
1497-
delayMicroseconds(100);
1498+
delayMicroseconds(600);
14981499
digitalWrite(PUMP2, LOW);
1500+
delayMicroseconds(200);
14991501
}
15001502
DateTime now = rtc.now();
15011503
dispenseTime = now.unixtime();
@@ -1582,12 +1584,17 @@ void Force::SenseRight() {
15821584
/////////////////////////////
15831585

15841586
void Force::prime_dispense() {
1585-
for (int i=0; i < 100; i++) {
1587+
for (int i=0; i < 20; i++) {
15861588
digitalWrite(PUMP1, HIGH);
1587-
digitalWrite(PUMP2, HIGH);
1588-
delayMicroseconds(100);
1589+
delayMicroseconds(600);
15891590
digitalWrite(PUMP1, LOW);
1591+
delayMicroseconds(200);
1592+
}
1593+
for (int i=0; i < 20; i++) {
1594+
digitalWrite(PUMP2, HIGH);
1595+
delayMicroseconds(600);
15901596
digitalWrite(PUMP2, LOW);
1597+
delayMicroseconds(200);
15911598
}
15921599
}
15931600

0 commit comments

Comments
 (0)