Retro-style terminal with video generation in software
Posted: 06 Dec 2020, 13:52
"Chasing the beam" (programming a micro to output video) is always an interesting challenge. There are plenty of examples of doing it with Arduinos on the web - but all at fairly low resolution.
I was looking at using the SPI "hardware" of an 8-bit Arduino to generate the 'pixel clock' - it can be coaxed up to 8MHz which theoretically allows about 416 pixels in the active part of a standard PAL scan line - and you get 460 'safe to use' interleaved scan lines vertically (or 230 if you just output the same data for odd and even frames).
The 8-bit Arduinos don't have enough SRAM to handle that much display in graphics mode, but in text mode it might be possible. For VT100 you really need more than 2 colours - the chip probably isn't fast enough to output 2 or more bits per pixel at that speed but in character mode you only need to change colours at 1/8 the pixel rate (assuming characters to be 8 pixels wide - which would likely be needed anyway, because using a narrower font would make more work for the micro - and it probably couldn't then hope to keep up with the beam).
There's probably enough time in the vertical blank intervals to handle the other tasks: serial port or keyboard scanning, and updating the video (character) RAM.
I don't know whether the 8-bit AVR chips are capable of maintaining the SPI clock rate between consecutive bytes. That may not matter if it produces a consistent gap between adjacent 8-pixel characters, but any jitter would ruin the display. I need to do some experiments.
Edit: using assembler, I could get the SPI bytes steady, and next to each other, but the processor isn't fast enough to access the character data then calculate the address and fetch the next byte from the font table in time. Graphics mode is easier for the CPU, but the ATmega328 is hopelessly short of RAM, and even the 2560 only has sufficient RAM for about a quarter of the screen area.
The Seeeduino XIAO is probably a better way to go for performance/price ratio. I've been meaning to put one of those to work in an R/C transmitter too - smaller than a Pro Mini, much more performance, 12-bit A/Ds, can be programmed with the Arduino IDE, and still less than £5 each.
I was looking at using the SPI "hardware" of an 8-bit Arduino to generate the 'pixel clock' - it can be coaxed up to 8MHz which theoretically allows about 416 pixels in the active part of a standard PAL scan line - and you get 460 'safe to use' interleaved scan lines vertically (or 230 if you just output the same data for odd and even frames).
The 8-bit Arduinos don't have enough SRAM to handle that much display in graphics mode, but in text mode it might be possible. For VT100 you really need more than 2 colours - the chip probably isn't fast enough to output 2 or more bits per pixel at that speed but in character mode you only need to change colours at 1/8 the pixel rate (assuming characters to be 8 pixels wide - which would likely be needed anyway, because using a narrower font would make more work for the micro - and it probably couldn't then hope to keep up with the beam).
There's probably enough time in the vertical blank intervals to handle the other tasks: serial port or keyboard scanning, and updating the video (character) RAM.
I don't know whether the 8-bit AVR chips are capable of maintaining the SPI clock rate between consecutive bytes. That may not matter if it produces a consistent gap between adjacent 8-pixel characters, but any jitter would ruin the display. I need to do some experiments.
Edit: using assembler, I could get the SPI bytes steady, and next to each other, but the processor isn't fast enough to access the character data then calculate the address and fetch the next byte from the font table in time. Graphics mode is easier for the CPU, but the ATmega328 is hopelessly short of RAM, and even the 2560 only has sufficient RAM for about a quarter of the screen area.
The Seeeduino XIAO is probably a better way to go for performance/price ratio. I've been meaning to put one of those to work in an R/C transmitter too - smaller than a Pro Mini, much more performance, 12-bit A/Ds, can be programmed with the Arduino IDE, and still less than £5 each.