Monday, February 25, 2013

IR Receiver on Teensy

For the past few days I've worked on the first building blocks of my Space Invaders project. As of right now, the approach I've decided to take is to have the Teensy board take the inputs from an infrared remote and control most of the game logic there and then send some display information, like the position of the different objects on the screen to the Spartan-3 board (maybe via Serial port) and have the Spartan-3 do all the display work through its VGA port.

I have been working in the VGA controller and video memory on the Spartan-3 (more on that later) but I took a break from it to work on the controller for the game. Basically, there is only need for 3 buttons: left, right and fire. Maybe I'll add extra functionality after the basic part is done and use some other buttons, but for now 3 is all I need.

This was my first time using the Arduino environment to program Teensy(or anything), which is compatible with it as well as with C. I was glad to find the many libraries at my disposal. I started with Ken Shirriff's IRremote library and added my 7-segments display with slightly different code than the one I used last time to make its timing more independent from the rest of the program. I also used a piece of an old Ethernet cable for the wiring to make it nicer and avoid the mess from last time.


My IR remote uses the NEC protocol and Shirriff's library worked like a charm, I only added a few lines of code to account for held-down keys so the code for the key pressed keeps repeating instead of changing to the special repeat code. The above picture is of the 7-segments display showing the last 2 bytes of the decoded result, which in the case of my remote, are the only ones that change.

As I mentioned, this is just part of the Space Invaders project, so the code for this sill be available on GitHub HERE. The 7-Segments display files can be reused as a basic library, just keep in mind that the pin assignments are defined in the .h file.



Thursday, February 21, 2013

What's next?

Remember all that hardware I got last year? Well, I finally have some time to start playing with it! I still don't have any original project to work on, therefore, in the meantime I will be doing an adaptation of one of my old school  labs to practice, focusing especially in my coding style because I am well aware of my deficiency in that area.

A couple years ago, for my embedded systems class, we replicated the space invaders game on a Xilinx Virtex-II Pro board. Sadly, I didn't catch in video the finished product and the only thing I could find was this  video of me testing part of it:


So, for my practice project I think I'm going to do the same thing but this time I'll use my Teensy++ and Spartan-3, which is by far less powerful than the Virtex-II, and adapt some of my old VHDL code to build everything again from scratch. As of right now I haven't really considered the limitations of my current hardware now that I won't have a "fancy" PowerPC processor and 2GB of RAM, but the plan is to program a part of the game on each device and get them to talk to each other. This way I get to practice on both of them and also learn something in the process of making them interact. It should be doable... right? ....right?

Anyway, once I get started I'll post my code on GitHub for everyone to see, just keep in mind that it will be a  long-term, always work in progress thing for learning and practice purpose only.






Pey! Where have you been?

Wow, it's been almost a year since my last post. I had to set aside my little projects because 2012 was my last year in college and since I left the best classes for last, I had to focus on them. My last semester was especially interesting, as I did my senior project and learned a little about android development, something that I hadn't even touched before. In a nutshell, what my team and I did was develop an android app for a Galaxy Nexus to drive a little toy truck using its GPS, compass and camera receiving target locations from another android app developed for a Nexus 7 tablet via the internet.

The tablet app had a map to select destination points and a couple testing functions as well as a D-Pad for manual override. It looked like this:


We used OpenCV to make the camera look specifically for orange cones and avoid them. Here's a video of the last test we ran of the completed project (I'm the guy in the red jacket):


I admit there was some room from improvement here and there, but given the time we had to do it and the fact that we really didn't know anything about android development or computer vision when we started I think we did great. And with this I said good bye to college and I am officially an Electrical Engineer! Yay!