# linear motion # # Xiang Zhai, May 2, 2013 # # zxzhaixiang at gmail.com # # For instruction on how to build the laser engraver and operate the codes, please visit # # funofdiy.blogspot.com # # # ################################################################################################ import RPi.GPIO as GPIO from Bipolar_Stepper_Motor_Class import Bipolar_Stepper_Motor import time from numpy import pi, sin, cos, sqrt, arccos, arcsin GPIO.setmode(GPIO.BOARD) M = Bipolar_Stepper_Motor(11, 7, 5, 3) speed = 200 #step/sec try: for i in range(30): print "Move to %s .." % ((i + 1) * 1000) M.move(-1, 1000, 1.0 / speed) except KeyboardInterrupt: pass M.unhold() GPIO.cleanup()
# Ian D. Miller # Jan 7, 2014 # http://www.pxlweavr.com # info [at] pxlweavr.com print "Program Started" import RPi.GPIO as GPIO import Motor_control from Bipolar_Stepper_Motor_Class import Bipolar_Stepper_Motor import time from numpy import pi, sin, cos, sqrt, arccos, arcsin #Test program for stepper motor GPIO.setmode(GPIO.BOARD) GPIO.setup(3, GPIO.OUT) motor = Bipolar_Stepper_Motor(8, 10, 12, 16) try: while True: direction = int(raw_input("Input Direction: ")) steps = int(raw_input("Input Step Number: ")) laservar = int(raw_input("Laser state: ")) GPIO.output(3, laservar) motor.move(direction, steps, 0.01) except KeyboardInterrupt: GPIO.cleanup()
# Ian D. Miller # Jan 7, 2014 # http://www.pxlweavr.com # info [at] pxlweavr.com print "Program Started" import RPi.GPIO as GPIO import Motor_control from Bipolar_Stepper_Motor_Class import Bipolar_Stepper_Motor import time from numpy import pi, sin, cos, sqrt, arccos, arcsin #Test program for stepper motor GPIO.setmode(GPIO.BOARD) GPIO.setup(3,GPIO.OUT) motor=Bipolar_Stepper_Motor(8,10,12,16) try: while True: direction = int(raw_input("Input Direction: ")) steps = int(raw_input("Input Step Number: ")) laservar = int(raw_input("Laser state: ")) GPIO.output(3,laservar) motor.move(direction,steps,0.01) except KeyboardInterrupt: GPIO.cleanup()
no_step=int(round(r*theta/dx/5.0)); # number of point for the circular interpolation for i in range(1,no_step+1): tmp_theta=i*theta/no_step; tmp_x_pos=xcenter+e1[0]*cos(tmp_theta)+e2[0]*sin(tmp_theta); tmp_y_pos=ycenter+e1[1]*cos(tmp_theta)+e2[1]*sin(tmp_theta); moveto(MX,tmp_x_pos,dx,MY, tmp_y_pos,dy,speed,True); else: #Manual Control Mode while True: xsteps = int(raw_input("X Stepper Steps: ")) ysteps = int(raw_input("Y Stepper Steps: ")) laservar = int(raw_input("Laser state (1 on, 0 off): ")) GPIO.output(Laser_switch,laservar) if (xsteps > 0): MX.move(1,abs(xsteps),0.01) else: MX.move(-1,abs(xsteps),0.01) if (ysteps > 0): MY.move(1,abs(ysteps),0.01) else: MY.move(-1,abs(ysteps),0.01) except KeyboardInterrupt: popen.kill() pid = subprocess.call('pkill raspivid', shell=True) pass GPIO.output(Laser_switch,False); # turn off laser moveto(MX,0,dx,MY,0,dy,50,False); # move back to Origin MX.unhold();