Hot-Headed Munny

I suppose it’s about time that I update the world with the goings-on in my projects. I spent what free time I had this weekend working on my KidRobot Munny. I haven’t actually worked on the Munny yet, but rather the related software and hardware. “Software in a Munny?” you exclaim. Indeed. I’ve taken a BlinkM from ThingM, loaded up some software on it as though it were an Arduino (yes, it can be done), and hooked it up to a Memsic 2125 accelerometer breakout board from Parallax. The goal is to insert all of this in the head of my Munny so that when you shake it, it glows various colors as though it’s heating up from the movement. I’ve built a rudimentary version already, but now I need to smooth out the color transitions.

So what’s the hold up? Well, I thought it would be neat to program everything in software on the ATTiny on the BlinkM, so I wrote some code with an HSV to RGB color converter (which, by the way, I borked from the get-go), a cute exponential averaging filter to smooth out the transitions, and even gamma calculating functions (with fractional powers and all). Oh, and all the calculations were in 32-bit floating point math (recall that the processor in question is an 8-bit unit, running at 8 MHz I think). So yeah, of course it didn’t work.

I spent the whole evening on Saturday debugging my unnecessarily complex code until it started working more or less. But it would send my debugging information over the console at a visible rate (a few bytes a second), and my code had no programmed delays. It was taking as much as a quarter second just to get the x and y accelerations and calculate PWM values to send to the LEDs.

I was really just being a brat anyway in trying to code the whole thing from stem to stern on the ATTiny. So now I’m going in the opposite direction and will use lookup tables generated in Excel (actually LibreOffice Calc). Let me tell you how that’s coming along. I started in Google Docs laying out my work in a columnar format (because it was easier for me to visualize). To get a nice CSV file, I figured I would transpose everything (columns to rows) and export. But it turns out that the number of columns are limited to some number less than I had rows. I probably should have exported the file and continued my work in LibreOffice, but out of frustration I just erased it.

At this point I’m still working on the spreadsheet. I’ve arbitrarily decided that my arrays shall have 256 cells. It seems like a reasonable size for an array, especially considering that there will be three of them (R, G, B). I can do whatever crazy calculations I want in there and just copy them to the firmware and upload it to the microcontroller anew. The problem is that for each color (R, G, B), there are at least two distinct regions, one where the function is flat, and one where it slopes up or down. Moving the border points between those regions is not easy unless I use IF() statements in Excel. I hate using IF() statements in Excel. But should I just go ahead and do it because I’ll regret having to move them around by hand later? Probably. Who knows whether I will actually do it.


One response to “Hot-Headed Munny

  1. Pingback: Hot-Headed Me « squishyrobot·

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s