From 4ed392f8f790e135996ca020d82695b19bde1cd8 Mon Sep 17 00:00:00 2001 From: Amber Fechko Date: Sat, 15 Jun 2013 21:41:53 -0700 Subject: [PATCH] Updates (broken!) --- L293D_pump_code.py | 42 ++++++++++++++++++++++++++++++++++++ ps pump equipment list and notes.txt | 22 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 L293D_pump_code.py diff --git a/L293D_pump_code.py b/L293D_pump_code.py new file mode 100644 index 0000000..48785bb --- /dev/null +++ b/L293D_pump_code.py @@ -0,0 +1,42 @@ +# this uses the Adafruit PWM kernel library in their Occidentalis distro +import RPi.GPIO as io +io.setmode(io.BCM) + +in1_pin = 4 +in2_pin = 17 + +io.setup(in1_pin, io.OUT) +io.setup(in2_pin, io.OUT) + +def set(property, value): + try: + f = open("/sys/class/rpi-pwm/pwm0/" + property, 'w') + f.write(value) + f.close() + except: + print("Error writing to: " + property + " value: " + value) + +set("delayed", "0") +set("mode", "pwm") +set("frequency", "500") +set("active", "1") + +def clockwise(): + io.output(in1_pin, True) + io.output(in2_pin, False) + +def counter_clockwise(): + io.output(in1_pin, False) + io.output(in2_pin, True) + +clockwise() + +while True: + cmd = raw_input("Command, f/r 0..9, E.g. f5 :") + direction = cmd[0] + if direction == "f": + clockwise() + else: + counter_clockwise() + speed = int(cmd[1]) * 11 + set("duty", str(speed)) \ No newline at end of file diff --git a/ps pump equipment list and notes.txt b/ps pump equipment list and notes.txt index 8d3fd31..b36ae75 100644 --- a/ps pump equipment list and notes.txt +++ b/ps pump equipment list and notes.txt @@ -72,6 +72,28 @@ A gertboard is overkill for this, but again, I already had it sitting around. :) 6. Play with the other Gertboard examples (including motor ones) if you are so inclined: >> get http://raspi.tv/download/GB_Python.zip + + +---------------------------------------------------------------- +-------------------ARDUINO OR PI W/L293D CHIP------------------- +---------------------------------------------------------------- +As a starting off point, the DC motor tutorials at Adafruit can be used for either the Arduino or the Raspberry Pi. The Adafruit Raspberry Pi tutorial makes use of their Occidentalis distro, which has a custom PWM kernel module included. This might make your life easier, but I prefer Raspbian and wiringPi (below). +Raspberry Pi: http://learn.adafruit.com/adafruit-raspberry-pi-lesson-9-controlling-a-dc-motor/overview +Arduino: http://learn.adafruit.com/adafruit-arduino-lesson-15-dc-motor-reversing/ + +I used the Raspberry Pi with the L293D, with a base (updated) Raspbian install. +1a. Install wiringPi either w/apt-get from the command line: +>> sudo apt-get update +>> sudo apt-get install python-dev python-pip +>>sudo pip install wiringpi +1b. Or install wiringPi from the git repository: +>> sudo apt-get install git-core +>> git clone git://git.drogon.net/wiringPi +>> cd wiringPi +>> ./build +2. + + ---------------------------------------------------------------- --------------------------GENERAL NOTES------------------------- ----------------------------------------------------------------