Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Removed debugging print statement and added motor priming functionali…
…ty to the driver
  • Loading branch information
mbasescu authored and Max Basescu committed Jul 22, 2015
1 parent 1a784f3 commit a0d1315
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
14 changes: 13 additions & 1 deletion TrainingDriver.py
Expand Up @@ -7,8 +7,12 @@
import socket
import time
import os
import RPi.GPIO as GPIO
import Adafruit_CharLCD as LCD

motorPin = 17
GPIO.setup(motorPin, GPIO.OUT)

os.chdir('/home/pi/DomeTrainingRig/')

while True:
Expand All @@ -29,7 +33,15 @@

# Wait for select to be pressed
while not lcd.is_pressed(LCD.SELECT):
pass
# If up is pressed
if lcd.is_pressed(LCD.UP):
while lcd.is_pressed(LCD.UP):
time.sleep(0.1)

# Send a 440 second pulse to prime lines
GPIO.output(motorPin, True)
time.sleep(440)
GPIO.output(motorPin, False)

# Wait for select to be released
while lcd.is_pressed(LCD.SELECT):
Expand Down
7 changes: 2 additions & 5 deletions TrainingRig_UserInput.py
Expand Up @@ -16,7 +16,6 @@
# +- 20deg randomness

import math
import sys
import csv
import time
import random
Expand Down Expand Up @@ -54,8 +53,6 @@
# starts the motor and logs the event
def buttonPress(ch):
try:
print('hi')
sys.stdout.flush()
global f, buttonFeedStart, buttonIsFeeding

# Only do stuff if we're not already pulsing
Expand Down Expand Up @@ -123,7 +120,7 @@ def readEncoderB(ch):
# Attach interrupts
GPIO.add_event_detect(encoderPinA, GPIO.BOTH, callback = readEncoderA)
GPIO.add_event_detect(encoderPinB, GPIO.BOTH, callback = readEncoderB)
GPIO.add_event_detect(buttonPin, GPIO.RISING, callback = buttonPress, bouncetime = 2000)
GPIO.add_event_detect(buttonPin, GPIO.RISING, callback = buttonPress, bouncetime = 5000)

# Converts encoder angle to degrees
def toDeg(ang):
Expand Down Expand Up @@ -181,7 +178,7 @@ def toEnc(ang):
lcd.show_cursor(False)

# Duration of motor per feeding
pulseDur = 2000 # ms
pulseDur = 5000 # ms

# Local base path to log folder
logBase = 'logs/'
Expand Down

0 comments on commit a0d1315

Please sign in to comment.