WLAN phone operated tank with webcam – hardware

Intro

A few years ago I bought a “bifferboard“.  This amazing little computer is about the size of a box of matches, and has the computing power of, well, about a Pentium 100.  But it’s good enough to run a headless Linux environment.  After I bought my bifferboard I was impressed with it, but couldn’t really come up with anything to do with it, so it languished in my parts drawer.

After idly looking at some youtube videos of people who had glued Arduiono boards into RC toys, I had the idea to do something similar with my old bifferboard.  Using a more complete “PC” inside the model has several advantages:

  • Quicker development as high-level languages can be utilised.
  • Direct access to USB devices (webcams etc)
  • Linux platform base

The disadvantage is that I/O would have been done through an intermediate board.  Although the biffer has some GPIO pins, Arduiono and similar boards will have TTL compatible lines.  I’d have to add those myself.  In the end, this turned out to be much easier then I expected.

One of the things I wanted out of my project was a roving webcam.  Other ideas I had at the outset were that it should be able to make noises; one of the things I’d done before with the bifferboard is to use flite as a text-to-speech engine.  The biffer is just fast enough to render speech in a timely way, and if I could get my tank to talk it could be cool.

Why a tank?  Well why NOT. 🙂 Tanks have advantages compared to cars: they can turn on the spot, which would be useful for the webcam.

Bought-in Bits

Heng Long Radio Remote Control US M41A3 Bulldog Smoking RC Battle Tank

Remote Control tank, before it was dismantled

I got this from Amazon for about £80.  It is ready to run and comes with a charger and 7.2V battery pack.  It even has cute little accessories like plastic men to stick atop the tank.  I chose this tank after finding out that some other companies sold “upgrades” (for the motors, gears etc).  This indicated that the tank was customisable and could be dismantled easily without breaking it.  Also, looking at some pictures of the guts showed the motors in the rear of the body with lots of room in front, which I would need for the bifferboard and other electronics.

As it turned out, I was sad to take this apart as it was great to play with.  The tank itself is well built (good enough to play outside when the weather is dry), and of fairly thick plastic, though the transmitter is shockingly crappy.  The tank has a rotatable turret, moveable (up and down) gun barel, and it even shoots plastic ball-bearings!  It was this feature which lead me to take the thing apart on the day I bought it – the shooting mechanism on my tank was broken.  Not to worry, as I didn’t want this anyway.The tank also has the usual assortment of lights (LEDs) and sounds.

On taking the tank apart and removing the RF control gear, etc, I found I had the ideal base for my computerised tank.  Not only was there lots of room for my additional electronics, but I could re-use the battery compartment, power switch, motors, etc. There was even a speaker which I could reuse.  I also had spare motors, LEDs etc.Dual USB bifferboard with case

Bifferboard mini PC in half its case

I started out with a regular single USB bifferboard, but I managed to fry the main circuit board somehow.  The 2 port is slightly larger, but it has the advantage that, with the addition of the 4 port hub, I now have 5 useable USB ports for the tank.  I had hoped to make use of the memory card slot, but this wasn’t practical as, when inserted, a memory card sticks out by about 1.5cm.  In the confines of the tank “tub”. this is a lot!

The rough spec for one of these bifferboards is:
  • Approx 150Mhz i386 compatible CPU, without FPU
  • 32MB RAM
  • 1 onboard ethernet NIC
  • 2 USB ports
  • 5V power supply required (@200mA)
  • Runs pretty much any flavour of linux.
  • £45

4 port USB hub

USB hub after removing case and superflous LED

There are literally hundreds of different USB hubs out there on the market.  But the tank’s requirements are a little special, because of the limited space.  The one I settled on has the ports arranged in a 2 by 2 setup, and the connecting cable (to the PC) is built in, and nice and short.  This minimised the space needed in the tank.  I further saved space by stripping off the plastic shell.  This hub came with a “night light” (it’s for laptops, apparently).  Not much use – it was quickly unsoldered – but it’s a nice “free” (and bright) LED to add to the collection.

Vellman VM167 USB I/O module

VM167 with shortened USB cable

This is my solution to the problem of I/O pins.  This was actually the second board I tried.  I first used another Vellman part, the K8055 (purchased from maplin), but it turned out that this board was much to big to fit inside the tank. I hope to use this in another project.  The K8055 is great because it has screw terminals, push buttons for simulating inputs, and even pots for simulating analog signals, but as far as actual use the VM167 fits the bill and I highly recommend it for anyone wanting a solution to getting TTL signals in and out of a PC with the minimum of fuss.

The VM167 has the following inputs and outputs:
  • 8 TTL input/output lines, configureable as either inputs or outputs in 4 bit slices
  • 2 TTL PWM outputs
  • 5 analog inputs (0V .. 5V), at 10bit resolution
  • Linux C API (3rd party, for some reason Vellman do not support Linux themselves)

This is a terrific little module, at a cost of about £30 from the nice guy at www.esr.co.uk.  As I found out through trial and error, the TTL outputs are easily powerful enough to light some high-power LEDs, thus separate driver circuity is not needed when driving moderate loads, like collections of LEDs.2GB USB memory stick

USB memory stick

Any old memory stick would have sufficed, with 2GB of storage being easily enough for a substantial Linux distribution (see later on for a description of the software).

For space reasons, it is sometimes nice to be able to strip away the plastic cases for various devices, but in this instance the memory stick I used was nice and small already.  Plus it meant I wouldn’t be “destroying” the pendrive.

USB 5.1 Stereo Sound Card Adaptor

USB audio dongle

I was nervous about ordering this – it only cost about £2 after all – but it seems to work well enough.  Delivery took about a month from China.  Driver support on Linux is good for USB sound devices, and this one is no exception.  It has a few quirks, and it is not as easy to use as the Pantronics USB sound adaptor I have kicking about, but for the money I wont complain.  The case was removed to save space (another great thing about this little device is that it is only about 5cm from the plug end to the 3.5mm jack end).

Logitech webcam C200

Webam PCB, after stripping down

This has a number of factors in its favor:

  • UVC compliant so works well with Linux
  • Small size
  • Integrated microphone (though I haven’t made any use of this yet)
  • Fairly cheap
The webcam was stripped down (as you can see in the picture), and the USB cable was shortened.  The mic presents itself as USB audio, so it should be possible at some point to be able to make the tank record, or relay live, sound.  While I could use a mic plugged into the USB sound adaptor, using the webcam is better as the webcam is already nicely placed to “listen”. I’m pleased with the picture quality, and the build quality, of this little webcam.  Of note is the fact that the USB cable is socketed and not soldered directly onto the PCB, which was handy when “re-purposing” this webcam.

Realtek USB WLAN adaptor

Realtek USB WLAN

I bought this from a Currys shop on a whim, and a hope that it would work on Linux.  USB wireless support is one of the few things that remains patchy on Linux, but luckily this adaptor works well.  Annoyingly it does not operate in Access Point mode, which means the tank will never be able to operate as self contains wireless network.  Also, the power usage seems quite high.  None the less, it works well.

Power and Motor Driver Board

The bought-in components wont do a lot on their own; I still had to figure out how to drive the track motors, and what would power the bifferboard computer.  This was before I even thought about writing some software to control the thing.

I used to buy alot of electronic components from maplin, but the prices are (sorry to say) horrific.  So I went to Rapid instead for my bits.

Essentially I needed a circuit that did two things:
  1. Convert the 7.2V battery power into 5V for the bifferboard
  2. Drive the two track motors from the TTL signals from the VM167 board

Power Supply

The first thing is the simpler of the two.  There are many voltage regulator ICs on the market, including the venerable (and somewhat junk) 7805.  After looking at the spec sheet, I realised that the 7805 is not really meant for such a “small” drop from 7.2 to 5V.  It’s minimum input voltage is about 8V.  So I looked for an alternative and found the LM2940CT-5 (PDF).  It is pinout the same as the 7805 but can take inputs down to about 6V.

Power supply circuit
After making up this circuit on a bit of stripboard, it was time to try to power the bifferboard from the original 7.2V battery that came with the tank.  Hooking everything up was fairly easy; the power lines on the tank went through a switch hidden at the bottom of the tank, and then onto a standard 0.1″ pitch plug.  Two PCB pins on the stripboard receive this plug.
Power supply section of stripboard

From top to bottom:

  1. 7.2V line, from the power switch in the bottom of the tank
  2. LM2940, with heatsink
  3. Couple of smoothing caps
  4. 5V plug (hot-glued)

The two PCB pins and the two screw terminal blocks are for hooking up other 5V circuits.

There is no parity notch on the PCB pins of course.  Unfortunately the first time I hooked things up the parity was wrong.  Some smoke from the caps resulted but, seemingly, no real damage.

After getting the parity right, success!  The bifferboard booted up under the power of the 7.2V battery.  This was the first real sign of progress.  Unfortunately I immediately spotted a problem: the regulator was getting very hot, to the point where it couldn’t be touched.  This wasn’t good, and shows how inefficient these voltage droppers are.  The voltage drop, times the current, is effectively turned into heat.  At 2.2V divided by 7.2V, this means about 30% of the power is wasted from the battery.  Not good.  Replacing the regulator with a switching power-supply (you can get some miniature ones which are pin-compatible with the 7805 for about £10 of ebay), which are much more efficient was a logical next step, but first I decided I would have a go at driving the motors.

I bought a small clip-on heat sink for the regulator, in the hope it might help dissipate the heat, and thus extend the regulator’s life, but I’m not sure it’s made much difference.

Motor Control

The next step in the quest to get the tank moving under computer control was to figure out how to drive the track motors.PWM (Pulse Width Modulation) is a technique to send “variable” signals based on the length of a pulse.  So if the “1” signal is present for 50% of the time, the signal is at “half”.  For devices like motors and LEDs, this means they would be driven at roughly half-brightness or half-speed.  The VM167 handily comes with two PWM outputs, one for each track motor.

In addition, the VM167 has ordinary digital outputs.  While there are at least two ways to drive a motor a motor in two directions (when combined with a PWM signal) the simplest is to use two outputs, one for forward and one for backwards.  When neither signal is set, the motor should be stationary, regardless of the PWM output.

The next problem was figuring out how to drive enough current into the motors.  There is no way the VM167 would be up to this task.  In my experience of playing with other RC models, some cars use big motors which are rated at up to 8 Amps.  This could have been a problem, since high currents are more work to deal with.

After doing some research I found these little beauties: the L293E (PDF).  It is a stepper motor controller, rated up to an Amp.  It can drive either a 2 channel stepper or 2 ordinary motors, forwards and backwards.  It looked ideal for my needs, though the single Amp rating was a concern.  But looking at the thickness of the wires on the tank motors made me think an Amp should be enough to drive the tank reasonably well.

The circuit is fairly simple.  Here only a single motor driver is shown:

Motor controller circuit

The schematic shows a L293D, but I actually used a L293E.  The parts are almost the same; the ‘E has 4 extra pins for “sense” (which I did not use).  In anycase, there are similar parts available from other manufacturers, such as the SN754410 (PDF).

This particular IC has two power pins, one for logic (VCC2 in the diagram) and one for the load.  This is handy as it means the 5V “bifferboard line” can be used for the logic side of the motor driver, whilst the motor side of the driver is connected directly onto the 7.2V battery line.

The three resistors act as pull-ups, for when there is no input connected.  In this case, pull-downs would have worked as well, except in the case of the PWM input which I wanted to be “optional”.  Using pull-ups means if it is not connected it will float high.

The PWM input is connected to the “Enable” pin, whilst Forwards and Backwards inputs are connected into the respective inputs on the driver IC.  The motor is connected between the 3Y and 4Y pins (labeled Output 1 and Output 2 in the datasheet).

The four diodes act to block return currents from the motors.  They are positioned “backwards”.  In my case I only used them on one of the motors (the one on the turret motor, which we will come to later).  For the main track drive motors I omitted them and haven’t seen any problems.

After drawing out the circuit for the motor driver, it was time to solder it up on the same piece of stripboard as the power supply.  This turned out to be easier then expected, and for good measure I attached a PC memory heat-sink to the L293E as it was certain to get hot.

VM167 plugged into the combined power-supply and motor driver board.  The blue heat-sinks cover the L293E ICs.

It was then time to see if I could drive the track motors!  But for that, I would need some software….

To come…

In the next post I hope to describe the software used to control the tank, as well as present a video of the tank in action, showing the functionality implemented so far.

In the mean time, as teaser, here is a video of the tank under bifferboard control.  This was taken just after I had the motors driving through a commandline program, which in turn was run via SSH.  Apologies for the portrait orientation…. It seems the video is now broken.  Ah well.

1 thought on “WLAN phone operated tank with webcam – hardware

  1. LBIndigo

    Hi, I was looking for a Linux driver for the VM167 board with no succes. It seems you have found one. Can you indicate where you have it from ?

    thanks, Luc

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.