So, when I begun my little blinkenlights project I did not have a lot of faith about my manual abilities. Fortunately, electronics prototyping has advanced a lot and now it is posible to build circuit prototypes without having to struggle with a soldering iron. I will eventually try to do some soldering, but right now it is all about solderless breadboards.
And I been able to get some blinking leds :). I won't post again a video... just check the previous entry!
Goals and basic design
My goals are quite modest: I wanted just to have the equivalent to the display data lights one can find in a "classic" PDP-11 console, like the one in the PDP-11/70. That console has more lights than those: a 22 lights address display and several status and error reporting indicators. My "console" will have just 18 LEDS: 16 leds for the 16 bits of a PDP-11 word, plus a parity indicator and a generic error light.
The data to be displayed will be selected depositing values into three "registers" in SIMH, belonging to a new device which I have called "BLNK":
- DATASEL will represent the "Data select" key in the real console. The posible values are:
- 0 for Register
- 1 for Data Path
- 2 for Bus Register
- 3 for micro Address
- DISPSEL will represent the "Display select" key. The values are:
- 0 for Console Physical
- 1 for User - Instruction
- 2 for User - Data
- 3 for Super - Instruction
- 4 for Super - Data
- 5 for Kernel - Instruction
- 6 for Kernel - Data
- 7 for Program Physical
- DISPADD will hold the displayed value.
The default values will be zero for all three registers, so the "console" will show the value for R0. The light chasers implemented in several PDP-11 operating systems rotate and shift bit patterns in R0 which are shown in the lights, so it seems like a decent default setting.
Functional design and implementation
I have not done any simh hacking before, so one of my goals was to go the easy way. I implemented the console lights as a new device, so I didn't had to patch neither the scp (the control program for all the simh emulators) nor the core pdp-11 implementation. All the simh part functionality is in two new files (one of them being a header) and a small, controlled modification to pdp11_sys.c just to add the new device. This way it will be easy to merge my patches with future versions of simh. If you want to check it you can download from https://github.com/jguillaumes/retroutils/blob/master/simh-patches/pdp11-blinken.patch. This patch is for the current development version (4.0-beta), but it should apply to 3.9 too (I have not tried that).
If you want to build simh with this patch you will need too the code which actually implements the blinking lights. My implementation has two parts:
- A server part, which holds the real (or virtual) lights to be shown. This server gets the bits to represent via UDP packets or via serial connection.
- A client library, which sends the information to display to the server, either via UDP or serial connection.
I have written three different servers. Two of them are real, and the other one is virtual.
- The virtual one is written in java, and can be found at https://github.com/jguillaumes/retroutils/tree/master/JBlinkenServer. This is a netbeans project, but it should build without the IDE, just running ant.
- I wrote also a Raspberry Pi version which gets the data listening to UDP packets.
- And finally, I made an Arduino controlled version, which gets the data via serial port.
The rasperry and the arduino versions use basically the same hardware; the only difference is in the resistors used to limit the current going thru the leds. The Arduino operates at 5V, while the Raspberry uses 3.3V (it has also a 5V current source pin, but it is not wise to mix both tension levels). The resistors for the Rasp-pi version are of 330 Ohms, while for the Arduino I use 470 ohms. Oh, the circuit is basically the one described in this tutorial, with a minor modification.
The code for the client library and the servers is also accessible here https://github.com/jguillaumes/retroutils/tree/master/BlinkenServer. The arduino sketch is also there. To build simh with the client code you have to build the client library and install it (the makefile installs it in /usr/local, edit it if you want to use a different location). Then build the pdp11 simulator using the patched makefile.
Once you have built the pdp11 simulator, you will be able to use the new BLNK device (which is disabled by default). Enable it with:
sim> SET BLNK ENABLE
And attach it to a running udp server using:
sim> ATTACH BLNK udp:ip-address:port
If you are running the java application, it should be:
sim> ATTACH BLNK udp:localhost:11696
If you build the arduino circuit, then the attach command is:
sim> ATTACH BLNK tty:/dev/name-of-your-arduino-serial-usb
The only modifier is RATE. The command
sim> SET BLNK RATE=50
will try to establish an update refresh rate of 50 Hz (the leds will be updated 50 times at a second). The default value is 100. Don't push it too hard if you are using an Arduino, since the poor thing will not be able to cope with the load and will hang up...
If you attach BLNK and boot RSX-11M+ you will enjoy a nice light show.
As usual, your comments and suggestions will be very welcome!
I have made some corrections to the simh part and to the arduino side. I have created a simh repositoy at github, accessible via https://github.com/jguillaumes/simh. The master branch of that repository will follow the "official" simh tree (https://github.com/simh/simh). The branch "BlinkenLights" will contain my modified version (https://github.com/jguillaumes/simh/tree/BlinkenLights). I will try to keep it in sync with the master, so it should build without too much trouble. I don't plan to ask Mark to merge my changes, since there is the possibility of developing an "official" blinkenlights support into simh (which would make mine obsolete).