Tuesday, 2 December 2008

Can it be done ?

Free Web Counters
Free Counter

Well, there are many conversations that start off down the pub about stupid gadgets and devices, and here is the story of one of them that made it into reality. So we are all sitting down the pub after work and we are all passing around the latest gadgets that people had bought, there was the inevitable i-Phone and i-touch and i-this and i-that. Everyone got to have a play and as we were browsing away on the i-phones net connection. I happen to mention that if there was a standard USB port on these sort of devices, you could attach all sorts of rubbish for example USB Missile launchers, toothbrushes, lamps, lights and all the other wacky USB stuff that seems to have spawned itself since the invention of the little plug and play port on the side of every computer. After a few more beers had been drunk the conversation rapidly degenerated into what great devices out there that should be USB-enabled, for example, the USB toaster (for handy snacks at work), the USB micowave, kettle etc.... until one of our work colleagues (who had obviously had too much christmas cheer) blurted out "how about a USB Rampant Rabbit". Well, half the people round the table fell about laughing, the other half had no idea what she was talking about (mostly the male workers). After 10mins of explaining what the Rampant Rabbit(TM) was, and what it did, everyone was back on the same level. Now the innovative juices really started flowing, and people were throwing in all sorts of ideas of how it might work and what you could use it for. We got a good hour of humour out of the idea and we all went home laughing.

The idea was then forgotton, until two days later, when I passed the said colleague in the lobby, the conversation went along the line of
"You made it yet ?" ...
"made what ?"...
"that USB thing we were laughing at down the pub"...
"errr nope"
And thats what started me thinking, could it be done ?, how would you do it ?, is it indeed possible. So I embark on the quest... to make the first home made prototype USB controlled internet enabled Rampant Rabbit(TM).

My line of work is IT prototypes and investigations, so this should not be too impossible, the 1st step would be to order up one of these devices, pull it apart and see just what would be involved in converting it to be USB-enabled. So after a few hours perusing a well known online shop I came up with the model I was going to have a go at converting. I did not want anything too complex for the first attempt, so I picked a basic model with two sets of controls. There seems to be a control switch to operate the main motor part, and there looked like there was a second control to operate the secondary motor. (all this was pretty tricky to work out from the picture on the website and they don't give any detailed PDF specs on the workings of these devices.. how unusual ??)
So I pays my money and click in my order for one of said devices.
And sit back and wait for it to turn up.....

Under the bonnet of a Rampant Rabbit !

So two days later the large brown parcell arrives at my door, (which I sign for quickly... as the postman gives me a knowing wink) How do these guys know ? I am mean they must know the packaging from every online store or something. NIGHTMARE !. So then unpacking the stupidly large amount of packaging I eventually retreive said item. It is all packaged up in more layers of plastic that on a food product in a supermarket, and I have to liturally cut my way through to it. I now hit my first problem, NO BATTERIES, I have of course did not add them to my order and the thing requires 3AA batteries before it is gonna start. So I now have to run round the house to liberate all the AAs from my TV remote controlls etc, which now leaves me unable to change TV channels (I make a mental note to buy batteries). So I fire the thing up and see what happens.

Well for those of a nervous disposition (or have yet to understand) I shall endeavour to explain. This Rabbit comes with two motors, Motor one controls the main part of the device, and causes an interesting rotating wobbling motor to make the whole thing move. There is also a second smaller motor to control the "Rabbits Ears" which uses a variable vibration device to make the ears oscilate at high freqency. As you can see from the picture, the device has 2 control switches that enable the motors to be set at 5 diffrent speeds. These can be set indepenently and each switch controls a diffrent motor (I have removed the tops of the switches in the photo so you can see better how the sliders operate)

The next step is to have a look at what is going on underneath the bonnet of this thing....

I remove the batteries and locate some small screws which hold the top of the device together, and this should allow me to get at the circuit board. (the idea being, to put a meter on it and see what is going on) The top comes off fairly easily and I can now see the main circuit board in the device.
As you can see there are 2 slider switches (one I have removed) and these basically complete a circuit between a ground rail (the long copper strip) and 5 more copper strips (the broken copper rail). Each of these settings removes more and more resistors (you can see them, blue for the main motor, and brown for the rabbits ears) from the circuit making the motors go faster on each setting of the slider switch. Not too complicated then... sooo far.

The whole board is held in place by the little screws as well as some plastic posts in each corner, and the it is also soldered directly onto the terminal posts of the battery compartment which sticks through the plastic surround to make contact with the board.

The next step is to remove the board from its case, so we can have a closer look....

The board comes out fairly easily and by sticking a meter inline with the motors we can see just how much current each of them pulls from the battery. I enlist the help of techno geek friend, as this is going to envolve some electronical calculations and he is a bit of an expert in this field. We work out the big motor is going to need about 1amp, and the smaller one about 0.8amps. This of course is going to be far to much power than I can get out of a USB port directly. We are going to have to use some sort of isolated circuit / relay to control the main motors from the USB side, otherwise we could do some serious damage to the USB port.

Thats enough for today, am going to have to do some research and come back to it....

Will have to spend a couple of hours googling stuff and come up with a plan.

Research and Development..

So, the next evening we reconvene, and start to work on a plan.

I have a way of controlling the USB part already, I am going to use the Velleman experimental USB board.This is a handy bit of kit, even though it is obviously far too large to use for a finished product, it will be ideal to test the prototype. It gives me a number of inputs / outputs, both digital and analogue as well as some sample software to enable us to test the theory of whether we can get it to work.

We intend to use the 2 analogue out channels from the board, which will give us a variable 0-5V supply at a about 200mA, we can use this to power a relay / transistor or what ever we come up with to power the motors. Here you can see the 2 analogue output channels with 2 LED indicators. They both use a simple common ground and we can then use the inbuilt software to control the voltage.

We do a bit of research and find that a great way to do the control is to use an Opto-isolator.

Opto-isolators, or opto-couplers, are made up of a light emitting device, and a light sensitive device, all wrapped up in one package, but with no electrical connection between the two, just a beam of light. The light emitter is nearly always an LED. The light sensitive device may be a photodiode, phototransistor, or more esoteric devices such as thyristors, triacs etc.

This makes them ideal for this type of job.
We can make up a circuit similar to the one above, where the two side are isolated by the opto-isolator (means we can't blow up the USB end) and we can then use the optoisolator to power a transistor, to regulate the two motors.

We sit down and do some calculations on what we are going to need to buy and we come up with.
1: A 2 channel opto-isolator TLP-624-2 (a channel to control each of the motors)

2: A couple of 560 ohm resistors to regulate the voltage into the optoisolator (R1 in the diagram)

3: A couple of transistors (BD136) these are to allow the power to the 2 motors. They are quite big transistors, but are spec up to 1.5amps and will cope if the motor is ever "jammed" and starts to pull more current than normal. (best to be safe than sorry)

4: 2 Diodes, to protect the transistors if the motors ever get wound backwards, and start generating a reverse current.

A quick trip down to the local electronics store and we have all the bits we need. I also got some Vero strip board on which to mount the circuit, and already had some wires etc to make up the terminals. (you notice I have 4 transistors here, the others are BD140s which are slightly higher rated and we can substiture in, just in case the others get a bit too hot.)
The other bit you may notice is the 8 pin socket for the optoisolator chip, this will make life much easy when soldering (and there is no danger in messing up the chip through heat damage)

We sit down and draw out the diagram and mark up what we gonna put on the board and where, then we leave it as it is getting late. (and the pub has opened)

We will start constuction... tomorrow.

Construction begins !

OK... so today we start on the construction. The first thing to do is to make up the new circuit board to mount in to the handle of the device. We did this by measuring up the strip-board to the original control circuit. This was cut to shape the the appropriate hole drilled to make sure it could be mounted correctly. This was a tricky process as this meant that some of the copper strips were now not completely connected which would mean we would have to plan our circuit diagram pretty carefully.

The circuit board would hold the main components including the attachments to the USB control board, so I also made a small hole in the rear of the handle so that the lead that would attach to the base of the device would fit cleanly and the wires would not be fouled by the case.

We mapped the components out on the board and then fitted into place for a test.

Here you can see the new circuit board in its place, with the 4 wires that countrol the motors now showing, these would all be wired on the board including the battery terminals and control leads.
Next we added the 1st set of components, here we have soldered on the opto-isolator socket as well as the 1st 2 resistors. (the control leads would be added last as it makes the soldering job more tricky)

The 2 control leads were soldered into place (along with the common ground) and the rails tested for connectivity, before we connected it up to the USB board.

Here you can see the control leads all connected and a basic test was done to see if the opto-isolator was responding as designed.. (yep all tested good) we get a resistance drop across the output of the opto-isolator if we adjust the voltage on the USB board (we getting somewhere). We now have the controlling part of the circuit working fine.

The rest of the components were now soldered onto the board, including the two battery terminal wires (shown red and black) these would be looped through and soldered onto the exposed battery terminals.
The new completed control board was now offered up into place and a complete test was done.
Using the software we could now operate the main motor on channel one as well as the bunny ears on channel two, there now proceeded a small break of 40 mins while we drank beer, pissed ourselves laughing while we buzzzzzzed the device all over the dining room table. The pick up on the main motor was slightly behind the smaller one, but this would not be a problem as we can fix the motors start point in the software. The great thing is you now get complete linear scalability on each motor. No more ratchetted steps of speed, more like a smooth transitition from 0-100. (I sound like Jeremy Clarkson...now )
Here is the completed device with the top re-attached. The new circuit board is in place, with the transistors having to be bent over slightly to allow the board to fit into place. The whole thing screws together nicely, with the battery compartment underneath.
And here is the finished product....
A working USB controlled Rampant Rabbit (TM) the next step would be to make the USB control board smaller. Or what would be better would be to blu-tooth enable it. (designs are being drawn as we speak) The software will be easy to write, as I have complete development kit for the USB board so we can now get a simple client / server type application running. Although we did to a simple internet test using a remote desktop to control the device over the net. It WORKS !!!!
So in conclusion, YES you can make a homebrew Rampant Rabbit.
If anyone is interested .. the cost for the replacement board is under 5 pounds. (of course this does not include the price of the rabbit)
All we need now is some beta testers !!... and some market research.