Author Topic: AVR Text Console / Pong System  (Read 19516 times)

FyberOptic

  • King of Earth
  • Administrator
  • Hero Member
  • *****
  • Posts: 2522
  • Oh god what is that?
    • Fybertech.com
AVR Text Console / Pong System
« on: November 13, 2010, 12:20:17 am »
I thought I would crosspost this to here, since I realized I never made a topic about it!



I suppose I can post the videos I made recently of my AVR video project.  They're not much to look at, particularly since I have a hard time filming it without the picture looking overexposed (which it still does a little even in these, because the TV image has crisp edges).  But they're enough to demonstrate what my code is doing for now.

The first one is of my 16x8 text display, using a 4x6 font.  I only put in 128 possible characters, and some of those aren't even there so I just used black and white blocks for the time being.  But the alpha-numeric ones are the most important anyway.  I'm just incrementing through all the possibilities, at a slow enough rate to view them.  It's also showing off the text scrolling capability I added.

[youtube]http://www.youtube.com/v/gKgVoWyGCdA[/youtube]

The later iteration still had the ability to draw text and everything, but it's not doing it anymore.  It's basically a simple Pong game, using a potentiometer (a knob) to control a paddle on the screen to bounce the ball around.  There's even sound, using a roughly 1300hz tone through the TV speaker.  You can hear it faintly through the terrible buzzing sound of the camera.

[youtube]http://www.youtube.com/v/0GrvTjoXa0w[/youtube]

I thought I would have a problem cleaning up the pot input, because the paddle was jittering around at first.  But a smoothing capacitor took care of that.  A neat thing I found was that using a cap that was too high in value would actually make the paddle glide to position rather than respond instantaneously.  That could be neat to implement in something in the future.

The sound is a simple square wave generated by one of the PWM channels of the chip.  Not much needed externally for that, aside from resistors to limit the output and a capacitor for coupling.  Though since it uses the same pin as one of the connections used for programming it, I had to stick a diode in too.  Every time I program it now I hear a neat little electronic spurt through the speaker briefly.

This is still using the 64x48 pixel display as from before, just to clarify.  It takes 768 bytes for video memory, since each pixel takes 2 bits (allowing four possible colors, of black, white, and two shades of gray).  The ATmega8 I'm using to do all of this only has 1KB of RAM, which is a huge limitation in the quality of the video I can generate.  I mean, it's possible to generate higher resolution video lines on the fly if I wanted, but that's too much like Atari 2600, where you figure out what to draw on each line when you get to it.  In other words, too much work.  I just wanted a bitmap-based display, where I could have a code loop running which just writes pixels to memory locations, and then the video interrupt handles displaying that independently. 

If I went to 1-bit-per-pixel, that would still just allow something like 128x48 resolution with the way things work now, and limit me to just two colors.  Even using every single byte of RAM and limiting the functionality of the game code would manage 128x64.  Just not worth the limitations it would cause.

Anyhow, I want to put this all in a project box, running from a battery, and with a couple of RCA jacks for audio and video sticking out of the top.  I have a box like that laying here which I ordered years ago.  Just needs a hole drilled into it for the pot's stem to come through.  I also need to find a knob for the pot.  It's almost worn a blister on my finger from turning the stem so much, since it's kind of stiff.  I stuck a piece of plastic on it for now which makes it a bit easier.  I'm just not sure who even sells individual knobs that will fit on that, other than like Ebay.  I'd rather buy it local though so I can make sure it fits first well.

I still need to clean the code up too, maybe add in a scoring system, maybe an AI paddle, I dunno.  But I still feel like I accomplished my original goal(s).  Not only of a generating video, but of a text display, as well as a simple Pong game.  So anything else I add is just icing on the cake.  It's been a good learning experience and confidence booster, and I feel like now that I'm comfortable with AVRs enough that I can do most anything I want in the future with them now.

FyberOptic

  • King of Earth
  • Administrator
  • Hero Member
  • *****
  • Posts: 2522
  • Oh god what is that?
    • Fybertech.com
Re: AVR Text Console / Pong System
« Reply #1 on: November 13, 2010, 12:21:40 am »
I initially just did some static images as a test.  Here's a peek at the source code of that if anyone's curious.

And some of the photos of other junk I stuck on Facebook before, while I'm at it:









This last one was a demo from after I added a fourth color possibility by putting the sync on a separate output pin.

« Last Edit: November 13, 2010, 12:32:12 am by FyberOptic »

Bluejay

  • HERO OF FYBERTECH (tm)
  • Collguy
  • Hero Member
  • *
  • Posts: 1624
  • Careful, or the mice will rise up.
    • My Deviant Art page
Re: AVR Text Console / Pong System
« Reply #2 on: November 30, 2010, 05:02:10 pm »
The last one made me think of Excite bike.
One day, when the zombies rise and destroy humanity; I will survive, I will live on, I will take your best stuff for myself.