lundi 13 juillet 2026

The Cody Computer : With an USB keyboard?

From time to time, I've mentioned the little computer designed by Frederick John Milens. The main reason for my interest in this small machine is that all the source code is provided, it's very simple to build, and for learning what microcomputing is, or what it was, or what it might well become again, it's an absolutely brilliant tool.

I repeat myself, but for me, the only "small issue" with this machine is its keyboard. In my opinion, it's really not very practical, and it adds an unnecessary extra cost to its construction.

So much so that I didn't actually build the keyboard. As a result, in the few months I've owned this little computer, I've never been able to type anything on the keyboard to test its functionality. Until now, I only had its startup screen. That's already a good sign that it's working, but still, a bit frustrating.

So, a few months ago, I developed a small electronic board to adapt a standard USB keyboard to the Coddy. For the interface, two approaches are possible. The first is to connect directly to the keyboard connector, thus simulating the keyboard hardware with I/O ports on a microcontroller.

This principle works, but obviously, since the computer's keyboard scanning and the microcontroller's I/O matrix scanning are asynchronous, there are rare occasions where a key press is missed.

The other solution is to present to the computer, one way or another, the key code directly returned by the USB keyboard. But this solution, although more reliable than the first, requires having full access to the computer's resources, because it involves not only some hardware modifications but also system software changes.

Since the designer of this computer provides absolutely all the source code, I opted for this second solution.

The hardware principle used is simple: a USB-to-serial converter translates the codes from a standard USB keyboard into codes available on a serial port. A small microcontroller retrieves these serial codes and presents them in parallel on the computer's data bus.

A tri-state buffer allows placing this code on the data bus using an additional selection signal generated from the Coddy's VIA selection signal, discriminated from the VIA by taking into account an extra address signal. Basically, I'm using one of the VIA's memory maps to place the I/O registers that provide the keyboard code.

And that's it.



From a software perspective, it's "simply" a matter of hooking into the existing system code by adapting certain routines according to the new hardware.

Said like that, it sounds simple, but in fact it's not really, because even though all the source code is available, you still need to understand how it works and its subtleties. And adapt to the 6502 assembly language, which I had never used since until now I've always worked on Z80 or 68000. This caused me some initial confusion. But then again, when you know assembly language, switching from one processor to another isn't difficult.

And so, after a few hours of studying and testing, I finally have a keyboard connected to the Coddy. 

And, compared to my previous article where I showed the very first signs of character reception but where the whole processing of commands entered via the keyboard was not yet functional, now it is fully working.


And now?

Well, not everything is actually functional. The "break" that allows stopping a running program hasn't been implemented yet. This system uses certain hardware lines from the original matrix keyboard to generate the Break. I haven't implemented it for now. After the few hours I spent on the BASIC assembly source, I don't think it will be very complicated to implement.

My interface is a bit complicated. I use a small USB-to-serial conversion module, then my decoding and data presentation board that interfaces with the Coddy's data bus.
I think there's a way to do it much more efficiently by using a Pi Pico with the TinyUSB library.

Since I managed to set up (without difficulty) the Pi Pico development environment with Visual Studio Code, I should be able to greatly simplify all this into something better!

And yes... Unlike my first attempts at installing Visual Studio Code with the Pi Pico package for VSC, I was able to complete the installation without any problem whatsoever. It just goes to show that some Microsoft solutions work almost intuitively!

And I almost forgot to thank Frederik for a very handy little detail in his code: PUTHEX.
This routine allows displaying in hexadecimal at the cursor position any data previously placed in the A accumulator.
A very handy little utility for real-time debugging.

 

Aucun commentaire:

Enregistrer un commentaire