ServoBlaster and “The Face”

Image

4 servos and a few decorations. A great introduction to servo control.

Here’s a bit of fun…

It’s just four servos connected to yet another ServoBlaster buffer board. Some simple Python programming can be used to create a variety of expressions. The advantage of this as a starter activity is that it’s really quite easy to make and yet works so well.

There’s a good range of emotions that can be shown – happy, sad, angry, confused. With a random number generator in Python, it’s possible to get it showing all sorts of faces.

I’m intending to upload a video of this in action shortly, once I’ve got my head around the processes involved…

Python Program:

import time
import os
import random

shortdelay=1
DELAY = 0.2

left_eye = 0
right_eye = 1
left_mouth =2
right_mouth =3

def pwm(pin, angle):
    print("servo[" + str(pin) + "][" + str(angle) + "]")
    cmd = "echo " + str(pin) + "=" + str(angle) + " > /dev/servoblaster"
    os.system(cmd)
    time.sleep(DELAY)

def random_face():
        for movements in range(0,10):
                le_move=random.randint(75,225)
                pwm(left_eye,le_move)

                re_move=random.randint(75,225)
                pwm(right_eye,re_move)

                lm_move=random.randint(75,225)
                pwm(left_mouth,lm_move)

                rm_move=random.randint(75,225)
                pwm(right_mouth,rm_move)

                time.sleep(2)

while True:

        random_face()

Servoblaster – a daemon for driving servos from the Raspberry Pi.

Well… I tried a serial to servo controller which worked fine, but required nearly a second between commands (0.88 seconds to be precise) and didn’t maintain the pulses for any longer than that time. It was okay as a proof of concept, but no good for controlling servo speed from my Python program. The alternative was to download and install ServoBlaster.

I did damage one Raspberry Pi by connecting the servo straight to the outputs. Not sure what the problem was as I was being careful. It seemed better economy to create a buffer board.

This buffer board safely interfaces between the Raspberry Pi and up to eight servos. It can also be used to drive LEDs if they are wired correctly.

This buffer board safely interfaces between the Raspberry Pi and up to eight servos. It can also be used to drive LEDs if they are wired correctly.

The buffer board is single sided and uses a 74LS245. I’m being a bit lazy as the ‘245 is intended to be a bi-directional tristate buffer and I’m forcing it to work in one direction. The advantage with this is that the inputs and outputs are pretty much in line. I can minimise the number of links required and ensure that only a single-sided board is needed. An alternative might be the 74HC541, but I didn’t have these and I’d have to re-design the board. Maybe another day…

Servoblaster Board

The files for the buffer board are at the bottom of this post.

Here are the files for the buffer board. It uses a 26 way connector for GPIO, a bunch of 3-way connectors for the servos, 74LS245 octal buffer, 7805 regulator and a couple capacitors to keep the power supply happy.

Circuit Wizard – ServoblasterInterface- Normal Circuit Wizard – ServoblasterInterface-artwork Circuit Wizard – ServoblasterInterface-proto

ServoBlaster and “The Arm”

The next challenge was to try to create a simple robot arm that could be easily cut out on a CAM router and assembled with a glue gun, and yet be sufficient to demonstrate some programming techniques. It actually works rather well although it is a bit lightweight and has a tendency to skip across the table. It also misses the target pieces if someone fiddles with them, but that’s not the fault of the robot…

This robot is made of foamed PVC board, cut on a CAM router and assembled with hot glue.

This robot is made of foamed PVC board, cut on a CAM router and assembled with hot glue.

I’ve uploaded a few files for “The arm” in PDF¬†format but I also have them in wmf and dxf so maybe others can make use of them. However, I can’t upload them here as they’re not supported without me having to pay…

ServoRobot РPage2 ServoRobot РPage1 RobotArm- dimensions

ServoBlaster and “The Head”

I’ve been working to create a servo controlled head and a servo controlled robot arm over the past few months and it’s starting to produce pretty encouraging results. I did damage a Pi – not too sure how – so I built a simple buffer board to prevent that happening again.

Image

Some servo extension leads soon made the wiring easier, and it’s great fun to run the head along with espeak handling voice. My next goal is to have it reading RSS news feeds or perhaps the weather.

This version of “The Head” has been made using artist’s foam-core board which is really easy to work with. It’s a polystyrene sheet with a layer of good quality paper on each side. It can be cut with a craft knife and glued together with a glue gun.

Another alternative is a PVC sheet material known as Foamex. It cuts well in a CAM router and it is also possible to cut it with a craft knife or a coping saw.