Page 8 of 9

Re: Driving multiple servos from the RaspberryPi

Posted: Thu Oct 03, 2013 5:22 pm
by rgh
clicky wrote:BTW quick question: is it going to be possible to read /dev/servoblaster of userspace implementation?
No, because the user space implementation is not really a device driver in the usual sense of the word and /dev/servoblaster is a FIFO, not a device node. Your code writes to that FIFO, and servod reads from it, so it's not possible for your code to also read it.

Re: Driving multiple servos from the RaspberryPi

Posted: Thu Oct 03, 2013 5:55 pm
by clicky
Thank you for the explanation! It makes perfect sense.

Would you be cross if I ask for you to, maybe, consider providing those values on /dev/servoblaster-cfg? O : )

It surely is not that bad as an idea, is it? :)

Generally it can serve as initial value for our abstraction or to be able to slowly move servo from where it was left last time, process was killed, to new value making sure I don't jerk servo too quickly to new position - for purpose of effect or weak power supply which sometimes drops voltage if servo is driven at its maximum speed.

Re: Driving multiple servos from the RaspberryPi

Posted: Thu Oct 03, 2013 6:02 pm
by rgh
I understand why you would want that; to provide it I'd have to rewrite a file containing the data for every servo position update; maybe that's ok, provided its on a RAM file system - I wouldn't want servod to start blocking just because the SD card was busy, for example. I'll think about it some more.

Re: Driving multiple servos from the RaspberryPi

Posted: Thu Oct 03, 2013 6:09 pm
by clicky
Oh - no - that wouldn't be right. I am just forgetting that those are not real devices. :(

Re: Driving multiple servos from the RaspberryPi

Posted: Tue Nov 19, 2013 12:01 am
by Zeryk
Hi,
I would like to control servos using C++ and I hope this could be the way (I tried wiringPi but without success)
I am new to all of this and I have the same problem as "Forris ยป Sun Jan 20, 2013" - when sudo insmod servoblaster.ko then Error: could not insert module servoblaster.ko: Invalid module format

I have followed all the steps. I have the 3.6.11+ version and the servoblaster.ko is 3.6.11 too.. but still not working.

Thanks for any advice.

Re: Driving multiple servos from the RaspberryPi

Posted: Tue Nov 19, 2013 9:01 am
by rgh
Zeryk wrote: when sudo insmod servoblaster.ko then Error: could not insert module servoblaster.ko: Invalid module format
Please see the README in the github repository, and use the user space servod implementation, not the kernel space servoblaster.ko implementation.

Richard

Re: Driving multiple servos from the RaspberryPi

Posted: Mon Nov 25, 2013 2:01 pm
by desihacker
Hey,
I am trying to control 5 servos using python using the one PWM pin... Any suggestions and code help? I'm young and kinda new at this... its for a school robotics competition

Re: Driving multiple servos from the RaspberryPi

Posted: Mon Nov 25, 2013 2:05 pm
by ame
You don't have to restrict yourself to the single hardware PWM pin. The servoblaster code does everything in software, so you can control your 5 servos from 5 different GPIO pins.

Re: Driving multiple servos from the RaspberryPi

Posted: Sun Dec 29, 2013 12:26 pm
by JohnneyBoy
Hello,

I'm trying to compile the driver, however I'm, getting the following error

/home/servoblaster/PiBits/ServoBlaster/kernel/servoblaster.c:52:27: fatal error: mach/platform.h: No such file or directory

I have the latests kernel source downloaded and compiled. (3.10.25)

I suspect the include path needs changing..
I also suspect the <asm/uaccess.h> may have the same issue.

Regards John

Re: Driving multiple servos from the RaspberryPi

Posted: Sun Dec 29, 2013 12:31 pm
by joan
The kernel version is probably deprecated.

Try the userland version instead.

Re: Driving multiple servos from the RaspberryPi

Posted: Sun Dec 29, 2013 2:47 pm
by JohnneyBoy
Hello,

I looked like I needed to update the kernel source .config file with a valid one, the driver now compiles.

Just need to test it....

John

Re: Driving multiple servos from the RaspberryPi

Posted: Sun Dec 29, 2013 4:50 pm
by mikronauts
I've had great success with using the pigpio library to drive multiple servos - I used three in my SPRITE bot (Servo Jan.2014)

Re: Driving multiple servos from the RaspberryPi

Posted: Tue Dec 31, 2013 12:50 pm
by rgh
JohnneyBoy wrote:Hello,

I looked like I needed to update the kernel source .config file with a valid one, the driver now compiles.

Just need to test it....

John
Joan is correct, the kernel space driver is depreciated and you really should use the userspace servod.c one instead (ServoBlaster/user/servod.c).

Re: Driving multiple servos from the RaspberryPi

Posted: Tue Dec 31, 2013 12:55 pm
by rgh
New version pushed to github:
  • You can now specify the step increment, in case 10us wasn't want you wanted.
    You can specify a cycle time other than 20ms, which might be useful if driving LEDs and you don't like the 50Hz flicker.
    You can specify pulse widths in microseconds or as a percentage, as an alternative to the original "units of 10us" scheme.
    You can make incremental adjustments to the position via a '+' or '-' prefix to the width you specify.
Richard

Re: Driving multiple servos from the RaspberryPi

Posted: Tue Dec 31, 2013 1:26 pm
by clicky
Really nice! :) Thanks!
You can specify a cycle time other than 20ms, which might be useful if driving LEDs and you don't like the 50Hz flicker.
Or driving fast (tail) servos!
You can specify pulse widths in microseconds or as a percentage, as an alternative to the original "units of 10us" scheme.
That's fantastic! I'll go and update pi4j servo driver immediately to switch to that scheme! Thanks again!

Re: Driving multiple servos from the RaspberryPi

Posted: Fri Apr 25, 2014 4:53 am
by vdnguyen58
Hi everybody. I'm new with Raspberry Pi. After installing Raspian using NOOBS image (totally fresh), I downloaded the servoblaster from github:

Code: Select all

sudo apt-get install git
git clone git://github.com/richardghirst/PiBits.git
Then compiled it:

Code: Select all

cd PiBits/ServoBlaster/user/
sudo make
sudo ./servod
Then I connected the wire: yellow (servo motor) -> P4, and configured the file:

Code: Select all

echo 0=150 > /dev/servoblaster
But nothing happened. Did I miss anything?

Re: Driving multiple servos from the RaspberryPi

Posted: Fri Apr 25, 2014 8:19 am
by ame
Did you connect some power to the servo? Did you connect a common ground line from the servo's ground to the Pi ground?

Re: Driving multiple servos from the RaspberryPi

Posted: Fri Apr 25, 2014 9:40 am
by vdnguyen58
My bad, I think I connected wrong GPIO cable. After changing the cable now I could do only two things: turn on and turn off the servo motor. Turn on: echo 0=0 > /dev/servoblaster and whatever value other than 0 makes the servo rotate to only one extreme and it seems that the servo tries to continue rotating :(. I tried 0=50, 0=100, 0=120 and they produces all the same angles. I think the angles will be different with these values, right?
(I guess the output pin cannot produce the pulse)
Image
Image

Re: Driving multiple servos from the RaspberryPi

Posted: Fri Apr 25, 2014 9:58 am
by joan
Those photos are either old or you haven't done what the previous poster told you to do.

Re: Driving multiple servos from the RaspberryPi

Posted: Fri Apr 25, 2014 10:11 am
by vdnguyen58
I didn't connect the batteries' GND with RPi's GND. Everything is fine now.
Thanks for all of your help.

Re: Driving multiple servos from the RaspberryPi

Posted: Tue Jul 29, 2014 12:45 pm
by Maschs
Hi I'm with my raspberry pi and I can't get servoblaster to start working.

I cloned the github repo and installed it.

Code: Select all

git clone git://github.com/richardghirst/PiBits.git
cd PiBits/ServoBlaster/kernel
make install_autostart
sudo modprobe servoblaster
But after executing the last command I get: "ERROR: could not insert 'servoblaster': Exec format error"

and it doesn't work when I try to pass commands to it.

How do I fix this error? Already tried redownloading it and rebooting my pi.

Re: Driving multiple servos from the RaspberryPi

Posted: Wed Aug 06, 2014 7:15 pm
by mrmsbarnes
Richard, You have the power (should have the power) to modify your original post to note you no longer provide 'ready built' drivers at your git repository (unless I'm mistaken - still newish to git). That way newishbies won't read 8 pages of replies to be certain such was not already covered. OTOH, reading those pages were also instructive. Just a suggestion. Thanks for servoblaster.

Re: Driving multiple servos from the RaspberryPi

Posted: Mon Aug 25, 2014 2:20 am
by CalcProgrammer1
Thanks for this awesome program! I was working on hooking up an ATTiny2313 over i2c to drive servos when I found this, completely eliminated the need for such a setup and I'm driving four servos just fine on my robot. Two are actually Vex Robotics continuous-drive motors supplied from 12V (but still tolerate a 3.3V signal line) and the other two are TowerPro SG90 micro-servos running off the Pi's 5V supply installed in a 3d-printed pan and tilt mount for the Pi camera module. It's simple to interface to servoblaster in C, at least the way I do it is just sprintf a command like "echo 1=50% > /dev/servoblaster" and then use the system() function with that string as the argument to write it out. I have my Pi-bot streaming video to my PC as well as streaming inputs from a PC gamepad from the PC to the bot which is turned into control signals to the servos. I might add more servo-driven stuff if I can figure out how to attach an arm or something. I also put 1K-ohm resistors in series with the servo control lines to protect the RPi, servos don't seem to care.

Re: Driving multiple servos from the RaspberryPi

Posted: Mon Dec 01, 2014 3:53 am
by ktemby
Really enjoyed getting the Pi up and running servos with ServoBlaster! Thank you RGH! I followed the instructions on the github site, https://github.com/richardghirst/PiBits ... rvoBlaster, but actually found this tutorial to be the fastest and easiest explanation of what was going on - http://cihatkeser.com/servo-control-wit ... s-or-less/

I'm using a model B+, and one of the nice features is the expanded GPIO. I know RGH hasn't uploaded any new source to the Git since the B+ came out, and a nice feature would be to get the extended GPIO mapped.

I'm having a look at the c source presently, wondering if we can create a new board model - there's the P1 and P5 pins right now, maybe there can be a new one with NUM_BPlusPINS 40 etc...
#define NUM_P1PINS 26
#define NUM_P5PINS 8

Anyway, I'm just starting to look at this, so if anyone else has already completed, please do share with the world!

Kelton

Re: Driving multiple servos from the RaspberryPi

Posted: Tue Dec 02, 2014 6:16 am
by ktemby
Well after a little more digging around I found that pigpio from joan is actually already able to do all the things I wanted.

What's even nicer is that it has a nice python wrapper
http://abyz.co.uk/rpi/pigpio/python.html

I'm going to migrate my project over to pigpio, and see how that goes.

If anyone wants it, here's some basic test code I used for servoblaster, within python -

call(["sudo ~/PiBits/ServoBlaster/user/servod --p1pins 11,19,16,18"],shell=True)
call(["echo " + str(self.panPin) + "=" + str(self.panPos)+ "% > /dev/servoblaster"],shell=True)

where panPin was the mapped pin number (servo 1-4 etc)
where panPos was the position in percentage of the servo (e.g. 50% is centered).

Really glad to see there's multiple people making great tools to build with! Maybe one day these projects can merge into an "official" branch everyone loves (yeah you can tell i'm coming from the Arduino world..!)