Four motors moving.
.END
# *** Guzunty Pi Step Motor ***
ftguzuntypi.Test4StepMotors(stepSequence = ftguzuntypi.Wave,
stepAngle = ftguzuntypi.Byj48stepAngle,
stepTime = ftguzuntypi.MilliSeconds50,
direction = ftguzuntypi.Clockwise,
degrees = 10)
ftguzuntypi.Test4StepMotors(stepSequence = ftguzuntypi.Wave,
stepAngle = ftguzuntypi.Byj48stepAngle,
stepTime = ftguzuntypi.MilliSeconds50,
direction = ftguzuntypi.CounterClockwise,
degrees = 10)
def Test4StepMotors(stepSequence, stepAngle, stepTime, direction, degrees):
ftprint.PrintDoubleSpaceLine("*** Start testing stepping motor ***")
print "Step sequence = ", stepSequence
print "Step angle = ", stepAngle
print "Step time = ", stepTime
print "Direction = ", direction
print "Degrees = ", degrees
spiChannel = spidev.SpiDev()
spiChannel.open(0, 0)
stepCount = int((degrees / stepAngle) * 32) # why not /64 ???
if (direction == Clockwise):
for i in range(stepCount):
for stepPattern in stepSequence:
stepPattern1 = stepPattern
stepPattern2 = stepPattern << 4
stepPattern3 = stepPattern1 | stepPattern2
spiChannel.xfer2([stepPattern3, stepPattern3])
time.sleep(stepTime)
else:
for i in range(stepCount):
for stepPattern in reversed(stepSequence):
stepPattern1 = stepPattern
stepPattern2 = stepPattern << 4
stepPattern3 = stepPattern1 | stepPattern2
spiChannel.xfer2([stepPattern3, stepPattern3])
time.sleep(stepTime)
spiChannel.close()
ftprint.PrintDoubleSpaceLine("*** Stop testing stepping motor ***")
.END
No comments:
Post a Comment