Site icon Evil Genius

Physical Computing with Servos and the Raspberry Pi

Giving The Raspberry Pi a Body

In this post I go over how to set up your Raspberry pi for servo based operations. When your done, you’ll have a solid, customizable platform To build a huge variety of robots and gadgets as well as the know-how To use it.

Hardware

First thing you’ll need is of course, is The Raspberry Pi 3B(+) or any model will do.

The perfect building block for any DIY gadget.

Next you’ll need a servo controller. I’ve used two kinds that work the same way:

The Adafruit 16 Channel Servo Hat:

The Adafruit 16 Channel Servo Hat– is an easy to use expansions board for the pi and gives it the ability to efficiently control up to 16 servos, the muscles of your robot.

Assembling the Servo Hat

Unless you’ve somehow found a preassembled servo hat, you’re going to have to solder it together. Could be fun for you, could be a chore but you’d only have to do ot once. And if you dont know about soldering, I’d highly recommend it as it’s a most useful skill for mostly any aspiring tinkerers arsenal.

Same But Different

If you absolutely refuse to solder however, there is an option! an amazing alternative to Adafruits servo hat would be the SunFounder PCA9685 16 Channel 12 Bit PWM Servo Driver for Arduino and Raspberry Pi

which needs no soldering, its smaller(like a pi zero) and uses the same code as the Adafruit hat.

This video does a great job explaining how to connect it to the pi:

Optional Gear

The CableDeconn USB to 5.5 mm/2.1 mm 5 Volt DC Barrel Jack Power Cable to power your servos with a regular portable USB charger.

Servos

Once you’ve chosen a servo controller, you’re going to need some actual servo motors, The “muscles” of your machines body that will move all of your inventions.

1st Tier Servos
Regular 9g servos like these

are perfect for experimenting and prototyping(it’s a terrible feeling to experiment with an high grade, expensive servo only to break it early on).

2nd Tier Servos

And when you are confident about your code and gadget set up etc, you may want to upgrade to metal geared servos.

More expensive usually but they certainly are more durable and tend to offer better performance than your typical blue nylon servos.

3rd Tier Servos

But my small servo of choice for more finalized gizmos would have to be the AGFRC Sub-micro Servo

For machines that need to handle more weight and/or deserve peak performance, my absolute favorite. (Its designated a size 13g but is usually pretty interchangeable to the regular 9g sizes.)

Standard Sized Servos

And lest we forget The mg996r Standard sized servo:

Bigger, badder, a little on the slower side but perfect for projects requiring some more kick or just bigger projects in general.

Configuring and Testing

Now that we gave our gear all set, it’s time to configure and test our hats with the raspberry pi.

As Always update the pi Everytime you plan on doing something new:

$ sudo apt-get update
$ sudo apt-get -y upgrade
$ sudo apt-get -y dist-upgrade

Next we get the Servo Hat to accept and communicate with the raspberry pi and then test the set up by following along with the Official overview. (Remember: both recommended hats work and set up the same.)

Make sure everything’s powered and connected and your results should look like this:

Eventually I developed my own customized servo control script based on the Adafruit test scripts. Using the fuchikoma.py as a base, i can easily add servo functionality to any python program. The git also includes an EvDev program to control your servos via keyboard. Enjoy 🙂

And that’s about all there is to integrating a reliable and robust servo system into your raspberry pi effectively turning it from a regular small computer into a robot capable computing device.

What’s Next?

I found Servos to be a gateway of sorts to projects of a much higher Calibur, encouraging me to go deeper and take a cracks at, say:Building my very own homemade robot! An obvious choice for anyone looking to build a body for their pi.

..Or even my very own cybernetic prosthetic which relies on a gesture control system so cutting edge, it can even work on amputees.

And it all started with these basics.

Well That’s all for now. Stay tuned for updates. Please like, share and consider showing support with a donation if you found this post useful. Your gratitude aids and abets my obsession and helps me get more gadgets to research so i can share more knowledge with the world. Thank you for finding me. Cheers! 🙂

Exit mobile version