CBM-HD
What is it
CBM-HD is a project where a PC simulates IEEE devices. If you are familiar with 64HDD, a PC simulating a 1541 drive, then you can consider CBM-HD as its IEEE equivalent.In 2000 I realised a connection between my CBM8032-SK and the LPT-port of my PC using my own XIEEE-cable. Originally it was planned to be able to support both the IEC and IEEE computers but due to some problems I encountered and lack of time, CBM-HD only supports the IEEE protocol for the moment.
The problems
The problems I encountered are all related to the fact that the CBM is much more time critical then the C64 is. To give you a good example, in PC-Disk I didn't collect the data for displaying the directory until the actual TALK command was received. This process doesn't take much time, but according my 8032 too much: it timed out and displayed "?file not found"! This simply meant that I had to collect the data immediately after the initial command (just like a C= drive does).Much worse was the fact that the PC now and then failed somehow to notice that the CBM had activated the ATN line. On the end I was forced to add a bit of hardware that actually can be found in the real IEEE drives as well: a circuit that negates NRFD and NDAC as soon as ATN becomes low (called 'ATN-trap' from now on).
The third problem: as you probably know, the difference between LOAD"$" and DIRECTORY is the fact that in the first case the data is stored as a program and in the second case is displayed directly on the screen. In the first case the data is sent as one file, in the second case the transfer is interrupted all the time by the CBM every one or more bytes. In this particular case the PC proofed to be too fast in sending bytes. The frustrating thing was that the CBM accepted the extra byte(s) but a debug session showed that it had not used it. Inserting a delay of about 250 uSecs between each byte seems to solve this problem.
The above problem becomes even weirder with the PRINT# and GET# command: between each byte I have to wait up to 2 mSecs otherwise the CBM doesn't see them !!!
Features
- Multi-drive.
CBM-HD can emulate up to 8 devices if you want to. - Multi-diskformat.
CBM-HD supports several formats including a kind of 4040/8250-compatible 16 MB harddisk. - Multi-OS.
CBM-HD supports the MS-DOS file system. But only the 8.3 naming convention can be used.
I'm also working on a CBM look alike system: although using the DOS file system, it looks like a CBM one.
Disadvantages
CBM-HD is a simulator, not an emulator! It simulates the 4040 and some other drives only at the point of file handling. Memory-Read and write are not fully supported. Memory-Execute is not supported at all for the simple reason that a PC cannot run 6502 code.
So speedloaders certainly won't run because they rely on these commands that I don't support.
The future
The first goal is to solve the above time problems in case CBM-HD is to blame (you never know). The next step is to enable you to use the onboard printer- and COM-ports as well as the use of other drives like network drives and CD-ROM.Theory
If you forgot how IEEE-488 looked like, take a peek at my IEEE-document .IEEE has 16 active lines in total. All 16 can be either input, output or tri-state. Eight of them are used for transferring data, the other eight for control. The state of each of the control lines depends on the fact what role the device is performing at the moment: a listener, a talker or a controller.
I copied one part of this document to make the next part more understandable:
Line NRFD NDAC DAV ATN EOI IFC REN SQR
I O | I O | I O | I O | I O | I O | I O | I O |
-----------|------|------|------|------|------|------|------|------|
Listener | X | X | X | X | X | X | | |
Talker | X | X | X | X | X | X | | |
Controller | X X | X X | X X | X X | X X | X | G | X |
X marks line used as "I = Input" or "O = Output" The block Controller/REN is marked G because a CBM doesn't use this line. In this case it is hardware-wired to GROUND.
As you can see a device like a diskdrive needs 4 input/output- and 2 inputlines. A computer needs 5 I/O-, 1 output- and 1 inputline. Beside these lines, both need 8 bi-directional datalines of course. So the original idea was to use an LPT port as IEEE port.
Unfortunately the ATN-trap was needed and that's where the COM port comes in. This port delivers the output to control the extra hardware.
To be able to use it in combination with Star Commander, the PC must be configured as Controller, meaning we need 6 outputs. A COM port has three so problem solved :)
There is only one small problem: RS-232 uses voltages that certainly don't match TTL levels! So extra hardware is needed here as well.
The hardware
What kind of PC do you need? I tested everything on a Pentium-1 75 MHz but I don't see any reason why it should not work on a 486 or 386. The program runs under DOS so 1 MB should do. Any PS/2 (also known as bi-directional), EPP and ECP printer port should do.As already said, a cable plus a bit of hardware is needed. And here I ran into a bit of trouble. My first design only worked for the PS/2 printer port. But nowadays too many PC's only have an EPP and/or ECP port. So I changed the actual design. But I also wanted to add some 'goodies': active reset and active ATN. The reason for this is I can use the cable for another project I'm still working on: SC4IEEE, a Star Commander clone for IEEE devices.
Anyway, the result is I ended up with several versions. I first thought about dropping the first ones and come out with only one cable that can be used for any system. But then a friend of mine mentioned he was interested in the second version as this one was the most user friendly in his opinion. So I decided to publish all versions and leave the choice to you.
More versions means more software. But IMHO it is just adding an extra parameter and changing some subroutines. And I don't mind doing that. This kind of flexibility has another advantage. All my versions are based on the use of one LPT- and one COM-port. For example using two LPT-ports would mean one wouldn't need the electronics needed for the TTL <-> RS232 conversion. And that could be quite an advantage for people with not much soldering experience.
Version 1
The very first version, version 0, was just a cable wired like this:
LPT
D-connector IEEE
D0 2 1 D1
D1 3 2 D2
D2 4 3 D3
D3 5 4 D4
D4 6 13 D5
D5 7 14 D6
D6 8 15 D7
D7 9 16 D8
STROBE 1 5 EOI
SELECT IN 17 6 DAV
INIT 16 7 NRFD
AUTO FEED 14 8 NDAC
PAPER END 12 9 IFC (RESET)
ERROR 15 10 SRQ
ACKNWLDG 10 11 ATN
SELECT 13 17 REN
GND 18/25 18/24 GND
12 Shield
But then I found out that some extra hardware was needed. The basic idea is simple: ATN must be able to negate NDAC and NRFD but the PC must be able to disable this function (otherwise it would loose control of these lines the moment ATN is active).
|\ (1) |\
ATN ----| >0---+---+---| >0---- NDAC
|/ | | |/
| |
|\ | | |\
PC ----| >0---+ +---| >0---- NDAC
|/ |/
The above four figures represent Open Collector Invertors (OCI), see later.
Assume PC is (L). The moment ATN becomes (L), point(1) becomes (H), thus negating NDAC and NRFD.
Making PC (H) means that point(1) remains (L) regardless of the state of ATN. So NDAC and NRFD can only be negated by the original outputs.
But what is to be used for 'PC'? The specification of the cable already reveals that there is no free output left to perform this function. But AFAIK almost every PC and laptop also is equipped with a COM-port which has at least three outputs. And one of them is going to be used; RTS in this case.
The reality:
I myself already found at least two ways to realise the above and still be able to use the same program.
- Replace the OCI connected to ATN, NRFD and NDAC with a 7406 gate, replace the last one with a transistor. Connect a pull-up resistor at point (1). For more details see this schematic for more details. Using a 7406 means a power supply is needed. Fortunately no external power supply is needed. The trick is to extract the power from the three RS232 outputs using diodes and a 78L05 supplies the needed 5 Volt.
- Replace all OCIs with a transistor. Here is the schematic. Not tested in this form, but see version 3.
Version 2
I found an original IBM serial/parallel card and realised the needed changes directly on the card. Advantage: as all circuits are inside the PC, only a cable converting LPT to IEEE is needed. Looked a bit nicer without extra external hardware too :) But when trying the software, I found out I had made a small mistake. I simplified things by skipping the RS232 drivers (which are invertors FYI) and this had consequences for the software. I could correct this by adding more hardware but in the end I chose for the software version.No schematic available so far. But if you are interested to alter such a card yourself, feel free to ask me about details.
FYI: I had a broken 8050, removed all its inner parts and inserted a PC motherboard, the card mentioned above and a harddisk. I was able to do it in such a way I even didn't need to drill extra holes :) I used the plastic fronts of two scrapped drives to fill the holes of the drive. The IEEE connector of an unrepairable board completed the transformation.
Version 3: EPP and ECP
My PC has an EPP/ECP printer port that behaves like a bi-directional one. But I have a laptop that doesn't at all. It even doesn't cooperate with my X1541 and forced me to build a small X1541-to-XE1541 adapter.But this behaviour simply meant that my XIEEE cable wouldn't work either. So I started to look for another solution that was found very quickly: using Scottky-diodes as used in the XE1541 cable, the X1541 variant meant for the EPP- and ECP-ports. So credits for this idea go to Nicolas Welte and Wolfgang Moser.
Unfortunately this means we need four extra inputs. On it self no problem, we still have a free one at the LPT-port and the COM-port can provide another four free inputs. But the use of these requires some extra hardware because of the differences in the used voltage levels.
LPT
D-connector IEEE
D0 2 1 D1
D1 3 2 D2
D2 4 3 D3
D3 5 4 D4
D4 6 13 D5
D5 7 14 D6
D6 8 15 D7
D7 9 16 D8
STROBE 1
BUSY 11 5 EOI
AUTO FEED 14
ERROR 15 8 NDAC
INIT 16
NO PAPER 12 7 NRFD
SELECT IN 17
SELECTED 13 6 DAV
GND 18/25 18/24 GND
12 Shield
RTS 7 enable ATN-trap
ACKNWLDG 10 11 ATN
DTR 4
TxD 3 9 IFC (RESET)
DCD 1
As you can see, I added the active ATN and Reset output, as used in revision 2. And as you can see, SRQ and REN aren't present anymore; Commodore doesn't use them at all, so why should I.
But using a RS232 input means we need a -12V supply as well. Using one of the RS232 outputs means we have one signal less to generate the needed +5V. And at this spot I ran into some serious trouble. The trouble went so far that I had to replace the used 7406 gates with transistors.
Version 4: EPP and ECP again
Nicolas and Wolfgang informed me that they encountered systems where even their XE1541 cable didn't work properly; in this case one or more gates weren't able to sink enough current. So they developed the XA1541 cable where every Scottky-diode is replaced by a transistor and a resistor. Not needing this cable myself and knowing very well how to alter the program, I decided not to build the cable but only to give you the schematic .Version 5: Two LPT ports
I just happened to run into some ISA cards with two bi-directional LPT ports onboard. This means eight outputports! One extra 7406 IC is still needed but that can be piggybacked on one of the existing IC's. The nice thing is that I can use the cable meant for version 0 here as well.
LPT1
D-connector IEEE
D0 2 1 D1
D1 3 2 D2
D2 4 3 D3
D3 5 4 D4
D4 6 13 D5
D5 7 14 D6
D6 8 15 D7
D7 9 16 D8
STROBE 1 5 EOI
SELECT IN 17 6 DAV
INIT 16 7 NRFD
AUTO FEED 14 8 NDAC
PAPER END 12 9 IFC (RESET)
ERROR 15 10 SRQ
ACKNWLDG 10 11 ATN
SELECT 13 17 REN
GND 18/25 18/24 GND
12 Shield
LPT2
D-connector IEEE
STROBE 1 11 ATN --> pin 10 of LPT1
SELECT IN 17 9 IFC (RESET) --> pin 12 of LPT1
INIT 16 enabling ATN trap
The flashing LED
Using my rebuilt 8050 I bumped into a quite stupid error: it had no screen. So what's the point you may think? The screen showed the errors the software encountered. As you know, the real 8050 will flash a LED when encountering an error. To blink a LED, I would need yet another output and again none are left. I could redesign the cable but had little interest to be honest. Then I decided to use the speaker for this purpose. I replaced it with a resistor (150 Ohm) and a LED and this worked like a charm.The source code
All is available in this file. It contains the executables for MS-DOS/W98-DOS, the sources and a D64 containing the Basic programs I used to test things.Having questions or comment? You want more Info?
You can email me here.