Update: For those who are interested in seeing how this is done, I have posted schematics and source along with some technical details about this project. Click here to learn more.
After two days of straight coding, this is the result – two more aliens and an animation routine that toggles between 2 images for each alien and changes aliens every n frames. The alien selection routine is implemented as a state machine and uses way too many instructions, but fit within a blank line of video so I called it good. The hardest part again was maintaining a constant number of clock cycles regardless of the program flow through the display loop. This is required to maintain the video timing and keep the LCD happy.
I also changed the image lookup table routine so that the image to be displayed is loaded during the blanking interval above the top of the visible screen. This makes the pixel display much more efficient during the field but at the cost of a bunch of memory. Now instead of execution time during the horizontal line limiting the max resolution, it’s memory instead… sometimes you can’t win. If I encoded color more efficiently the memory limitation would go away.
I need to clean up the code and add some more comments, but I’ll post the source in case anyone else is interested in learning how to generate RGB video with a PIC or wants to try a similar project.
Update: The LCD display I am using is a Sharp 4L-U4EB I bought surplus years ago. I haven’t been able to find any more of them since, does anyone have a source?
Here are some still images showing the animation sequence for each alien. Click on each for a bigger version.
This project was inspired by Rickard Gunee’s PIC Video Howto which gave me a big headstart in writing the code. Thanks Rickard! I have been wanting to work on this project since reading the tutorial several years ago, and finally got a chance to start it last week.
There are few fundamental differences in my approach compared to Rickard’s and others I have seen in the past. His tutorial was written a few years ago before 20MHz PICs were commonly available (it uses an overclocked PIC16F84.) He also focuses on generating composite video to drive a standard television (using the AV inputs). I am generating RGB video which will interface with the Sharp LCD I had sitting on the shelf. RGB is a little different in that it uses a separate sync signal (composite horizontal and vertical sync on one inverted TTL line) and each color is brought out as a separate 0.7Vpp signal. These two differences make the RGB interface considerably easier (in my opinon) to work with, especially since the approach to composite video Rickard uses is limited to black and white.
So far the biggest challenges have been with getting the video timing right. I am writing the whole program in PIC assembly and every clock cycle counts.
Andrew Milmoe of Make:SF recommended Charles Petzold’s book Code to me several months ago to help me refresh my knowledge of computer architecture as I dive into embedded systems development. I finally finished reading it this week and thoroughly enjoyed it. Code is both a history of the computer as well as a tutorial illustrating how to build one from the ground up using switches and gates. Some chapters are slow reading due to the complicated subject matter, but the way he brings everything together at the end makes it a great read. Although the book is in some ways dated (written in 1999, it talks about 128MB of memory being novel and Apple having problems in the desktop market) I found that it is still relevant. This is particularly true for microcontrollers and embedded systems which have more in common with the 8 bit computer that is the subject of the book than a Pentium 4 in today’s desktop PC’s.
Charles Petzold’s latest book, Code: The Hidden Language of Computer Hardware and Software, crosses over into general-interest nonfiction from his usual programming genre. It’s a carefully written, carefully researched gem that will appeal to anyone who wants to understand computer technology at its essence. Readers learn about number systems (decimal, octal, binary, and all that) through Petzold’s patient (and frequently entertaining) prose and then discover the logical systems that are used to process them. There’s loads of historical information too. From Louis Braille’s development of his eponymous raised-dot code to Intel Corporation’s release of its early microprocessors, Petzold presents stories of people trying to communicate with (and by means of) mechanical and electrical devices. It’s a fascinating progression of technologies, and Petzold presents a clear statement of how they fit together.
The real value of Code is in its explanation of technologies that have been obscured for years behind fancy user interfaces and programming environments, which, in the name of rapid application development, insulate the programmer from the machine. In a section on machine language, Petzold dissects the instruction sets of the genre-defining Intel 8080 and Motorola 6800 processors. He walks the reader through the process of performing various operations with each chip, explaining which opcodes poke which values into which registers along the way. Petzold knows that the hidden language of computers exhibits real beauty. In Code, he helps readers appreciate it. –David Wall
This past weekend, I attended The Last HOPE at the Hotel Pennsylvania in NYC. The con was awesome and I had a great time. This was my first HOPE, and I noticed a few strong themes this year, including:
Hardware hacking is getting a lot of attention and there is a lot of interest in microcontrollers including new design and reverse engineering off the shelf hardware like RFID.
Local community based physical spaces for hacking are booming. Hackerspaces like NYC Resistor and the Hacktory are becoming a very big part of the scene, and new hackerspaces are popping up all over the world. Each space has their own unique interests, but common themes seem to be microcontroller hacking (especially Arduino), fabrication (like Reprap and Fab@Home) and other more physical projects instead of just writing code. There was even a new wiki announced at the show that is devoted to tracking hackerspaces and helping start new ones at hackerspaces.org.
There was an awesome talk about Biohacking by Chris Seidel (I wish I could find a link) that makes me wonder if we will see more of this in the future as Bioengineering becomes more accessible to the masses. The parallels Chris identified between biological processes and electrical circuits were spooky.