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

Sinclair QL – modifications for EPROM

I have Sinclair QL, “issue 5″ with 3 EPROM chips. One of the chips is riding on the other chip. And yes, it is the original solution from Sinclair engineers- they were pressed by Apple computers new product and they had to make it fast. This computer had some problems- the screen was filled with garbage and nothing was working. Looks like a RAM issue, but original firmware is not very good at diagnostics. It is very nice that there is a third party ROM for this computer and it is possible to download ROM image. This ROM image will not fit to single ROM in current configuration and it is quite crazy to piggyback ROM chips. This topic is also commercialized in retrocomputer world, but there is very simple fix.

First, I just placed a small PCB to test the computer and check RAM. The RAM was good, problems were in piggyback ROM.
big EPROM on Sinclair QL
(Some images are clickable)

Computer requests ROM’s chip select rising HIGH ROM_OEH. Typical EPROM chips use inverted CS/OE pin. So, I placed a 74HC00 chip to invert the signal. And one wire for the missing address pin.
Continue reading

Posted in Anything | Tagged , , | Leave a comment

Real easy Video fix for ZX Spectrum +2 (gray, “Toast Rack”)

I bought a ZX Spectrum +2 gray (toast rack) for my retrocomputer collection and it was the fail. The video output was bad and also there is a serious problem with RAM or ULA. But this article is about making perfect video output without fancy tuning. This article is a bit rude- I was searching the internets for more information and almost all data I found is copy paste of people without any deep analysis. Also, I found that about everything for this computer is deeply commercialized compared to Atari ones. Also, schematics and documentation are shitty.

So here is the starting PCB of ZX Spectrum +2, marked Amstrad 0500 ISS3 (Z70500):
ZX Spectrum +2 PCB 0500 ISS3 Z70500
(press on image for bigger)

Continue reading

Posted in Anything | Tagged , , , | Leave a comment

Printer from calculator, part 2

Continued from part 1.
The printer from the calculator is a neat toy, but we want a real USB printer. So, using my new STM32F103 CubeMX USB printer class for communication with the host computer and some tricky INT based software from me, I built a real working* printer. The asterix near working has meaning- there is a problem with printing one text combination and I don’t know how to change the color of the print and how to print first (rightmost) symbols.

STM32F103 USB printer device class citizen

All software is module based. One module is USB stack, one module is USB printer device class, one module is interface with real printer hardware. There is one trick with USB device software- the USB INT level must be lower than INT used for printer mechanics. Yes, the printer is interrupt driven and completely asynchronous from the main body loop.
My software and compiled binary is for a slightly bigger chip – STM32F103RET6 (512kB ROM, 64kB RAM), but it is usable with regular blue pill PCB (If China people put at least the same size chip as in real blue pill. I had some weird problems with alieexpres blue pill boards, so I build my “white pill” boards).

Warning, do not rebuild STM CubeMX project in source code. The Cube program will overwrite my printer class.
STM32F103RET6 USB printer device source code and binary – printing on Citizen CX-123II calculator printer.

It was fun, but I lost interest continuing this Citizen printer. It can print only numbers and there is no real documentation.

Posted in Anything, MCU | Tagged , , , , | Leave a comment

Printer from calculator, part 1

In a pile of e-waste I found a printing calculator, Citizen CX-123II. It is a regular calculator (with some wicky calculations), but with a printer- all output from the screen are hard-copied to paper roll. It can print only numbers and some special symbols. But it has two colors- red and white.

Citizen printing calculator Citizen CX-123II
The printer inside (printer module or body) is made by Espon, M-71T. But I didn’t find any documentation about this device. The only way to play with it is reverse engineering. There are only a few lines connecting the printer to the mainboard, so I hooked my logic analyzer and watched what was happening when printing.

logic analyzer output for Epson M-71 printer
The hardware inside the calculator (regarding printer) is very simple – two transistors and 3 lines directly going to MCU. Printing is “very intensive” job for a calculator’s MCU- even LCD images are switched off during printing. Mainly because the printer is asynchronous and MCU must wait for specific data on those 3 lines. Meanwhile output lines are very simple- just motor (PWM) power and single pulse for print. Depending on print pulse timing, different symbols are printed. And more, depending on the time used to hold the print command, new line and maybe color is selected. (I didn’t manage to decode how color is changed and how the first [leftmost] character is printed).

Epson printer to MCU
There are some tricks in this mechanical device, like it is impossible to print two nearby symbols on a rubber stamp (“1234..”) because mechanics are too slow, but there is no problem printing alternative patterns (“1357..”). So, when printing some numbers, the printer is printing slower and some numbers are printed at a remarkable speed.
The Printer is about a 5V device (~4V for motor, 5V for clutch), meanwhile the STM32F103 device I used is a 3V device. But using two mosfets from computer mainboards made good interface and level shifting. Input data from the rotor position encoder is used with MCU pullup- automagic 3V interface. This encoder is a mechanical switching device, there is very bouncy data from it. In my software, I used quite complicated debouncing software tricks. But all software stuff is in the next article.

Posted in MCU | Tagged | Leave a comment

ARM:0018 STM32CubeMX hack – printer class device

This article is about printer class device for STM32F103 and STM32CubeMX.
Somehow there is NO printer device class example in whole internet. There ar CDC or HID examples copied from same STM32CubeMX example with minimal explanation, few of mass storage device samples (without real usability), some audio device. But there is no PRINTER CLASS example at all. Looks like that everybody is using printers and nobody is designing printers. Meanwhile, printer is very simple device- it receives some data from host and reports few bytes of status data. So here is my project- printer class device for STM32F103 MCU. Project is based of canned CDC example, with light modifications. I don’t know how to make CubeMX templates. So if you rebuild project using Cube software, some of files will be overwritten, some added. Do not rebuild project using cube.

What my project can do:

  • Connects to host computer (Windows, Mac, Linux) and enumerates as printer class device.
  • Printer reports 1248 id string. If string is properly coded, host OS recognizes printer model. Example printer is “text only” – no drivers needed.
  • Printer can “print”- example code just translate raw data using USART. Error state, “paper out” is send to host, but interpretation of data depens on OS and printer driver used.
  • Printer is fully “plug and play”.
  • I don’t have enough documentation about “MS descriptor”. Theoretically it is special descriptor request (0xEE), but somehow it is not working. Maybe it is dependant of OS and printer driver.

How to make clone of my project or incorporate to you existing desing. Start STM32CubeMX, configure all your pins and devices, select USB device and CDC class. Then, manually remove all the stuff related to CDC class and copy printer class files. There are minor changes (not very useful) in USB core library (mainly for MS Windows tricks), it is noted in comments as “levo”.

The only interesting file for end user is “printer_hardware.c” – it is few subroutines to pass control for USB device to physical printer software.  It is like interface for printer interface :) .

Older version of software, for analysis only:

Download STM32CubeMX USB PRINTER CLASS demo code (source and compiled hex for bluepill STM32F103C8.

There was error is “plug & play” section. Small change, but it caused bigger change in other source code- printer response is not always same size as host request size. This caused buffer overrun and garbage reported to host. Also, there was error in 1284 string report- I forgot to add size of the report to the body of report (this is compatibility with LPT cable) :

/* ************************************************************************
Low-level function to report 1284 id string
Input: pointer to buffer
Returns: length of the string
************************************************************************ */
uint16_t printer_hardware_id(unsigned char * pbuf)
static unsigned char Id1284String[] = "00MFG:Generic;MDL:Generic_/_Text_Only;CMD:1284.4;CLS:PRINTER;DES:TTY;";

uint16_t length=sizeof(Id1284String);
Id1284String[0]=(length >>8) & 0xFF;
Id1284String[1]=length & 0xFF;
// IEEE 1284 device ID string (including length in the first two bytes in big endian format).
return length;

USB report
Better version of printer device source code:
New version of USB PRINTER device for STM32f103 (STM32CunbeMX) with proper lenght in printer internals description.

Posted in Anything, MCU | Tagged , , , | Leave a comment