RoboSheep

I got inspired to build something that has been bouncing around in the back of my mind for a while:

A stuffed animal that turns it’s head to watch you! I figure this would be a fun way to build a simple robot, and would also serve to spook out house guests (and my wife!) :)

Last week, I ordered a Basic Stamp from Parallax — a most excellent beginner’s microcontroller. A microcontroller is a very cool thing — it’s like an entire computer on a single chip. You can plug each pin in to a servo or button or any other input or output, and get it to interact with its environment. The only drawback is that the microcontroller is slow, and only has a little RAM. The one I got has only 8 bytes! Of course, it only costs $15… I definitely recommend this board for anyone getting started in robotics or micro controllers.

Anyway, I built my robot into a stuffed sheep my wife had. I used Parallax’s PIR sensors for the eyes. These are infrared motion sensors. I figured that if it senses motion only in the right one, it should turn the head right. If it senses motion only in the left one, it should turn left.

This basic idea worked fine, although there were some problems with the sensors.

First, the sensors were way too sensitive — the slightest thing would set them off. This was due in part to the fact that they have a very wide field of view. This is good for a security system, but for my robot, if one sensor saw motion, they both did, making it difficult to tell which direction the motion was coming from. I countered this by cutting out paper “irises” for the PIR sensors, which you can see in the pictures below. This turned out to be pretty easy.

Next, the sensors take a long time to reset. They basically send a 0 or 1 to the CPU: 1 means there is motion, and 0 means there isn’t. This worked fine, and when I moved my arm, it sent a 1. However, it takes 2-3 seconds for the sensor to reset back to a non-motion state, even if I stop moving. There are a variety of reasons for this, and you can read up on how PIR sensors work to learn why, but the problem was that the head would always turn too far. Also, since the motion sensors were mounted on the turning head, they would constantly detect motion!

The solution here was to turn the head when motion was detected on one side, but then wait a few seconds before looking at the sensors again. This worked great, but unfortunately means that the stuffed animal won’t be able to track motion smoothly.

The last problem I ran into was that the motion sensors don’t provide any sort of degree of the motion sensed. Therefore, we don’t know how far to turn towards it. 90 degrees? 45? My solution was to turn the head some random amount within a small range. If it turns out this amount was too small, the robot will detect more motion the next time its sensor resets and turn some more. if it was too much, then the next iteration it will turn back to correct. if it was just right, then it will detect motion with both detectors and stop turning.

Incidentally, by the way, a regular human will almost constantly set off a motion detector pointed at them. They are sensitive enough that even breathing motions can be detected unless you are specifically trying to hide. The end behavior is that if there is a person in the room, the robot will turn towards them, slowly zeroing in on looking right at the person. Also, because the servo is embedded in a stuffed animal, the sound is muffled, and pretty silent. Basically, it looks like any other stuffed animal, except that if you sit in the same place for a while, you will notice that it seems to be looking at you. And, unless you happen to be looking at it exactly when it turns its head, you won’t know what’s going on! Excellent — exactly what I wanted :)

There are some drawbacks. Since the sensors are so simple, multiple people in the same room will confuse it. Also, because the sensors are infra-red, they can be confused with an air conditioner in the room, or by opening the window on a hot day. But overall, those effects are negligable.

All in all, this was a great project. I haven’t really build a robot or my own circuit before without any instruction, and this project took me maybe 6 hours, including reading the manuals, learning pBasic, figuring out how to wire everything, and tweaking the code. Total cost was $65, including shipping for all the parts, but not for the stuffed animal :)

Attached is the pBasic code which I have running right now, as well as some photos of the robot. I think my next step is going to be to put the Basic Stamp board inside the sheep, so it isn’t so conspicuous. :)
Feedback / Comments welcome!

RoboSheep 4RoboSheep 2RoboSheep 1RoboSheep 3

‘ {$STAMP BS1}
‘ {$PBASIC 1.0}

SYMBOL Servo_pin = 0

SYMBOL Temp = W0
SYMBOL Temp2 = W1
SYMBOL Rand = W2

SYMBOL RSensor = PIN1
SYMBOL LSensor = PIN2

Init:
Rand = 55

Main:
RANDOM Rand
Rand = Rand // 8
Rand = Rand + 8
PAUSE 2300
Temp = RSensor
Temp2 = LSensor
DEBUG Temp, Temp2, ” ”
IF Temp = Temp2 THEN Center
IF Temp > Temp2 THEN Right
GOTO Left

Right:
DEBUG “Right”
FOR temp = 0 TO Rand
PULSOUT Servo_pin,120
PAUSE 30
NEXT
GOTO Main

Left:
DEBUG “Left”
FOR temp = 0 TO Rand
PULSOUT Servo_pin,190
PAUSE 30
NEXT
GOTO Main

Center:
‘FOR temp = 0 TO 2
‘PULSOUT Servo_pin,150
‘PAUSE 20
‘NEXT
GOTO Main

Posted in Myself, Programming
12 comments on “RoboSheep
  1. yxjrxdfujb says:

    Hello! Good Site! Thanks you! eioiszqdtt

  2. marklen says:

    How do you sleep at night knowing that lamb is watching you? Don’t be suprised if that sheep turns evil! ;P

  3. Robot Two says:

    FB, good question!
    Actually, it doesn’t really matter. Once the program is translated to the microcontroller’s assembly code, “IF Temp” equates to something like “IF Temp != 0,” which ends up being about equally efficient with “IF Temp> Temp2″

  4. FB says:

    Nice and simple project and as Alan said, a video would be much appreciated.

    Also I just have to ask.
    Wouldn’t it be better to use IF Temp THEN Right instead of IF Temp > Temp2 THEN Right?

  5. bharath says:

    Awesome, quite interesting.
    Do update me about your future projects like these..

  6. A nonymous says:

    8 bytes? … 8 kbytes sounds better …

  7. Alan says:

    Great job! What you need is some action on video to show it off!

3 Pings/Trackbacksfor “RoboSheep”
  1. […] Make a robosheep for your shagging/amusement By CyberChrist Very nice introduction to robotics.read more | digg story This entry is filed under General News. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site. Leave a Reply […]

  2. […] Very nice introduction to robotics.read more | digg story Links […]

Leave a Reply