Introduction: Hacking the Spy Video Trakr III: Make a Grabber Bot Out of Legos, Snap Circuits, and the Spy Video Trakr

About: You can try my projects AT YOUR OWN RISK. There's infinite ways to damage or destroy persons and property. I can't think of them all. Kids use adult supervision. I've lost count of the number of items that I h…

In this instructable I will demonstrate how to use Legos, Snap Circuits, and the Spy Video Trakr to create a remote controlled grabber bot. I will demonstrate how to download and install the C language compiler for the Trakr. Next I’ll explain how to compile a simple program and install it on the Trakr and then run this simple program. Then I will demonstrate how to open up the Trakr, attach jumper pins to the GPIO connections on the circuit board of the Trakr. With the jumper pins installed I'll show you how to tap into the 9 volt power supply of the trakr and make connection cables to connect to Snap Circuits and the Lego motor. The Lego grabber arm will need to be mounted on the Trakr so, I'll show you how to attach a payload deck made out of Legos. Finally I'll provide you with the C language code that you can compile and install on the Trakr to operate the remote controlled grabber bot.

The Spy Video Trakr is a remote controlled robot equipped with a microphone and color video camera, speaker, a near infrared LED for night vision, an SD memory card slot for recording audio/video and 8MB of on board memory for storing downloadable and user designed programs. The remote control unit has control levers to drive the robot, a speaker and color video display so you can hear the audio picked up by the microphone and display the video transmitted by the camera, and several function buttons that can be used to control additional program functions of user designed programs.

Please vote for this Instructable, "Make a Grabber Bot Out of Legos, Snap Circuits, and the Spy Video Trakr," in the Toy Challenge Contest. Go to https://www.instructables.com/contest/toy2/?show=ENTRIES and click the vote button (you may have to scroll through a few pages to find it).

I created this Instructable specifically to enter it into the Toy Challenge Contest. I have recently become interested in hacking toys as is evidenced by the numerous Instructables I have posted about hacking the Spy Video Trakr:

https://www.instructables.com/member/KRA5H/

I have posted these hacks hoping to inspire other Trakr owners to come up with their own new hacks for their Trakrs (and hope they post an Instuctable about their hack so I can try it too).

I am very interested in hacking the Parrot AR Drone. Unfortunately, I cannot afford to purchase the AR Drone, nor an iPad, nor an iPhone--not even an iPod to use as a remote control for the Drone. Obviously I hope to win the the grand prize for the Toy Challenge Contest so I can have an opprotunity to try hacking the AR Drone.

Step 1: Download and Install the C Language Compiler for the Trakr

What's a compiler? Have you seen those geeky T-shirts that say "there are only 10 types of people in the world: those who understand binary, and those who don't?" If you find yourself scratching your head instead of laughing hysterically, then you don't understand binary. Computers, on the other hand, understand only binary. 1s and 0s. On and off.

I have heard of some people who can do binary code, or machine language in their heads, but the rest of us normal people would have a difficult time writing a computer program out of nothing but 1s and 0s. Instead we use a higher level language like C language to write software.

Have you ever been to a foreign country and didn't know the language? You can hire a translator to translate what you say into the language that the locals can understand. That's what a compiler does. Computers can't understand C language so, a compiler translates the software you write in C language into machine code, or the 1s and 0s that computers can understand.

You'll need to download and install the C language compiler so that you can write programs for the Trakr and compile your software into machine language that the Trakr can understand. The C Language compiler is included in a fairly complete software development kit (SDK) that the folks at Wild Planet call the "Primer." So, download the Primer and save it on your computer where it'll be easy to find by clicking the following link:

http://www.spygear.net/help/files/TRAKR_APP_PRIMER_V1.2.zip

Step 2: Download and Install the C Language Compiler for the Trakr (continued)

Make a new folder in the root directory of your hard drive (usually the C: drive) called C:\trakr. Then open the Trakr Primer zip file you downloaded from the Trakr web site and copy all the files and folders from the Trakr Primer zip file into your C:\trakr folder.

Step 3: Download and Install the C Language Compiler for the Trakr (continued)

(Screen shot courtesy of Wild Planet)

Next you'll need to update the environment variables to include the path to the Primer's compiler and tools. If you don't know what environment variables are, don't worry, you're just telling your computer where to find the compiler and the tools it needs to compile your Trakr programs.

Open a command prompt, which is a Windows text based interface. Go to Start->Programs->Accessories->Command prompt. You will see a flashing cursor after the ">" and you can type text based commands. When you're done typing a command press the Enter key on your keyboard to execute the command. At the command prompt, type the following commands:

cd trakr

setup

cd Internals

Step 4: Download and Install the C Language Compiler for the Trakr (continued)

(Screen shot courtesy of Wild Planet)

The compiler runs when you type "make" at the command prompt so you need to make sure you navigate to the folder where the makefile you want to run is located. The compiler then follows any instructions in that "makefile" to convert the "app.c" file (the text file containing the source code) into a TRAKR program.

The compiler only looks for the "app.c" file in the current folder so always name your source code app.c. Save your programs in separate folders with names which make sense. This helps to keep all the various "app.c" files organized. As shown in the screen shot, you'll want to run "make clean" in the C:\Trakr\Internals folder. It reports all the files it is removing before returning the prompt to you. Then type "make" at the command prompt and the compiler will use the "makefile" to assemble all the parts of your program (which may include many libraries, images and files specified by your code) into a .bin file to write to the TRAKR hardware.

At the "C:\Trakr\Internals>" prompt type:

make clean

make

Your newly compiled program or app for the Trakr is called "Test.bin" and the file will need to be copied to the Trakr. Make sure the Trakr is switched off and connect it to your computer using the yellow USB cable that came with the Trakr. Copy Test.bin to the APPS folder inside the Trakr folder. Disconnect the Trakr from your computer and switch the Trakr on. Switch the Trakr remote on, click the home button, and select Test from the menu. It's just a little app that tests all the various functions that your Trakr can do such as motor tests, screen functions and so on.

Step 5: Install the Header Pins on the Trakr Circuit Board

(Photo courtesy of CPT Hans)

In this section, I'll show you where to install the header pins in the General Purpose Input/Output (GPIO) connections on the Trakr's circuit board. You will need the following:

1 40-pin headder. Sparkfun part# PRT-00116 ($1.50).
1 Jar of Wire Glue. Think Geek ($3.99).
Wire cutters. There are only 9 GPIO connections so, you'll want to cut 9 pins off the header and save the rest for other projects.
Phillips screw driver, size 1 (fits fastener sizes 2-4).
Toothpics to apply the Wire Glue

Step 6: Install the Header Pins on the Trakr Circuit Board (continued)

(Photo coutesy of CPT Hans)

Remove the back cover from the Trakr.

Step 7: Install the Header Pins on the Trakr Circuit Board (continued)

(Photo courtesy of CPT Hans)

Fold the antenna over and then flip the Trakr over so you can get at the screws that fasten the Trakr case together. Use the Philips screwdriver to remove the screws circled in the picture. The screw marked with a star is smaller that the rest so, remember to put it back in the same hole when reassembling the Trakr.

Step 8: Install the Header Pins on the Trakr Circuit Board (continued)

(Photo courtesy of CPT Hans)

Once you have removed the screws, lift the top cover of the Trakr off carefully. There are wires from the cover that are connected to the circuit board and there is an emblem that says "Spy Gear" on it that'll fall out. Don't forget to put it back in when you put the Trakr together again.

Step 9:

(Photo courtesy of CPT Hans)

These are the wires that are connected from the cover to the circuit board. The connectors for the wires are modular, but to make the Trakr more rugged, the connectors have been glued together. It is an annoyingly strong glue. I tried both rubbing alcohol and nail polish remover, but neither were able to dissolve the glue. So I had to use my pocket knife to cut through the glue.

On the microphone connector I thought I had cut away all the glue but I accidently pulled the entire connector off the circuit board leaving the pins sticking up from the board. It was easy to reattach the connected to the exposed pins, but since the microphone connector has a plus and minus side, I had to remember to reattach it back in its original orientation on the circuit board (or it could have fried the microphone).

Step 10: Install the Header Pins on the Trakr Circuit Board (continued)

(Photo courtesy of CPT Hans)

You will see two sets of connections on the circuit baord. The smaller set are Joint Test Action Group (JTAG) connections and are labeled "Jack4". Ignore them for now (not sure what to use them for, yet).

Jack3 is where you will insert the 9 header pins. The GPIO connections are labeled GPCO through GPC7. You will be using GPC) and GPC1 for this hack. You will notice that the header pins fit quite snugly into the GPIO holes and for a while I didn't bother to solder them down, but eventually after trying several hacks the GPIO holes will wear which will break the connection to the header pins.

Use a toothpic to apply the Wire Glue to the GPIO holes on the circuit board. Only use enough to glue the header pins to the board being careful not to let the wire glue create a short between GPIO holes (equivalent to a "solder bridge").

Step 11: Snap Circuits Jumper Wire 9Volt Battery Pack Tap

The Lego motor for the grabber arm requires 9 volts. Since I am going to connect the 9 volts to a Snap Circuits H-Bridge block, This part of the hack will require:

2 Red Snap Circuits Jumper Wire C&S Sales Part# 6SC J1 ($0.85 each)
2 Red Snap Circuits Jumper Wire C&S Sales Part# 6SC J2 ($0.85 each)
Motor Control IC for Snap Rover Part# 6SC U8 $19.95
Wire Cutters
Wire strippers
Shrink tubing or electrical tape

Cut the red jumper wire in half and strip about a quarter inch of isulation from one of the wire haves. Save the other half of the wire.
Cut the black jumper wire in half and strip about a quarter inch of isulation from one of the wire haves. Save the other half of the wire.

You can solder or Wire Glue the black Snap Circuit jumper wire half to the ground or negative solder point on the Trakr's circuit board. It is where the black wire from the battery pack is soldered to the Trakr's circuit board.

You can solder or Wire Glue the red Snap Circuit jumper wire half to the 9 volt or positive solder point on the Trakr's circuit board. It is where the red wire from the battery pack is soldered to the Trakr's circuit board.

Step 12: Lego Payload Deck

This is a payload deck that I made out of Lego Technic Beams.

I discovered that Lego cross axles fit snugly into the the mounting holes for the plastic payload deck that came with the Trakr.

The holes in the Lego Technic beams are very versitile and allow me to mount many kinds of external devices.

Step 13: Header Pin Connector

Next you'll need a way to connect wires to the header pins. I got the LED from an old computer. The LED was a Hard Disk Drive indicator LED. I've connected the LED to the headers pins GPC0 and GPC1 as an example.

Step 14: Make Conversion Cables

Next I made a header pin connector to Snap Circuits Jumper Wire conversion cable (left side of photo). I cut the wires from the LED, and stripped about a quarter inch of insulation from each wire. I stripped about a quarter inch of insulation from the red and black Snap Cicuit Jumper Wire halves that were left over from the 9 volt Trakr battery pack tap, twisted the wires together, Wire glued them, and covered them with shrink tubing to prevent short circuits from the exposed wire.

To make the Lego Technic Motor connector to Snap Circuits conversion cable (right side of photo), I cut the second set of red an black Snap Circuits Jumper Wires in half and stripped about a quarter inch of insulation from each. I cut  Lego Technic Motor connector, split the connector wires in half for about tow inches and stripped about a quarter inch of insulation from each wire. I twisted the wires together (one black and one red) Wire glued them, and covered them with shrink tubing to prevent short circuits from the exposed wire.

You may substitute elctrical tape if you don't have any shrink tubing.

Step 15: The Snap Circuits Motor Control IC (H-bridge)

This is a simplified H-bridge. The motor in the center is connected to the Trakr's 9 volt power and ground by four switches (S1, S2, S3, and S4). With all four switches off, the motor will not get any power and the motor will not turn. The switches can be turned on in pairs: S1 and S4 or S3 and S2 to allow current to pass from the Trakr's 9 volt batteries through the motor to the Trakr's negative or ground.

Step 16: The Snap Circuits Motor Control IC (H-bridge) Continued

If you close switches S1 and S4, current will flow through the motor and it will turn in one direction.

If you close switches S3 and S2, current will flow through the motor and it will turn in the opposite direction.

The H-bridge is a very simple circuit. Unfortunately it would be impractical to use manual switches to drive a motor from the Trakr. Several companies make H-bridge integrated circuits (ICs) that are easy to use by simply applying power to a particular pin also called "setting the pin high" to drive the motor in one direction. Cutting the power to that pin and applying power to another pin will drive the motor in the opposite direction. The circuitry inside the H-bridge ICs is somewhat complicated, so most folks will choose to use an H-bridge IC rather than building the circuit themselves.

Step 17: The Snap Circuits Motor Control IC (H-bridge) Continued

This is the Snap Circuits Motor Control IC, or H-bridge. At the top of the figure you can see the electronic schematic of the Motor Control block. On the lower left you can see a picture of the block. The lower center shows the pinouts for the block. And on the lower right is a description of what each pin does.

The next steps will demonstrate how to connect the Trakr to the motor control block and to the Lego motor on the Lego grabber arm.

The Lego grabber arm I used was from the book Robot Invasion by Dave Johnson, but here is a link to detailed instructions of another Lego grabber arm using the original Lego Mindstorms (not the NXT) technic parts:

http://pille.iwr.uni-heidelberg.de/~mindstorms/data/GrabberArm.pdf

Step 18: Connecting Up the Lego Grabber Arm

1. Connect the red Snap Circuits Jumper Wire half that is Wire Glued/soldered to the Trakr's 9 volt (positive) solder point on the Trakr's circuit board to the + snap (positive snap) on the Snap Circuits Motor Control IC.

2. Connect the black Snap Circuits Jumper Wire half that is Wire Glued/soldered to the Trakr's ground (negative) solder point on the Trakr's circuit board to the - snap (negative snap) on the Snap Circuits Motor Control IC.

Step 19: Connecting Up the Lego Grabber Arm (continued)

3. Connect the Lego motor to Snap Circuits conversion cable to the Lego motor.

4. From the Lego motor, connect the red Snap Circuits Jumper Wire half to the L+ Snap on the the Snap Circuits Motor Control IC.

5. From the Lego motor, connect the black Snap Circuits Jumper Wire half to the L- Snap on the the Snap Circuits Motor Control IC.

6. Insert the header pin to Snap Circuits Conversion cable to pins GPC0 and GPC1 on the Trakr's circuit board.

7. From the header pin connector, connect Connect the red Snap Circuits Jumper Wire half to the LF snap Snap Circuits Motor Control IC.

8. From the header pin connector, connect Connect the black Snap Circuits Jumper Wire half to the LB snap Snap Circuits Motor Control IC.

Step 20: Mounting the Lego Grabber Arm

Now add the Lego payload deck to the Trakr.

Step 21: Source Code

Finally, attach the Lego grabber arm to the Lego payload deck.

Here's the code:

                                 ////////////////////////////////////////////
                                 //Trakr motor control for Spy Video TRAKR
                                 //Program scans to see if button A was
                                 //pressed on TRAKR remote and sets GPC0 high
                                 //and GPC1 low to send current to the LF pin on the
                                 //Snap Circuits Motor Control IC truning the motor forward
                                 //
                                 //If button B is pressed, it sets GPC0 low
                                 //and GPC1 high to send current to the LF pin on the
                                 //Snap Circuits Motor Control IC truning the motor reverse
                                 ///////////////////////////////////////////

#include "svt.h"                 //include Official API
#include "JAPI.h"                //include "Secret sauce" API

#define GPC0 (1<<0)              //bitmask for pin GPC0 = 00000001
#define GPC1 (1<<1)              //bitmask for pin GPC1 = 00000010
#define GPC2 (1<<2)              //bitmask for pin GPC2 = 00000100
#define GPC3 (1<<3)              //bitmask for pin GPC3 = 00001000
#define GPC4 (1<<4)              //bitmask for pin GPC4 = 00010000
#define GPC5 (1<<5)              //bitmask for pin GPC5 = 00100000
#define GPC6 (1<<6)              //bitmask for pin GPC6 = 01000000
#define GPC7 (1<<7)              //bitmask for pin GPC7 = 10000000

int keyState;                    //define "keystate" as integer

void Start()
{
JAPI_SetIoOutputMode(GPC0+GPC1);//Set output mode for pins GPC0 and GPC1
}
bool Run()
{
    keyState=GetRemoteKeys();    //TRAKR remote control key pressed
                                 //assign to keystate
    if (keyState > 0)
     {                           //if keystate is greater than 0
       if(keyState&KEY_INPUT1)
        {                        //Button A pressed (motor forward)
            JAPI_SetIoHigh(GPC0);//Set GPC0 pin high (3.3v)
         } else {
            JAPI_SetIoLow(GPC0); //Switch off pin GPC0
        }
       if(keyState&KEY_INPUT2)
        {                        //Button B pressed (motor reverse)
            JAPI_SetIoHigh(GPC1);//Set GPC1 pin high (3.3v)
         } else {
            JAPI_SetIoLow(GPC1); //Switch off pin GPC1
        }
       if(keyState&KEY_HOME)
        {                        //if Home button pressed
         return false;           //this will end the loop
        }
    }
    return true;                 //loop will repeat until false
}
void End()
{                                //Program end - switch off both pins
JAPI_SetIoLow(GPC0+GPC1);
}



Here is the Make file:

# Makefile for TRAKR Toy
# Trakr Project

TRACKR_PATH = C:/Trackr
PROGRAM_NAME = trakrmotorcontrol
PRETTY_NAME = trakrmotorcontrol
OUTPUT_PATH = ./Intermediate
OUTPUT_NAME = $(OUTPUT_PATH)/$(PROGRAM_NAME).elf
INTERNALS_PATH = ../Internals

SOURCES = app.c
S_OBJECTS = $(OUTPUT_PATH)/app.o

OBJECTS = $(S_OBJECTS) $(INTERNALS_PATH)/trakr.a

SHELL = sh
CC  = arm-elf-gcc
AS  = arm-elf-as
BIN = arm-elf-ld
LD  = arm-elf-ld

TOPMEMORY=0xFFE7C000
CFLAGS = -O0 -I../Internals/Include -I../Internals -Wall -gstabs+
TARGET_FLAG = -mcpu=arm926ejs -mapcs-32 -mlittle-endian -specs=specs.semi
LDFLAGS = -T ../Internals/WJ_APP_8M.ld -Wl,--defsym -Wl,__stack_base=$(TOPMEMORY) -Wl,-Map -Wl,$(basename $@).map -nostartfiles -static

all: prebuild $(OUTPUT_NAME) postbuild

$(OUTPUT_NAME): $(OBJECTS)
@echo "Linking... "
@echo "Creating file $@..."
@$(CC) -u _start -o $@ $(INTERNALS_PATH)/trakr_start.a $(OBJECTS) $(TARGET_FLAG) $(LDFLAGS)

$(OUTPUT_PATH)/app.o:app.c Makefile
@echo "Compiling $<"
@$(CC) -c -o "$@" "$<" $(TARGET_FLAG) $(CFLAGS)

.PHONY: clean prebuild postbuild

clean:
$(RM) -f $(PROGRAM_NAME).bin
$(RM) -f "$(PRETTY_NAME).bin"
$(RM) -f $(OUTPUT_PATH)/app.o
$(RM) -f $(OUTPUT_NAME)
$(RM) -f $(MKDEPFILE)

postbuild:
arm-elf-objcopy -O binary $(OUTPUT_NAME) "$(PRETTY_NAME).bin"
@if [ -d "E:/" ] ; then \
  cp "$(PRETTY_NAME).bin" e:/APPS/ ; \
    fi
prebuild:




# End of Makefile


When you compile the above code with the above make file, this will create a Trakr App file called "trakrmotorcontrol.bin" and the file will need to be copied to the Trakr. Make sure the Trakr is switched off and connect it to your computer using the yellow USB cable that came with the Trakr. Copy trakrmotorcontrol.bin to the APPS folder inside the Trakr folder. Disconnect the Trakr from your computer and switch the Trakr on. Switch the Trakr remote on, click the home button, and select trakrmotorcontrol from the menu.

Here's a video of the Trakr with the Lego grabber arm:

http://player.vimeo.com/video/24143672

To quote Brian Benchoff from Hack A Day, "Not a bad build for what amounts to a pile of toys."

http://hackaday.com/2011/11/03/bomb-disposal-robot-with-lego-gripper/

In this instructable I will demonstrated how to use Legos, Snap Circuits, and the Spy Video Trakr to create a remote controlled grabber bot. I will demonstrated how to download and install the C language compiler for the Trakr. I explained how to compile a simple program and install it on the Trakr and then run this simple program. Then I demonstrated how to open up the Trakr, attach jumper pins to the GPIO connections on the circuit board of the Trakr. With the jumper pins installed I showed you how to tap into the 9 volt power supply of the trakr and make connection cables to connect to Snap Circuits and the Lego motor. I showed you how to attach a payload deck made out of Legos to mount the Lego grabber arm. Finally I provided you with the C language code that you can compile and install on the Trakr to operate the remote controlled grabber bot. Happy hacking!

Toy Challenge 2

Participated in the
Toy Challenge 2