USB disk adapter for HP21xx minicomputers ========================================= This directory contains the essential details for a VDRIVE-based USB disk adapter that should work with just about any HP21xx minicomputer with a 5V "microcircuit" or a 12V "+16B DUP REG" bidirectional interface(s). Files can be read and written using VDOS and a single interface, papertape punch emulation requires a separate interface, can be a 12V "+8B" or another 16 bit interface. As usual, build at your own risk - the information is provided as-is and without warranty of any kind. This material is documentation of a system that works for me, efforts were taken to make it work with a wider range of HP interface cards but I only have my particular system to test with, and it probably hasn't been tested as much as it should be. If I discover or am informed of major error(s) I'll update this archive, otherwise refer to the project page at http://newton.freehostia.com/hp/usbadapter.html for code updates and other notes. A list of parts and Digikey part numbers is in the parts.txt file. [note - parts list was typed in manually after the fact, verify before assuming correct and keep in mind it is not optimized, just the parts I used. In particular the heatsink probably should be larger and must be larger if not using a 12V DC regulated supply, perfboard could have been a bit larger. I have NOT tested with an AC supply, there is a possibility the 470uF 35V capacitor might need to be bigger (the bridge rectifier is to not worry about polarity, not so much to run from AC). The schematic shows a power switch which wasn't used and not on the list. Finally consider using a polyfuse in series with the power input jack for protection, something in the 500ma range should do. Remember, this is documentation of a circuit I made, it is not meant to be a finished product at this point - to make a "nice" version of this I'd probably want to rig up a true +/-12V serial port instead of the resistor-to-PIC interface along with changes to the firmware to uninvert the polarity. Nevertheless, other than a few resistor values on the SPI buss (mine are a bit higher) this is what I'm using, thus what is documented.] The firmware source code is written in Great Cow Basic but requires a patched version of the compiler to recompile (available from the project page, presently included with the full hpusb.zip package but this might change in the future depending on what other projects I use it for). If using a current official version of the compiler (before Nov 2010) then a few patches need to be applied, see the gcbmods.txt file. The hex files contain library code written by others, see LGPL.txt and the source files in the libs directory. Hardware notes -------------- The I/O schematic shows 5 resistor packs, the prototype used 6 resistor packs so that 3 of them can be lined up with the ULN2003 output pins to minimize wiring. The ULN2003 sections are assigned differently in my proto, the first two chips are wired for out bits 2-15, the third chip is for out bits 0,1 and both flag outs. Arrange however convenient. The serial port is implemented without an inverting +/-12V interface, using just current limiting resistors. This should work with most PC's, if not a MAX-type interface can be used but add extra inverters for the RX and TX lines and arrange so that if a serial port is not connected the RX line at the PIC is high. Alternatively the firmware code can be modified to eliminate the extra inverters. The outputs of the circuit cannot drive the inputs of the circuit. If that is desired then the pullups on the ULN2003 chip outputs need to be significantly smaller than the pulldowns on the inputs, say use 3.3K pullups, leave the pulldowns 8.2K. The inputs and outputs were designed to interface with an HP minicomputer, hopefully with both 12V and 5V cards. 3.3K pullups probably would still work for 12V cards, but will result in more "backcurrent" into the supply when the HP is on and the adapter is off. The 8.2K pulldowns on the inputs are sized to load 12V HP outs to about 5V to minimize current injected into the supply through the MCP23S17 protect diodes. The I/O supply is isolated from the main supply so that the processor and in particular the VDRIVE will reset properly if the adapter power needs to be cycled when the HP is on. Isolation is provided by a silicon rectifier, a 100uF capacitor, a 1K resistor to discharge the I/O supply to 0 when everything is off, and a big 5.1V 5 watt zener diode to absorb backcurrent from a 12V HP card when the HP is turned on. This causes the I/O supply voltage to vary from about 4.3V to 5.1V depending on the app, that's OK. A Schottky-type diode would reduce variation but very risky since the zener has a tolerance of 5% and even worse at low current (a 5.1V ZD starts conducting a bit at about 4.8V), and cheap 7805 regulators might be a bit higher than 5.0 volts. If tolerances collide then poof. The 1 amp rectifier and 5 watt zener also serve to protect the main circuitry (briefly anyway) in the event of a supply meltdown. The 220 ohm resistor on the main supply serves to absorb backcurrent from the control lines to ensure that the supply voltage drops to near 0 when power-cycled. 470 ohm would probably work here, just making sure. The VDRIVE will not reset properly if there is more than about 0.8 volts on the supply. The 150 ohm resistors in series with the enable and SPI lines going to the I/O section serve two important functions - they limit current flow through the MCP23S17 input protect diodes as the I/O supply is less than the main supply, and they limit current flow in the event the PIC is misprogrammed with the SDI line programmed as an output. My prototype uses 220 ohms here, no problems at all even though the SPI buss runs at 8mhz, so 150 ohms should be fine and still limit fault current to 30ma. The 150 ohm resistor between the VDRIVE data out line and the SDI pin also serves to limit fault current. The resistors in series with the switch circuits and PIC pins limit current flow from programming errors and prevent the debounce caps from discharging a large current into the pins if the supply is suddenly shorted. Microchip app notes also have a diode from the cap to the supply but that's probably overkill, the 1K resistors limit the current to a few ma. Any other oddities? Love that LCD circuit! Firmware overview ----------------- The gcboot program implements a serial bootloader to permit loading new hex code without having to remove the PIC and place it into a PIC programmer. It is not required for operation. See gcboot.txt for details. The main firmware in hpusb.hex implements all of the HP-specific functions including debugging via the serial port, setup via switches and the LCD, and normal operation as a disk adapter. The setup screens permit setting the data polarity and flag and command polarities for both the main port and the punch port, and other options such as command loop delay for compatibility with existing versions of VDOS. When the adapter starts it searches the USB disk for a file named "HPBOOT", if it exists it will be attached for reading. Put the boot binary in this file. In normal operation, commands with the inputs (HP outs) set to logical 0 are assumed to be reads from the currently open read file, and any write to the punch port appends to the currently open write file. Files "A" to "Z" can be selected using switches and the LCD, 8.3-format filenames can be specified using a serial terminal. When files are manually opened then whatever bits are currently on the HP outs will be treated as papertape reads unless changed. When manually attaching a write file, if it exists then the LCD or serial terminal prompts to delete it, otherwise new data will be appended to the file. See hpusb.txt for more details. VDOS Builds ----------- Two VDOS builds are provided, VDOS.ABS is based on hposdms.abs with altutil.ipl, vdos.ipl and vdosext.ipl added. VDOSC.ABS is a more compact build without the TBG and other unneeded words. These builds require a HP21MX machine such as a HP2113 with at least 64KW memory. File VDOS.ABS, build date 6/14/11... HP-IPL/OS VDOS 1.64 ? WORDS DO +DO INDEx +LOOx >STEx IFNZ IFZ IF<0 ENDIx ELSE UNTIx WHILx CASE = < > <= >= <> DEFAxxx ENDCxxx EXECxxx WBOOx AND OR XOR ADD SUB INC DEC NOT 2CPL DUP DROP OVER ROT SWAP GET PUT PNUM CRLF DECIxxx OCTAx BINAxx RADIx SP>S SB>S XP>S XB>S YP>S YB>S ZP>S ZB>S END EOD DEFIxx DMPS S>SR SR>S PCHR PWRD CHRIx S>X X>S S>Y Y>S S>Z Z>S MUL ASL ASR ROL ROR DIV RUN X>>Y X>>Z Y>>X Z>>X $PRIxx $SWAx $CPY $DUP $DROx $LEN $ADR $XTExx $PUT $GET $CRExxx $STR $HEAx $APPxxx $TAIx $IN $CAT $VAL <>COx >PTP MS TBG TBGZxxx >WDT +WDT -WDT !100xx T>>S TIMExxx PTIMx !WDA !BACx MSBAxx BACx BACIxxx TTYCxx CBUS ?BUS >BUS BUx $ACxxx A>CCxxx USPAxx DMSTxxxx UPTR MSUSxx ABSLxxx GOUSxx GOSYxxxx ALTSxxx ?DMS MKWOxx ENDWxxx DADD D2CPx EMUL EDIV DSWAx $DVAx $DSTx DASL DASR DLSL DLSR DROL DROR FIX FLT FP+ FP- FP* FP/ DFLT DFIX PWR1x $>FP FP>$ FSGN FSQR TTYPx TERMxxxx ESC POS CLS COLOx -COLxx ZAM HLT ALTRxx RUNAxx PTHExxxx AAOUx ALTAxx ALTDxxx CLRHxxx ALTHxxx VDOS VSYNx VCLExx VDR &SIW &ORF &OWF &WFVxx @GSB @SSB &UCLxxx USBSxxx @PVLx PVDR $>VDx $>VCxx VECS VPROxxx VDIR VCD VSHOx VDEL USBRxxx USBAxxxxx USBWxxxx USBCxxxx VOWCxxxx VLOAx VSAVx VCOPx VREAx VWRIxx VCLOxx UFSIxx EOD=040264 FREE=017513 Package list... Start with hposdms.abs (version 1.64 6/13/11) altutil.ipl vdos.ipl vdosext.ipl Default allocation is 4 blocks, enter 2 ALLOCATE for more IPL memory. Configuration is TBG=10, TTY=11, PTR/USB=12, PTP=13, HPIB=17, BACI=22, use CONFIG to change. Supports reconfig on startup... put TTY slot in switch bits 0-5, BACI slot in bits 6-11 (or leave off), set bit 12 to default to BACI console or (if not using BACI) set bit 15 to disable autostarting. Run from location 70 to reconfigure and start HP-IPL/OS. If the USB adapter slot is not 12 then do slot# VDOS before using. File VDOSC.ABS, build date 6/14/11... ? WORDS DO +DO INDEx +LOOx >STEx IFNZ IFZ IF<0 ENDIx ELSE UNTIx WHILx CASE = < > <= >= <> DEFAxxx ENDCxxx EXECxxx WBOOx AND OR XOR ADD SUB INC DEC NOT 2CPL DUP DROP OVER ROT SWAP GET PUT PNUM CRLF DECIxxx OCTAx BINAxx RADIx SP>S SB>S XP>S XB>S YP>S YB>S ZP>S ZB>S END EOD DEFIxx DMPS S>SR SR>S PCHR PWRD CHRIx S>X X>S S>Y Y>S S>Z Z>S MUL ASL ASR ROL ROR DIV RUN X>>Y X>>Z Y>>X Z>>X $PRIxx $SWAx $CPY $DUP $DROx $LEN $ADR $XTExx $PUT $GET $CRExxx $STR $HEAx $APPxxx $TAIx $IN $CAT $VAL <>COx >PTP MS ACxxx A>CCxxx USPAxx DMSTxxxx UPTR MSUSxx ABSLxxx GOUSxx GOSYxxxx ALTSxxx ?DMS ZAM HLT ALTRxx RUNAxx PTHExxxx AAOUx ALTAxx ALTDxxx CLRHxxx ALTHxxx OE OE? SYSAxx VDOS VSYNx VCLExx VDR &SIW &ORF &OWF &WFVxx @GSB @SSB &UCLxxx USBSxxx @PVLx PVDR $>VDx $>VCxx VECS VPROxxx VDIR VCD VSHOx VDEL USBRxxx USBAxxxxx USBWxxxx USBCxxxx VOWCxxxx VLOAx VSAVx VCOPx VREAx VWRIxx VCLOxx UFSIxx VERSxxx EOD=033024 FREE=024753 Package list... Start with hpiplos1.abs (version 1.6 6/9/10) extra.ipl (select 32KW) create.ipl double.ipl dms.ipl altutil.ipl oct70.ipl vdos.ipl vdosext.ipl version.ipl Default allocation is 4 blocks, enter 2 ALLOCATE for more IPL memory. Configuration is TTY=11, PTR/USB=12, PTP=13. There is no config utility, to change the slot assignments put the TTY slot in location 355, the PTR slot in location 357, the PTP slot in location 356, then run from 2. Using VDOS ---------- See the vdos.ipl and vdosext.ipl files for docs of all the words provided. The main usages are... slot VDOS - change the USB adapter slot (as in 12 VDOS) VDIR - list the disk directory VPROMPT - run a VDRIVE dos prompt "FILENAME" VDEL - delete a file "FILENAME" VSHOW - list file contents to the console "FILENAME" VSAVE - save the current system to a binary "FILENAME" VLOAD - load a binary or an IPL file "DIRNAME" VCD - change to a subdirectory (".." and "/" for navigating up) "FILENAME" "NEWNAME" VCOPY - make a copy a file in the same subdirectory (use to rename files or set the HPBOOT file) USBSTAT PNUM - prints disk error status These print status info and warmboot if error... "FILENAME" VREAD - opens a file for reading "FILENAME" VWRITE - opens a file for writing, prompts to delete if exists VCLOSE - closes a write file These do not print prompts or status... "FILENAME" USBREAD - opens a file for reading "FILENAME" USBWRITE - opens a file for writing, deletes if it exists "FILENAME" USBAPPEND - opens a file for writing, appends new data USBCLOSE - closes a write file Any MS-capable word(s) can be used to read bytes from an open read file and/or write bytes to an open write file. These include... MSBIN - read a byte and push to the stack MSBOUT - pop the stack and write the byte MSWIN - read a word (2 bytes) and push to the stack MSWOUT - pop the stack and write the word MS$IN - read a line up to CRLF and push to the string stack (CRLF required or stack overflow, CRLF not added to the string) MS$OUT - pop the string stack and write MSCRLF - write CRLF LOAD - redirect read into the console SYSALL - save the current system ABSLOAD - load ABS binary into alternate memory (ALTSAVE ZAM to clear alt, run 77000 to swap and run) From altutil.ipl (included in VDOS builds)... RUNABS - load and run an ABS binary (run from 77000 to exit) PTHEADER - writes 8 zero bytes for ABS leader/trailer from to AAOUT - writes alt mem range in ABS format ALTABS - menu-driven alt mem saver From fcam.ipl... AM2ABS - scans alt mem and saves non-zero ranges in ABS format From fedutil.ipl (utilities for fed.ipl, an "array" text editor)... MASAVE - saves edited text (adds ~TERMINATE~ for MALOAD) MALOAD - loads text to edit (requires ~TERMINATE~ else halt, run from 2) >MS can be used to redirect console prints to an open write file... almost anything that prints can print to a file instead. Use CONSOLE to reset redirection back to the console and stock papertape drivers. For example to save a word definition to an IPL file... "WORDNAME.IPL" VWRITE >MS EXPLAIN WORDNAME "CONSOLE" $PRINT CRLF CONSOLE VCLOSE Multiple EXPLAIN commands can be used to add multiple words to the file, which can be reloaded into the dictionary like any other IPL file. This is useful for rearranging the dictionary. There are limitations to the technique - only high level words made using DEFINE can be saved, and if variables or constants are involved they need to be printed to the file where they need to appear. UDOS builds ----------- UDOS is an extremely simple dos for the USB adapter, the menu has options to save all of memory to an ABS binary, attach a file for reading, run a VDRIVE prompt for file management, and exit by running from location 2... 1) SAVE BINARY 2) ATTACH FILE 3) DOS PROMPT 4) RUN FROM 2 > UDOS doesn't have a binary load, rather it opens the file for read and uses the firmware's "read as PTR" command so the HP's stock papertape loader can load the selected binary file. The attach option can also be used to attach IPL or data files to load into HP-IPL/OS (or other applications). The udos8k directory contains source and binaries for UDOS, a "hook" binary and IPL package for accessing UDOS' internal code for additional functions, an IPL package containing DCON for changing UDOS' USB slot, an IPL package containing a version of Octapus that doesn't include the extra punch code, and a smaller version of the MAZE game (no map, that's kinda cheating anyway). There are two versions of UDOS - The udos_c2.abs binary is a stand-alone version that loads at 17000 octal and can be added to HP-IPL/OS or about anything else not using the top 0.5KW of memory. The hhooks.abs overlay loads at 16400 octal and links to udos_c2.abs to provide stack pop/push and other code to easily access internal UDOS functions using RUN commands. The udos_b2.abs binary is designed to be used with the preconfigured basic1.abs binary obtained from "The HP2100 Archives" or an 8KW version created by running the HPBASIC prepare program and making no entry in response to the PHOTO READER and PUNCH prompts. UDOS "B" loads between 16350 octal and the beginning of the HPBASIC TTY driver (17217), puts a jump to 5137 in locations 2/3 (autorun), puts a jump to UDOS in locations 77/76 to run UDOS when BYE is entered, and adjusts locations 106 and 116 to make room for UDOS. To install, load basic1.abs, load udos_b2.abs, then run from location 100. For more BASIC program memory remove the matrix functions as indicated in the udos_b2.asm comments. Binaries saved using UDOS will contain the interpreter plus BASIC code, run from location 2 to start the BASIC program. Running from 100 will erase the BASIC program for entering new programs. A few 8K-compatible BASIC programs are in the docs/hpbas directory. Two HP-IPL/OS builds with UDOS are provided, one with the MAZE game, another with extra utilities, file access words and Octapus. For both of these builds, configuration is TTY=11, PTR/USB=12, PTP=13. There is no config utility, to change the slot assignments put the TTY slot in location 355, the PTR slot in location 357, the PTP slot in location 356, then run from 2. Do slot# DCON to change the USB adapter slot. File UDOSMAZE.ABS, build date 11/16/10... HP-IPL/OS 8K V1.6 ? WORDS DO +DO INDEx +LOOx >STEx IFNZ IFZ IF<0 ENDIx ELSE UNTIx WHILx CASE = < > <= >= <> DEFAxxx ENDCxxx EXECxxx WBOOx AND OR XOR ADD SUB INC DEC NOT 2CPL DUP DROP OVER ROT SWAP GET PUT PNUM CRLF DECIxxx OCTAx BINAxx RADIx SP>S SB>S XP>S XB>S YP>S YB>S ZP>S ZB>S END EOD DEFIxx DMPS S>SR SR>S PCHR PWRD CHRIx S>X X>S S>Y Y>S S>Z Z>S MUL ASL ASR ROL ROR DIV RUN X>>Y X>>Z Y>>X Z>>X $PRIxx $SWAx $CPY $DUP $DROx $LEN $ADR $XTExx $PUT $GET $CRExxx $STR $HEAx $APPxxx $TAIx $IN $CAT $VAL <>COx >PTP MS STEx IFNZ IFZ IF<0 ENDIx ELSE UNTIx WHILx CASE = < > <= >= <> DEFAxxx ENDCxxx EXECxxx WBOOx AND OR XOR ADD SUB INC DEC NOT 2CPL DUP DROP OVER ROT SWAP GET PUT PNUM CRLF DECIxxx OCTAx BINAxx RADIx SP>S SB>S XP>S XB>S YP>S YB>S ZP>S ZB>S END EOD DEFIxx DMPS S>SR SR>S PCHR PWRD CHRIx S>X X>S S>Y Y>S S>Z Z>S MUL ASL ASR ROL ROR DIV RUN X>>Y X>>Z Y>>X Z>>X $PRIxx $SWAx $CPY $DUP $DROx $LEN $ADR $XTExx $PUT $GET $CRExxx $STR $HEAx $APPxxx $TAIx $IN $CAT $VAL <>COx >PTP MS VI $>VD $>VC &WFD VECS PVDR VDIR VDEL VSTAx VREAx VAPPxxx VWRIxx VCLOxx VLD OE OE? EOD=012706 FREE=001071 ? Package list... Start with hpiplos1.abs (version 1.6 6/9/10) internal.ipl - select option 2 to remove block support overlay udos_c2.abs overlay hhooks.abs DEFINE UDOS to 17000 RUN END dcon.ipl 8kextra2.ipl FORGET ABSOUT hhooks.ipl oct14a.ipl Memory from 16500 to 16777 is empty and available for custom machine code. Machine code can written in assembly and loaded as an overlay, or if not too complex, entered using the Octapus utility (or PUT). For more IPL programming memory, Octapus can be removed... ? FORGET OE ? @BLK 16400 PUT @END 16377 PUT This provides 3513 octal words free. The hooks provide a set of words that resemble VDOS but are simpler... "FILENAME" VREAD - opens a file for reading via MS input commands "FILENAME" VWRITE - opens a file for writing via MS output commands (deletes) "FILENAME" VAPPEND - opens a file for writing, data is appended to the file VCLOSE - closes a write file VDIR - lists the disk directory "FILENAME" VDEL - deletes a file "FILENAME" VLD - loads an IPL file VSTAT PNUM - prints error status Usage is about the same as with VDOS, any MS-capable words can be used to read from or write to open files. A possibly useful aspect of UDOS is it can also punch... if the USB device is connected to a PTP device it detects the situation and just saves memory to ABS. This can be used to make UDOS builds under simulation without having the usual punch code loaded, which is how these builds were made. ------------------------------------------------- Last modified 6/14/11