ZX81 I/O interface for your projects

Discussions about Sinclair ZX80 and ZX81 Hardware
zx81user
Posts: 54
Joined: Mon Mar 25, 2013 3:14 am

ZX81 I/O interface for your projects

Post by zx81user »

I mentioned in some other thread that I used to have an I/O interface that had 8 TTL inputs and 8 TTL outputs. It was a board that came together with a book called "20 Simple electronic projects for the ZX 81 and other computers". Now, I don't have this interface no more but I still have the board layout. I reconstructed the schematic diagram from the tracks on this board (see attached file ZX81IO.PDF).

Please let me know if you are interested in one of these boards, if there is about 10 people or so, then I will have the boards manufactured. Cost will be around AU$30. Board only, no parts, but parts are easy to find locally.

Michel
Attachments
Original board layout
Original board layout
IOprint (507x640).jpg (239.63 KiB) Viewed 9546 times
ZX81IO.pdf
Schematic diagram 8 bit input/output interface
(20.5 KiB) Downloaded 979 times
User avatar
user@lab1
Posts: 60
Joined: Thu Apr 14, 2011 6:20 pm

Re: ZX81 I/O interface for your projects

Post by user@lab1 »

Hi Michel,
Beautiful interface, and the software? How does it work?
Thanks.
User avatar
1024MAK
Posts: 5101
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZX81 I/O interface for your projects

Post by 1024MAK »

@ Michel, thanks for posting the PCB layout and the schematics :D

Last year I searched the web for this interface, but found no results.

Have a look at this thread :P
I made some changes, so compare the schematics ;)

Mark
Last edited by 1024MAK on Mon Apr 20, 2015 10:19 am, edited 1 time in total.
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
RetroTechie
Posts: 379
Joined: Tue Nov 01, 2011 12:16 am
Location: Hengelo, NL
Contact:

Re: ZX81 I/O interface for your projects

Post by RetroTechie »

Afaict it's a simple latch (for writing) and bus buffer (for reading), addressed via memory mapped I/O.
So you write to some memory address, and the 8-bit value shows up as 8 TTL-level signals on a connector. Or you read from some memory address, and value comes from the 8 TTL-level inputs on the other connector. Of course one could use that for 1001 purposes, but that's all there is to it, really.

Personally I'd have stuck a 82C55A (or something like that) on those addresses. That provides you with 24 I/O's, software programmable as input or output, and even special commands to toggle single I/O pins. About as easy to design hardware-wise, much more flexible in terms of use.

Memory mapped I/O is pretty clever, though. I'm getting rusty, but it seems ZX81 Basic doesn't have commands to directly read or write to I/O ports? :o Kinda weird for such a low-level, hacking friendly machine. Please correct me if I'm wrong! Memory mapped I/O then avoids the need for a tiny bit of machine code, just to be able to read/write those I/O ports.
User avatar
1024MAK
Posts: 5101
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZX81 I/O interface for your projects

Post by 1024MAK »

RetroTechie wrote:Afaict it's a simple latch (for writing) and bus buffer (for reading), addressed via memory mapped I/O.
So you write to some memory address, and the 8-bit value shows up as 8 TTL-level signals on a connector. Or you read from some memory address, and value comes from the 8 TTL-level inputs on the other connector. Of course one could use that for 1001 purposes, but that's all there is to it, really.
Yes, exactly ;)
RetroTechie then wrote:Personally I'd have stuck a 82C55A (or something like that) on those addresses. That provides you with 24 I/O's, software programmable as input or output, and even special commands to toggle single I/O pins. About as easy to design hardware-wise, much more flexible in terms of use.
Ahh, but this is an existing published design...
RetroTechie went on and wrote:Memory mapped I/O is pretty clever, though. I'm getting rusty, but it seems ZX81 Basic doesn't have commands to directly read or write to I/O ports? :o Kinda weird for such a low-level, hacking friendly machine. Please correct me if I'm wrong! Memory mapped I/O then avoids the need for a tiny bit of machine code, just to be able to read/write those I/O ports.
Yep, the ZX81 does not have an IN function or an OUT command :(. The machine code required to access the Z80 I/O ports is very simple though.

An example BASIC program to access this board is shown in the thread I linked to earlier ;)
1024MAK wrote:Have a look at this thread :P
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
user@lab1
Posts: 60
Joined: Thu Apr 14, 2011 6:20 pm

Re: ZX81 I/O interface for your projects

Post by user@lab1 »

Hi.
Mark I have read the thread that you reported, and as I understand it, each output has its "weight".
So, correct me if I'm wrong:
out1=1; out2=2; out3=4; out4=8; out5=16; out6=32; out7=64; out8=128
Therefore to activate all outputs, I must write:

Code: Select all

POKE 65535,255
Instead, if I want to activate (for example) the outputs 2; 5; 7; I have to write:

Code: Select all

POKE 65535,82
And for the inputs how it works? As I do for read and process the signals present on the inputs?
Uhmm... Mumble... Mumble... I try to answer by himself: PEEK 65535 ?!? :shock:

You added a TRANSISTOR, which acts on the logic level of /RAMCS. What are the implications of this modification compared to the original scheme?
Thanks.

P.S. However the line 20 goes rewritten so: :mrgreen:

Code: Select all

20 PRINT AT 0,0;O;"  "
Otherwise at the end of the counting, there is an overlap of numbers. ;)
User avatar
1024MAK
Posts: 5101
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZX81 I/O interface for your projects

Post by 1024MAK »

In reverse order...

Yes, I took the picture and then altered the program but forgot to take another picture before switching off :mrgreen:.

A standard ZX81 has minimal address decoding. Indeed, the Z80 address line A15 is not used at all by the rest of the ZX81 circuitry. Also not all of the addresses used for the on board ROM or the on board RAM are fully decoded.

This means that even though the standard ZX81 has only 8k bytes of ROM and 1k bytes of RAM, as far as the Z80 CPU is concerned, any of the 64k bytes of available memory addresses will return a value from memory for reading data only (it is more complex when the Z80 CPU reads a machine code instruction due to the way the display system works) from either an address in ROM or an address in RAM.

So what is happening?

The Z80 CPU counts on it's address bus using binary, from zero (0) to 1111 1111 1111 1111 binary (FFFF hex, 65535 decimal). That's sixteen lines, numbered A0 to A15.

The hardware of the ZX81 ignores the CPU address line A15, so any memory in the address range zero (0) to 0111 1111 1111 1111 binary (7FFF hex, 32767 decimal) will also respond in the address range 1000 0000 0000 0000 binary (8000 hex, 32768 decimal) to 1111 1111 1111 1111 binary (FFFF hex, 65535 decimal) as it cannot tell if the difference.

The memory map looks like this:
0000 hex, 0 decimal
> ROM (8k bytes)
1FFF hex, 8191 decimal
-----
2000 hex, 8192 decimal
> ghost of the ROM at 0000 hex to 1FFF hex
3FFF hex, 16383 decimal
-----
4000 hex, 16384 decimal
>RAM (1k bytes)
43FF hex, 17407 decimal
-----
4400 hex, 17408 decimal
> 15 ghosts of the 1k bytes of RAM at 4000 hex to 4400 hex
7FFF hex, 32767 decimal
-----
8000 hex, 32768 decimal
>ghosts of the memory from 0000 hex to 7FFF hex
FFFF hex, 65535 decimal

By ghosts, I mean because the hardware cannot tell the difference between two or more address ranges, the same memory chip is accessed at more than one address range. So if you store a value of 181 decimal at address 17407 decimal (43FF hex), if you read back address 18431 (47FF hex), or any other higher address where the address lines A0 to A9 and A14 are the same, you will get the same value (181 decimal) returned.

As far as the 1k bytes of RAM is concerned, the state of address lines A10 to A13 and A15 does not matter.

So when any expansion, interface or extra memory is added, it is the responsibility of the expansion, interface or extra memory to control the /RAMCS line. By driving it to logic high, you prevent the ZX81 internal RAM from responding to the same addresses used by the expansion, interface or extra memory.

If you examine the Sinclair 16k byte RAM pack, you will see that on the PCB there is a direct connection from the +5V line and the /RAMCS line, so the ZX81 internal RAM is always disabled.

If an expansion, interface or extra memory does not control the /RAMCS line, both the expansion, interface or extra memory and the internal memory in the ZX81 will respond to the same address. This does not matter for writing to memory, but when reading, both will put data on the data bus. Two different chips putting data on the same data bus lines at the same time is not good. This is known as a data bus clash or a data bus collision.

The original scheme makes no attempt to deal with this problem. I do not know why. As I spotted the problem when working out the schematic by reverse engineering the PCB, I added the extra transistor before I tested it with a ZX81. So I cannot say what the actual result would be if a board based on the original scheme was plugged into a ZX81. I suspect that as the interface board uses a bus buffer chip (the 74LS244), this is more likely to have more powerful outputs than the RAM chips, so will overpower the output from the RAM chip. As the overpowering is only for a short time, it may not cause any damage to the RAM chip, but it is not recommended.

Yes, the data bus is a 8 bit binary number. The BASIC used on the ZX81 only uses decimal when communicating with the user. So you have to convert a binary number to decimal to select which output lines are logic high (one).

The same applies when reading the input port. If you convert the decimal number that is returned to binary, you can see which lines are high and which are low. Because of the pull up resistor network, the normal state of each of the input lines is logic high.

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
user@lab1
Posts: 60
Joined: Thu Apr 14, 2011 6:20 pm

Re: ZX81 I/O interface for your projects

Post by user@lab1 »

Wow that explanation, I'm speechless! :shock:
Congratulations also to the work of reverse engineering! :mrgreen:
I have a sound card that works connected to a card with 8 outputs (card that I have to rebuild) very similar to your.
So I said to myself, why not build a card like yours. So much the functioning is similar, I just have to change the address of POKE... I'll let you know! :)

Mark in the thread that you reported, it also speaks of a telex decoder. What can you tell me on that card?
Thanks.
User avatar
1024MAK
Posts: 5101
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZX81 I/O interface for your projects

Post by 1024MAK »

user@lab1 wrote:Mark in the thread that you reported, it also speaks of a telex decoder. What can you tell me on that card?
Thanks.
So far, I have not done anything with this. After I finished the I/O card, I got distracted by building a Jupiter ACE Kit (remake using the same chips) and then building a new Atom (modern remake of an Acorn Atom using a mix of 6502 CPU, 6522 VIA, 8255 PIO and modern memory and CPLD chips but without a keyboard). The Atom main board is nearly built. The "telex decoder" is therefore still sitting on the to-do list.

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
Rishi
Posts: 107
Joined: Mon Jun 08, 2015 6:57 pm
Location: Amsterdam

Re: ZX81 I/O interface for your projects

Post by Rishi »

I do actually have one of these, but i was a bit to young to get it functioning properly, now i've dug it up and in the booklet, it describes that any address above 61440 will communicate with the port in fact it just test if A12, A13, A14, A15 are on but this obviously this can be separated out more, just test on any of the other address pins. also the schematic is not hugely complicated and could also easily be mounted on a universal experiment board (that may even be smaller) i'm planning to build one with double ports using 1 more 7400 (or one of the other logic chips and include a ULN2803 on the board for the output so i can power some things without worry.. the amount of pins i can create with the ZX81 is actually incredible, no Raspberry PI or Arduino can compete with that :D
32K SRAM WRX compatible, 32Bit IO-Port, ROM Ghost, ZX-Printer.
Post Reply