Intro: Hack the Nabaztag.
This is a Nabaztag - Armenian, apparently, for "hare". It's an adorable bunny rabbit packed with sensors and communication devices.... and it's completely unusable. There's people who wrote some interesting software to hack it, and I applaud them: however, I could never actually get my Karotz (Nabaztag's third incarnation) through the arduous initialization. So, to gain full control over the Bunny, we'll have to do some hardware hacking.
This Instructable takes you through the dissection of a "Nabaztag/tag" and the re-assembly of the basic bits - ears, buttons, and LEDs - with all the code you need to hack one yourself. It doesn't have to end there, though - once you've embedded your own microcontroller, you'll have the flexibility to add whatever functions and sensors you'd like.
Step 1: Materials.
I use a Nabaztag/tag, but either the Nabaztag or Karotz will be fine for this, as we don't delve into the more complicated communications.
This is based on the Teensy 3.1, but virtually anything will do. In fact, if you're familiar with BeagleBoneBlacks or RasPi's and plan on doing advanced processing or communication (audio, bluetooth, wifi), use that, as it'll make your bunny way more powerful.
I used addressable LED strip (WS2811), but plain old LEDs will work fine if you just want them to turn on and off.
H-Bridge and Breakout board.
To control the motors, you need an H-Bridge chip. I use an SN754410 to control both motors. It's also good to get a breakout board for it so you don't have to solder directly to its pins.
Headers and sockets.
These are small and break into perfect-size pieces to fit into the existing plugs.
Hacker's screwdriver set.
The first set of screws you need to take out need a triangle screwdriver bit; the rest are all regular Phillips screws. I highly recommend this set as an excellent addition to your kit, if you don't have one already: http://www.ifixit.com/Store/Tools/54-Bit-Driver-K...
We're going to be connecting lots of I/O devices, so colorful wire is highly recommended to keep track of everything.
2 x 150 ohm
2 x 10K (or something within 5-20K range)
USB Micro cable.
Power/data to the Teensy. It's gonna be permanent, though, so make sure you don't mind sacrificing it for the project.
- Soldering kit
- Electrical tape
- Wire cutters/strippers
- Heat shrink
USB phone charger (Optional).
If you want to make your little guy portable, get one of these "lipstick" batteries. You can find them at best buy and even some drug stores, but they're cheaper online: http://www.ianker.com/product/79AN3K-PKA
If you like to test stuff out before hard-soldering anything, a prototyping board can be very handy. Line your Teensy with header pins and stick it in, then remove it when you're ready to build it.
To use my code, you need:
- Arduino environment
- Teensyduino driver
- Adafruit Neopixel library
Step 2: Dissection.
Pop the magnetic ears off and undo the four triangle screws on Bunny's underside; the whole thing should slide open.
All the I/O devices (except for the LEDs) are connected to the main board via quick-connect headers. Do NOT cut the wires: we'll be attaching our own headers later, so there's no sense in ruining the existing wires. Pry each one out of its plug; peel back the sticky gum that holds it in place with something pointy.
Keep unplugging and unscrewing until you have all the parts disconnected from the main blue board. If you want a full step-by-step, there's one here: http://www.petertyser.com/2007/03/11/nabaztag-nab.... The next step also lists all the parts.
Step 3: Parts.
Here's what we're going to use:
- On/off button (on its head)
- Scroll wheel (yellow, on its butt)
- Ear motors (DC motors, which control the ears through a plastic gear box)
- Ear encoders (blue chips at ears that 'watch' gear teeth for positioning)
There's some parts that you can use, but that I don't cover in this Instructable:
- Microphone (embedded in the black base ring)
- Speaker (on its back)
- Headphone jack
- Power jack (8V, 900mA, on the bottom of the black column)
- RFID reader (smaller blue chip mounted above main board)
- WiFi antenna (green board on its back, with the thin silver wire)
And finally there's some stuff on the main board, which I don't think we can reuse:
Step 4: INPUT: Head Button.
We'll start with the easiest bit: the on/off button on top of the bunny's head. Find the white and grey wires trailing down the side. If you take some wire and tin the ends just a little bit, they'll be perfect for sticking into the connector.
Grab your microcontroller and connect one wire to GND and one to a pin (it doesn't matter which). This one is a digital input pin, which means we're only looking to see if it's HIGH or LOW. Write your own code to test it, or use mine:
This script repeatedly checks to see whether the button is being pushed, and returns a 1 or 0 in the serial monitor. The signal is being 'debounced' - that is, accounting for any tremors in the analog signal.
Step 5: INPUT: Scroll Wheel.
The scroll wheel is a potentiometer: it measures voltage, which changes as we rub the 'wiper' up and down. This is an analog input, which the Teensy will convert into a number between 0 and 1023.
- BROWN wire to GND
- ORANGE wire to PWR
- RED wire to an ANALOG PIN
Write some code to read the potentiometer's values. They should be fairly steady as you "scroll" through them; for most purposes, you won't need any signal conditioning.
This script will return the scroll value to the Serial Monitor if the head button is held.
Step 6: OUTPUT: LEDs.
Since the Nabaztag's LEDs are embedded on the main board, we're going to have to build our own. First, decide what LEDs you want. You can use addressable strip to make shapes (a heart? a red nose?), or string a line of basic LEDs together, or connect several LEDs to different pins and leave them as spots, like the original.
For mine, I used five pixels from an addressable strip, cut and wired to make a zig zag. The wires should connect to 5V PWR, GND, and an output pin.
If you're using simple LEDs, use Arduino's "Blink" as an example for writing your code. See if you can get your lights to turn on when you press the head button.
In this script, you can click the head button to turn the LEDs ON or OFF. Use the scroll wheel to pick from one of 6 colors.
Step 7: An Enclosure for the LEDs.
Note that the LEDs on the main board have the cone of black plastic around them. This is to prevent the light from filling the inside of the whole rabbit, giving you a nice round spot of light instead.
To replicate this, take thin cardboard (such as from a cereal box, etc) or other stiff material, and cut a rectangle the shape of the original PCB. Include the holes so it can slide properly into place. Then, cut strips of cardboard about an inch wide and make walls to define the shape you want. It's easier to bend cardboard if you pass a blade along the fold line first.
Tape them to the cardboard rectangle, then put the bunny back together to see how it looks through the white plastic. If the bunny's cover doesn't fit, trim the cardboard to fit the contours; if the light bleeds out around the edge, add electrical tape 'flaps' that can bend and create a seal along the edge.
The first photo is my enclosure half-finished; the second is what it looks like inside the bunny. You can see how the walls define a nice, crisp edge, and where there is no wall, the light bleeds out.
Step 8: OUTPUT: Ear Motors.
Each ear's motor and encoder wires are located in the rainbow bundle on each side. The motor wires are BROWN and RED. If you connect one to GND and one to PWR, the ears will spin in one direction; if you swap them, they go in the opposite direction.
If you want the ears to be bidirectional, you will have to implement an H-bridge - a hardware switch that reverses a motor's polarity.
Each ear will have an ENABLE pin, which turns movement on and off; a FORWARD pin, and a BACKWARD pin. The H-bridge itself will be wired to PWR and GND, and lead two wires to the motor itself. Refer to the diagram above for wiring specifics; I use a double H-bridge: it controls both motors, but the ears are independent of each other.
Some important notes on writing code for the motors:
- In your setup loop, set each pin (enable, fwd, rev) to LOW before you enable them as outputs. As a general rule, it's a good idea to make sure moving parts are OFF before you plug them in. Do it for both ears.
- To STOP the ears, set the Enable pin to LOW to disable the circuit. As I understand it, it's safer to do this than set both FWD and REV to the same values (both HIGH or both LOW). Although any of the three will cause the motor to stop, there may be a slight risk of burning out/shorting out the motor in the latter cases.
- That being said, be careful that your code doesn't accidentally set both FWD and REV to HIGH or LOW at the same time (if you want to go forward, FWD should be HIGH and REV should be LOW). In fact, it's good practice to repeat yourself: even if you think a previous function set REV to LOW, set it to LOW again just in case if you're setting FWD to HIGH.
In my script, the head button turns the LEDs on and off, and the scroll wheel makes the LEDs change color. Every 2 seconds, each ear chooses a new movement - backward, forward, or stopped - and continues until unplugged.
Step 9: INPUT: Ear Encoders.
Moving the ears based on temporal intervals isn't particularly accurate - over time, or if the ear gets caught on something, the hardware can get misaligned with what the firmware *thinks* it's doing. To fix that, we have the encoders to tell us in which position each ear is at any given moment.
Each of the little blue chips has a small optical encoder on it: an IR LED and a receiver that senses it. As the ear turns, a gear's teeth pass between the LED and receiver, and turn it 'on' and 'off'. The gear is missing one single tooth, so the encoder knows: when its signal does NOT get interrupted by the gear's teeth, the ear is pointing forward. On tooth 3, ears point up; on tooth 13, they are horizontal.
On the rainbow wire bundle, the wires are:
- BLUE: the IR LED's PWR.
- GREEN: GND wire.
- YELLOW: the receiver's PWR.
- ORANGE: the receiver's signal pin.
Put a 150 ohm resistor on the BLUE wire.
Put a 10K resistor between the GREEN and ORANGE (that is, signal and ground) wires. (The encoder, for some reason, is designed to be "active high"; the Teensy can do input pullups, but in this case, the resistor modifies it to be a pulldown.)
Here is a scrap of code for testing your encoders:
Step 10: Wiring It Up, for Reals.
At this point, if you've been working on a breadboard, it's time to take it all apart and re-solder it permanently. This is going to be a MESS of wires, so pay close attention to where you route things - there's less space in that rabbit than you think!
My recommendation: take your break-apart headers, and solder your wires to them first, so that they are like breakaway extensions from the existing wires. Do everything but the H-bridge; that's a special case. Once you have extension wires on all 5 sets (head, scroll, LEDs, and two ears), temporarily mount the H-bridge and the Teensy somewhere on your cardboard block. Route wires as carefully as you can into their final places, and solder them into the Teensy. Finally, connect all the H-bridge wires to the motors and the Teensy.
As a review, these are the pins, as I've placed them:
- Head button 14 (digital input)
- Scroll wheel 21 (analog input)
- LEDs 2 (output)
- Left motor enable 7 (output)
- Left motor reverse 8 (output)
- Left motor forward 9 (output)
- Right motor enable 10 (output)
- Right motor reverse 11 (output)
- Right motor forward 12 (output)
- Left encoder 18 (analog input) (with resistor --> GND)
- Right encoder 19 (analog input) (with resistor --> GND)
The power should be:
- Head: NONE
- Scroll: 3.3V
- LEDs: 5V
- H-Bridge: 5V
- Encoder BLUE wires (with resistors): 5V
- Encoder YELLOW wires: 3.3V
... and you should have 6 wires going to GND.
Step 11: Putting the Bunny Back Together.
Once you have all the wires soldered and heat-shinked, it's time to wrap up.
First, make sure you've removed the existing power jack from the base of the black column, then thread your USB micro cable through the white base. If it doesn't fit, shave some plastic off the cord's head until it does. Plug it into the Teensy, and you're set for powering and updating your new Bunny.
Screw the black column back onto the white base. You don't need the black ring around the base anymore (though you can put it back if you like).
Gently wiggle the white case over the electronics and back into place. This might take a while. Just be patient - press wires out of the way, shave off more cardboard, add tape where needed - until it all fits again. It's important to get the alignment right, or the ears will get stuck against the body. If you run into this problem, place a thin washer-magnet between the ear and the socket to give the ear some extra clearance.
Put the screws in, and you're done - at least, with this part. But there's still so much you can do. Add the microphone back in to make it sound reactive; play mp3s through the speaker. Add proximity or temperature sensors. If you get really ambitious, use a Beaglebone or Raspberry Pi and get it WiFi enabled again, or try some fancy audio stuff. And even the Teensy can send and receive serial messages - connect it to your computer and have it react to stuff.
If anyone makes any changes or progress on this... leave me a comment and/or send some pictures!!!