#coins | weight | slips | notes |
---|---|---|---|
50 | 178g | NO | |
75 | 267g | YES | Slips only when running counter clockwise |
90 | 320.4g | YES | Slips in both rotations |
#-----------------------------------
# Name: Step.py
#
# Author: Rob Davis
# Based on the Stepper Motor code from matt.hawkins www.raspberrypi-spy.co.uk/2012/07/stepper-motor-control-in-python/
#
# Created: 2014/02/09
#
# Takes parameters for number of steps and which direction from the command line.
# e.g.
# sudo python step.py 4100 CCW
# To operate the motor for 4100 steps (a complete revolution) in a counter clockwise direction.
#-----------------------------------
#!/usr/bin/env python
import sys
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
# Define GPIO signals to use
# Pins 18,22,24,26
# GPIO24,GPIO25,GPIO8,GPIO7
StepPins = [24,25,8,7] # CW rotation
if (sys.argv[2]=="CCW") :
StepPins = [7,8,25,24] # CCW rotation
# Set all pins as output
for pin in StepPins:
GPIO.setup(pin,GPIO.OUT)
GPIO.output(pin, False)
# Define some settings
StepCounter = 0
WaitTime = 0.01
# Define simple sequence (do not use)
StepCount1 = 4
Seq1 = []
Seq1 = range(0, StepCount1)
Seq1[0] = [1,0,0,0]
Seq1[1] = [0,1,0,0]
Seq1[2] = [0,0,1,0]
Seq1[3] = [0,0,0,1]
# Define advanced sequence as shown in manufacturers datasheet
StepCount2 = 8
Seq2 = []
Seq2 = range(0, StepCount2)
Seq2[0] = [1,0,0,0]
Seq2[1] = [1,1,0,0]
Seq2[2] = [0,1,0,0]
Seq2[3] = [0,1,1,0]
Seq2[4] = [0,0,1,0]
Seq2[5] = [0,0,1,1]
Seq2[6] = [0,0,0,1]
Seq2[7] = [1,0,0,1]
Seq = Seq2
StepCount = StepCount2
# Start main loop
steps = int(sys.argv[1])
stepc = 0
while stepc<=steps:
print "Step %i of %i" %(stepc,steps)
for pin in range(0, 4):
xpin = StepPins[pin]
if Seq[StepCounter][pin]!=0:
GPIO.output(xpin, True)
else:
GPIO.output(xpin, False)
StepCounter += 1
# If we reach the end of the sequence start again
if (StepCounter==StepCount):
StepCounter = 0
if (StepCounter<0):
StepCounter = StepCount
# Delay to allow electro magnets to align the gear wheel
time.sleep(WaitTime)
stepc+=1
dmesg
[2504032.732583] usb 1-1.2: new full-speed USB device number 4 using dwc_otg
[2504032.837909] usb 1-1.2: New USB device found, idVendor=0d8c, idProduct=000c
[2504032.837941] usb 1-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[2504032.837961] usb 1-1.2: Product: C-Media USB Headphone Set
[2504032.852884] input: C-Media USB Headphone Set as /devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2:1.3/input/input0
[2504032.853327] hid-generic 0003:0D8C:000C.0001: input,hidraw0: USB HID v1.00 Device [C-Media USB Headphone Set ] on usb-bcm2708_usb-1.2/input3
[2504033.096745] usbcore: registered new interface driver snd-usb-audio
lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter
alsamixer -c 1
aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
sysdefault:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
default:CARD=Set
C-Media USB Headphone Set, USB Audio
Default Audio Device
sysdefault:CARD=Set
C-Media USB Headphone Set, USB Audio
Default Audio Device
front:CARD=Set,DEV=0
C-Media USB Headphone Set, USB Audio
Front speakers
surround40:CARD=Set,DEV=0
C-Media USB Headphone Set, USB Audio
4.0 Surround output to Front and Rear speakers
surround41:CARD=Set,DEV=0
C-Media USB Headphone Set, USB Audio
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Set,DEV=0
C-Media USB Headphone Set, USB Audio
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Set,DEV=0
C-Media USB Headphone Set, USB Audio
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Set,DEV=0
C-Media USB Headphone Set, USB Audio
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Set,DEV=0
C-Media USB Headphone Set, USB Audio
IEC958 (S/PDIF) Digital Audio Output
arecord -D "default:CARD=Set" file
Recording WAVE 'file' : Unsigned 8 bit, Rate 8000 Hz, Mono
arecord -f cd -D "default:CARD=Set" file
aplay -D "default:CARD=Set" file
email
root
flog archives
In fact I'm not responsible for anything ever, so there!
Disclaimer:
This page is by me for me, if you are not me then please be aware of the following
I am not responsible for anything that works or does not work including files and pages made available at www.jumpstation.co.uk
I am also not responsible for any information(or what you or others do with it) available at www.jumpstation.co.uk