Esempio n. 1
0
class PhidgetMovement:			
	def __init__(self,serial):
		self.servo = Servo()
		self.servo.openPhidget(serial)	
		print "connecting to servo: " + str(serial)
		self.servo.waitForAttach(10000)
		
	def setValue(self,value):
		self.servo.setPosition(0,value)
Esempio n. 2
0
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)
    print("Exiting....")
    exit(1)
else:
    DisplayDeviceInfo()

try:
    print("Setting the servo type for motor 0 to HITEC_HS322HD")
    servo.setServoType(0, ServoTypes.PHIDGET_SERVO_HITEC_HS322HD)
    #Setting custom servo parameters example - 600us-2000us == 120 degrees
    #servo.setServoParameters(0, 600, 2000, 120)
    print("Move to position 10.00")
    servo.setPosition(0, 10.00)
    sleep(5)
    
    print("Move to position 50.00")
    servo.setPosition(0, 50.00)
    sleep(5)
    
    print("Move to position 100.00")
    servo.setPosition(0, 100.00)
    sleep(5)
    
    print("Move to position 150.00")
    servo.setPosition(0, 150.00)
    sleep(5)
    
    print("Move to position PositionMax")
Esempio n. 3
0
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)
    print("Exiting....")
    exit(1)
else:
    DisplayDeviceInfo()

try:
    print("Setting the servo type for motor 0 to HITEC_HS322HD")
    servo.setServoType(0, ServoTypes.PHIDGET_SERVO_HITEC_HS322HD)
    #Setting custom servo parameters example - 600us-2000us == 120 degrees
    #servo.setServoParameters(0, 600, 2000, 120)
    print("Move to position 10.00")
    servo.setPosition(0, 10.00)
    sleep(5)
    
    print("Move to position 50.00")
    servo.setPosition(0, 50.00)
    sleep(5)
    
    print("Move to position 100.00")
    servo.setPosition(0, 100.00)
    sleep(5)
    
    print("Move to position 150.00")
    servo.setPosition(0, 150.00)
    sleep(5)
    
    print("Move to position PositionMax")
Esempio n. 4
0
except PhidgetException, e:
    print "Phidget Exception %i: %s" % (e.code, e.message)
    try:
        servo.closePhidget()
    except PhidgetException, e:
        print "Phidget Exception %i: %s" % (e.code, e.message)
        print "Exiting...."
        exit(1)
    print "Exiting...."
    exit(1)
else:
    DisplayDeviceInfo()

try:
    print "Move to position 10.00"
    servo.setPosition(0, 10.00)
    sleep(1)    
    print "Move to position 50.00"
    servo.setPosition(0, 50.00)
    sleep(1)
    print "Move to position 100.00"
    servo.setPosition(0, 100.00)
    sleep(1)
    print "Move to position 150.00"
    servo.setPosition(0, 150.00)
    sleep(1)
    print "Move to position 200.00"
    servo.setPosition(0, 200.00)
    sleep(1)
    print "Move to position 0.00"
    servo.setPosition(0, 0.00)
Esempio n. 5
0
except PhidgetException, e:
    print "Phidget Exception %i: %s" % (e.code, e.message)
    try:
        servo.closePhidget()
    except PhidgetException, e:
        print "Phidget Exception %i: %s" % (e.code, e.message)
        print "Exiting...."
        exit(1)
    print "Exiting...."
    exit(1)
else:
    DisplayDeviceInfo()

try:
    print "Move to position 10.00"
    servo.setPosition(0, 10.00)
    sleep(5)

    print "Move to position 50.00"
    servo.setPosition(0, 50.00)
    sleep(5)

    print "Move to position 100.00"
    servo.setPosition(0, 100.00)
    sleep(5)

    print "Move to position 150.00"
    servo.setPosition(0, 150.00)
    sleep(5)

    print "Move to position 200.00"
        servo.closePhidget()
    except PhidgetException as e:
        print("Phidget Exception %i: %s" % (e.code, e.details))
        print("Exiting....")
        exit(1)
    print("Exiting....")
    exit(1)
else:
    DisplayDeviceInfo()

try:
    print("Setting the servo type for motor 0 to RAW_us_MODE")
    servo.setServoType(0, ServoTypes.PHIDGET_SERVO_RAW_us_MODE)

    print("Move in positive direction")
    servo.setPosition(0, stopPW + goPW)
    sleep(5)
    
    print("Move in negative direction")
    servo.setPosition(0, stopPW - goPW)
    sleep(5)
    
except PhidgetException as e:
    print("Phidget Exception %i: %s" % (e.code, e.details))
    print("Exiting....")
    exit(1)

print("Press Enter to stop and quit....")

chr = sys.stdin.read(1)