Sunday, 11 May 2025

Minstrel Input Monitor (Revisited)

About a year ago, I designed a one of a series of new modules for the Minstrel Expansion Bus (which has yet to catch on, but you never know).

This was a simple module that was meant to show keyboard and tape input activity with LEDs and a sounder to click when a key is pressed (like a Spectrum) and relay the tape loading noises.

As I was writing up the original blog post, I worked out that I had made a mistake, but the boards had already been ordered by that point.

They arrived and as expected, did not work as expected, and were consigned to the rejects pile.

The problem was one of timing of the Z80 read cycle.

Let me try to explain......

The Minstrel and ZX81 have a single input port. This is used to read the keyboard and tape data from the earphone socket.

The Minstrel 2 / ZX80 input port is shown here as that is the simplest version.

When the Z80 makes an IO read request and the address is even, the Port Read signal will go low (A0, IO_RQ and RD are low).

The 74LS365 has until the rising edge of which ever of those rises first to place the appropriate data on the databus in time for the Z80 to read it (shown as "In" in the diagram above).

The Minstrel Input Monitor duplicates that decoding and a 74HC74 flip flop is triggered on the rising edge of the port read signal to read the data from the bus.

At this point, it samples D7, the data from the tape as the Z80 will see it, digital data, rather than the analogue tape input signal.

That is quite useful to set your tape volume correctly, and also if the load fails, the IO reads will stop, so the LED will stop flashing.

When loading is complete, the display cycles resume. At the top of each frame there is an IO Read (actually the keyboard scan) that starts the vertical sync pulse, and an IO Write which ends the vertical sync. (from http://blog.tynemouthsoftware.co.uk/2023/10/how-the-zx80-generates-video.html)

That IO Write pulse is used to clear the flip flop in case the last data sampled was a high and would have left the LED on.

That all works fine, both the Z80 and the new latch are sampling on the rising edge of the Port Read signal.

The problem was the keyboard scan.

The keyboard is read once at the top of each screen draw cycle. For that first scan, the keyboard rows are setup so that if any keys are pressed, one of the data lines will read as low.

If that is detected, then each of the 8 rows are scanned separately to determine which key or keys are pressed (making the 9 IO Read pulses shown above).

You would think that you could do something like this, when any of the data lines are low on the rising edge, the Key Pressed signal will go high.

The problem is when the subsequent rows are scanned, if no key is pressed on that row, the signal will be cancelled and the pulse would be very short.

To get around this, on the first version I thought "if it is an IO request and one of the lines is low, then trigger the flip flop". Which seems reasonable?

But of course it isn't. That is triggering the flip flop if "any of the data lines are low during the IO read cycle". But the data is not valid for the entire IO read cycle, only on the rising edge at the end. So of the data on the bus happens to have any of D0-D4 low at any time during the IO read cycle, then it will trigger the key press unintentionally.

I must have been having an off day when I put that together.

This is what I should have done.

Here a second AND gate combines the keyboard scan data with the previous state, so if a key is pressed, or a key has been pressed, Key Pressed will remain high even if a row is scanned with no keys pressed.

If a key press is registered, the Key Pressed signal will remain high until the vertical sync pulse ends with an IO write, which will clear the flip flop so Key Pressed will go low.

This sequence happens at the start of every frame, so this will create a 50Hz tone on the piezo if any keys are pressed.

The two signals generated will be high when active, one if there is a key pressed, one when the tape data is high.

Two LEDs are used to show the state of those signals. I have used green for a key press and red for tape data.

Audio indication of the two signals can be provided by a piezo sounder.

The OR gate mixes the signals to drive the piezo sounder. (I had previously used the spare AND gate as the mixer, but I had to switch them around and now I have the spare OR gate).

Jumpers are provided to disable either signal before the mixer, in case the sound becomes annoying.

The board is designed to be used with the Minstrel Expansion Bus, either the socket on the back of the later Minstrel 2 and 3 boards.

Or in the backplane with other cards.

You could also fit an edge connector and use it with a Minstrel or a ZX81. (joystick module show here as an example)

Or you could use the backplane with the ZX81, lots of options.

The schematics above use ideal arrangement of gates, but it is not possible to easily get a 5 input AND gates, or the other assortment of 2 and 3 input AND and OR gates on just a few chips.

The actual design uses a quad 2 input OR gate and a triple 3 input AND gate to implement the same logic, as shown in the complete schematic.

I don't really like those "all on one diagram" type schematics, but it seems everyone else does, so I have made that a full page at the end of the manual. Landscape to make it most readable. Posh.

The new version looks almost identical to the original, other than a few traces have been rearranged.

This is available in kit form or assembled.

Adverts

I have listed this and all the other Minstrel Expansion Bus modules and backplane on Tindie (including the full size Minstrel ZXpand).

Last week, (yes, on May the 4th), I relaunched the Minstrel 4th.

The new version is available now form my Tindie store, and soon from Z80 kits, home of the RC2014.


Patreon

You can support me via Patreon, and get access to advance previews of development logs on new projects and behind the scenes updates. New releases like this will be notified to Patreon first, if you want to be sure to get the latest things. This also includes access to my Patreon only Discord server for even more regular updates.