User avatar
joan
Posts: 13542
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Servoblaster compatibility with latest May Jessie

Wed Jun 08, 2016 10:42 pm

harlock74 wrote:
Great, thank you very much joan.

I should have mentioned that my project involves the use of two servos (pan&tilt) to control the pi camera attached to it. Can I use pigpio in such a way that I can rotate gradually the two servos (from left to right and up and down) same as with servo blaster?

Cheers
Yes, pigpio allows independent servo control.

pigpio differs from servoblaster in that it only accepts absolute microsecond pulsewidths (i.e. 1000 not 100, no percentages, no increments) and does not have a pulse timeout parameter.

harlock74
Posts: 182
Joined: Fri Jan 18, 2013 10:47 am

Re: Servoblaster compatibility with latest May Jessie

Wed Jun 08, 2016 10:58 pm

joan wrote:
harlock74 wrote:
Great, thank you very much joan.

I should have mentioned that my project involves the use of two servos (pan&tilt) to control the pi camera attached to it. Can I use pigpio in such a way that I can rotate gradually the two servos (from left to right and up and down) same as with servo blaster?

Cheers
Yes, pigpio allows independent servo control.

pigpio differs from servoblaster in that it only accepts absolute microsecond pulsewidths (i.e. 1000 not 100, no percentages, no increments) and does not have a pulse timeout parameter.
Excellent, many thanks for that. I need to study it first. But hope you don't mind if I bother you again should I need some further help :mrgreen:

Cheers.

askming
Posts: 2
Joined: Sun Dec 04, 2016 1:46 am

Re: Servoblaster compatibility with latest May Jessie

Sun Dec 04, 2016 2:00 am

joan wrote:
harlock74 wrote: ...
Cool! I will study the documentation first and then I will give it a go..I am very intruigued by these two tools indeed. :ugeek:

I will try to find new servos from eBay to see whether it is an hardware issue or not. I have got 6 Dagu Pan&Tilt and I have been experiencing the same issue with all of them.

Would you please recommend to me any servos in particular?
...
I'm not the person to ask to recommend servos. I buy the cheapest I can find on eBay as I'm only interested in the software side of things.

By the way I should point out that pigpio can drive servos.

From the command line

sudo pigpod # start daemon

pigs s 4 1000 # 1000 µs servo pulses to GPIO 4
pigs s 14 1500 # 1500 µs servo pulses to GPIO 14
pigs s 23 2000 # 2000 µs servo pulses to GPIO 23
Hi joan, my issue is almost same as harlock74, besides my doesn't respond at all. this is what I got back from

Code: Select all

 sudo pigpod # start daemon

Code: Select all

[email protected]:~ $ sudo pigpiod
2016-12-04 01:58:33 initInitialise: Can't lock /var/run/pigpio.pid
Can't initialise pigpio library



calleblyh
Posts: 54
Joined: Thu Feb 12, 2015 6:14 pm
Location: Southwest Finland

Re: Servoblaster compatibility with latest May Jessie

Sun Feb 18, 2018 3:12 pm

Asking for help to install ServoBlaster on latest 2017-11-29 Stretch.
My intention is to control 2 servos for pan & tilt using arrow keys for up/down left/right. There are lots of postings on many forums on this subject. However all my attempts to install ServoBlaster have failed in respect of getting servos to move. My python pantilt.py is copied from tuckershannon.com and video on YouTube and based on installing PiBits/ServoBlaster. Everything else works except moving the servos. Cam preview is ok, taking a snapshot is ok, I get up,down,left,right on screen but servos don't move. Either my procedure installation of PiBIts I manage to do it wrong ? OR ?? is there a compatibility problem using Stretch ? Has anybody used Stretch with ServoBlaster ? A step by step instruction would be best.
My pantilt.py is located in PiBIts/ServoBlaster/user folder where also servod is located . Running sudo ./servod gives me a listing available gpio's. Do I need to sudo pigpiod to activate deamon? I am quite confused how to proceed. So any input to get me on track is highly appreciated. Attached my pantilt code

Code: Select all

#Raspberry-Pi pan and tilt using arrow keys script
#must be run from Pi's terminal!
#use code "python pantilt.py" after you cd into the correct folder!

#By Tucker Shannon @ tucksprojects.com 11-08-16

#importing required libraries
import curses
import os
import time
import picamera

#setting up camera
camera = picamera.PiCamera()
camera.resolution = (1024, 768)
camera.start_preview()



#activating servo blaster (servod must be in the same folder as this script!)
os.system('sudo ./servod')

#flipping the camera for so its not upside down
camera.vflip = True
camera.hflip = True

# get the curses screen window
screen = curses.initscr()

# turn off input echoing
curses.noecho()

# respond to keys immediately (don't wait for enter)
curses.cbreak()

# map arrow keys to special values
screen.keypad(True)

#setting start up serrvo positions
#positions range from (50-250)
servo1 = 100
servo2 = 100
# print doesn't work with curses, use addstr instead
pic = 1
try:
    while True:
        char = screen.getch()
        if char == ord('q'):
            #if q is pressed quit
            break
        if char == ord('p'):
            #if p is pressed take a photo!
            camera.capture('image%s.jpg' % pic)
            pic = pic +1
            screen.addstr(0, 0, 'picture taken! ')
        elif char == curses.KEY_RIGHT:
            screen.addstr(0, 0, 'right ')
            if servo1 > 50:
                servo1 = servo1 -2
            os.system("echo 0=%s > /dev/servoblaster" %servo1) 
            time.sleep(0.005)
        elif char == curses.KEY_LEFT:
            screen.addstr(0, 0, 'left ')
            if servo1 < 150:
                servo1 = servo1 +2
            os.system("echo 0=%s > /dev/servoblaster" %servo1) 
            time.sleep(0.005)
        elif char == curses.KEY_UP:
            screen.addstr(0, 0, 'up ')
            if servo2 < 150:
                servo2 = servo2 +2
            os.system("echo 1=%s > /dev/servoblaster" %servo2) 
            time.sleep(0.005)
        elif char == curses.KEY_DOWN:
            screen.addstr(0, 0, 'down ')
            if servo2 > 50:    
                servo2 = servo2 -2
            os.system("echo 1=%s > /dev/servoblaster" %servo2) 
            time.sleep(0.005)
finally:
    # shut down cleanly
    curses.nocbreak(); screen.keypad(0); curses.echo()
    curses.endwin()

User avatar
joan
Posts: 13542
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Servoblaster compatibility with latest May Jessie

Mon Feb 19, 2018 8:28 am

pigpio is an alternative to servoblaster for driving servos. Use one or the other. Using both will confuse both unless you start them up with the proper options.

Post a photo or a link to a photo of your Pi <-> servo connections. The most likely problem is you are using the wrong GPIO (there are several numbering schemes) or you have not connected the Pi and servo grounds.

calleblyh
Posts: 54
Joined: Thu Feb 12, 2015 6:14 pm
Location: Southwest Finland

Re: Servoblaster compatibility with latest May Jessie

Mon Feb 19, 2018 4:16 pm

joan wrote:
Mon Feb 19, 2018 8:28 am


Post a photo or a link to a photo of your Pi <-> servo connections. The most likely problem is you are using the wrong GPIO (there are several numbering schemes) or you have not connected the Pi and servo grounds.
Thanks Joan for replying.
It was certainly NOT a wiring problem. Rather the servoblasters servod.c needed an update to recognise BCM2835 and I found the answer on https://github.com/richardghirst/PiBits/issues/91. Making that update my application came alive.. So, for the moment this issue is solved.

However, I have not been working with pigpio very much, but still interested to evaluate how to use arrowkeys up-down-left.right to control a pan&tilt servos. For the moment I am happy but as time permits I will dig into pigpio.
Thanks again
calleblyh

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: jamesh and 11 guests