Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # from: Jiankia Li on MotorBridge.py from Github.com '18 and '15.
- # Trying to understand my source, their source, and updating it '20.
- ...
- # init stepper motor A
- def StepperMotorAInit(self):
- WriteByte(TB_1A_MODE,TB_SPM) #Stepper
- time.sleep(DelayTime)
- WriteHalfWord(TB_1A_DUTY,1000) # voltage
- time.sleep(DelayTime)
- # MoveSteps > 0 CW
- # MoveSteps < 0 CCW
- # StepDelayTime : delay time for every step. uint us
- def StepperMotorAMove(self,MoveSteps,StepDelayTime):
- if MoveSteps > 0:
- WriteByte(TB_1A_DIR,TB_CW) #CW
- else:
- WriteByte(TB_1A_DIR,TB_CCW) #CW
- MoveSteps = -MoveSteps
- time.sleep(DelayTime)
- WriteOneWord(TB_1A_SPM_SPEED,StepDelayTime) # unit us
- time.sleep(DelayTime)
- WriteOneWord(TB_1A_SPM_STEP,MoveSteps)
- time.sleep(DelayTime)
- ...
- # from Jiankia Li on the Stepper.py source '15.
- # And...again! Me trying to understand the source to make my ball screw move in accordance with my thinking...'20.
- import MotorBridge
- import time
- # def StepperMotorATest():
- # print 'Hello From MotorBridge'
- # motor.StepperMotorAInit()
- # motor.StepperMotorAMove(1000,1000) # 1000 steppers 1000us every step
- # time.sleep(1)
- # motor.StepperMotorAMove(-1000,1000) # 1000 steppers 1000us every step
- # time.sleep(1)
- def StepperMotorBTest():
- print('Movement!')
- motor.StepperMotorBInit()
- motor.StepperMotorBMove(1000,1000) # 1000 steppers 1000us every step
- time.sleep(1)
- motor.StepperMotorBMove(-1000,1000) # 1000 steppers 1000us every step
- time.sleep(1)
- if __name__=="__main__":
- motor = MotorBridge.MotorBridgeCape()
- while True:
- #StepperMotorATest()
- StepperMotorBTest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement