Sunday, June 13, 2010
NEStalgia Demonstration Video and Project Files
Saturday, June 12, 2010
Penn's Engineering Dean Checks Out NEStalgia!
Friday, April 30, 2010
Love, Loss, and Redemption
Wednesday, April 21, 2010
Reading Keyboard Input
This is just a brief post - Kevin's posts and videos are usually clear and succinct enough not to warrant additional cruft by me :) For those who watched the game play video in the keyboard input post, you might have noticed that Kevin was pressing the key repeatedly before the input was accepted.
Due to Nano-RK's task based style, getting user input from the keyboard needs to be a bit of a polling hack. This is because C input methods such as getchar() are blocking methods, meaning that once called the program will not continue until the function has returned. Unfortunately Nano-RK sees this blocking as the task being in use and will not preempt it, so it never switches to the idle task. This causes the task reading user input to eventually violate its period allotted, as well as the additional reserve.
To solve this problem we loop, waiting for the signal in uart_rx_signal, which is registered with the system before. Once the signal is set, and data is ready essentially in the buffer, we then call getchar(), which should return almost immediately with the typed character.
Until we work out exactly how the uart_rx_signal is set and tighten up the timings a little bit, we will continue to experience this lag and missed keystrokes when checking for keyboard input. Fortunately however, using the keyboard for input was only a midway point to prove that we could send user-defined input to the NES. We can now safely put the keyboard aside, since the Firefly node attached to the NES will now be receiving all of its inputs from its corresponding Firefly node in the toy gun.
Tuesday, April 20, 2010
Hacking the Toy Gun
Today we started taking apart one of the toy guns that will eventually become the wireless controller for the NES.
Toy gun that will soon become a wireless NES controller
The toy gun is really 4 plastic parts that are held together by many screws. Two of the parts are actually glued together at the ring of the front of the flashlight, which is located below the barrel of the toy gun. To disassemble the gun, we unscrewed all of the screws and used a saw to cut off the glued-on ring of the flashlight.
Inside of toy gun after flashlight ring was cut off with saw
Once the ring was removed, we had easy access to all four pieces of the toy gun as well as the underlying circuit that powers the speaker and flashlight. The gun is actually perfect for this project because it provides an easy-access panel to the battery compartment, which we can gut out and replace with the Firefly node. This will allow for easy programming of the node while it is embedded in the toy gun.
Using a Dremel to round off the edges where we cut off the flashlight ring
Lastly, in an effort to improve the aesthetics of the gun were we had sawed off the flashlight ring, we used a Dremel to round off the edges. During the next week, we'll embed the Firefly node in the toy gun and program it to wirelessly transmit accelerometer data to the receiver node connected to the NES.
Hardcore Hackers
Monday, April 19, 2010
Writing to the NES
Today we successfully used the computer keyboard via serial terminal to control the NES. We tested everything using Super Mario Bros. 3.
We ran into some trouble in trying to use the Firefly to mimic the 4021 parallel/serial shift register IC that's in the NES controller. Apparently the Atmega chip that the Firefly uses is just too fast to achieve the correct division you would need to send data out to the NES at the correct frequency (83.33 KHz).
Using a USB TV Tuner to view the NES game on a laptop
We then attempted to use SPI (Serial Peripheral Interface) with the Firefly as a slave to the NES. That way the NES could provide the correct clock frequency and latch signal and the Firefly could output data accordingly. However, to accomplish this on the Firefly you must de-solder a resistor and switch one of the reset lines. Long story short, we were asked to find another solution.
Stripping the wires of an NES controller
So we decided to simply stop trying to reinvent the wheel. We de-soldered the 4021 chip from the NES controller and connected 8 GPIO pins from the Firefly to the 8 parallel input pins of the chip. Finally, after more than a week of head-scratching, we were able to control the NES using the PC keyboard. Check the video below to see our setup in action.
This week's goal will be to figure out wireless transmission so we can efficiently transmit the ADC information from the Firefly node in the gun to the receiver Firefly node connected to the NES. We'll also post pictures of what the inside of the toy gun looks like.