Keyboard replacement

Modern, Memotech inspired, hardware projects
User avatar
Dave
Posts: 747
Joined: 11 Aug 2012 18:16
Contact:

Re: Keyboard replacement

Post by Dave » 16 Feb 2018 17:39

Hi Tony,

your wish is my command :)
StarTech USBMBADAPT.jpg
StarTech USBMBADAPT.jpg (20.66 KiB) Viewed 1852 times
StarTech GC46MF.jpg
StarTech GC46MF.jpg (25.48 KiB) Viewed 1852 times
The plan at the moment was to have USB and PS/2 connectors on the PCB (they should fit in the deepest past of the case OK). I realise that this would mean opening the case the plug in the keyboard, but if a jumper (or jumpers) are used, the case would need opened anyway to swap keyboard types.

However, given that it would make connection/disconnection easier, I am happy to go with the USB adapter cable. One of the reasons that I went away from having an adapter cable is that PS/2 adapter cables are like hens teeth these days, but USB adapters like the one you found seem to be much more readily available.

The open collector buffers were specifically recommended by Bill so that the MTX keyboard would work in parallel.
Bill, could you remind me what the reason was please?

regards
Dave

Martin A
Posts: 414
Joined: 09 Nov 2013 21:03

Re: Keyboard replacement

Post by Martin A » 16 Feb 2018 18:21

Just for confirmation, the current prototype board connects via the 20 pin header, so there's direct access to:
KB9 to KB0
DR0 to DR7
a pulled up connection to Z80 reset
Ground

And that's it

The 5v is picked up from the Port 7 header. There is the posibility of accessing other port 7 signals, or the extra 0v as Dave does. But there's no help from the OS using extra signals. There are other places where 5v is accessible on the board, but none of them are "novice friendly"

Some of us are happy with diving in and modifying the PCB and have the tools to do that. Most owners don't, If Dave's going to make something available to other MTX users, it's got to be minimally invasive or there's no point doing it.

The MTXplus on the other hand anything goes. Since the I/O board's not finalised and there's only 3 system "in the wild" at the moment, that can have a version of the MTX solution whatever that turns out to be, included on the final draft.

As far as PS2 vs USB availability goes, I just did a quick search on Amazon, for PS2 Keyboard under £25 and had a single page with 19 options come up. Swapping PS2 to USB re-running the search, there were 9 pages of results (at 30 per page). So they are available but definitely in the minority.

The one I got for use on the the ReMemotech is a dual function USB keyboard, that uses a passive adaptor to connect to PS2. It was about 50% more expensve than the equivalent USB only option.

For me, the "perfect" option would be to have a dual use header on the interface board, then just run the chosen cable out the gap between the top part of the case and the plastic I/O shield. A small trailing lead, with a USB or PST socket on it, is to me easier to accomodate than drilling the end plate - beacuse of the positioning of the CFX/CFX-II on the external expansion port.

Tony Brewer
Posts: 62
Joined: 08 Jan 2014 20:50

Re: Keyboard replacement

Post by Tony Brewer » 16 Feb 2018 20:26

Dave wrote:Hi Tony,

your wish is my command :)

The plan at the moment was to have USB and PS/2 connectors on the PCB (they should fit in the deepest past of the case OK). I realise that this would mean opening the case the plug in the keyboard, but if a jumper (or jumpers) are used, the case would need opened anyway to swap keyboard types.

However, given that it would make connection/disconnection easier, I am happy to go with the USB adapter cable. One of the reasons that I went away from having an adapter cable is that PS/2 adapter cables are like hens teeth these days, but USB adapters like the one you found seem to be much more readily available.

The open collector buffers were specifically recommended by Bill so that the MTX keyboard would work in parallel.
Bill, could you remind me what the reason was please?

regards
Dave
Thanks, Dave. The 74LS06 and 74LS16 are open-collector inverters (last post edited to make that clear) with same pinout as 74LS17. The outputs would be identical but the inputs inverted and the Propeller would be protected as now. On your schematic, the drive signals could be /DR0-7, the sense signals /KB0-9 on J0 and KB0-9 elsewhere.

Forget I ever mentioned connecting OUT 5. All my previous posts that did so have been edited. :mrgreen:

Tony Brewer
Posts: 62
Joined: 08 Jan 2014 20:50

Re: Keyboard replacement

Post by Tony Brewer » 16 Feb 2018 21:01

Bill B wrote:Tony,

The Propeller output cog does a "waitpne" on nine pins, not eight. The ninth pin is toggled by the keyboard decode cog whenever the state of the keyboard matrix changes. This causes the output cog to update the sense lines, even if the drive lines don't change.

Bill.
Thanks for the clarification, Bill. Changing to open-collector inverters would allow more than one cog to output to the sense lines, reducing the workload by half. My feeling is the sense cogs could read key bits from the hub and output them continuously, with no need for an internal inter-cog pin, if the cogs always input from DRx just before the output to KBx, to check there has not been an OUT 5 and DRx and KBx no longer match. There should be plenty of time to do this with two sense cogs and the bonus would be fewer wait states on the MTXPlus+ for faster clocks.

Bill B
Posts: 173
Joined: 26 Jan 2014 16:31

Re: Keyboard replacement

Post by Bill B » 16 Feb 2018 23:12

Dave,

The open collector / open drain buffers were mandated by your requirement of being able to connect the Propeller interface in parallel with the MTX keyboard. Without them you could have the situation of no keys on the add-on keyboard pressed, so the Propeller outputting a logic high on all the sense lines while a pressed key on the MTX keyboard, and an output on an MTX drive line is attempting to pull a sense line low. The buffers form a wired-or, so that either the Propeller or the MTX keyboard can safely pull a sense line low, and the sense line only goes high if nothing is pulling it down.

Tony is correct in that the buffers could be either inverting or non-inverting, it only changes the polarity of the signals the Propeller has to output.
Last edited by Bill B on 16 Feb 2018 23:30, edited 1 time in total.

User avatar
Dave
Posts: 747
Joined: 11 Aug 2012 18:16
Contact:

Re: Keyboard replacement

Post by Dave » 16 Feb 2018 23:30

Hi Bill,

Thanks for that, yes, I knew they were to allow the keyboards to work in parallel, but wasn’t sure what difference the polarity made.

OK, it sounds like inverting is the way to go then

Regards
Dave

User avatar
AndyKey
Posts: 74
Joined: 12 Aug 2012 01:29
Location: Southampton, UK
Contact:

Re: Keyboard replacement

Post by AndyKey » 17 Feb 2018 20:29

On the subject of programs that drive multiple sense lines at once:

You can try using MEMU to find such programs, eg:

Code: Select all

./memu -s -v -diag-console -diag-kbd-sense games/ALPHA.COM | egrep -v "0x(ef|df|bf|7f|fe|fd|fb|f7) returns"
The above displays nothing because I don't tend to do this in my games. Some games though

Code: Select all

./memu -s -v -diag-console -diag-kbd-sense games/BAKERY.RUN | egrep -v "0x(ef|df|bf|7f|fe|fd|fb|f7) returns"
kbd_in6 0x00 returns 0x03
and I suspect in this example it might be MTX BASIC looking to see what language the keyboard is.

I've yet to find a program that spits out lots of output, which is encouraging.
{{{ Andy

User avatar
AndyKey
Posts: 74
Joined: 12 Aug 2012 01:29
Location: Southampton, UK
Contact:

Re: Keyboard replacement

Post by AndyKey » 17 Feb 2018 20:47

General comments

I did consider whether it would be possible to do something like this.
I hadn't considered using a Propeller (or PIC or other micro-controller) based solution.

I was originally thinking of using a CPLD to hold the mapping from PS/2 protocol to MTX sense grid.
This is essentially the ps2_kbd.vhd and mtx_kbd.vhd VHDL in REMEMOTECH.
This has the advantage of no vulnerability to the quick OUT 5 followed by IN 5/6 problem.
But the logic is too big really for this, you'd need a small FPGA, and all the attendant support logic.
Maybe FPGAs from some of the smaller vendors, with built in configuration EPROM?

The approach like in my Colecovision Keyboard, with an ARM chip to convert PS/2 protocol to a grid on one side and a CPLD to bridge port accesses to it on the other would also fall foul of the quick OUT 5 followed by IN 5/6 problem. A small dual-port RAM between the MTX bus and the ARM would be an option, but I never looked at that.

So I look at this project and cross my fingers you'll be able to respond quickly enough to avoid mis-typing glitches.
{{{ Andy

Martin A
Posts: 414
Joined: 09 Nov 2013 21:03

Re: Keyboard replacement

Post by Martin A » 04 Mar 2018 22:48

Version 2.1 of the keyboard interface.

Ok there's logic analyser clips all over it, and it's drawing power from the JTAG header on the CFX-II board, but Bill's latest version of the propeller code allows some USB keyboards to work on the MTX.

Looking amazingly similar, the PS2 version of the board can be seen to the right of the CFX-II. There's very little hardware difference between the two. The magic is all in Bill's code.
re-built.jpg
Is that a USB lead I see ?
re-built.jpg (512.04 KiB) Viewed 1750 times

Bill B
Posts: 173
Joined: 26 Jan 2014 16:31

Re: Keyboard replacement

Post by Bill B » 05 Mar 2018 20:36

Not that I can claim too much credit for the "magic". I just borrowed the USB driver from here and here, and stitched the pieces together.

Post Reply