How to enable ZX-Key external keyboard with Minstrel 3 board

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Post Reply
Mustermann
Posts: 34
Joined: Sun Dec 22, 2019 12:09 pm
Location: Augsburg, Germany

How to enable ZX-Key external keyboard with Minstrel 3 board

Post by Mustermann »

There is an external ZX-Key Keyboard existing.
https://www.sellmyretro.com/offer/detai ... d=noscript

This keyboard can be connected with ZX81 by an ZX-Key expansion card at the ZX81 Bus connector.
https://www.zx81keyboardadventure.com/p ... age_9.html

Unfortunately the expansion card doesn't work with the minstrel 3 as described in this article .
http://www.zx81keyboardadventure.com/20 ... 3-kit.html

The proposed solution to connect the external keyboard to the keyboard connector of the minstrel does not work for me(even if there is a nice, ready made connector board available). My keyboard connector is already occupied by another keyboard and I'd like to connect a joystick.


If I understand right, the expansion board is reading A8-A15 when the ZX81 or clone is reading keys by IN $FE, connect this thru the keys to an output line as the original keyboard does and than send the result to D0-D4(external connector).

At the same time the ULA read data from internal keyboard and send the result to D0-D4(internal connection CPU-ULA).
As these both data lines are separated by an array of 470 Ohm resistors this will not harm any logic even if level of ULA and expansion card are opposite.

So how can CPU read from expansion card as ULA level will always win as it is connected directly to the CPU?

The answer is, if I am right, that the ULA use open collector output that is pulled to high level by an array of 10k resistors when not pulled low by the ULA.
In this case the expansion card is able to pull down the data lines to low, if ULA does not. The other way around, the ULA is able to pull the data lines low even if the expansion card try to keep it at high level, because CPU/ULA data lines are isolated from expansion card by the 470 Ohm array.

Why doesn't this work with minstrel 3?

Answer might be, that minstrel use 74HC257 for keyboard read. This chip is tri-state but not open collector. So if the 74HC257 decide to keel the data lines on high level when reading keyboard, the expansion board is not able to pull that down to low.

Do you think, separating 74HC257(IC24 PIN 4,7,9,12 and IC25 PIN 4) by a set of diodes from data bus, enabling the IC to pull data lines to low and pull the data lines to high by a set of resistors may work with ZX-Key expansion card?
ZX81 issue 1 near to original state
ZX81 issue 1 56k internal ram with battery backup, UDG, CHR$128 and WRX enabled
Minstrel 3 ZX81 clone 64k with battery backup, UDG, CHR$128 and WRX enabled

User avatar
Paul
Posts: 1087
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: How to enable ZX-Key external keyboard with Minstrel 3 board

Post by Paul »

The same happens with original ZX80.
If I want to use an external keyboard I just pull the keyboard driver IC and everything works perfectly.
In theory, there is no difference between theory and practice. But, in practice, there is.

Mustermann
Posts: 34
Joined: Sun Dec 22, 2019 12:09 pm
Location: Augsburg, Germany

Re: How to enable ZX-Key external keyboard with Minstrel 3 board

Post by Mustermann »

In the Minstrel design the keyboard driver is also generating NOP for CPU while screen data is shifted out. So Z80 solution will not work here.
ZX81 issue 1 near to original state
ZX81 issue 1 56k internal ram with battery backup, UDG, CHR$128 and WRX enabled
Minstrel 3 ZX81 clone 64k with battery backup, UDG, CHR$128 and WRX enabled

User avatar
1024MAK
Posts: 2897
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: How to enable ZX-Key external keyboard with Minstrel 3 board

Post by 1024MAK »

The phase that you are looking for is “bus contention”. Both devices contain chips that drive the data bus high as well as low. So if one is driving high and the other is driving low...

As the relevant chips for the “internal” keyboard are connected directly to the CPU data bus, and the external keyboard is connected to the expansion edge-connector via the resistors on the Minstrel 3 board, the “internal” keyboard will always win the bus contention fight...

For the Minstrel 3, you could add some extra circuitry to IC9 (74xx08) pin 12 to switch off the “internal” keyboard (via a manual switch), but that means either making an adaptor for IC9, bending a leg up, or cutting a track...

And the switch has to go somewhere...

Mark

User avatar
1024MAK
Posts: 2897
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: How to enable ZX-Key external keyboard with Minstrel 3 board

Post by 1024MAK »

Mustermann wrote:
Fri Jan 03, 2020 8:13 pm
Do you think, separating 74HC257(IC24 PIN 4,7,9,12 and IC25 PIN 4) by a set of diodes from data bus, enabling the IC to pull data lines to low and pull the data lines to high by a set of resistors may work with ZX-Key expansion card?
This may work. I suggest you use Schottky signal diodes (BAT42, BAT43 or BAT46 or similar) rather than normal silicon signal diodes. The reason is, when the 74HC257 tries to take a data line low, you want the CPU to see a logic low level. And if silicon signal diodes are used, you have just reduced the logic low margin by approximately 0.6V. Although you may be using a CMOS Z80, these are made to be compatible with TTL logic levels.

The other possible problem is that I can’t see any pull-up resistors on the circuit schematic for the Minstrel 3 board. You you would have to fit some...

Then there is the problem of getting the value right. If too high a value is used, the problem is that the pull-up resistors may pull up the data bus line logic levels too slowly if there is enough stray capacitance on the data bus lines.

Mark

Mustermann
Posts: 34
Joined: Sun Dec 22, 2019 12:09 pm
Location: Augsburg, Germany

Re: How to enable ZX-Key external keyboard with Minstrel 3 board

Post by Mustermann »

Thanks Mark, I have totally overseen this possibility to disable internal keyboard.
1024MAK wrote:
Sat Jan 04, 2020 12:41 am
The phase that you are looking for is “bus contention”. Both devices contain chips that drive the data bus high as well as low. So if one is driving high and the other is driving low...

As the relevant chips for the “internal” keyboard are connected directly to the CPU data bus, and the external keyboard is connected to the expansion edge-connector via the resistors on the Minstrel 3 board, the “internal” keyboard will always win the bus contention fight...

For the Minstrel 3, you could add some extra circuitry to IC9 (74xx08) pin 12 to switch off the “internal” keyboard (via a manual switch), but that means either making an adaptor for IC9, bending a leg up, or cutting a track...

And the switch has to go somewhere...

Mark
As all my chips are in sockets it is easy to cut IC9 pin 12 and put something between this and IC19 pin 11.
How about to let internal keyboard be the switch?
Keyboard_disable.jpg
See page 5 within https://d3s5r33r268y59.cloudfront.net/d ... v3.5.2.pdf

If any internal key is pressed this will enable internal key board.
Otherwise /COL0-/COL4 are all pulled to high by resistors, IC_N2 pin 12 will be high, IC_N1 pin 3 will be high and IC24 and IC25 will stay at high impedance in keyboard cycle, giving the external keyboard the chance to send a character.

In case neither an internal key is pressed nor an external, IN $FE will read an open bus and result may be in-predicable.
So pull up resistors are needed to pull open data bus to a defined value.

To ensure that low level will be appropriate at both sides of the bus isolator(R11-R18), 15k pull up seems to be ok.
15k Pull up and 1k isolator resistors are dividing (VCC-low level of IC output).

0.4V from IC output + (5-0.4)voltage over divider * (15k+1k)*1k =0.67V which is still a valid low level.
12k might also work(0,75V) but this is quite near to maximum low level.

Anything wrong?
Last edited by Mustermann on Sat Jan 04, 2020 8:34 pm, edited 4 times in total.
ZX81 issue 1 near to original state
ZX81 issue 1 56k internal ram with battery backup, UDG, CHR$128 and WRX enabled
Minstrel 3 ZX81 clone 64k with battery backup, UDG, CHR$128 and WRX enabled

User avatar
tynemouthsoftware
Posts: 7
Joined: Wed May 31, 2017 9:40 am

Re: How to enable ZX-Key external keyboard with Minstrel 3 board

Post by tynemouthsoftware »

One option I suggested when this was first raised was to swap out the 257s that are used for the keyboard read with 74LS257s. The LS is good at pulling down, but has a weak pull up. If the ZX-Key interface is driving low strongly with it's HCT245, that may be enough to register?

The main thing those 257s have to do is drive low, so it may be too bodgy, but you could try putting a resistor in series with the 5V line on those two chips, again limiting the ability to drive high strongly enough to override the external low signals when present. Everything is driven by active low signals, so it could work, but it's more of a bodge that diodes in series.

There's not really much space left on the PCB, I did look at all sorts of things during development for that section, including using something like a ULN2803 transistor array to do the pulling down (driven from 258s instead of 257s to invert the signals).

If there are any ideas for a reliable way of enabling an external keyboard, I can add that to the next revision of the Minstrel board. But for the moment, just connecting an external matrix to the internal keyboard matrix is the easiest way forward and David has produced a board for that already, so it's just a mechanical issue of connecting both at the same time (one of each side of the board?)

Thanks,

Dave


Edit - just missed the previous post.

Regarding the option of disabling the 257s if no key is pressed on the internal keyboard, remember the input port is used for the ear signal and the NTSC detect (which is read every video frame).

Mustermann
Posts: 34
Joined: Sun Dec 22, 2019 12:09 pm
Location: Augsburg, Germany

Re: How to enable ZX-Key external keyboard with Minstrel 3 board

Post by Mustermann »

Ok. that make things difficult.

Splitting IC25 into one that is handling D5, NTSC/PAL and EAR(not disabled) and another one that is handing /COL4(disabled when no key is pressed) may fix that but we have added 3 chips for that feature now.

Reason why I'd like to solve that is that I am planning to have internal keyboard and external Joy-Ram adapter for Joystick.

Still investigating,

Max
ZX81 issue 1 near to original state
ZX81 issue 1 56k internal ram with battery backup, UDG, CHR$128 and WRX enabled
Minstrel 3 ZX81 clone 64k with battery backup, UDG, CHR$128 and WRX enabled

Mustermann
Posts: 34
Joined: Sun Dec 22, 2019 12:09 pm
Location: Augsburg, Germany

Re: How to enable ZX-Key external keyboard with Minstrel 3 board

Post by Mustermann »

So I come back to "diode and pull up resistor" solution:
1024MAK wrote:
Sat Jan 04, 2020 12:56 am
Mustermann wrote:
Fri Jan 03, 2020 8:13 pm
Do you think, separating 74HC257(IC24 PIN 4,7,9,12 and IC25 PIN 4) by a set of diodes from data bus, enabling the IC to pull data lines to low and pull the data lines to high by a set of resistors may work with ZX-Key expansion card?
This may work. I suggest you use Schottky signal diodes (BAT42, BAT43 or BAT46 or similar) rather than normal silicon signal diodes. The reason is, when the 74HC257 tries to take a data line low, you want the CPU to see a logic low level. And if silicon signal diodes are used, you have just reduced the logic low margin by approximately 0.6V. Although you may be using a CMOS Z80, these are made to be compatible with TTL logic levels.

The other possible problem is that I can’t see any pull-up resistors on the circuit schematic for the Minstrel 3 board. You you would have to fit some...

Then there is the problem of getting the value right. If too high a value is used, the problem is that the pull-up resistors may pull up the data bus line logic levels too slowly if there is enough stray capacitance on the data bus lines.

Mark
We will go to this diagram(with /COL4 as an example for all the COL)
Diode resistor.jpg
A BAT48 will add 0.3V to the low level of 74HC257. That should be ok for low level at CPU_D4 and Alt_D4 if 257 is driving data lines.

If CPU is driving data lines there is no difference.

If RAM or external are driving data lines we will have voltage divider as described above(15k pull up /1k R11-R18)
From static point of view that should be ok.

From dynamic point of view we need to think if pull up resistors will pull up fast enough.
As I do not know captive load I need to try that out.

In the original ZX81 there is the same solution but using 10k pull up and 470Ohm in line resistors.
If 15k/1k won't work changing 1k to 470Ohm may be a solution.

Diodes can be put in place by pulling 257 out of the socket, put diodes into the socket at output pins, shorten pins and solder diode to pin.
For all other pins an additional row of socket pins may be pluged into the socket to add space for the diodes.

Implementing and testing that will take some time.

Max
ZX81 issue 1 near to original state
ZX81 issue 1 56k internal ram with battery backup, UDG, CHR$128 and WRX enabled
Minstrel 3 ZX81 clone 64k with battery backup, UDG, CHR$128 and WRX enabled

Post Reply