I was going to type up a thing documenting the video project I finished, in case anyone stumbled across it and wanted to learn how to do such things themselves. But ehhh, I'll work on it later. I'm more in just a mood to ramble from a personal point of view.
Using only a microcontroller chip and custom software I wrote, I was able to generate a composite NTSC television signal.
This is something I've wanted to be able to do for a long time now, and due to a combination of things (including laziness), I never did. I tried once a long time ago, but it didn't work, and thinking back on that now I probably didn't even fully understand what I was doing. I've learned a lot about NTSC video from various sources over all this time, so I realized I had the concept down, at least. But I had to teach myself how to use this particular brand of microcontroller to even do this (since it's the only one I had handy), which was another reason I never did it sooner.
I used an ATmega8 microcontroller from Atmel running at 4mhz. I did't use any interrupts in my code, so everything is carefully instruction-timed. I managed to squeeze in a 64x48 pixel resolution, using three possible colors: black, gray, and white. It's even technically a bitmapped display, because the pixel data all comes from RAM, and can be changed during retrace periods and the code will then display the new content appropriately at the start of the next field (at 60 fps).
To give you an idea of just how little time you have to work with, a complete horizontal line of NTSC video plus the retrace period takes 63.5 microseconds. At 4mhz, each instruction executed by the microcontroller is 0.25 microseconds. And you need more than one instruction to be able to toggle output pins of the microcontroller to control the color/signal being output. So I was lucky to get those 64 pixels horizontally!
The only reason the screen is vertically limited to 48 pixels is because of RAM limitations, and me using a bitmapped display. I designed it to use 2 bits per pixel. So that's 4 pixels per byte. At 64 pixels per line, you're using 16 bytes. A normal TV is capable of 242 lines of video, but just say I decided on 192 (since some of those lines are off-screen). 16 x 192 lines is 3072 bytes, or 3KB. The microcontroller I'm using has 1KB of RAM. Not gonna work. So what I did was to clone each line 4 times, effectively dividing that 192 lines by 4, giving me the 48 vertical resolution. 16 bytes per line times 48 lines is just 768 bytes, which will in fact fit in our 1KB of RAM. And best of all, 64x48 is a 4:3 aspect ratio, just like the TV.
Somebody somewhere reading this might be thinking thinking "2 bits per pixel allows 4 possible values, so why did you only use 3 colors?" And the answer is that technically there IS a fourth value. But that value outputs a sync signal on the line, which is only used in retracing the beam. So yeah, you could specify that value in RAM for a particular pixel, but you would just succeed in messing up your display.
I tested my timing in the simulator that comes with the assembler I'm using, and it was perfect. I was pretty confident that this would work on the first try once I got the chip programmed and connected to the TV. And I was kind of right; I just didn't realize it at first! I had an issue with the reset line of the programmer keeping the chip in reset, and me not realizing what the problem was for a few minutes. Once I remedied that though, it sprang to life, and I was a bit surprised at just how good it looked on the TV screen. I could never take a good enough photo of it.
So yeah, I have to say, I'm proud of it. Sure, it doesn't actually do anything visually, aside from show the Fybertech logo in a couple color shades with a border around it all. But there's something very awesome to me in being able to control a CRT. I'm literally telling it when to intensify a beam of electrons at a particular microsecond in time, when to retrace the beam across the screen for each line, when to retrace the beam back to the top of the screen, etc. LCDs are just not cool to me in that sense, because they don't actually do anything exciting.
Anyway, I didn't do color because that's a whole 'nother ball game. I doubt I'll even try to do it without assistance from another chip which will handle the encoding for me, because you start getting into quadrature encoding of signals. Fortunately for me, the chip I want to use is the same chip I plan to use for converting the output from my Karate Champ arcade board to work on the TV. So I should be able to rig up a single converter board and use it for various things like that.
I guess that's it for now!