Jump to content
  • Advertisement
  • entries
  • comments
  • views

About this blog

Of game and graphics programming, cryptography, and electronics.

Entries in this blog


The Call of the Dark Side

So I've been working on a little Android game for a while now. Mainly as a first effort, small scope, learn the technology sorta deal. So it's pretty simple in concept.

Anyway it's getting to the end of development now, mainly just polishing and tweaking, so I decided to take a crack at making an ad supported version. Generally Ad Mob is meant to integrate with standard Android UI elements, and not just an all encompassing OpenGL ES canvas, so it look a little shoe horning to get it in there, but it's in now.

I had been loading it up and trying it out, clicking the ads and testing how well my app resumed and such. And then I looked at my Ad Mob account... I had made $0.02!!! That's real money! I mean not a lot obviously, but man! I was expecting like $0.00000001 or something! I mean after all it had only been me messing around for a few hours testing my app!

Now up until this point I had been taking care to only show ads in non-intrusive places, like on the menus, or only after you died in the game. But man! For a moment I had a flash of "holy cr@p! I could make real money off of this! Lets put ads EVERYWHERE!!!!"

I started rationalizing to myself how I could display ads during the actual game play, and I could use Ad Mob's feature for interstitial ads ( for those of you that don't know, an interstitial ad is one that takes up the whole screen and is usually placed in the middle of a flow between screens and must be manually skipped to continue on to the next screen, they are terribly terribly annoying ) to get even more ads in there!

I began tweaking some things and then stopped myself. I know how I feel about ad supported software to begin with. And especially software that's just crammed with intrusive ads all over the place. Usually doesn't stay installed on my phone too long.

I want this to be software that I would want to use. I want it to be a quality (if small) game that can still make at least some money. I plan on releasing the ad supported version along with a $1 ad free version. I feel like that's the best compromise. And one that I would be happy with as a consumer & gamer.

But man... wouldn't it be awesome to see that # in Ad Mob go way up




Arduino Adventures :: Day 2

After talking with a few people who saw Day 1's pictures, I tried a different technique, and it worked so well I didn't get a single Cold Solder, and finished the entire board in the time it took me to do just 10 pins last night!

The finished product!

Those are some nice solder joints!

Plugged in for the first time, and Win7 found the drivers w\o any help, I'm kinda impressed!

Running my first program! (it just toggles 1 of the digital outputs High (5V) and then Low (0V)) and I hooked up an LED so it would look pretty while doing it:
">Day 2 : Video 1
(wish I could embed youtube videos or even HTML5 videos here...)

I disected an old XBox controller and extracted the 2 rumble motors. Then I hooked the larger of the 2 up to the digital output that my program is toggling:
">Day 2 : Video 2

Now I am going to run through some of the tutorials and stuff to learn all the little ins and outs of programming this thing, and then I can start coming up with some cool projects!




Arduino Adventures :: Day 6

I had been thinking about how to achieve individual addressing using demultiplexers even before I gave Charlieplexing a shot. But during my preliminary research the stumbling block was that the largest demux I could find was only a 4 to 16. If I wanted to individually address 64 LEDs I would need four of these, thats 16 I/O pins required to drive them all (I only have 14 on the Arduino).

So that wouldn't work. I continued to mull about this because there was an itch in the back of my skull telling me it could still work. And then it hit me! As you may or may not know, demultiplexers have a given number of inputs to select which output pin to activate. But they also have an enable pin that can disable the entire demux (so no output pins are active).

My idea was to hook up all of the four demux inputs up in parallel with each other. So pin 1 for each demux would be hooked up in parallel together to one I/O pin on the Arduino, and same for pin 2, 3, and 4. So to drive all four demux's you only need 4 I/O pins on the Arduino. Now the problem with this of course is that if you select pin 8 for output, then pin 8 on every demux will go active.

My solution is to use a smaller 2 to 4 demux, and hook these outputs up to the enable pins on each 4 to 16 demux. So with only 2 I/O pins on the Arduino I can select which Demux is active, and only that one will have an output pin going active.

When all is said and done, I only need 4 pins to drive the 4x16 inputs, and 2 to drive the 2x4 inputs. Thats 6 I/O pins to individually address 64 LEDs :D

Now my previous exploration of Charlieplexing was far from a waste of time because it got me thinking about Persistence of Vision as a valid way of presenting a static image. Using this demux method for individual addressing of the LEDs, and Persistence of Vision to present a static image, I have a perfect method for engineering my display! Some bonuses of this method over Charlieplexing are: The circuit complexity increases linearly as you add more LEDs LEDs always get the same amount of current The layout lends itself very well to being in a grid!
So with this rough sketch I set forth! It's a real shame that "The Shack" (Formerly known as Radio Shack, they re-branded them selves, seriously) doesn't carry the stuff they used too. They have just a single cabinet of fairly worthless components. It's a real let down. So finding ICs and other small electronics is a real pain these days. Ordering them from sites is an option, but it took some research to find sites that sell in small quantities. I did find a few good ones finally. Shipping time and cost kinda suck, but what can you do.

The first issue I ran into was that nearly every demux was active LOW. Meaning, all unactive output pins were putting out 5V (HIGH), and when you activated one, it would go to 0V (LOW). Thats fine if you have a logic circuit that is all active LOW. But in my case, that would mean that every LED would always be on, and when I addressed one of them, it would actually turn OFF... Not what I wanted :P

So the only one I found that was active HIGH had a 4bit transparent latch for the input. Not a big deal, kinda cool actually, but it means I need an extra I/O pin for the latch strobe. That puts me at 5 pins rather then 4 for the 4x16 demux's (since i will be hooking all the strobes up in parallel as well), which makes it 7 pins total, well within bounds. The inputs were active HIGH as well, but oddly the enable was active LOW. So if I'm pushing 5V (HIGH) into the enable pins, it DISABLES the demux, and if I drop that to 0V (LOW) it ENABLES the demux.

This actually worked to my advantage because every 2x4 demux i could find (whos output would feed into the 4x16 demux's enable pin) were active LOW logic, so every output pin would propagate HIGH until I activated one, which itself would then go LOW.

2 to 4 Demultiplexer : CD74HC139E

4bit Transparent Latch/4 to 16 Demultiplexer : MC14514BCP

As I was saying, the thing that sucks with Radio Shack and every other small eletronics outfit going the way of the Dinosaurs, is the shipping time. If i got a dead IC, or burned one out my self, I'd have to wait another two weeks for a replacement. So i ordered double of everything I needed. (Each IC was only like $0.75, so not a big deal). And to be extra careful, I'm ordering IC sockets, so I won't be soldering the ICs directly.

Now I ordered and received the demultiplexers already. And hooked one of the 2x4s up to my Arduino to test it all out. I haven't worked with ICs let alone demux's in years, so I wanted to test out my self as well as the hardware, to know for sure they all work:

This is being controlled by my computer via serial input, so i can flip the inputs manually, and see the output state instantly. I plan on modifying the program to run through each state automatically and verify the output for each input state. Sort of unit testing the ICs. Then I will do the same for my 4x16's.

Still quite a bit to do before I'm ready to begin the build, but it feels good to have a solid design finally.




Arduino Adventures :: Day 7

So on my last post, benryves pointed out that I might be able to use some of the Analog input pins as Digital I/O pins. And as it turns out, he's right. I could swear I read some where that you couldn't, but I was wrong.

Well this put my design in a bit of jeopardy, not because it was wrong or wouldn't work, but just because it might be unnecessary, which would make it kinda silly.

And for a 64 LED circuit, its actually a bit overkill. Because I could hook up four 4x16 demux's and address them just fine with only 16 pins. But if I wanted anything more than 64, I would be out of luck. Since I have had plans for larger arrays all along, this made me feel a bit better about my design. But to make my self feel even better, I made my self a bunch of graphs on how my design is superior to straight demultiplexing :P

(Efficiency in terms of LEDs per Input Pins increases as you add more pins)

So, being softly reassured by my graphs, I turned my attention to the build.

I still needed quite a few things to manufacture the circuit board. I needed a way to drill the holes in the board. I needed a way to get the circuit design onto the board precisely, and so on. So I did some research and bought some tools! (Who doesn't love power tools!!)

I had read that high RPMs (around 30,000) was key to getting clean precise holes on your boards, and the Dremel 4000 has variable RPM control that can go up to 35,000 RPMs, so I should be good :D

Also, the printable Acid Resist allows me to design my circuit on the computer, and just print it out, and apply it to the board, very precisely, so that's nice.

For drill bits, all the reading I did mentioned that I would need Solid Carbide Drill bits to really drill precision holes, but they were $5 a bit! So after some quick searching I found a few on E-Bay selling military surplus ones for mmuucchh cheaper:

With all my new tools, I finally got around to designing the actual circuit board. And wow... I under estimated this. It was not trivial. And it's still not perfect.

First thing is, I have these two 3"x5" blank PCBs that I want to use as practice before I etch the much larger 9"x12" blank that I have. So I wanted to design a paired down version of the circuit that would fit on the smaller one. So here it is. This is the actual circuit, but it only has half the outputs that the final one will have (32 instead of 64, there will be two more 4x16 demux's in the final one). And on this one I have all the LED leads on the edge of the board since this is only for testing purposes:

Well that's all from me for a bit. On Wednesday I'm heading to Belize for a week! Gonna romp around in the jungle for a few days :P




C3: Prototype Testing

Good news everyone! I've reached prototype stage! And I've got a video to prove it!

[media] [/media]

And with that I set to some real world testing.

Night 1: The alarm went off as expected! I snoozed it (as I am want to do). But 30 seconds later it went off again! I had left in my hard coded debugging value of 30 seconds for the snooze time :/ Realizing this in my half awake state, I got out of bed in order to turn the alarm off... but nothing happened... with the alarm still blaring out at full volume, I inspected the app closer, and noticed the pressure value was not updating. I close and reopened the app in an effort to reconnect to the sensor, but to no avail. I ended up having to go under my bed and power cycle the IOIO.

Debugging first thing in the morning is not my idea of fun.

Night 2: In preparation for night 2, I decided to connect to the IOIO over USB to ensure the connection remain steady for the whole night. But 8am come and went with no alarm. I didn't have time to collect any data on what went wrong because I was in quite a rush when I finally did get up.

I had a nagging suspicion however that the volume may have been at least partly to blame. So I modified the app to hard set the volume to max every time it went off, and I improved some of the data smoothing related to the pressure sensor to avoid false positives for getting out of bed.

I also discovered that, with the current firmware on the IOIO, it won't provide power to the phone over USB, so that's not really an option at the moment.

Night 3: Connected over Bluetooth again for this night of testing (due to the charging issue over USB), and added in some more debug logging. This time the Alarm went off at full volume, exactly when it should, and snoozing worked beautifully. But the Bluetooth connection was lost again. I got up and plugged my phone into my computer and dumped the logs. They don't go back far enough to see the disconnect, but I got some data out of it anyway.

I've modified the app now so that when the connection is lost, it dumps the Log to disk right then and there, so Night 4 should produce some more definitive results as to whats going on.

Onward and upward I say!




No good Android phones on Verizon...

I've had my Droid for about a year and a half now (got it the day it came out) and all though it has treated me well, it's getting quite old in "phone years".

I'm not due for an upgrade until July, so it's not a pressing issue at the moment, but while musing on what I might get when it's time, I have come to the conclusion that there really isn't any Verizon Android phones in the near future that look compelling.

Probably the most interesting phone currently is the Motorola Atrix 4G, but of course that's AT&T.

HTC's up coming phones are decidedly last-gen, lacking the hardware sensors that 2.3 brings to the table, and shipping with 2.2.

The Sony PlayStation phone (Xperia Play) is fairly interesting to me for it's performance and how up to date it is with 2.3's hardware features, I feel like it will be kept up to date as new versions of Android roll out, but that's admittedly based on nothing.

And then there is the news that Netflix simply won't ship apps to phones with out hardware DRM support. Meaning ALL current phones will never get Netflix streaming. And more than likely all the phones currently in the pipe line will similarly never get Netflix. This is actually kinda a big deal to me, I'm a Netflix addict!

On the same vein, the Motorola Xoom, while very sexy from a lot of stand points, will NEVER get Netflix! And at least for me, it's primary use case would BE streaming movies!

Now Qualcomm has recently announced a new rev of the Snapdraggon line that included hardware DRM, and Netflix has given it it's blessing, so thats great news, but they are only now shipping samples to manufacturers, which means we most likely won't see handsets with it till NEXT YEAR! Suck!

And none of the other SOC manufacturers have even announced a similar solution yet. NVidia already release their road map through early next year, none of which included hardware DRM, and that's just the SOC release schedule, not end user devices including them. TI to my knowledge has not released a road map showing so far out, but we can assume they have at least the rest of this year planned out. All this means is we probably won't see wide spread Netflix support till the end of 2012! SUCK!

As a small side note, I'd been down on Qualcomm for their less then stellar GPU they saddled their Snapdragon SOCs with, but the new rev of their GPU is a whole different ball game, it's goes head to head with the Tegra 2 and holds it's own, so I'm very interested in the next generation of phones based on this SOC.

But I digress...

The last thing that weighs in on my decisions is both UI customization (I don't want any!), and time-to-update when new versions of the OS come out. Google's own handsets get updated very quickly, but they never come to Verizon. Both HTC and to a lesser degree Motorola manage to update their handsets, but pretty much every other manufacture has a MISERABLE track record.

So where does all this leave me...

I guess what I really want is a Nexus X, Google made, Verizon loving, stock UI, always updated hand set, with Motorola's industrial build quality, and hardware DRM for my precious Netflix... Let me know if anyone sees one laying around




Silly Encryption Schemes: Part 1

[ My first real post, it's a bit long, sorry about that :D ]

[ I'm more accustom to writing for less technical audiences, so if this comes across as too much hand holding, I apologize, I'll try to tech it up more in the future ;) ]

So I have had an interest in Cryptography for a while. Now let me stop you right there, no, I'm not a crazy math genius, so I'm not going to regale you with formulas and number theory. No my interest is more... playful.

My first ever Cryptography related thing I wrote some years back was a super simple cipher tool. My girl friend at the time was giving me notes in a cipher she created (it was a straight forward, 1 for 1, substitution cipher), so I wrote a program to decode them more quickly. I then expanded the program to some other simple ciphers.

Later I wrote a simple XOR encryption program, and also a steganography program which can hide ASCII text in 24bit Bitmap images. (Both projects can be seen here)

Finally I wrote a web based cryptography game called Decrypt that teaches people how to decode ciphers by hand while unveiling a story to them. (Though as browsers have changed and improved, it has falling into a bit of disrepair, though it is still playable I believe.)

Fast forward to a few months ago:

I have been milling around on cryptography sites again, pretending to understand what I'm reading. I can't see the day when my pseudo understanding of asymmetrical encryption will pay off, but hey, you never know ;)

So with thoughts of lovely encryption algorithms dancing in my head, I turned to another topic I had been mulling about, it had to do with some 3D math I had abandoned in another project: Calculating the intersection points of 3D Spheres (It's not redundant, look up 4D Spheres, AKA: Quaternions). This oddly enough lead me to a silly idea for an encryption key generation scheme: Distributed Planar Key Encryption

( Or at least that's what I'm calling it. I don't know if it's something that has been done before. It's kinda pointless, but cool :P )

Let me stop right there, I'll come back to the math in a moment. So the idea for this encryption scheme came (as many ideas of mine do) from the movies. You've seen those movies where a super important vault, or missile launch system, or whatever has multiple key holes, and both keys must be inserted at the same time to be able to unlock it? It prevents any single person from misusing their key, as multiple people are required to agree on accessing it.

Well maybe it's just me, but I think that's kinda cool :P

Ok so back to Distributed Planar Key Encryption, that's exactly what this scheme aims to be. You see, several Child Keys will be generated at encryption time. These keys, Child Keys, will combine to form the single unique Parent Key which is the actual encryption key. That of course will be used to encrypt the data.

Then the encrypted data can be sent to each concerned party along with a single Child Key. Or the encrypted data can be kept in a single place, whatever, that's not the point. The point is that no single user can decrypt the data with their given key. They must bring together enough keys to pass the Key Threshold. Once that Threshold is passed, the Parent Key can be generated, and the data can be decrypted.

The important part is that ANY combination of Child Keys, as long as you have enough of them, can generate the Parent Key. So you can't just take the Parent key and break it up into pieces. If you did that, you would have to have specific Child Keys in order to reconstruct the Parent Key. It would also mean that given one Child Key you could begin to solve for the other Child Keys. Needless to say, this would be a bad thing...

OHKAY... So. How do you go about making a scheme that satisfies these requirements! Actually it's a lot easier than you'd think. And this is where we come back to the 3D Spheres I mentioned earlier. Given 4 unique Spheres (they ALL must overlap) you can calculate a single unique point in 3D space where they all intersect. And use that point as the basis for your encryption key (aka: the Parent Key).

So this was my first attempt at a Distributed Key Encryption Scheme, dubbed: Distributed Spherical Key Encryption

But there were some problems. The first was that the math to intersect Spheres is quite complicated. Though I got that working finally. The next problem is what killed it however. See, on the surface of a sphere, there are, in theory, an infinite number of points, because 1.3 is a different number then 1.33, and so on. (Of course, a computer is a finite machine, so it's not quite infinite, but still pretty good.) The problem came in how modern computers store decimal (aka: rational) numbers.

They are called "Floating Point" numbers, and computers actually suck at storing them exactly. You can read up more on why that is on Wikipedia if it really interests you. But here is why it's a problem: when I run these complicated equations to calculate the point of intersection, I get slightly different numbers every time. That is to be expected with Floating Point arithmetic. And we, as computer scientists, have ways of dealing with it. Generally, we look at two numbers that we want to compare, and if the difference between them is under some threshold (epsilon) then we consider them to be the same number.

So the difference between 1.45555 and 1.45556 is less then the threshold of 0.001, we would consider them the same number. I'm pulling these numbers out of you know where, in reality epsilon (aka: 0.001) is much much smaller, but you get the idea.

So it should have worked, right? Wrong. See, the equations are complicated enough, and each time a floating point operation is done (+, -, *, /) there is a slight bit of error. Since so many operations are done in the course of determining the point of intersection, all the different errors add up to quite significant fractions so that the epsilon test would fail ~9 out of 10 times, making it quite unreliable.

What this means is... Given however many Child keys, 9 out of 10 times, you would NOT generate the proper Parent Key. And the Decryption of the data would fail.

My only option was either to round off to, at MOST two decimals, or to use fixed point math and drop decimals all together (sort of).

Neither solution was preferable. The first one, would probably make it reliable to 99 in 100, but that 1 in 100 times when your secret data didn't decrypt, wouldn't be a happy day.

The latter method can be refereed to as "Discretizing" the math. Or, making the math use Discrete numbers. The problem with this is that, instead of having theoretically INFINITE points of intersection on the surface of your sphere, you now had a discrete, known number of possible points. Now remember, the point of intersection of 4 Child Keys IS the Parent Key. Thus, the complete Parent Key actually and truly exists on the surface of every single Child Key sphere.

When there were an infinite number of points of the surface of each child, it didn't matter. But now, by making the numbers discrete, there are a known number of points on each sphere. Thus, given a single Child Key you could brute force through the points on that Sphere alone, and find the Parent Key.

(While there are ways to mitigate this [using particularly massive spheres], it actually reduces the search space in other ways, but that's for another article.)

Just to reiterate, one of the key points of this encryption scheme is to not be able to determine the Parent Key with any fewer then N Child Keys. N being the Key Threshold as defined by the algorithm.

So this was clearly not an acceptable solution as it violated one of the core tenants of the encryption scheme.

(As a side note. The spherical keys were flawed from the start. See, N (the Key Threshold) for the algorithm was 4. You need 4 spheres to generate a completely unique point. But given just 3 spheres, you can in fact generate exactly 2 unique points. Well you don't need a computer scientist to tell you that brute forcing 2 possible solutions won't take you very long... Thus with only 3 of the 4 required Child Keys, the Parent Key could easily be deduced.)

Quite a bit discouraged, I stepped back from it and had some dinner. And it struck me. I was only fixated on using Spheres because it was what I had been working with previously in an unrelated project. And that in fact, as I just mentioned, they are quite poorly suited to the task anyway.

3D Planes however are perfect!

For those who forgot their highscool geometry:
3 Dimensional Plane: A theoretical surface which has infinite width and length, zero thickness, and zero curvature.

Planes have a theoretically infinite surface area, thus they don't suffer the same problems from using discrete, fixed point math

Planar intersection testing is much simpler then Spherical intersection testing.

It only required 3 planes to determine a unique point of intersection (Thus the Key Threshold is one less then for Spheres)

Given 2 keys (AKA Planes) an entire line of intersection results with theoretically, infinite points on it, even with discrete math, the security of the algorithm doesn't degrade as you approach but do not meet the key threshold.
So while 3 keys are the minimum that must be generated, you can generate any number you wish that all intersect at a single unique point, and any 3 keys can be intersected to unlock the Parent Key.

This was exactly what I had been searching for. So I began coding in earnest. (It also occurred to me, that a Linear Key system could work as well, reducing the number of Child Keys required down to 2. But I stuck with the Planar Keys.)

Now. That's all well and good. Mission accomplished and all that. (No really!) But encryption can be a very boring subject to many people. And it sure doesn't look as cool as it does in the movies, crazy blocks flying every which way to unlock the secret file. Which got me thinking. I am actually using 3D constructs in the math, so there really is no reason I couldn't visualize this in a 3D app. Ya know, actually show the different planes (keys) in a 3D view, and show them intersecting, and then highlight the common intersection point. I could even do a little animation with it to make it snazzier.

So that's what I'm currently working on, and I will be sure to post here about it when it's done!




DIY Capacitive Touch Gloves, Take that Apple patent #20090000010

So a small diversion from my Arduino efforts today, and a focus on warm winter apparel.

I bought a Motorola Droid when it came out last year and haven't looked back to my LG 77C (the C is for crap) or what ever it's stupid model was.

But now that winter is firmly upon us, grinding us down 'till the last breath of hope and life escapes from our frigid, sun starved bodies, as nothing more then a fart in the arctic wind... I got to thinking:

"Boy my hands are cold, wish I could answer phone calls with out having to take my gloves off."

So I began testing a few materials around my house, trying to find something non-abrasive that would create some capacitance on the screen (since they are capacitive touch screens). Nothing worked, not well anyway, so I tried tinfoil which worked of course, but covered it with some thin plastic, as to protect the screen, and it worked!

So without further ado, I give you the DIY Capacitive Touch Glove, or as I like to call it, "The one glove to rule them all":

">Video: DIY Capacitive Touch Glove




Back to the grind

Welp, I'm back from my vacation. Actually I got back over a week ago, things have just been really busy.

Some cool photos if you are into Mayan ruins or caves (this pic links to the whole gallery):

Anyway, easing my self back into things I finally finished up a long time (non-technical) project:
Paper Craft - Mad Cat (BattleTech)

You can see the full build log here

(I'm a big BattleTech fan, just started reading the Blood of Kerensky series, any BattleTech fans here?)

I also finished up my encryption project, so I will have a postmortem on that soon, as well as progress on my Arduino hardware project. So keep reading! :D




C3: First steps

As I stated in my last post, I began some actual work on this project over the weekend.

What's some times not appreciable, is the amount of time it takes just to get started on something like this. Finding all my Arduino parts and pieces, installing the software, figuring out all the little quirks again (It's been more than 6 months since I finished the robot project).

Finally being setup again for Arduino development, I set to soldering together a little voltage regulator for my bread board. It would allow me to put in anywhere between 3V and 36V and get a nice clean 5V signal out. This way I could independently power my breadboard without extra wires from the Arduino.

Next I needed to test my pressure sensor, to figure out how it works and how best to use it. I started by building a little RC (resistor capacitor) circuit as described in the sensor's user manual. But quickly realized this wasn't necessary with the Arduino, Just using one resistor and an Analog pin I could read it directly. Problem was, I was getting these highly variable values. In fact, when graphed over time, they looked quite a bit like the charge and release cycle of a capacitor.

This puzzled me of course because all I had in the circuit was a resistor and the sensor. After more fiddling and frustration, I removed my nifty bread board power supply and hooked it up directly to my Arduino's 5V pin, and instantly I got stable values. Good for my level of frustration. Sad because I really liked my little bread board power supply. Not sure what I screwed up when soldering it together...

Anyway, I happily played around with my sensor, creating functions to produce readings in lbs rather than voltage and such. It was fun and cleared the way for what was, in my mind, one of the biggest question marks for the whole project.




Hello World

Well for my first post I think I will keep this short, and tell you a bit about my self.

I am, among other things, an avid gamer (FPS,RTS,Puzzle/Adventure,Horror) and game programmer. I've made a few game engines, and a few games. I worked at a small, independent game company where we made a game for the Nintendo Wii. It's called Gravitronix and it's on WiiWare (the Wii's digital distrobution platform). For better or worse, we made the engine from scratch, and if nothing else, it was a massive learning experience.

Since then I have been working at monster.com doing web programming. That's about it as far as my professional life goes, but what I will be focusing on much more in these posts will be my personal projects. My personal interests center largely around game and graphics programming, but I also have a hobbiest's interest in cryptography and electronics. Both of which I intend to cover here.

I currently have two active projects which I will begin posting about soon. So if it sounds interesting to you, check back soon!




Arduino Adventures :: Day 4

So I've been thinking about what I want my first big project to be, tossing around a lot of ideas. Trying to balance complexity & difficulty VS coolness. (Also, I want the project to be fun to make!) One of the things I've been interested in doing ever since I heard that you could do it at home, was acid etching your own circuit boards, so I wanted that to be a part of the project too.

With those requirements in mind, I finally settled on a project: John Conway's Game of Life. I've written two different versions of it in software previously:

I am absolutely fascinated by the whole thing. At one point I was in the planning stages of a hardware based version using only logic gates. But the complexity was astronomical, I would have ended up building an ENIAC sized machine :P

But now with a micro-controller to do all the heavy lifting, it's feasible! With that as my goal, I began planning and research in earnest. So what do I need. Well all I really need is a way to display a grid. There are some LCD screens you can buy and hook up, but thats no fun, and doesn't look very cool. So I began looking into LEDs.

Now, in the software version I wrote, the longer a cell had been alive, the more it's color would change. So I wanted multi-color LEDs that I could modulate the color on. The plan was to have a grid of NxN multi-color LEDs. But after thinking things through a little, I decided I had enough issues to deal with anyway, without adding in the whole analog aspect, so I opted for digital (one color, on or off) LEDs.

My next step was to prototype. I needed to determine what the value of N would be. This would determine a lot about the circuit complexity and how I would go about implementing things. Now in the theory behind the Game of Life, the grid is infinite, there for the larger your actual grid is, the more interesting the result will be. So size is key.

The grid in my software version is 64x64. But after looking at things from a hardware perspective I figured roughly 8x8 was the largest I could manager. So I tweaked my software to be 8x8 to see if it was still interesting. It wasn't...

Until I wrapped the world that is! (So each edge is connected to each other edge.) Satisfied that it could still be interesting at 8x8 as long as the edges wrapped to each other, it was time to start thinking seriously about how I was going to implement this in hardware.

The key here, is I need to be able to individually address each LED. An 8x8 grid means 64 individually addressable LEDs, but the Arduino only has 14 digital I/O pins! (and even less analog I/O pins.) So the question became: "How to drive 64 LEDs with only 14 digital I/O pins?"

The first thing that jumped into my head was multiplexing (well, demultiplexing to be accurate). But that meant researching and ordering ICs, and during some research on the interwebs I found a possible alternative called "Charlieplexing". No ICs were required, just a few current limiting resistors. It allowed you to address N(N-1) LEDs where N is the number of I/O pins. Thus with only 14 pins, I could address 182 LEDs! (Plus the circuit looks fun to design)

So I ordered parts for that: 100 red LEDs and some 68 and 82 Ohm resistors (I'll get into why that is later) and I will write up another entry on that build soon :)
(Probably do a video too, I'm still exploring video editing software, trying to figure it all out.)




Arduino Adventures :: Day 3

It's time to do my first actual Arduino project!

This is a very simple one, but taught me some very important lessons about physical computing. Modern computers do tons of things so that we as programmers don't have to worry about all the random chaos in the real world. But in physical computing, small micro-controllers like the Arduino don't have the complexity to handle these things, so we as the designers/programmers must handle them our selves.

Take a look and see what I mean:
" target="_blank">Day 3 : The LED push button!

[I also took this as an opportunity to try making a real video about it. Still learning the best ways to record it all, and splice it together, so some parts of this are rough.]




Oceans Unleaded!

[ A bit late on this post, but as the guy in Ghost Busters 2 said when the Titanic arrived in New York... Better late than never. (What? too obscure?) ]

So my friend and I have released our first Android game!

[Android Market Link] Oceans Unleaded
[Android Market Link] Oceans Unleaded Lite

It is small in all respects. We intentionally picked a very simple game so we could focus on refining our process of working together, and the tech and idioms specific to Android, and how the release & advertising process works.

However, while small, we still wanted it to be a quality and polished effort.

And I'm happy to report that I think we succeeded gloriously in all areas

It's a fast paced "whack-a-mole"-esque game set under the surface of the ocean. There's a circuitous mess of oil pipes which... low and behold... begin springing leaks! You must rush around and fix the leaks as fast as possible. As the oil content of the water rises, the poor fishes who are swimming around die and float to the surface Poor fish.

And no matter what you do, you always lose. (It's sorta like the helicopter game, you always lose, but you're trying to beat your previous high score for how long you stayed alive).

There are a few extras thrown into the mix, like a supply plane that drops power ups randomly. And a rescue boat you must find when you run out of bandages for fixing pipes. But like I said, it's a small game in all respects.

There are a few interesting things (at least I think so) technically that bear mentioning. The game is written entirely in Java, based on a great library called libGDX. GDX abstracts away the platform specific stuff (Think SDL, or SFML) and provides back ends for PC & Android. The great thing is that you can develop right on your computer, run and debug right on your computer (much nicer than debugging over the USB link) which makes iterations MMUUCCHH quicker.

As GDX develops it's starting to provide a robust set of base classes for game development. Which is even nicer than it sounds because the GDX author is a performance Nazi! (You know... the good kinda Nazi) Always benchmarking and improving. So if you go that route you really will get the best performance possible out of Java. And the heaviest lifting is done in native Android back ends.

For this project, the team was just me (programmer) and my friend Mike (artist/anything creative). We have already started pre-production (doing a much more robust planning stage this time around) and have brought in a long time friend of ours who works in the AAA industry to do art and game design. We're learning a ton from his experience and adapting some of the process he has seen that work well. (Still keeping the process pretty light weight as this is just a 3 man side project.)

With both of these artists though we officially have WAY more asset bandwidth than technical bandwidth. And our next project is a fair bit more ambitious which worries me. So I'm mulling over the idea of a 2nd programmer. For side projects I've found it exceedingly difficult to find competent programmers who have both the desire, and time to devote. Which is to say I've never found a programmer with those 3 elements Also if there is going to be money involved (which we sure hope there will be lol) then it gets more difficult bringing in someone you don't know. There can be some sticky legal issues down the road.

Well anyway, I'm really rambling now, so go give our game a try if you have an Android phone!




C3: From the ashes!

I had an unexpected break through on my C3 project! A couple nights ago, I had some spare time, and had been thinking about the pressure sensor for a long time. The problem with it is, there is a circle with a radius of just 4mm, and in order to get good readings, the force must be applied to the center, not the edges. This gives me only about 2mm's in radius to apply force in. Since this will be under my mattress where things can be jostled or move around, that's a pretty narrow margin of error.

With this in mind, I came up with an idea for a "puck" and threw it together in Google SketchUp:

I was blown away by how easy SketchUp was, I learned the program and made this model all in less than an hour. What you are looking at here, on the right is the base of the puck. The sensor will sit at the bottom of the trench and be held in place by it's constrained neck. And the left is the top, that will insert into the trench, and the notch will hold it perfectly in place, while the nubbin will be the only thing applying pressure, and it will be held perfectly on the 2mm pad.

The ease of all of this, really motivated me, and the next night I got my self over to my local hacker space, sprout & co. and printed this baby up using their fantastic Thing-o-matic:

So I brought it home, marveled at how this thing that had been in my brain just two nights before, was now sitting in my hand, and set to programming my Arduino. Came up with a voltage divider so I could get good values out of it, and calibrated it so I could convert the values to readings in pounds. Then I set it up to record a full night of sleep, and dump the contents to a text file on this little net book.

And it functioned perfectly!

You can even see when I got out of bed near the beginning there!

Despite these resounding successes, I hit the same wall I had been at for a while now. The standard Arduino, as well as the available WiFi shields, really weren't up to the scale of the project I had in mind. And the new Arduino Due and the official Arduino WiFi shield which might solve my problems, are seemingly never to be released.

After a day or two of mulling this issue over in my head, I began perusing SparkFun as I am want to do. And I came across the IOIO which I have seen before, but this time it sparked (see what I did there?) a sea change in how I was thinking about this project! So many of the things I wanted the project to do (Like WiFi, NTP, Google Cal sync, Text-to-Speech) are exceedingly difficult for little 8bit Arduino's to do. And other things I wanted the project to do (interfacing with a variety of hardware sensors) are difficult for Android phones to do.

But my change in thinking was to treat my Micro-controller merely as a "Sensors Package". Which a custom Alarm Clock app on my phone will communicate with in order to be smarter than it could be on it's own.

So that's what I'm doing! I'll hook my sensors into my IOIO (pronounced yo-yo) which will connect to my phone via Bluetooth. And my Alarm App which I will make, will utilize the sensor data to do everything I had hoped it work! And more!




RSS Needs

As most techies I know, I have a set of websites I check up on each morning, and throughout the day. I get to the office in the morning, and first things first, I "make the rounds." And thanks to my handy dandy RSS reader, I never miss a single thing. I'm hyper-informed about the narrow set of topics that the sites in my usual rotation cover.

One of those sites is The Verge. A splinter group formed from former Engadget editors, it's quickly becoming one of the best tech and tech culture news sites on the web.

Recently, one of the editors that I follow closely, Paul Miller, came up with an experiment he wanted to run: go internet free for an entire year. And I mean completely internet free. Not just browsing websites, but email, streaming video, music, everything. He even ditched his smart phone and got an old Nokia, and won't even text on it.

I actually kinda get it at a basic level. The internet is completely integrated into my life, it's always there. Any lull in a conversation, out comes the smartphone. Any down time at the office, up comes the browser. So limiting one's interactions with the internet to a more balanced amount sounds perfectly fine to me.

I began following his updates from the disconnected world with some interest. My first reaction was one of: Why so extreme? So many little tasks would become orders of magnitude more difficult for him.

But the more I read of his dispatches, I began identifying with a lot of what he was saying. He talks about the "phantom limb syndrome" of the tech world. Like when you Ctrl+X a piece of text, you almost feel its unpasted ghost in your fingers until you Ctrl+V it back into existence. Or phantom leg vibrations that make you check your phone.

Or worse still for me... the phantom RSS stories left unchecked in my feed. I get a high filtering through my RSS feeds, saving the interesting articles to Pocket (formerly Read-It-Later) for more dedicated consumption later. I've got it down to a science, I'm hyper efficient at it. Clearing out my RSS feeds in the morning is a cathartic experience. For a few minutes... and then I start to get the itch... What new stories have been posted... What am I missing. I better check now so they don't pile up and require even more time to sift through later!

It kinda sucks actually. Something I really enjoyed has become a compulsive need. I tell myself it's both enjoyment (I do genuinely enjoy tech news) and important to stay up on the industry for professional reasons. But it's almost a chore now. This must be how OCD people feel about checking the lock on their door twenty times before they leave. They know it's bad but can't help themselves.

Now I'm not saying the internet is bad. It's a piece of technology. And Technology isn't inherently good or evil, it's how we as human use it that give it import and meaning. I think in terms of inventions that have most profoundly impacted our species, it goes like this so far: Fire, Wheel, Internet. So don't misread my next statement.

In his most recent dispatch, he talks about the signal to noise ratio on the internet being askew. And it really struck a chord with me. It's something that's been burning in the back of my mind for a long time now, and this put a name to it. I instantly seized on it. This was my problem with my RSS feeds. Out of usually around 200 articles sitting in my feed in the morning, I usually only save out about five to read later. I glean tiny fragments of information from scanning the rest, but it's mostly worthless.

For the last year or so I've been trying to cut down on the worthless noise that I usually click on. I've seen enough people walking into signposts and cute kittens to last me a lifetime. It's absolutely a waste of time. So I've been making a conscious effort, before I save something out to read later, to ask myself, is this really worth spending time on? And it's helped. Some. But I'm still filtering through hundreds of articles a day. The internet has lowered the barriers on content creation so far that the noise is now the pervasive standard. And finding the signal in it requires this OCD level of effort, filtering through it all if you don't want to miss something.

My RSS addiction is just one of my "phantom limb" problems though, which cumatively add up to a very distracted life style. So I'm back to reading Paul's dispatches, and being kind of jealous actually.

For my part, I've got a backpacking trip coming up to the Grand Tetons in Wyoming, and from the moment my plane lands I intend to turn my phone off, throw it in the trunk of the rental car, and have my own week of extreme disconnectedness.




Robo-pernicus: Part 2

Read Part 1 here

The next day at work it was all I could think about, and around lunch time, it hit me. They are in series! I'm dividing the voltage between the two servos! If I hook them up in parallel they'll EACH get 9V!

That night after a flurry of cutting, de-soldering, and re-soldering, it was ready. Popping a 9V on it made it leap forward! Excited, I set to work hooking the logic boards together, but when it came time to affix them to the chassis I encountered another problem. It wasn't really meant to host a board like this. The screw holes were probably intended for something else, but certainly not for my Arduino. Additionally, I have a bare circuit board I'm trying to attach to a metal chassis! I looked all around in my spare parts for some sort of fastener or holder or something to mount my logic boards with to prevent them from shorting out on the chassis, but couldn't find anything. Finally I settled on cutting an anti-static bag from an old video card and screwing the boards awkwardly through that bag and onto the chassis however I could make them fit.

I then set to testing out some stuff with the Arduino. Read up on the docs for the motor driver, wrote some test programs making it move and turn. Then did the same with the wireless chip, tested hosting a webserver on it and allowing you to control the motors by clicking links. It worked! It wasn't very responsive of course, reloading the page after a link click was pretty slow and all. But it worked! So I called one of my friends via Skype who lives in Texas, and using the webcam on my laptop gave him a view of the robot on the floor. Then I setup some port-forwarding so he could access the server hosted on the robot, and it was ready to go! I stepped back, couldn't see the laptop because of how it was positioned for the webcam. And all of a sudden this little robot starts moving on its own, via commands from my friend in TEXAS! (I live in Boston) I mean c'mon! We really take the internet for granted I know, but the series of events that are transpiring to make his actions in Texas manifest themselves in the real world in my apartment in Boston... I mean c'mon!!!

As Tesla once said: "I do not think there is any thrill that can go through the human heart like that felt by the inventor as he sees some creation of the brain unfolding to success... Such emotions make a man forget food, sleep, friends, love, everything."

Over the next several days I fast iterated. I ripped out the webserver and wrote a proper socket server for the robot, and socket client that ran on my home server. It was MUCH more responsive. Then I wrote a webpage that used AJAX to send "real-time" control commands to stub PHP script, which in turn sent them onto the socket client. And finally, after much research, I found a webcam that worked with Linux, had auto-focus, and great video quality (glass optics, no plastic crap), and a software package for streaming the video to the control webpage (no X11 or GUI of any kind, which restricted my options quite a bit).

This was a blast, you could log onto the site, see the robot from the webcam mounted in the corner of the room, and drive it around using WASD or GUI controls on the webpage. And I did some input wrapping so key down & key up worked the way you'd expect. It was fun. But it was lacking something big. I wanted to drive this robot in first person perspective.

I began researching wireless webcams, or really wireless cams of any kind, and there weren't a whole lot of options. I know you're reading this and saying "Oh c'mon, there's GOT to be some wireless webcams out there!" But really! There aren't! Try Googling for them! There's one or two that were prohibitively expensive and had other problems. Using a regular camera and streaming the video over the robot's WiFi connection was not an option. The Arduino has 2KiB of RAM, and clocks in at 15MHz. That's not a typo. One, Five MegaHertz. Ya, you're not doing video processing of ANY kind on that

The last option I had was home security cameras. But they were prohibitively expensive. The CHEAPEST were well over $100, most up around $300. To give you an idea, I was into this project for about $150 so far, so this camera would cost more than the rest of the project COMBINED. Not an option. But lo and behold, I found a home security camera meeting all my criteria for HALF OFF on a Black Friday sale! So for $60 I was in business.

I got it, chopped up its power cord so I could run it off the robot's internal power, and was off and.... crawling? Ya... and that's where this project kind of ends... After all of that, the wireless security camera was too heavy for the servos. It could BARELY crawl forward, and could only turn about 50% of the time. And this was one of the smaller ones I had seen while doing my research (size was one of my criteria when selecting a camera!). Anti-climactic, trust me I know.

But still, it was a great project, and I learned a LOT. I would post a demo or pictures of me controlling it, but the robot has since been dismantled. I'm scavenging parts for my next project which I hope to be much more successful!




C3: the Cloud Connected Chronometer begins

Over the weekend, many weeks of research culminated in the first concrete progress on my new hardware project. First let me give a run down of the idea for this project.

The core idea originated from the fact that I'm a bit like Jekyll and Hyde. Except instead of a murderous monster living in my psyche, there is a sleep loving monster who shuts off my alarm clock instead of snoozing it. I know. It's ridiculous. I'm determined to be victorious, however, which brings us to my latest weapon in this battle:


It's an alarm clock that solves the problem using a pressure sensor. The sensor will be between my mattress and box spring, so it will "know" if I'm still in bed, and simply not allow me to turn an alarm off until I get out of bed and stay out. Though I will still be able to snooze alarms as usual.

Now in order to interface with this pressure sensor, I will of course be using my trusty Arduino. And given that, a whole world of possibilities open up! So in addition to the Arduino, I've also pilfered the Wifi board from my robot. So here is the short list of features the C[sup]3[/sup] will center around:
Time always accurate using NTP (Network Time Protocol), never set it again after losing power! OLED touch screen for simple input, vibrant graphics, no back-lighting for good night time viewing. Alarms scheduled using Google Calendar. Never have a work alarm go off on the weekends, vacations, or days off. Pressure sensor to ensure alarms are not turned off while still in bed. Current weather conditions displayed on screen. WAV or MP3 playback for more pleasant alarm types.
I'm also investigating a speech synthesization chip (SpeakJet) to allow it to talk And obviously there are many more possibilities having an internet connected alarm clock that I will explore once the base features are implemented.

So stay tuned for more updates as I progress on this!




MQ3 :: Completion!

Welp, JUST over a month, and I've got it pretty much completed. I have it all together, working, packaged up in it's enclosure, and mobile. (I'll do a proper video of it soon and post it)

(Reading from a Vodka bottle, not a person ;))

It's currently using an external 9V battery for power. Though I'd like to devise an internal battery solution, it's difficult. There is much less room in the enclosure than I expected once all the components and wiring were in.

(Lots of wires to route and cram in there.)

The BAC calculation is pretty simple currently. I took the data I compiled from my many tests over this past month, and calculated a magic value that I simply multiply the voltage reading against. There's certainly room for improvements. For instance, according to my data, it's not a perfectly linear relationship between the voltage readings and actual BACs, so the magic value should modestly scale up as the voltage increases, but I haven't found a good fit yet.

All things considered, my magic value method is producing surprisingly accurate readings, and if you just focus on the Summary I output (Sober, Buzzed, Drunk. Very Drunk, ect...) it's more than sufficient for what I was trying to accomplish with this project.

Also I got to have some fun with my Dremel in order to customize parts of my enclosure:

(35k RPM Dremel with solid carbide drill bits. Overkill? Yes. But sure was fun!)

In other quite serendipitous news! On this very day, Arduino has FINALLY announced the imminent release of their official Wireless module and 1.0 library which brings wondrous high level networking support This is what I've been waiting for to get back to work on my C3 Alarm Clock. Unfortunately it took so long that I'm just about to begin development on a fairly sizable game project. So C3 will be on the back burner. Hopefully I'll find time here and there to push it forward, but it certainly won't be a quick project.

I'll post more on C3 and the new game project as things progress. Anyway for today, it's just nice to have a working, finished project




C3: Prepping for serious dev

The next real step forward was to begin working on the networking and time keeping. But those steps were the beginning of what is to become a real software project. Still small to medium sized compared to PC projects. But it will have a level of complexity that Ardunio projects don't usually achieve. What this means is the Arduino IDE would be wholly unsuited for developing it. I ran into this a bit with the Robot project. Towards the end of development as some complexity emerged with the socket communications, it got fairly difficult to manage in the Ardunio IDE.

My solution was to fall back to my trusty C++ IDE Code::Blocks.

I love this IDE, so light weight, cross-platform, and infinitely configurable. C::B has some high level support for AVR projects (that's the architecture of the micro-controller that the Arduino uses), but it's really a thin veneer. All of the guts, GCC-AVR and others, must be setup on your own.


I was following spotty tutorials written for much older versions of every piece of software in the chain. I had to extract AVR-libc and the Arduino Core lib from the Arduino IDE, get headers, do all sorts of fun stuff that Arduino clearly never intended for you to do. But in the end, I got it all compiling, burning, and running from within C::B. I even got C::B auto-resetting the hardware prior to burning! (Something none of the tutorials managed to do!)

I'll tell you, when I got my own code without any of the Arduino auto-magical trickery running on that chip:

int main()

// Insert celebration here

That was a gooooood day.

So with everything ready to go, all set for serious software development, I began looking into the networking. Dusted off my old networking WiFi shield (Arduino speak for daughter board) and began loading up all the libraries. I got a basic web server test running, and then went on to compile in more feature in the library. And all of a sudden, cla-thunk! My program wouldn't upload. Scrolled through the build log and found "Memory out of range". Crap... opened up the /bin directory of my project and saw the .elf file's size at 33KiB. The Arduino only has 32KiB of program memory...

After playing with stripping & size optimization options, and weighing if I really needed those library features that had pushed me over the limit. I concluded that I needed a new micro-controller with more memory. Luckily Arduino's come in several flavors! After a quick look-see, I decided on the new Arduino Mega 2560. It's based off of the newest Arduino, the Uno, has 8 times the program memory, and MANY more I/O pins. But other than that, it's identical to my current one. Which means it can be a slot in replacement, and I don't have to change any of my plans

So I'm waiting on that to be delivered before I can continue.

That's all!




C3: Misery and Progress

So I got my brandy new Arduino Mega 2560 in the mail. It has 256KiB of program memory (8x the memory of a standard Arduino!)

As I mentioned in my last post, the standard Arduino only has 32KiB of program memory, and with all of the networking features I want compiled into the library I'm using, I was already at 33KiB. But now with a spacious 256KiB (What will I ever do with it all!) I can add in features until my heart's content! (DNS and DHCP oh my!) Other than the extra memory (and extra I/O pins) It is identical to the regular Arduinos. Or so I thought... (cue the misery.)

Getting a blinking LED sketch (Arduino speak for program) running on it from the Arduino IDE was easy enough. But replicating it inside my Code::Blocks setup was not so easy. It took further modification of my command line scripts for which there was little to no documentation to base it off of. After lots of groping around in the dark, trial and error, and some guess work, I got it there. Though the auto-reset was not working, so I have to time a physical reset of the board with the compile button in the IDE to get the programs to upload. *annoying*. This took a few hours... but it gets worse.

Then began the real pain. You see, the trouble starts with the fact that the wonderful WiFi board that I use (the WiShield, made by AsyncLabs) is no longer in production. In fact, in March of this year, AsyncLabs shuttered their little studio completely. Which is a real bummer because they are the ONLY mature, drop-in WiFi solution for Arduino

With AsyncLabs out of the picture, development on its library and support in its forums has all but ceased. With the Mega2560 being a relatively new board, its fair to say that support will never be added for it in the WiShield's code. Now you might ask, but Adam! You said the Mega was pretty much identical to other Arduinos! Why would support need to be added at all! And it's because it's NOT identical. There is a small difference that turned out to be vitally important.

You see the Arduino's are based on an AVR type chip manufactured by Atmel. Atmel makes a variety of these chips under the ATmega line.

These ATmega chips provide a nice little piece of hardware/software functionality called SPI or Serial Protocol Interface. I won't go into the details, but it's critical to the functioning of the WiShield.

This is where the problem lies. Arduino's based on the ATmega168 or the ATmega328, have their SPI pins on 11, 12, 13.

But Arduino's based on the ATmega1280 or the ATmega2560, have their SPI pins on 51, 52, 53.
This was a deep rabbit hole the wasn't helped by my ignorance of underlying hardware. Most Ardunio hobbyists never need to get this deep into the micro-controller at the heart of the Arduino, so I initially wasn't trying to learn all about it, I was just trying to solve the problem. And I wasted a *lot* of hours going down this vein. After two days of researching the problem, banging my head against a wall, investigating other WiFi chips and even other micro-controllers entirely, the project was in real danger. But I finally had a break through. I pieced together a solution from many different forum posts and a deeper understanding of the hardware and the problem at large.

It ended up being both a hardware and a software fix. And I had to mutilate my beloved WiFi board a little

This was not a fun excursion. But I hope it clears the the path for some smoother sailing. Next I'm going to try to make the Arduino keep time using NTP (Network Time Protocol) for synchronization. And after that work on pulling events from a Google Calendar. So stay tuned, and I hope to keep these posts shorter




Robo-pernicus: Part 1

I probably should have posted about this when I was actually doing it. But C'est la vie.

Anyway I had been messing around with some Arduino stuff a while back, and got pretty far but never finished a project. Other things came up so I shelved it all. Then we got a kitten and I thought it would be fun to be able to play with the kitten while I was out of the house.

So I came up with the idea for a remote control robot with a kitten toy attached to it that you could control from a web page. Already having an Arduino, the natural choice was to extend what I had.

I looked into the different parts I would need and settled on this build:
Arduino SyncLabs WiFi Shield (802.11b) 1amp dual motor driver shield 4 wheeled chassis kit

Now being, at least what I consider to be, a fairly adept programmer, I was not worried about the software side of things.

However I was also not worried about the hardware side of things... This was stupid.

Since the control side of the hardware was merely 3 boards that fit neatly together, I started by focusing on the chassis construction. Now I went into this wanting it to be a fun learning project, not just a robot in a kit. And boy did I get more than I bargained for.

The Chassis kit consisted of a 3 zip-lock bags. 1 contained several tiny metal pieces that clearly were meant to be the chassis frame. 1 contained assorted screws and other hardware necessary for assembly, and the last contained 4 small-ish servos.

I've done some electronics stuff, and we had covered circuits in my college physics classes, but any useful knowledge from those past experiences fell out of my head when I was presented with this unorganized, unstructured bag of parts. There was no manual, no instructions, no numbered pieces. Just a bag of constituent components that could, in the right and knowledgeable hands, be assembled into a robot chassis. Though truth be told they could also be assembled into a doomsday machine for all I knew. Each seemed equally possible from where I stood.

But this is what I had wanted! I wanted to embark on untrodden ground! I wanted to INVENT! Not to follow in the path of countless others! (Of course this isn't really Inventing, it's more so playing with Legos, assembling pre-made pieces into a semi-unique configuration, but give me a break )

So I dug in. Not knowing where in particular to start I began sizing up the metal parts that would make up the frame. Fitting them together didn't take long to figure out. I ended up assembling them, promptly realizing that the order I did it in presented me with problems, and reassembling it again, several times in fact, until I found the optimal method. Attaching the servos again made me disassemble and reassemble the frame (with the frame fully assembled the space was too small for me to work in to attach the servos).

So Finally, after longer then I'd like to admit, I had the chassis assembled and servo's installed inside it.

(I'd like to apologize to my past physics professors for this next part. You really did teach me these things! I just forgot for a few hours...)

I played around with my circuit boards a little, and mulled the problem before me. My motor drivers could drive 2 motor independently, but I had 4 servos. It's not a complex problem and the solution may seem obvious, but exactly how to go about it, and the fear derived from being "untethered", made it a contentious decision. After some rough sketches of my wiring harness, I did some Googling and found some one else's rough sketch that looked exactly like mine! That was enough confirmation for me that I was right. No thoughts back to my physics class about circuits, I forged ahead...

The design I had come up with was intended to keep things as simple as possible. Each motor driver had a + and - terminal on the shield, thus I only wanted 4 wires total coming out of the chassis bound for the control board. I would hook up the 2 motors on a given side in series. This kept wire clutter to a minimum, and kept everything as simple as can be.

I could regale you with tales of soldering through the plastic that held the leads, and cutting the wires too short after one end was already soldered, or how I realized the leads on the servo's were thin cheap and breakable, or how I forgot which lead was + and which was - on the servo because one was the revere of the other. But I won't, suffice it to say it's only the 3rd time I've soldered something. And I learned a lot.

At this point I had been at this for HOURS. It was a monster session. I was burnt out. My girlfriend who had been by my side for most of it, was passed out on the couch at this point, stirring only when I would get a face full of solder smoke and make a pained nasal sound.

I was DONE but couldn't go to sleep without seeing it move. Actually hooking up the logic boards was not an option so I just taped a 9V battery to the chassis and connected the leads to it. The results were less then spectacular. While holding it in the air, the wheels barely moved, and when sitting on the ground it couldn't overcome friction it seemed.

Blurry-eyed, frustrated, and tired. I called it quits for the night and passed out.




Arduino Adventures :: Day 5

As I stated last time, I had decided to try out Charlieplexing as a way of individually addressing 64 LEDs with only 14 I/O pins (9 is all I need for this actually). So I ordered some resistors and some very specific LEDs. Before I get into the build, let me give a high level overview of what Charlieplexing is and how it works, so that you can understand the conclusions I came to later.

Charlieplexing was invented in 1995 by Charlie Allen as a way of driving many LEDs with few I/O pins and nothing but resistors to implement it. It relies on two facts about LEDs:
That they are diodes, thus electricity will only flow through them in one direction That they have a specific "operating voltage", below which they will not light up even if current is flowing through them
( Instructables has a really great in-depth explanation here. )

Simply put, you hook LEDs up in combinations such that electricity will either not flow through certain LEDs due to the fact they are diodes in the wrong direction, or that electricity will flow through ones you don't want to light up, but not enough current to actually light them:

When all is said and done, only one LED will light up at a time. Thus, individual addressing:

Now the more astute reader may have noticed I just glossed over something. Yes I can turn individual LEDs on by themselves, but as is dictated by the circuit, I can not turn on all the LEDs at once, in fact not even a third of them, and in practice, you can actually only turn one LED on at a time using this method, which sounds pretty limiting. But there is a way around it: Persistence of Vision.

I'm sure you've seen it used some where before but not known it. The idea is if you can turn a light on and off fast enough, the human eye won't be able to perceive that it was ever actually off, and thus it will look like it is always on. So to make this useful, you "schedule" all the lights that you want to be on, and then the software scans through and turns each one on and off in succession, when it gets to the end, it starts over. You have to be able to scan through the lights enough times per second to fake out the human eye:

So with all that, I set forth to implement a prototype on my breadboard, and have a video of it ">here (it look a long time to make, not because it's long, but because I suck with the video editing software, so give it a watch :D ).
" target="_blank">

Now this whole research and prototype cycle allowed me to draw some important conclusions. And they aren't favorable for Charlieplexing :P

There are some small issues that make this method problematic for my application.
The circuit layout does not lend itself to have the LEDs in a grid. It could be designed around, but would be a real pain. This isn't a big one, but it's certainly a consideration.
As the circuit expands with more pins, and you want to have more LEDs on at once, I found the LEDs got dimmer. This could be for one of two reasons (or both). It could be the fact that the circuit itself is larger and has more resistance built into it over all (and the current is being split many different ways), and the more LEDs are scheduled to be on, the longer each LED will be off for during a given "scan". Now you can counteract this, by using lower ohm resistors to increase the overall current in the circuit, but then you run into the issue of the "compliment drive" LEDs lighting up dimly when they shouldn't.
And that last issue is a problem I ran into even in my small circuit.

So where does this leave me!

Well it leaves me out in the cold as far as Charlieplexing is concerned.

But I got to thinking... my original idea of using demultiplexers could still work, so that's where I am at, I have a few ideas I'm going to explore on paper, and I'll post when I have something concrete.




C3: NTP FTW! (And other acronyms)

LLOONNGG week of packing, moving, and unpacking. Still not done unpacking. Probably won't be fully unpacked by the time we move again Oh well.

ANYWAY! Onward and upward!

[sub][ I really like my little Paint.NET logo, so thought I'd throw it in again ;) ][/sub]

So since my last post I began working on NTP (Network Time Protocol) synchronization. As with EVERY part of the project so far, there were a lot of snags along the way, but I got it there. It's a truly crippling problem having the maker of my WiFi chip defunct. It leads to all sorts of problems with documentation and community support. But "Damn the torpedoes!" I say! FORWARD!

I had to implement the NTP protocol on my end. I simplified it quite a bit by not taking advantage of many features [40 bytes of hard coded zeros in the middle of my message ;) ], so it was actually pretty easy. Sending and receiving the UDP packets, however, was a bear because of the poor documentation for my WiFi chip. Took quite a bit of fiddling, but I got it working.

Then I found the great little Time library for Arduino that allows for easy manipulation of time and time keeping, and set that up to use my new NTP code for synchronization.

Putting it all together, here you can see the current boot sequence for the C3:

With this working, I set it up for a soak test. I wanted to see how much time the Arduino would lose after it synchronized only once, that way I could figure out how often I would have to re-sync with the NTP servers. After 24 hours I had lost just under a minute, and after 48 hours I had lost just about 2 minutes, which looks pretty good because it doesn't seem to be accelerating. It's a pretty minimal, and a pretty linear loss. I could probably sync with NTP as little as once a day, but to be safe I'll probably start by syncing every 12 hours.

So that's all good! But during the soak tests I did discover yet another problem with my WiFi software stack. It doesn't automatically reconnect when it's connection to the WiFi AP is dropped. It's a fairly minor problem in the software stack that I already found someone's patch for. My version of the stack is already pretty customized however.

So my next goal will be to setup auto-syncing at 12 hour intervals. Merge the WiFi auto-reconnect patch with my customized stack. And finally further customize the stack in preparation for working along side the display shield I will eventually be integrating. (I need to move some pins around in the code)

With all of that I should have a rock solid NTP clock, which of course is the necessary basis for everything going forward. After that I can focus on Google Calendar integration and other "fancy features" like audio output and a display




MQ3 :: A quick project

Still waiting on Arduino to release their official WiFi shield for my C3 project. So my mind began to wounder. And I started an Android app to help post articles to www.talentopoly.com. But got stalled due to waiting on 3rd party API support. So my mind began to wounder.

About two weeks ago I was browsing www.sparkfun.com checking out some of their Sensors and day dreaming about fun things to do with them, and came across this, the $4 MQ-3 Alcohol Gas Sensor. I immediately straightened up in my seat and all my synapses that had been on vacation began firing again.

You see, all my hardware projects so far get to a point of some sort of moderate success, and then get promptly torn down to produce another project. Mainly because their components are expensive and I don't want to re-buy them all. But also because those projects weren't something I could easily show someone. With the project now swirling around in my head, it was something I could put together, and keep together. And it would have obviously and meaningful applications to anyone I showed it to.

The project of course, is a Breathalyzer.

And after two nights of putzing around with it, I got it hooked up to a simple circuit, along with a 10 segment LED bar, and have it working.

[media] [/media]

This past weekend I put it to the test but came up short. Even after 3 beers it was still not able to detect anything. By the end of the night after 10 beers, the highest reading I got was 5 (out of 1023). The effective range of the device it turns out, is MUCH smaller than the absolute range I was reading it in. So the next day I adjusted the AREF (Analog Reference) value to greatly shrink the range I was reading. This boosted the sensitivity 4.5x. It can now readily detect just a single beer on your breath.

In addition to this I added in continuous sampling of the base line readings, and factor them out in order to get more constant and reliable values. My ultimate goal here is to make this as accurate as is possible with the MQ-3 sensor (there are certainly some very real limitations to this sensor), and to make it hand held. With a side goal of making it awesome ;)

This week I ordered a 16x2 character LCD display to display the calculated BAC, and more 10 segment LED bars to increase the resolution of the bar graph. Once that is all tested and working, I want to package this up in an enclosure and make it handheld.

[cross-posted from: darkrockstudios.com]



  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!