Tuesday, January 31, 2012

Why doesn't my circuit work?

Okay, so I finally managed to build something that didn't work! This is actually neat, since it represents a problem-solving challenge to be overcome, and something that goes beyond colouring in the lines. Well, apparently I couldn't colour in the lines, which is how I got here.


It looks like a fairly simple circuit. Basically, the motor is connected to ground at one end, and via a transistor to a 5V source at the other. Pin 9 there goes to the transistor, so pulsing that slowly ought to turn the motor on and off. There is also a diode, and I don't know what the hell it's for. To be more accurate, I don't know why it's necessary here, or what it's doing in this circuit. In general, the concept seems straitforward enough. I'm also not 100% confident I have the diode, the transistor or the various resistors the right way around.

The resistors, I'm pretty sure, could get plugged in backwards and still operate normally. The diode I realise will simply not allow current passed if plugged in backwards. Given that if I skip the transistor the motor spins, the diode 'must' be the right way in (assuming it's working correctly). So the fault seems to be with the transistor.

However, no matter how I connect the  transistor, it doesn't work correctly. One way, the motor is dead. The other way, the motor spins constantly. Total ignoring of the collector (Pin 9 there). Question: is it possible to break a transistor by sending current the wrong way through? How about with diodes?

Now, I did check. The transistor in NPN, which as far as I can tell translates as "on by default", so there is one explanation: Pin 9 is broken. I tried Pin 6, no luck. So I tried coding up a flashing LED to match the Pin 9 signal. The LED flashes as required, so unless both Pin 9 and Pin 6 are physically damaged on the Arduino, it shouldn't be that.

So, now I'm stuck. Without a multimeter (or maybe just some LEDs and alligator clips) I'm pretty much unable to determine which parts of my circuit are receiving the expected current. Did I short something out? Is my diode in backwards? What current is coming out of Pin 9?

Answers to all these exciting newbie questions, and more, in weeks to come.

In the meantime, to all you electrical engineers out there, I hope you enjoyed this brief sojourn into electrical bafflement :)

PS: Some people who spotted these photos on G+ have pointed out that the diode is likely present to protect against a back-spike of power coming FROM the motor as it spins down.

Saturday, January 28, 2012

Assembling the chassis

This post is going to document the assembling of the chassis. I purchased the Magician Chassis as the basis for my bot. Assembly was mostly straightforward, although I did need to do just a little hackwork along the way to bring it together. The finished product looks like this:



It's not the greatest photo ever, but you get the idea. There are two motors, one attached to each large wheel. There is an additional rear "trackball" thing which bears the weight of the rear end. The construction is sturdy-ish. Certainly it doesn't seem like it's going to break during construction, but it should definitely not suffer a drop.

The kit comes with instructions, which kind of mostly cover what you need to know. In addition to the instructions and this blog post, there is a similar blog post available here: http://www.hobbytronics.co.uk/magician-chassis-build. It's probably more useful than this post, but this is my story :)

Here is a photo of the kit parts, unassembled:



The process begins by attaching the motors. This turns out to be medium level tricky, where easy is "goes according to the instructions" and hard would be "I basically had to MacGuyver it from first principles". My main issue was there there are some little red things which look like gears which attach to a spindle on the side of the motor. THESE APPEAR TO HAVE NO FUNCTION. Even after assembly, no function.


You can see the red thing here. One of my red things needed to have the whole expanded carefully with a Stanley knife in order to accept the spindle. Bolting the struts on was not too bad, although it's a darn tight fit. I had to rotate the struts 180 degrees even though they look pretty symmetrical. They do go on. Anyone who knows what those red things are for, please let me know.

Attaching the wheels is a matter of shoving them onto the outside spindle of each engine. They don't fit very well (no satisfying push... click). So I hope they don't come off, but it seems okay.


Attaching the trackball is super easy. No worries there, although I might lubricate the socket at some point. The base is now completed! The leads running off the motors strike me as a bit of a catching hazard, I think it would be better to put some electrical tape on to help run them up to the upper level where they will attach to the Arduino later on, but I'll do that at another point in time.

The next step is to put the base right-way-up and attach the battery housing. The battery housing is terrible quality, and in a stupid place. The worst thing about it is that the screw-holes are so close to the edge that you can't actually put a screw in. I had to cut down the edges with a Stanley knife. I hope this isn't a problem later.


See the screw? You can see it through the hole I cut to allow the head through.

From here, it's a doddle to finish assembly. Screwing on the spacers and the top level is super-easy, leading to the finished product:


As you can see, the battery housing is in a near-inaccessible location. The HobbyTronics post I linked to earlier said they pulled it out and housed it on the top level, which certainly makes sense. However, I figure I should follow the rules before breaking them, so there is the finished product!

Of course, right now it doesn't DO anything, because I haven't wired up any power or attached the Arduino to control the motors. However, it was a great evening's work and took a little under two hours from fetching my equipment to a finished product and a clean workbench again.

Friday, January 20, 2012

Some inspirational material

This video does a fantastic job of expressing the sentiment and excitement around building a basic autonomous robot....

http://t.co/6ioJYoCI

Thanks, that guy! (http://www.instructables.com/member/Brandon121233/)

Monday, January 16, 2012

It's here! It's here!

Okay, so now my Arduino journey can begin in earnest. Why now? Because it arrived today! Squeee!

So, I thought a short unboxing post was in order. Obviously, I couldn't possibly wait until this evening at home to open it, so here are my on-the-desk photos. I'll follow up with some more later when I've actually had the opportunity to perform some construction or investigation.


Inside the SparkFun Inventor's Kit

The great, the only, Arduino Uno

I haz a "Magician Chassis", a "Sparkfun Inventor's Kit" and a "Soldering Iron". I presume that's enough to get in trouble with....

Thursday, January 12, 2012

Amateur robotics: getting started

So, here's the start of a blog series which I plan to use to document my tinkering with my soon-to-arrive Arduino board. For those who don't know, Arduino is an open-source electronics, um, computer board thingy with lots of i/o pins you can used for sensors and effectors. It can also be hooked up to a mobile phone (or cellphone for any North American readers), which can interface with the Arduino board. This can be done using Java, or even Python (thanks to the SL4A interpreter). No phone hacking required!

So I intend to thoroughly document my process, and share it here. This is really for myself, but anyone else who is interested in amateur robotics might be interested in following along my story as a complete newbie at this stuff.

So, the beginning...

I just placed my order for the following items:
 -- http://littlebirdelectronics.com/products/sparkfun-inventors-kit-for-arduino
 -- http://littlebirdelectronics.com/products/magician-chassis
 -- http://littlebirdelectronics.com/products/ioio-for-android
 -- http://littlebirdelectronics.com/products/infrared-proximity-sensor-short-range-sharp-gp2d120xj00f

My hope is to be able to build something like this:
 -- http://www.youtube.com/watch?feature=player_detailpage&v=9cVSzB8otpU#t=13s

But I'll have to start right from the very beginning:
  -- http://www.youtube.com/watch?v=fCxzA9_kg6s

Wednesday, January 11, 2012

Self-deprecating code

I want code that will raise a warning if a method is called that hasn't been used in six months. That would be awesome. By this I mean:
  -- A log of unused methods
  -- A log of uses of crufty old methods which might not be reliable