VT100 converter for QMK without an extra UART
Posted: 29 Nov 2019, 07:44
I finally got to doing something with another of these old boards. The VT100 isn't a particularly nice keyboard; the VT52 had much more personality. I never used a DEC terminal as my daily one. But VT100s were everywhere, so the nostalgia value is still pretty high.
The hardware protocol is also very interesting. It's a 1/4" audio jack with three wires: +12, ground, and signal. The signal is bi-directional serial; both ways on the same wire, sometimes at the same time. This requires some open-collector drivers to compose and analog comparators to decompose.
It's all in the DEC schematics, which have been preserved. I just borrowed the relevant circuit straight — with the exact same resistor values.
The very same borrowing was done by somebody's earlier effort and featured on Hackaday.
But they were concerned to replicate the timing and so their circuit has a 1MHz crystal and a classic 40-pin CMOS UART.
The UARTs used then and inside the AVR are designed to deal with small variations in timing. They take 16 samples and average. So there's a fair amount of wiggle-room. In fact, a complementary effort to build an interface from a modern USB keyboard to a VT100 terminal as an Arduino sketch just set the MCU's UART to 7867 baud, ignoring the clock PWM.
For my converter, I set a couple of the otherwise unused timers to generate 4µs and 8µs PWM. And set the UART's baud rate register to match. Since it all ultimately comes from the same I/O clock, everything should stay in sync.
It ends up looking like this: The signals are:
Zooming in, each serial bit takes 16 clock periods. And PWM has 75% duty-cycle for mark and 25% for space. For now the firmware in my fork.
And the hardware will, as always, need some cleaning up for putting into more permanent form. ETA: Perma-proto version.
The hardware protocol is also very interesting. It's a 1/4" audio jack with three wires: +12, ground, and signal. The signal is bi-directional serial; both ways on the same wire, sometimes at the same time. This requires some open-collector drivers to compose and analog comparators to decompose.
It's all in the DEC schematics, which have been preserved. I just borrowed the relevant circuit straight — with the exact same resistor values.
The very same borrowing was done by somebody's earlier effort and featured on Hackaday.
But they were concerned to replicate the timing and so their circuit has a 1MHz crystal and a classic 40-pin CMOS UART.
The UARTs used then and inside the AVR are designed to deal with small variations in timing. They take 16 samples and average. So there's a fair amount of wiggle-room. In fact, a complementary effort to build an interface from a modern USB keyboard to a VT100 terminal as an Arduino sketch just set the MCU's UART to 7867 baud, ignoring the clock PWM.
For my converter, I set a couple of the otherwise unused timers to generate 4µs and 8µs PWM. And set the UART's baud rate register to match. Since it all ultimately comes from the same I/O clock, everything should stay in sync.
It ends up looking like this: The signals are:
- receive
- transmit
- clock
- combined signal
Zooming in, each serial bit takes 16 clock periods. And PWM has 75% duty-cycle for mark and 25% for space. For now the firmware in my fork.
And the hardware will, as always, need some cleaning up for putting into more permanent form. ETA: Perma-proto version.