rgh
Posts: 211
Joined: Fri Nov 25, 2011 3:53 pm

Re: Driving multiple servos from the RaspberryPi

Thu Oct 03, 2013 5:22 pm

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.

User avatar
clicky
Posts: 298
Joined: Thu Oct 25, 2012 7:34 am

Re: Driving multiple servos from the RaspberryPi

Thu Oct 03, 2013 5:55 pm

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.

rgh
Posts: 211
Joined: Fri Nov 25, 2011 3:53 pm

Re: Driving multiple servos from the RaspberryPi

Thu Oct 03, 2013 6:02 pm

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.

User avatar
clicky
Posts: 298
Joined: Thu Oct 25, 2012 7:34 am

Re: Driving multiple servos from the RaspberryPi

Thu Oct 03, 2013 6:09 pm

Oh - no - that wouldn't be right. I am just forgetting that those are not real devices. :(

Zeryk
Posts: 1
Joined: Mon Nov 18, 2013 10:35 pm

Re: Driving multiple servos from the RaspberryPi

Tue Nov 19, 2013 12:01 am

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.

rgh
Posts: 211
Joined: Fri Nov 25, 2011 3:53 pm

Re: Driving multiple servos from the RaspberryPi

Tue Nov 19, 2013 9:01 am

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

desihacker
Posts: 5
Joined: Mon Jul 15, 2013 2:48 am

Re: Driving multiple servos from the RaspberryPi

Mon Nov 25, 2013 2:01 pm

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

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: Driving multiple servos from the RaspberryPi

Mon Nov 25, 2013 2:05 pm

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.

JohnneyBoy
Posts: 8
Joined: Sun Dec 29, 2013 12:18 pm

Re: Driving multiple servos from the RaspberryPi

Sun Dec 29, 2013 12:26 pm

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

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

Re: Driving multiple servos from the RaspberryPi

Sun Dec 29, 2013 12:31 pm

The kernel version is probably deprecated.

Try the userland version instead.

JohnneyBoy
Posts: 8
Joined: Sun Dec 29, 2013 12:18 pm

Re: Driving multiple servos from the RaspberryPi

Sun Dec 29, 2013 2:47 pm

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

User avatar
mikronauts
Posts: 2708
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Driving multiple servos from the RaspberryPi

Sun Dec 29, 2013 4:50 pm

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

rgh
Posts: 211
Joined: Fri Nov 25, 2011 3:53 pm

Re: Driving multiple servos from the RaspberryPi

Tue Dec 31, 2013 12:50 pm

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).

rgh
Posts: 211
Joined: Fri Nov 25, 2011 3:53 pm

Re: Driving multiple servos from the RaspberryPi

Tue Dec 31, 2013 12:55 pm

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

User avatar
clicky
Posts: 298
Joined: Thu Oct 25, 2012 7:34 am

Re: Driving multiple servos from the RaspberryPi

Tue Dec 31, 2013 1:26 pm

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!

vdnguyen58
Posts: 3
Joined: Sat Mar 22, 2014 10:39 pm

Re: Driving multiple servos from the RaspberryPi

Fri Apr 25, 2014 4:53 am

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?

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: Driving multiple servos from the RaspberryPi

Fri Apr 25, 2014 8:19 am

Did you connect some power to the servo? Did you connect a common ground line from the servo's ground to the Pi ground?

vdnguyen58
Posts: 3
Joined: Sat Mar 22, 2014 10:39 pm

Re: Driving multiple servos from the RaspberryPi

Fri Apr 25, 2014 9:40 am

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

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

Re: Driving multiple servos from the RaspberryPi

Fri Apr 25, 2014 9:58 am

Those photos are either old or you haven't done what the previous poster told you to do.

vdnguyen58
Posts: 3
Joined: Sat Mar 22, 2014 10:39 pm

Re: Driving multiple servos from the RaspberryPi

Fri Apr 25, 2014 10:11 am

I didn't connect the batteries' GND with RPi's GND. Everything is fine now.
Thanks for all of your help.

Maschs
Posts: 2
Joined: Tue Jul 29, 2014 12:40 pm

Re: Driving multiple servos from the RaspberryPi

Tue Jul 29, 2014 12:45 pm

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.

mrmsbarnes
Posts: 16
Joined: Thu Jul 31, 2014 11:27 pm

Re: Driving multiple servos from the RaspberryPi

Wed Aug 06, 2014 7:15 pm

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.

CalcProgrammer1
Posts: 5
Joined: Mon Jun 25, 2012 7:49 am

Re: Driving multiple servos from the RaspberryPi

Mon Aug 25, 2014 2:20 am

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.

ktemby
Posts: 12
Joined: Mon Dec 01, 2014 3:46 am

Re: Driving multiple servos from the RaspberryPi

Mon Dec 01, 2014 3:53 am

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

ktemby
Posts: 12
Joined: Mon Dec 01, 2014 3:46 am

Re: Driving multiple servos from the RaspberryPi

Tue Dec 02, 2014 6:16 am

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..!)

Return to “Automation, sensing and robotics”