Advertisement
silver2row

Hello and MotorBridge.py lib...

Dec 19th, 2020
1,033
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. # init stepper motor A
  2.     def StepperMotorAInit(self):
  3.         WriteByte(TB_1A_MODE, TB_SPM) #Stepper
  4.         time.sleep(DelayTime)
  5.         WriteHalfWord(TB_1A_DUTY, 1000)    # voltage
  6.         time.sleep(DelayTime)
  7.  
  8.     # MoveSteps > 0 CW
  9.     # MoveSteps < 0 CCW
  10.     # StepDelayTime : delay time for every step. uint us
  11.     def StepperMotorAMove(self, MoveSteps, StepDelayTime):
  12.         if MoveSteps > 0:
  13.             WriteByte(TB_1A_DIR, TB_CW)   #CW
  14.         else:
  15.             WriteByte(TB_1A_DIR, TB_CCW)   #CW
  16.             MoveSteps = -MoveSteps
  17.         time.sleep(DelayTime)
  18.         WriteOneWord(TB_1A_SPM_SPEED, StepDelayTime)  # unit us
  19.         time.sleep(DelayTime)
  20.         WriteOneWord(TB_1A_SPM_STEP, MoveSteps)
  21.         time.sleep(DelayTime)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement