Permalink
Browse files

Initial commit; notes & arduino code.

  • Loading branch information...
1 parent 2c47abe commit 9f107ddfc67fe413afeb3cf513b5c18d4910e249 Amber Fechko committed Jun 8, 2013
Showing with 34 additions and 21 deletions.
  1. +8 −5 arduino_motor_shield_drive/arduino_motor_shield_drive.ino
  2. +26 −16 ps pump equipment list and notes.txt
@@ -1,18 +1,20 @@
// Amber Fechko, quick and dirty motor/button solution for peristaltic pump driver.
// amber@kelpforest.org
-int buttonPin = 5; // which pin is the button switch connected to?
+int buttonPin = 4; // which pin is the button switch connected to?
int pinI1 = 8; // motor shield interface I1
int pinI2 = 11; // motor shield interface I2
int speedpinA=9; // enable motor A
-int pwmSpeed = 1000; // define the pwmSpeed of motor
+int pwmSpeed = 255; // define the pwmSpeed of motor
int buttonState = 0; // tracking whether button is pressed or not
void setup() {
pinMode(pinI1,OUTPUT); // configure pinI1 as output
pinMode(pinI2,OUTPUT); // configure pinI2 as output
pinMode(speedpinA,OUTPUT); // enable motor pin as output
pinMode(buttonPin, INPUT); // enable buttonPin as input
+ digitalWrite(pinI1,LOW);
+ digitalWrite(pinI2,LOW);
}
void forward() {
@@ -32,12 +34,13 @@ void stop() {
void loop() {
buttonState = digitalRead(buttonPin); // check button pin for pressed button
+ //Serial.print(buttonState);
if (buttonState == HIGH) { // if button is being pressed..
forward(); // move forward for ...
- delay(6000); // .. six seconds ..
+ delay(1000); // .. two seconds ..
stop(); // .. then stop the motor...
- delay(500); // .. and hold everything for a half second.
+ delay(100); // .. and hold everything for a half second.
} else {
- delay(500);
+ delay(100);
}
}
@@ -1,28 +1,35 @@
Most commercial water/fluid reward systems used in research settings cost a few hundred dollars (or more) and aren't easily modified. This is a fairly quick hack, but it does the job well and won't cost you >$100.. much less if you already have some of the components sitting around. Using a peristaltic pump is preferred, as the motor never actually comes into contact with the fluid itself.
----------------------------------------------
----------------EQUIPMENT---------------------
----------------------------------------------
+----------------------------------------------------------------
+---------------------------EQUIPMENT----------------------------
+----------------------------------------------------------------
Common Equipment (All Versions):
- Peristaltic Liquid Pump (12VDC / 300mA) with Silicone Tubing (max flow 100mL/min) [ http://www.adafruit.com/products/1150 ]
- 12VDC Adapter (old D-Link wall adapter in my case) to power the motor
+- Either a Raspberry Pi or an Arduino (see below)
+- Some way of driving the motor (Motor Shield, Gertboard, L293D, or Power Transistor -- see below)
- Momentary Push Button/Switch for manual fluid delivery (optional)
-Equipment Used for Raspberry Pi Version:
+
+---------
+Equipment Used for Raspberry Pi/Gertboard Version:
- Raspberry Pi Model B [ http://www.newark.com/jsp/search/productdetail.jsp?sku=43W5302 ]
- Gertboard [ http://www.newark.com/jsp/search/productdetail.jsp?sku=46W9829 ]
-Equipment Used for Arduino Version:
+---------
+Equipment Used for Arduino/SeeedStudio Motor Shield Version:
- Arduino Duemilanova w/ATMEGA328 [ http://arduino.cc/en/Main/arduinoBoardDuemilanove ]
- Seeed Studio Motor Shield [ http://www.seeedstudio.com/depot/motor-shield-p-913.html ]
-*** If you're not using a gertboard or motor shield of some sort, you'll need either a power transistor (basic on/off) or a motor driver chip such as the L293D to work with the DC motor which drives the peristaltic pump. [ http://www.ti.com/lit/ds/symlink/l293d.pdf ]
+---------
+Equipment Used for Arduino or Raspberry Pi w/L293D Version:
+- L293D[ http://www.ti.com/lit/ds/symlink/l293d.pdf ; http://www.adafruit.com/products/807 ]
----------------------------------------------
-------------ARDUINO VERSION------------------
----------------------------------------------
+----------------------------------------------------------------
+--------------ARDUINO/SEEED MOTOR SHIELD VERSION----------------
+----------------------------------------------------------------
I used an older arduino (duemilanova) I had sitting around, but any version should be fine. If you use the Seeed motor shield you'll need a compatible pinout -- the duemilanova or the uno both work well. I wouldn't specifically recommend the motor shield, it's overkill for this, but it's cheap/simple and if you have one laying around it works fine. If you do go for this particular motor shield, the wiki has good information: [ http://www.seeedstudio.com/wiki/Motor_Shield_V1.0 ].
Connect your DC power adapter to the motor shield Vs / Gnd pins, and connect the motor to the M1+ / M1- pins. Connect the motor shield to the arduino. Upload arduino code via USB. If you leave the J6 jumper connected, you don't need to provide a separate power source to the arduino -- it will pull power from the motor shield. If you want a manual "push button to dispense fluid" feature, you can pick up a button module from Seeed and connect it via their Grove system to make life easy, but I used a 10kOhm resistor and an old button switch I had laying around.
@@ -41,17 +48,20 @@ Connect your DC power adapter to the motor shield Vs / Gnd pins, and connect the
Gnd
The physical assembly was done using odd metal pieces I had laying around. I'm not particularly proud of it, but it works fine (it doesn't really need a physical assembly to be functional).
-
----------------------------------------------
------------RASPBERRY PI VERSION--------------
----------------------------------------------
+
+
+
+
+----------------------------------------------------------------
+-----------------RASPBERRY PI/GERTBOARD VERSION-----------------
+----------------------------------------------------------------
A gertboard is overkill for this, but again, I already had it sitting around. :) I used a raspberry pi model B, with a pre-assembled gertboard to drive the motor. If you go the gertboard route, their manual is valuable: [ ].
----------------------------------------------
---------------GENERAL NOTES------------------
----------------------------------------------
+----------------------------------------------------------------
+--------------------------GENERAL NOTES-------------------------
+----------------------------------------------------------------
You can use pulse width modulation w/the motor to speed up or slow down the flow rate; if you connect the motor the other way it will move fluid the other direction. It uses 3/16″ (4.7mm) outer diameter silicone tubing, which connects nicely to a metal drinking tube pulled out of a rodent water bottle.

0 comments on commit 9f107dd

Please sign in to comment.