HUB08 LED board (matrix) display protocol and interface to STM32F103

There are lots of China made LED board with HUB08 connector. Boards typically are single or two color ones, without variable brightness. Boards can be connected in daisy chain mode using 16 pin connector. There are specialized MCU boards from China with very ugly, sometimes password protected software. For custom use there are some bad coded Arduino “libraries”, but there is no protocol description. We will try to fill this gap and analyze China made controller and will connect some boards to STM32F103 “Blue pill” board.

The connector is standard 0.1″, 16 pin connector:
Hub08 pinout
7 – EN, enable image; 9,10,11,12 – data input; 14 -latch (transfer data from SPI register to output register; 16 – SPI clock; 2,4,6,8 – select current line to show, total 16 lines.

General timing of the interface:
HUB08 interface protocol LED board
SPI clock was about 1.2MHz, horizontal line refresh ~11kHz.

How it works: transfer via SPI some pixel data (up to 4 channels), send short LATCH command (74HC595) to transfer data and for some time enable EN to show line. The LED boad has hardware protection for stalled data transfer. If static data are detected, the output is disabled. To keep image on the board the clocks must be active.
Hub08 LED board SPI clock and data timings
Clock timings details.

There are two ways to create image on the LED matrix board: dynamic creation of the image and transfer from video RAM. First method saves lots of RAM, but there must be very strict timing, like in Atari 2600. Second method is much easier, but we need video RAM.
For our experiment I decided to use video RAM method. I connected two boards in 64×64 pixel (LED) configuration.
As “Blue pill” board’s MCU has only one channel SPI (STM32F103c8t6) I made some strange connections on the LED boards- all SPI data lines are connected in series: Data from the MCU goes to R2 of the first board, R2 output from first board returns to R1 of same, first board. Output R1 of first board goes to R2 input of second board. R2 output returns to R1 input. Now we have 4 rows of 64 LEDs int the single logical row. We need transfer the data for 4×64 LEDs (bits), total 32 bytes of data. And repeat this for 16 lines. Total we need 512 bytes of the video RAM.
All Hub08 interface is interrupt driven: first we use timer interrupt for line start (Horizontal sync). In this interrupt we calculate video RAM addres and transfer 32 byte via SPI using HAL routines (somehow DMA SPI is not working! Maybe some error or fake chip on this PCB). How we wait for SPI finish interrupt. Here we select LED row, enable output, change some variables for the software interrupts and return control to the main program.

All software and source code:
Hub08 LED board interface with STM32F103 Blue pill source code and compiled HEX file.

Hub08 software have only the basic functions: plot and point (setting the point and reading color of the point from video RAM).
Hub08 LED board interfacing with STM32F103 Blue pill

Posted in LED, MCU | Leave a comment

Power standard for my computer collection

I have small collection of vintage computers. Several computers do not have PSU, other one have very specific ones. The problem is with some that looks like “standard”, have same connector like others, but have reversed polarity. Like ZX Spectrum or Commodore 16.
I decided to introduce some standard for my collection:

  • The computer must accept any PSU in collection without damage to computer. It may work, o just do not work. But no damage to computer.
  • The computer may harm PSU by shorting it.
  • The computer must accept unregulated transformer PSU with “12V” marking (up to 16V unloaded) for few minutes without harm.
  • Computers can have upgraded internal regulators. (DC/DC converters) and crowbars.
  • Round connectors are “CENTER POSITIVE”.

To prevent reverse polarity, computer may have serial diodes, rectifier bridges installed.

Silicon rectifier installed in Commodore 16.

To prevent polarity errors it is possible to use 3..5A diode to short power input (assuming that PSU bricks are <3A).

Posted in Anything | Leave a comment

How to print, preview in VB Studio Express

There is classic basic program for Commodore 64 computer to print maze on the screen. This program random prints “/” and “\” character on screen. I wanted to implement same program on modern computer and print the result. Not only to print, but also, use print preview.

Original C64 program:
10 PRINT CHR$(205.5+RND(1)); : GOTO 10

After some investigation I found in the internet the best option for MS Visual Studio Express VB (.net). This software “set” allows to print the same stuff to windows form image, printer preview control or to real printer output. This is not very straight, with some hack, but source code is self explanative. Thanks to MS for making it so strange.

Printing, preview in VB Studio Express
Program is very simple- demo button to invoke various types of functions: print, printer setup, page setup, print preview… With small change it is posible to use same graphics commands to picturebox object.

Visual Studio Express VB Source code.

Program read “page setup” settings and adjust parameters for print. Still there is bug when changing paper orientation, but I think it is solvable.

Posted in Anything | Leave a comment

Quick hack – optical mouse for Amiga (or Atari) computer

I was testing old Amiga computer and noticed, that somewhere I lost the mouse. It is proprietary mouse for Amiga computer, it even does not work with Atari ones. The mouse itself is very simple- only raw quadrature information is sent (mouse buttons are on separate wires). This make mouse very simple, but it uses 8 wire cable! (9 with middle button).
I was thinking, that I might find some ball mouse for PC computer, remove controller and will build exact replica of the Amiga mouse. But ball mouses are rare. Instead I found several optical mouses, the old ones, with two chips inside.

The first mouse was USB one, with Avago chip:
The chip is ADNS-5020, from Avago.
This chip has SPI interface, too modern for our goals.

Next mouse was PS2 one:
This chip is older, OM02, from unknow company in China.
This chip is perfect- it has quadrature (delta X and delta Y) output pin. Datasheet even describes how to build your own mouse.
For Amiga mouse there is no need to build anything. Solder out controller, connect quadrature pins to cable. Rewire mouse buttons (if you need. Mines was connecting to Vcc, Amiga needs connection to GND).

The only problem is thick wire. But mouse works very well.

Posted in Anything, Vandalising | Leave a comment

8-bit font tool: editor, rotator, mirror

This is small tool writtent in Visual Studio Express VB. Main purpose of this tool is to find 8 bit wide fonts and graphics in various ROM, firmware files and export to binary or C source file.
Tool can edit single bits (pixels) change bit order (mirror), rotate bits and work with blocks of memory (in case of 8×8 matrix- rotate CW and CCW), flip up-down.
All these manipulations help to prepare custom fonts for cheap LCD/OLED screens for use with ST32 or AVR MCU.
Support different font height so it is possible to extract EGA/CGA/VGA fonts from video card BIOS.

Font rotator

Software requirements: modern 32 or 64 bit Windows computer with .NET framework. I do not have key to sign software, so during installation, your windows OS will warn you several times during install.

There is MS Visual studio “install page” to get the file.

Original Lithuanian page about font rotator.

Posted in MCU | Leave a comment

Permanent link to Atari 1088XEL SMD

Permanent page for Atari 1088XEL SMD project.

Posted in Anything | Leave a comment

TI-99/4A printing new key

Modern 3D printers allow us to print at tremendous quality and resolution. And some Chinese ones are quite cheap. My one of Texas Instruments TI-99/4A computers has a problem- due to a bad package and careless shipping it lost three keys. I still had keycaps, but it itself is damaged- the shaft is broken.

3D printed replacement key shaft for TI-99/4A computer keyboard
White ones are original, clear ones are new, 3D printed. It was quite hard to create a 3D model for this part as it is very small and has tons of details. But after four attempts I made it. On the left side of the image there are bad ones (the horse is also bad). Meanwhile on the right side there are some keys removed from the keyboard and disassembled.

Also, here is the STL file for this part. Take a note, that size of the key is ten times bigger (x10):
3D model in STL format for TI-99/4A keyboard key.

just scale the part to 10% and everything will be fine. Why? Because my 3D software is very buggy and only basic features are available. It is much easier to do bigger models in that software.

Posted in Personal | Leave a comment


Whenever I talk about designers of the ZX Spectrum computer I use to say that they were smoking weed. Now I acquired one computer from another family of computers, TI99, I can tell that Texas Instruments designers not only smoked weed, but also used some heavy stuff. This is a crazy computer from an internal design view. Or maybe it was done on purpose- there was a big company behind pressing to use some obsolete chips to increase sales.

And there is the result:
TI-99/4A computer
It is a Texas Instrument TI-99/4A computer, or maybe “console”- in all technical specifications it is called console.
Continue reading

Posted in Anything | Leave a comment

ZX interface 1 and Microdrive

I collected several ZX Spectrum series computers, but I don’t have any fancy peripherals. After several attempts I managed to buy ZX Spectrum Microdrive and interface 1 for it.
ZX microdrive
As always with ancient hardware it is working a bit, but in general not working: tape inside is moving, but nothing from the computer. The only problem, that to open this device I need to tear off the metal cover. According to original documentation, this metal cover is single use only.  Now it is impossible to get new cover, so I gently took it off, but some deformation happened.
Continue reading

Posted in Anything | Leave a comment

PS2 keyboard for ZX Spectrum (or clone)

ZX Spectrum and other computers of that period use proprietary keyboards with direct connection to some specific chip or connected directly to computer bus. Old keyboards are damaged from elementals or time, and sometimes are not very user friendly compared to standard ones. Goal of this project is to connect old and obsolete (!) PS/2 style keyboard to ANY old computer. This project is tested on ZX Spectrum CPLD clone, but mimics the original ZX 40 keys keyboard. Why not a USB keyboard? Because it limits to the narrower selection of MCU’s and USB HID is way more complex to implement.

This project consists of one easy part and one very rare part- CPLD. I think that maybe it is possible to directly connect without CPLD (or glue logic) with modern MCU, but my CPLD ZX spectrum uses “turbo mode” with 5MHz CPU clock and speed of keyboard scan is too fast for MCU pins.

How does it work? It is crazy multi conversion:

  1. Key press is connecting the matrix on the keyboard. Keyboard detects this and converts keypress to scan data. This data is transmitted serially to the PS/2 interface.
  2. MCU collects PS/2 data, decodes from scan code to ASCII.
  3. ASCII key codes with modificators are combined for extra key combinations and stored in the key buffer.
  4. The key buffer can hold up to 10 keystrokes (+modifiers). So multistroke is possible (especially for games). Multistroke is limited by keyboard hardware, not this project.
  5. All data is converted to a 40 bit key code matrix (8 columns, 5 rows) for the ZX computer.
  6. All 40 bits are shifted serially to CPLD at fast speed (2+ Mbit/s, depends on CPLD and connections) DMA SPI.
  7. CPLD decodes the bit stream and emulates keyboard hardware.

CPLD Hardware:
CPLD block diagram
Shiftreg is simple 40 bits shifting register to store SPI data, following with 40 bits latch register. This looks like five 74HC595 connected in serial. Last module is combinatory logic. It is written in Verilog:

module keyboard( keys, col, row);

input [39:0]keys;
input [7:0]col;
output [4:0]row;

assign row[4]=(col & keys[7:0]) !=0;
assign row[3]=(col & keys[15:8]) !=0;
assign row[2]=(col & keys[23:16]) !=0;
assign row[1]=(col & keys[31:24]) !=0;
assign row[0]=(col & keys[39:32]) !=0;



(my design uses inverted row/col. Depending on real hardware these buses may be inverted)

I am using a cheap STM32F103 MCU from China, Bluepill format (it can be a fake one, with smaller RAM/ROM size). All software is written using GCC and STM32CubeMX. All source code and compiled binaries are on the bottom of the page. PS/2 write is not implemented, now it just resets the keyboard on Esc key press. I have tested 3 keyboards and one has some strange bug- sometimes it starts translating some strange data if keys are pressed very fast or very long. Pressing Esc stops this chaos and inits keyboard interface.

Standard PS/2 keyboard has more keys than the ZX Spectrum, so some keys are redefined for more convenient usage: Like “;” and “:” pair- pressing dedicated key for semicolon and shift generates specific ZX spectrum keystroke. Same for “/?”, “=+”, “Backspace” and some other keys. Also, the numeric keypad is working too. “Caps lock” is working too, but LEDs are not used (because I do not implement PS/2 write properly and also, that it may not indicate real status of the computer). “Shitf”, “Alt” and “Control” are in use, but the logic is strange. And it is not my fault- it is Sinclair.

All source code and compiled binaries:
PS2 for ZX Spectrum source code, plain GCC for STM32F103.

Example Quartus project: Quartus archive. Will fit to EPM7128 or bigger chip.

Do not forget 5V/3V logic conversion. STM is not tolerating 5V logic very well.

Posted in FPGA, MCU | Leave a comment