今天製作的手臂用到樹莓派加上一塊台灣沒有賣的擴充板,走兩個I2C控制16個PWM訊號,走額外的電源供應器,利用這樣的系統可以使用Raspberry pi 的GPIO控制,控制機械手臂,目前用I2C的方式控制
https://www.adafruit.com/product/2327
目前還在摸索控制方法,希望接下來可以配合影像辨識,將自動下料的部份做好,原本規劃利用Octopi,進行控制,可是就目前進度,我們還沒拆開他的那包,還沒辦法寫自己的功能,現在想要用影像的方式辨認目標,然後夾取。
底下為control的程式
#!/usr/bin/python from Adafruit_PWM_Servo_Driver import PWM import time # Initialise the PWM device using the default address pwm = PWM(0x40) # Note if you'd like more debug output you can instead run: #pwm = PWM(0x40, debug=True) servoMin = 150 # Min pulse length out of 4096 servoMax = 600 # Max pulse length out of 4096 def setServoPulse(channel, pulse): pulseLength = 1000000 # 1,000,000 us per second pulseLength /= 60 # 60 Hz print "%d us per period" % pulseLength pulseLength /= 4096 # 12 bits of resolution print "%d us per bit" % pulseLength pulse *= 1000 pulse /= pulseLength pwm.setPWM(channel, 0, pulse) pwm.setPWMFreq(60) # Set frequency to 60 Hz while (True): # Change speed of continuous servo on channel O pwm.setPWM(0, 0, servoMin) time.sleep(1) pwm.setPWM(0, 0, servoMax) time.sleep(1)
Comments
comments powered by Disqus