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.clicky wrote:BTW quick question: is it going to be possible to read /dev/servoblaster of userspace implementation?
Re: Driving multiple servos from the RaspberryPi
Re: Driving multiple servos from the RaspberryPi
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.
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
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
Oh - no - that wouldn't be right. I am just forgetting that those are not real devices. 

Re: Driving multiple servos from the RaspberryPi
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.
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
Please see the README in the github repository, and use the user space servod implementation, not the kernel space servoblaster.ko implementation.Zeryk wrote: when sudo insmod servoblaster.ko then Error: could not insert module servoblaster.ko: Invalid module format
Richard
-
- Posts: 5
- Joined: Mon Jul 15, 2013 2:48 am
Re: Driving multiple servos from the RaspberryPi
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
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
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.
-
- Posts: 8
- Joined: Sun Dec 29, 2013 12:18 pm
Re: Driving multiple servos from the RaspberryPi
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
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
The kernel version is probably deprecated.
Try the userland version instead.
Try the userland version instead.
-
- Posts: 8
- Joined: Sun Dec 29, 2013 12:18 pm
Re: Driving multiple servos from the RaspberryPi
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
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
- mikronauts
- Posts: 2821
- Joined: Sat Jan 05, 2013 7:28 pm
- Contact: Website
Re: Driving multiple servos from the RaspberryPi
I've had great success with using the pigpio library to drive multiple servos - I used three in my SPRITE bot (Servo Jan.2014)
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi
Re: Driving multiple servos from the RaspberryPi
Joan is correct, the kernel space driver is depreciated and you really should use the userspace servod.c one instead (ServoBlaster/user/servod.c).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
Re: Driving multiple servos from the RaspberryPi
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.
Re: Driving multiple servos from the RaspberryPi
Really nice!
Thanks!

Or driving fast (tail) servos!You can specify a cycle time other than 20ms, which might be useful if driving LEDs and you don't like the 50Hz flicker.
That's fantastic! I'll go and update pi4j servo driver immediately to switch to that scheme! Thanks again!You can specify pulse widths in microseconds or as a percentage, as an alternative to the original "units of 10us" scheme.
-
- Posts: 3
- Joined: Sat Mar 22, 2014 10:39 pm
Re: Driving multiple servos from the RaspberryPi
Hi everybody. I'm new with Raspberry Pi. After installing Raspian using NOOBS image (totally fresh), I downloaded the servoblaster from github:
Then compiled it:
Then I connected the wire: yellow (servo motor) -> P4, and configured the file:
But nothing happened. Did I miss anything?
Code: Select all
sudo apt-get install git
git clone git://github.com/richardghirst/PiBits.git
Code: Select all
cd PiBits/ServoBlaster/user/
sudo make
sudo ./servod
Code: Select all
echo 0=150 > /dev/servoblaster
Re: Driving multiple servos from the RaspberryPi
Did you connect some power to the servo? Did you connect a common ground line from the servo's ground to the Pi ground?
-
- Posts: 3
- Joined: Sat Mar 22, 2014 10:39 pm
Re: Driving multiple servos from the RaspberryPi
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)



(I guess the output pin cannot produce the pulse)


Re: Driving multiple servos from the RaspberryPi
Those photos are either old or you haven't done what the previous poster told you to do.
-
- Posts: 3
- Joined: Sat Mar 22, 2014 10:39 pm
Re: Driving multiple servos from the RaspberryPi
I didn't connect the batteries' GND with RPi's GND. Everything is fine now.
Thanks for all of your help.
Thanks for all of your help.
Re: Driving multiple servos from the RaspberryPi
Hi I'm with my raspberry pi and I can't get servoblaster to start working.
I cloned the github repo and installed it.
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.
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
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.
-
- Posts: 17
- Joined: Thu Jul 31, 2014 11:27 pm
Re: Driving multiple servos from the RaspberryPi
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.
-
- Posts: 5
- Joined: Mon Jun 25, 2012 7:49 am
Re: Driving multiple servos from the RaspberryPi
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
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
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
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..!)
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..!)