Search This Blog

Sunday, July 29, 2018

ChibiTerm - Matrix Clock - Demo for the VGA Text

Projects / ChibiTerm  Original post date: 03/17/2016

Source code for this demo is now on github along with schematic, PCB layout, 3D model if you can't wait for the rest of the project.

https://github.com/FPGA-Computer/STM32F030F4-VGA

I whipped together a little demo for the VGA Text library I am working on for this project. It was inspired by The Matrix digital "Rain" sequence. It was a bit impulsive, but to be honest I think it is more interesting than seeing linux boot message flying off the screen.

I wrote the rip off effects myself using the VGA Text library. I haven't found a suitable Katakana font, so I stuck with the same terminal font. The font was reversed by telling the SPI to send out the video LSB first.

Spoiler: You are viewing this on a screen inside the computer, so everything is flipped.

The clock, rain effects and a shell are cooperative "task" in a big event loop. A callback program from vertical blanking is used to trigger events.

Would have loved to do this on the screen using PS/2, but not there yet.

(The long exposure time captured multiple frames and that's why the "rain drops " are smeared in block of 4)

Matric Clock demo
The schematic is the basic VGA output one with an external 25MHz oscillator. Pin 18 (PA10) is RxD, Pin 17 (PA9) is TxD. It is hooked up to a 3.3V TTL serial port (115,200, 8-bit no parity) on a PC for setting the time using a shell.

Matrix Clock demo schematic

Haven't ported the code to GCC. Probably going to take a while for source code release as I ound to find something I need to change.


The time is done by keeping track of vertical blanking. However the vertical blanking is not an integer. 31250Hz/525 = 59.5238Hz

This leaded to the clock not keeping time. I should have thought of using DDS technique for the timing.

Clock frequency = 31250/525 = 1250/21

Keep adding 21 to an accumulator until it reaches above 1250. That's 1 second.
Subtract off 1250 and continue counting. The remainder keeps track of the timing error
Sometimes it takes 60 vertical blanking and sometimes it takes 59, but on average the frequency is 60Hz. This trick can also be extended to correct for the tolerance of the crystal.


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.