Introduction: Spy Video Trakr: Add a Lego Claw Attachment

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 honor of National Robotics Week and the Instructables Robot Challenge I am submitting a few robot designs. This design (for ages 13-18) takes advantage of Wild Planet's Spy Video Trakr, which is easily programmable and designed by its developers to be hacked.

The 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.

If you take a moment to review this Instructable: Spy Video Trakr: Add a Missile Launcher https://www.instructables.com/id/Recycle-The-Spy-Video-Trakr-Add-a-Missile-Launche/, you will notice that I have designed my Trakr hacks without having to use soldering irons and hot glue so that younger kids can try these hacks. Unfortunately since Wire Glue is designed for ages 10 and older, the age group for National Robotics Week and the Instructables Robot Challenge are ages 13 to 18. Younger kids can try these hacks with the supervisoin of an adult. The two solderless alternative used in this Trakr hack are Wire Glue conducting glue and Snap Circuits.

Snap Circuits by Elenco is an educational toy that teaches folks about electronics with solderless snap-together electronic components. Each electronic component has the electronic schematic symbol and a label printed onto its plastic case that is color coded for easy identification. They snap together with what appear to be ordinary clothing snaps—hence the name Snap Circuits. The components also snap onto a 10 X 7 plastic base grid, which is analogous to a solderless breadboard.

There are several Snap Circuits kits that range from a few simple circuits to the largest kit that includes 750 electronic projects. All the kits include manuals printed in color with easy to follow diagrams to assemble the projects. The illustrations for each project look almost exactly like what the components will look on the base grid when finished. Because the electronic symbol is printed on each electronic component, once the project is completed, it will look almost exactly like a printed electronic schematic.

In this Instructable you'll learn how to add a Lego claw attachment to the Spy Vidoe Trakr. You'll learn how to download and install the C language compiler for the Trakr. You'll learn how to install jumper pins on the Trakr's circuit board to control external devices such as the Lego claw attachment. You'll learn how to add a common ground and 9 volt power tap for your Trakr hacking projects. You'll learn how to build a versatile cargo deck for the Trakr out of Lego. You'll learn how to build the Lego claw attachment. You'll learn how to connect the Lego claw to the Trakr. Finally you'll learn how to program the Trakr to operate your Lego claw attachment.

Step 1: Download and Install the C Language Compiler

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.

Download the Compiler Zip File

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

(see pictue 1 above)

Copy the Primer Files to the C:\trakr Folder

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. (see picture 2 above)

Update Windows Environment Variables

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 (see picture 3 above):

cd trakr

setup

cd Internals

Make a Test File to Verify Compiler Installed Correctly

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. (see picture 4 above)

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 2: Installing the Jumper Pins on the Trakr's Circuit Board

This section will briefly explain how to disassemble the Trakr and install the headers. Please note that this project is not difficult, but it does require some patience.

If you are inexperienced or uncomfortable soldering on a printed circuit board, you can follow the instructions to disassemble the Trakr, and either use Wire Glue (special conductive glue--see picture 1) to glue the header pins to the to Trakr's circuit board or you can take it to someone who can solder it for you.

The GPIOs and the Analog to Digital converter (ADC) are inputs and outputs that can be used to control things. They share a .1" pitch header. The JTAG is a programming/testing port that uses a 2mm header. You'll learn how to install both the GPIO and JTAG headers, but you can just install the GPIO header if you want.

Parts Needed

The GPIO header is part # PRT-00116 ($1.50). It is a 40-pin header. Since we only need 9 pins, that one part is enough for 4 Trakrs! (see picture 2)

The JTAG header is part # PRT-10112 ($0.95) from Sparkfun http://www.sparkfun.com for the JTAG header. It's 10 pins; we only need 7, so we can just snip off the extras. (see picture 3)


http://www.sparkfun.com/search/results?term=header&what=products

Wire Glue conductive glue can be ordered from ThinkGeek for $3.99

http://www.thinkgeek.com/gadgets/tools/b70c/?srp=1

You'll need these additional items for this project (see picture 4):
- Trakr
- #1 Phillips screwdriver
- Fingernail polish remover
- Cotton swabs
- Exacto knife (or similar hobby knife)
- Soldering iron
- Solder
- Vacuum desoldering tool (aka 'solder sucker'...hey, nobody's perfect, and you may have to fix a mistake!)

Remove the White Plastic Cover

Start by removing the two screws for the back cover. Throughout this project, be mindful of the antenna, and don't break it! (see picture 5)

When that's done, you can look in at the mainboard, and see where we're going to install the headers. (see pictute 6) If you have decided to use Wire Glue conductive glue to glue the headers to the Trakr circuit board, you can glue them down now and skip the rest of the Trakr disassembly instructions an go to the next Instructables step.

Remove the Black Plastic Cover

You'll want to fold the antenna over and then flip the Trakr over so you can get at the screws that fasten the Trakr case together. Use a philips screwdriver to remove all the case screws (you can ignore the battery and reset compartment screws). There are a total of 12 screws to remove. Note that the screw marked with a star is shorter than the other 11, so keep track of it. (see picture 7)

Once the cover screws are removed, you can pull the upper and lower housings apart. When you do, the emblem on the front will fall out. No worries. There's also another piece behind it that will now be loose. Set them both aside, and remember to replace them when reassembling the Trakr. (see picture 8)

With the upper housing moved aside, you can see the shiny screws holding in the mainboard. Resist the temptation and don't remove them yet! (see picture 9)

Once the cover screws are removed it's easy to lift the cover enough to see most of the main board. When opening up the cover remember to be careful. There are a number of wires that are connected between the cover and the mainboard. The connectors for the wires are modular, but to make the Trakr more rugged, the connectors have been glued together. I don't know what kind of glue Wild Planet used, but it must be UFO technology from Area 51! It's tough stuff! This is where the fingernail polish remover and patience are employed. (see picture 10)

Dealing With Circuit Board Connector Glue

With a cotton swab, apply fingernail polish remover to the glue to soften it up. It will probably take more than one application. Allow the polish remover time to soak into the glue. Use the hobby knife to trace along the connector joints, and to peel the glue away from the connectors. Note that the connectors also have two tabs molded into the plastic so they'll latch together. I used the knife to release the tabs, once the glue was cleaned away. (see picture 11)

With the connectors unglued and separated, you can now set aside the upper housing (see picture 12). If while trying to separate the connectors, you end up pulling the whole thing off the board, don't fret. The pins on the board will still be okay. If you look at picture 12, you'll notice that I accidentally pulled the whole connector for the speaker off of the left front leaving the pins sticking up from the board. It was easy to reattach the connectors to the naked pins once I got the connector separated. It is easy to reconnect the connector to the pins and they will hold quite snugly, but if you want you can use a hot glue gun to reattach it to the circuit board. Keep in mind that the connectors for the push button and the speaker are non-polar meanining it won't matter which way you reattach the connectors to the pins. On the other hand, the microphone connector needs to be reconnected exactly the same way it was accidently disconnected because it is a polar connector. It has a plus side and a minus side and if you reconnect it the wrong way you won't be able to hear anything from the microphone and it could burn out the microphone.

Camera Ribbon Cable

Before you take the main circuit board screws out, there's another connector to unhook. This flat white ribbon cable is on the right front of the Trakr, and is for the camera assembly. It's a pressure-type connector that holds the ribbon cable against the contacts of the socket. To release, slide the little brown tabs (they're actually connected and run underneath the ribbon cable) forward about 1/8" and the cable will slide right out. (see picture 13)

Remove the five main circuit board screws, and unhook the connector to the USB port from the bottom. I left the power leads from the battery pack soldered on, since I had enough freedom of movement even with them connected. (see picture 14)

Solder the Headers

At this point, it's a simple matter to insert the headers into the holes on the mainboard, and solder them in. Good solder joints are smooth and shiny like these (see picture 15). Ensure that none of them are soldered to their neighbor (solder bridge).

Now reverse the disassembly process to put your Trakr back together!

Step 3: Add a Common Ground and 9 Volt Power Tap for Your Projects

You'll want to add a common ground for your Trakr Hack projects. Since you'll have the Trakr opened up anyway, might as well add a 9 volt power tap the the positive solder point on the Trakr. In the spirit of creating Trakr hacks with solderless alternatives I used Snap Circuits jumper wires.

You can see how the Snap Circuits jumper wires that are connected to the Trakr's ground and 9 volt power tap are used to power a different style claw in this Instructable: https://www.instructables.com/id/Make-a-Grabber-Bot-Out-of-Legos-Snap-Circuits-an/

You'll need:

1 Black Snap Circuits jumper wire (picture 1)
1 Red Snap Circuits jumper wire (picture 2)

Snap Circuits parts or whole sets can be ordered from  C & S sales http://cs-sales.net/snapcircuits.html

Simply cut the Snap Circuits jumper wires in half, remove about 1/2 inch of insulation from the jumper wires and then Wire Glue or solder 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. Wire glue or solder 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. See picture 3.

You can use the unused jumper wire halves to make Snap Circuits conversion cables. See picture 4.

The cable on the left is a USB to Snap Circuits cable so I can connect Snap Circuits devices that require 5 volts from the USB port on the Trakr. The cable in the middle is a header pin to Snap Circuits cable so that I can connect a Snap Circuits block directly to the GPIO header pins on the Trakr's circuit board. The cable on the right is a Snap Circuits to Lego cable so I can connect a Snap Circuits block to a Lego technic motor. They were easy to make. Remove about 1/2 inch of insulation from the jumper wire and the wires I wanted to connect them to, twisted the wires together, and covered them with shrink tubing to prevent short circuits from the exposed wire (you can also use electrical tape).

Step 4: A Versatile Cargo Deck

Next you'll want to design a way of mounting the devices you want to control on to the Trakr. The deck in picture 1 was made from Lego technic beams.

Picuture 2 is the Lego Deck disassembled. I discovered that Lego cross axles fit snugly into the the mounting holes for the plastic deck that came with the Trakr.

Picture 3 shows the Lego cross axles inserted into the mounting holes for the plastic payload deck that came with the Trakr. I find that the holes in the Lego Technic beams are very versitile and allow me to mount many kinds of external devices.

Step 5: Build the Lego Claw

I found a cool design for a lego claw here: http://www.nxtprograms.com/claw_car/steps.html. All of the steps are for a claw car, but for this instructable we just need to build the claw part so, I've only included the steps to build the claw part. The last two pictures (26 and 27) show you how to complete the Lego claw attachment for the Trakr.

Step 6: How to Connect the Lego Motor to the Trakr

Picture 1 (source: http://mindstormsnxt.blogspot.com/2006_08_01_archive.html) is a diagram of the pinouts for for the NXT motor.

Here's a description of the pins:

Pin   Function
1       Motor signal 1 (from 0 to 9V)
2       Motor signal 2 (from 0 to 9V)
3       Ground
4       Encoder power (5v)
5       Encoder signal 1 (0 to 5V)
6       Encoder signal 2 (0 to 5V)

To Drive the NXT motor you only need to work with pins 1, 2, and 3. Pin 3 is ground, or negative (-). If you supply 3.3 volts from the Trakr to pin 1 and zero volts to pin 2 the motor will turn in one direction. Conversely if you supply zero volts to pin 1 and 3.3 volts from the Trakr to pin 2 the motor will spin in the other direction.

There are a number of methods to make a conversion cable to connect from the NXT to the Trakr availalble on the web and there are some companies who specially make conversion cables. I, however, did not wish to cut up my NXT cables because they are kinda pricey. So, this was one of those "What would Macgiver do" situations.

Fortunately there was a new business moving into the building where I work and building maintenance was doing some construction on the offices. Maintenance had thrown out those combination network and telephone wall jacks and I grabbed a couple to toss into my spare parts box.

Many office telephone systems use six wire modular telephone cords rather than the standard household two wire cords. Thus, the wall jacks had an RJ45 network connector and an RJ12 telephone connector (six wire modular connector). Now I have a method of interfacing the NXT motor to the Spy Video Trakr circuit borad header pins.

If you look at picture 2 (source: http://www.philohome.com/nxtplug/nxtplug.htm) you will notice that the RJ12 connector and the NXT connector are slightly different. The clip that holds the connector in is in the middle of the RJ12 connector, but on the NXT connector it is on the right of the connector. In my information technology work I have found that these clips often break off, but the connector is still usable. So, I broke one of the clips off one of the connectors on my NXT cable and filed the remaining plastic down so it would fit snugly into the RJ12 plug.

I removed the RJ12 plug from the wall plate. See pictures 3, 4, 5, and 6.

Next I created a hole through the plastic cover. I cut out the entire "R" in TRAKR including the drop shadow and this makes the perfect sized hole for the RJ12 plug. See pictures 7 and 8

To make the connection between the RJ12 connector and the header pins on the Trakr circuit board, I took and LED connector from and old computer (it was the "turbo" indicator to give you an idea how old the computer was) and cut the wires to the LED connector. I punched down the black wire into the pin 1 punch down on the RJ12 connector and the yellow wire into the pin 2 punch down on the RJ12 connector. See pictures 9, 10, 11, 12, 13, and 14

Now you are ready to put the plastic cover back on the Trakr. See picture 15.

I punched down the Snap Circuits jumper wire that is connected to the Trakr's ground on the circuit board (see step 4) to pin 3 on the RJ12 plug as close to the snap as I could which forces the snap to be on the outside of the plug since there is no room to fit the snap on the inside of the plug. The Snap Circuits jumper wire was thicker than the LED wire so, it was a little harder to punch it down. The I connected the LED header connector to pins GPIO 0 and GPIO1 on the Trakr's circuit board. See picture 16.

I replaced the plastic Trakr cover. I plugged one end of the NXT cable--the one where I did not break off the fastening clip--into the NXT motor. I plugged the other end of the NXT cable the one where I DID break off the fastening clip--into the RJ12 connector on the Trakr. See picture 17.

Finally added the Lego cargo deck to the Trakr and connected the NXT claw attachment. See pictures 18, 19, 20, and 21 

Step 7: Program the Trakr

C Language code:


                                 ////////////////////////////////////////////
                                 //trakrmotorcontrol program 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 through motor
                                 //in forward direction                                 //
                                 //If button B is pressed, it sets GPC0 low
                                 //and GPC1 high to send current through
                                 //motor in reverse direction.
                                 ///////////////////////////////////////////

#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);
}



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. Use the Trakr's remote contol to drive the Trakr to the object you want to grab. Aim the Lego claw attachment to close in around the object you want to grab and press button A on the remote control to grab the object. With to object held in the claw, drive the Trakr to the location you want to bring the object and press button B on the remote to open the claw and release the object.

Congratulations! In this Instructable you learned how to add a Lego claw attachment to the Spy Vidoe Trakr. You learned how to download and install the C language compiler for the Trakr. You learned how to install jumper pins on the Trakr's circuit board to control external devices such as the Lego claw attachment. You learned how to add a common ground and 9 volt power tap for your Trakr hacking projects. You learned how to build a versatile cargo deck for the Trakr out of Lego. You learned how to build the Lego claw attachment. You learned how to connect the Lego claw to the Trakr. Finally you learned how to program the Trakr to operate your Lego claw attachment.

Robot Challenge

Participated in the
Robot Challenge