Java Circuit Simulator

While looking for HackerSpaces in my area, I came across the Philadelphia HackerSpace Hive76. Apparently the group has an Art of Electronics class, and while looking through their wiki – I found an excellent Java applet that gives examples as to how many common circuits work.

Circuit Simulator: That's where my electrons went.

Thanks to Hive76 for linking to this electronics resource. Paul Falstad has done a great job putting this simulator together, I definitely recommend it.

The Great Internet Migratory Box Of Electronics Junk: Excavating a box.

I recently received a Great Internet Migratory Box of Electronics Junk (man is that hard to say in the proper order).

The rules are simple: Sign up for a box (or start your own), dig through it and document (in some form) what you’ve taken  from the box and what you’re doing with it, and ship it off to the next person in line. I feel bad that I’ve been sitting on this box for longer than I should have (normally no more than 7-14 days)… but with work, other projects, a house, and not enough sleep lately, progress has been a bit slow. (My apologies)

Let’s go digging:

I’ve found some use already with large capacitors and solenoids (and my Electronics Learning lab kit)… and a small handful of other parts are going into an upcoming project that I plan on writing up (that’ll happen soon). Adding  a few items to the box, and off to the post-office on Monday to keep this thing in circulation.

Video Game Creation using Blender, Gimp, and Allegro

I had an enjoyable assignment in a college course on the C language the other day – using the Allegro libraries, write a game of your choosing.

The assignment coincided with my recent discovery of Blender, the 3D mesh animation and design tool. Out of boredom on a recent weekend afternoon, I found Blender in a series of random Google searches… and dedicated the better part of 3 weeks teaching myself the ins and outs. (Surprisingly EVERYONE I know already knew about it, I’m not sure how Blender eluded my radar).

The entire movie Big Buck Bunny was created in Blender

So many people are familar with Blender  in fact, that there are hundreds of YouTube videos (and even  DVDs) covering practically anything you’re looking to do.

My first job was to model an alien – one similar to one of the enemies in a great game from my childhood – Commander Keen. (Side note: I first got the game from one of the many mail-order shareware companies that were popular before the Internet was in practically every home.)

Simple enough, the Alien is basically 3 spheres and 2 cylinders. After 30 or so iterations, I finally had one I liked.

My inspiration (from Commander Keen)
My Tribute to Commander Keen

Learning to paint took about 2 days of watching video after video trying to figure things out. Part of that time was devoted to me hunting down the cause of  a “bug”, which I later learned was a default setting in vertex paint.

This is not a boog.
With the Painting Mask enabled (the 'F' key)

The freenode #blender channel had plenty of knowledgeable users that convinced me that I wasn’t dealing with a bug in my install

Probably the best thing about Blender is that even I (having no real graphical talents), was able to create a decent looking object with a small amount of effort. And  I could then animate it, using armatures and a tutorial by Ira Krakow.

Citronella is Evil: The Action Editor and Timeline

After creating a few other random objects (some of which looked just plain pathetic), I ended up with a small stable of characters – and thankfully an assignment where they could live.

The Allegro programming library is a well documented, easy to use programming library that handles the tough parts of graphics programming – getting objects onto the screen. As with everything – where does one start?

Having two weeks to start and finish a game, I decided another childhood staple would be the perfect game to write – Jetpack.

Just a fun game.

Jetpack had a lot of great things going for it – fun game, re-playable (especially since it had a built in level editor) , and one of my favorite things – a jetpack. Jetpack could easily be thought of as Lode Runner with the ability to fly.

XScavenger is a fun Linux port of Lode Runner

While digging through Allegro’s online manual and chatting with other users on freenode (trying to  figure out how I could write this thing), my storyline inspiration played on my Last.FM stream – “Let’s save Tony Orlando’s House“, a great song by Yo La Tengo about Frankie Valli setting fire to  Tony Orlando’s house after a dispute over backup singers. The song is so subtle (it could easily be played in an elevator) that I had probably heard it a dozen times before actually realizing this soft song was all about a pretty amusing instance of arson.

So, I had a storyline, I had a borrowed game idea- and I had little time.  My first tasks basically drilled down to these items:

How do I make the background of a bitmap image transparent?

Set the transparent portion of the bitmap to #FF00FF (pink), and use masked_blit() or draw_sprite()

Hmm, Allegro didn’t remove all the pink background?

Make sure to disable anti-aliasing, you’re blending #FF00FF with nearby colors

How do I easily generate animations?

Design the models in Blender, use armatures and timelines to create the motion, save them as individual bitmaps (with OSA disabled and with the camera’s background color set to #FF00FF)

What’s the shortcut to add bitmaps to a datfile? Grabber would take forever!

Use the command line interface to datfiles – “dat”. Trust me on this one, I could archive 300 images in a few seconds, doing it by hand would be masochistic, taking hours.

How do I prevent choppiness in animations and movement?

There’s system bitmaps, video bitmaps, and memory bitmaps. Look into them, and the example code that comes with Allegro (especially exupdate) for ideas and examples.

How can I fade in/out?

One method is to place a semi-transparent black rectangle over the screen. Look at set_trans_blender(), drawing_mode(), and rectfill().

With the answers to those questions in tow, I had a decent demo ready in under two weeks; one that supported smooth screen scrolling, had some limited game-physics, and an even more limited level editor.

In the end, I pieced together level backgrounds using GIMP and a few photos from IStockPhoto.com. The game physics could be better, I’ll attribute their current state to my inexperience and the pending deadline. In the end – I think the project turned out fairly well.

GIMP and the first level background

Part of the Title Sequence to the game. Tony Orlando image used without his consent.

I took the following screen capture of the game using Taksi, an open-source, and free capture program in the same vein as Fraps (although Fraps is limited to 30 seconds of capture in the trial version). The screen-capture doesn’t have sound (the game does) and the actual game runs much smoother than the screen-capture..

So basically, you’re a mosquito with no wings (thank you Mr. Orlando) fighting to survive, collecting blood IV’s and gascans to fuel your jetpack. Now, I’ve got another project to dedicate free time to – all made possible with Blender, Allegro, GIMP,  and a little programming.

RadioShack Electronics Learning Lab

Recently I was intrigued by a Hack A Day post regarding a low-cost development platform for their MSP430 line of microcontrollers. I’ve long wanted to toy with an Arduino, but with many other projects currently under my belt, I’ve jut not had the time. When I heard the Launchpad was only $4.30, I figured I might as well pick some up for future use.

To make the shipping worthwhile, I ordered 3 of the boards from DigiKey. Unfortunately they were on back-order, but less than a month later – I got my purchase in the mail:

A couple Texas Instruments MSP430/Launchpads.The 3rd I gave to my brother

Each box contains the Launchpad Development board, USB cable, pin headers, a crystal, and two MSP430 chips. The online wiki contains links to a couple IDEs for use in the Windows world – and Hack A Day has a good writeup on using the msp430-gcc compiler in the Linux world.

Acting like an impatient kid, I put schoolwork and other projects on hold for a couple days to dig into the Launchpad. First mission – the basic “RC Car modification”.

Only modify full sized Police Cars.
To disassemble a real police car, first remove a couple tires.

After mapping out the pins on the H-Bridge of the RC Car, I decided to do something I’ve always wanted to do – buy a Radio Shack Electronics Learning Lab and brush up on what little I know.

The RadioShack Electronics Learning Lab. This circuit is a pacemaker for the human heart (from page 32)

This is something I should have had by the time I was in high-school – if not by 5th grade. The Electronics Learning lab contains 2 lab manuals (one covering Basic Electronics, the other Digital Logic), about 20 ICs, a handful of transistors, numerous resistors and capacitors, and jumper wires (among a few other things). The console itself has numerous built in potentiometers, LEDs, a relay, a transformer, a buzzer, speaker, DPDT switch, and many other components ready to use. Each of the built-in components uses springs to make contact. There’s also a built in breadboard.

The two included lab manuals.

Each lab manual contains background information on each of the various components, as well as example circuits that you can build. Each circuit contains a standard schematic, step-by-step instructions, as well as a checklist to help the user build an error-free circuit. The explanations on how many of the circuits work are lacking – requiring the user to do additional searching and reading to get a full understanding of what’s going on. (But seriously, that’s how it should be: You buy the lab to learn, doing additional reading should be encouraged)

If you look closely, you'll see an acrostic poem.

Which circuits you build and in what order you build them is entirely up to the user. Each manual is structured so that learning is incremental: You learn how resistors work, you learn how capacitors work, you learn many different ways in which resistors and capacitors can work together.

My goal is to work through each book page by page (I’m only just over halfway through manual 1). Each manual is about 96 pages long so this can easily be done in a long weekend (or a few in my case).

I really wish my high-school had offered an electronics class. My limited knowledge had been enough to get me by for basic projects, but the labs I’ve done so far have really bolstered what I know. And at $70, this is a real deal.

Next up: After completing all the labs, go back to the RC Car modifications and explore the possibilities of a TI Launchpad.